index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. :inline="true"
  7. v-show="showSearch"
  8. label-width="68px"
  9. >
  10. <el-form-item label="字典名称" prop="dictName">
  11. <el-input
  12. v-model="queryParams.dictName"
  13. placeholder="请输入字典名称"
  14. clearable
  15. size="small"
  16. style="width: 240px"
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="字典类型" prop="dictType">
  21. <el-input
  22. v-model="queryParams.dictType"
  23. placeholder="请输入字典类型"
  24. clearable
  25. size="small"
  26. style="width: 240px"
  27. @keyup.enter.native="handleQuery"
  28. />
  29. </el-form-item>
  30. <el-form-item label="状态" prop="status">
  31. <el-select
  32. v-model="queryParams.status"
  33. placeholder="字典状态"
  34. clearable
  35. size="small"
  36. style="width: 240px"
  37. >
  38. <el-option
  39. v-for="dict in dict.type.sys_normal_disable"
  40. :key="dict.value"
  41. :label="dict.label"
  42. :value="dict.value"
  43. class="input_xiala"
  44. />
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="创建时间">
  48. <el-date-picker
  49. v-model="dateRange"
  50. size="small"
  51. style="
  52. width: 200px;
  53. height: 36px;
  54. background: #00365f;
  55. border: 1px solid white;
  56. "
  57. value-format="yyyy-MM-dd"
  58. type="daterange"
  59. range-separator="-"
  60. start-placeholder="开始日期"
  61. end-placeholder="结束日期"
  62. ></el-date-picker>
  63. </el-form-item>
  64. <el-form-item>
  65. <el-button
  66. icon="el-icon-search"
  67. size="btn"
  68. @click="handleQuery"
  69. >搜索</el-button
  70. >
  71. <el-button
  72. icon="el-icon-refresh"
  73. size="btr"
  74. @click="resetQuery"
  75. >重置</el-button
  76. >
  77. </el-form-item>
  78. </el-form>
  79. <el-row :gutter="10" class="mb8">
  80. <el-col :span="1.5">
  81. <el-button
  82. type="primary"
  83. plain
  84. icon="el-icon-plus"
  85. size="mini"
  86. @click="handleAdd"
  87. v-hasPermi="['system:dict:add']"
  88. >新增</el-button
  89. >
  90. </el-col>
  91. <el-col :span="1.5">
  92. <el-button
  93. type="success"
  94. plain
  95. icon="el-icon-edit"
  96. size="mini"
  97. :disabled="single"
  98. @click="handleUpdate"
  99. v-hasPermi="['system:dict:edit']"
  100. >修改</el-button
  101. >
  102. </el-col>
  103. <el-col :span="1.5">
  104. <el-button
  105. type="danger"
  106. plain
  107. icon="el-icon-delete"
  108. size="mini"
  109. :disabled="multiple"
  110. @click="handleDelete"
  111. v-hasPermi="['system:dict:remove']"
  112. >删除</el-button
  113. >
  114. </el-col>
  115. <el-col :span="1.5">
  116. <el-button
  117. type="warning"
  118. plain
  119. icon="el-icon-download"
  120. size="mini"
  121. :loading="exportLoading"
  122. @click="handleExport"
  123. v-hasPermi="['system:dict:export']"
  124. >导出</el-button
  125. >
  126. </el-col>
  127. <el-col :span="1.5">
  128. <el-button
  129. type="danger"
  130. plain
  131. icon="el-icon-refresh"
  132. size="mini"
  133. @click="handleRefreshCache"
  134. v-hasPermi="['system:dict:remove']"
  135. >刷新</el-button
  136. >
  137. </el-col>
  138. <right-toolbar
  139. :showSearch.sync="showSearch"
  140. @queryTable="getList"
  141. ></right-toolbar>
  142. </el-row>
  143. <el-table
  144. v-loading="loading"
  145. :data="typeList"
  146. @selection-change="handleSelectionChange"
  147. :header-cell-style="{ background: '#003c69', color: 'white' }"
  148. >
  149. <el-table-column type="selection" width="55" align="center" />
  150. <el-table-column label="字典编号" align="center" prop="dictId" />
  151. <el-table-column
  152. label="字典名称"
  153. align="center"
  154. prop="dictName"
  155. :show-overflow-tooltip="true"
  156. />
  157. <el-table-column
  158. label="字典类型"
  159. align="center"
  160. :show-overflow-tooltip="true"
  161. >
  162. <template slot-scope="scope">
  163. <router-link
  164. :to="'/system/dict-data/index/' + scope.row.dictId"
  165. class="link-type"
  166. >
  167. <span>{{ scope.row.dictType }}</span>
  168. </router-link>
  169. </template>
  170. </el-table-column>
  171. <el-table-column label="状态" align="center" prop="status">
  172. <template slot-scope="scope">
  173. <dict-tag
  174. :options="dict.type.sys_normal_disable"
  175. :value="scope.row.status"
  176. />
  177. </template>
  178. </el-table-column>
  179. <el-table-column
  180. label="备注"
  181. align="center"
  182. prop="remark"
  183. :show-overflow-tooltip="true"
  184. />
  185. <el-table-column
  186. label="创建时间"
  187. align="center"
  188. prop="createTime"
  189. width="180"
  190. >
  191. <template slot-scope="scope">
  192. <span>{{ parseTime(scope.row.createTime) }}</span>
  193. </template>
  194. </el-table-column>
  195. <el-table-column
  196. label="操作"
  197. align="center"
  198. class-name="small-padding fixed-width"
  199. >
  200. <template slot-scope="scope">
  201. <el-button
  202. size="btu"
  203. type="text"
  204. @click="handleUpdate(scope.row)"
  205. v-hasPermi="['system:dict:edit']"
  206. ><span class="edit">修改</span></el-button
  207. >
  208. <el-button
  209. size="btd"
  210. type="text"
  211. @click="handleDelete(scope.row)"
  212. v-hasPermi="['system:dict:remove']"
  213. ><span class="delete">删除</span></el-button
  214. >
  215. </template>
  216. </el-table-column>
  217. </el-table>
  218. <pagination
  219. v-show="total > 0"
  220. :total="total"
  221. :page.sync="queryParams.pageNum"
  222. :limit.sync="queryParams.pageSize"
  223. @pagination="getList"
  224. />
  225. <!-- 添加或修改参数配置对话框 -->
  226. <el-dialog
  227. :title="title"
  228. :visible.sync="open"
  229. width="700px"
  230. append-to-body
  231. :closeOnClickModal="false"
  232. :expand-on-click-node="false"
  233. >
  234. <div class="jiben">基本信息</div>
  235. <el-form
  236. ref="form"
  237. :model="form"
  238. :rules="rules"
  239. label-width="80px"
  240. :inline="true"
  241. >
  242. <el-form-item label="字典名称" prop="dictName">
  243. <el-input v-model="form.dictName" placeholder="请输入字典名称" />
  244. </el-form-item>
  245. <el-form-item label="字典类型" prop="dictType">
  246. <el-input v-model="form.dictType" placeholder="请输入字典类型" />
  247. </el-form-item>
  248. <el-form-item label="状态" prop="status">
  249. <el-radio-group v-model="form.status">
  250. <el-radio
  251. v-for="dict in dict.type.sys_normal_disable"
  252. :key="dict.value"
  253. :label="dict.value"
  254. >{{ dict.label }}</el-radio
  255. >
  256. </el-radio-group>
  257. </el-form-item>
  258. <div class="jiben">备注</div>
  259. <el-form-item label="" prop="remark" class="textareas" style="width: 100%">
  260. <el-input
  261. v-model="form.remark"
  262. type="textarea"
  263. placeholder="请输入内容"
  264. ></el-input>
  265. </el-form-item>
  266. </el-form>
  267. <div slot="footer" class="dialog-footer">
  268. <el-button type="primary" @click="submitForm">确 定</el-button>
  269. <el-button @click="cancel">取 消</el-button>
  270. </div>
  271. </el-dialog>
  272. </div>
  273. </template>
  274. <script>
  275. import {
  276. listType,
  277. getType,
  278. delType,
  279. addType,
  280. updateType,
  281. exportType,
  282. refreshCache,
  283. } from "@/api/system/dict/type";
  284. export default {
  285. name: "Dict",
  286. dicts: ["sys_normal_disable"],
  287. data() {
  288. return {
  289. // 遮罩层
  290. loading: true,
  291. // 导出遮罩层
  292. exportLoading: false,
  293. // 选中数组
  294. ids: [],
  295. // 非单个禁用
  296. single: true,
  297. // 非多个禁用
  298. multiple: true,
  299. // 显示搜索条件
  300. showSearch: true,
  301. // 总条数
  302. total: 0,
  303. // 字典表格数据
  304. typeList: [],
  305. // 弹出层标题
  306. title: "",
  307. // 是否显示弹出层
  308. open: false,
  309. // 日期范围
  310. dateRange: [],
  311. // 查询参数
  312. queryParams: {
  313. pageNum: 1,
  314. pageSize: 10,
  315. dictName: undefined,
  316. dictType: undefined,
  317. status: undefined,
  318. },
  319. // 表单参数
  320. form: {},
  321. // 表单校验
  322. rules: {
  323. dictName: [
  324. { required: true, message: "字典名称不能为空", trigger: "blur" },
  325. ],
  326. dictType: [
  327. { required: true, message: "字典类型不能为空", trigger: "blur" },
  328. ],
  329. },
  330. };
  331. },
  332. created() {
  333. this.getList();
  334. },
  335. methods: {
  336. /** 查询字典类型列表 */
  337. getList() {
  338. this.loading = true;
  339. listType(this.addDateRange(this.queryParams, this.dateRange)).then(
  340. (response) => {
  341. this.typeList = response.rows;
  342. this.total = response.total;
  343. this.loading = false;
  344. }
  345. );
  346. },
  347. // 取消按钮
  348. cancel() {
  349. this.open = false;
  350. this.reset();
  351. },
  352. // 表单重置
  353. reset() {
  354. this.form = {
  355. dictId: undefined,
  356. dictName: undefined,
  357. dictType: undefined,
  358. status: "0",
  359. remark: undefined,
  360. };
  361. this.resetForm("form");
  362. },
  363. /** 搜索按钮操作 */
  364. handleQuery() {
  365. this.queryParams.pageNum = 1;
  366. this.getList();
  367. },
  368. /** 重置按钮操作 */
  369. resetQuery() {
  370. this.dateRange = [];
  371. this.resetForm("queryForm");
  372. this.handleQuery();
  373. },
  374. /** 新增按钮操作 */
  375. handleAdd() {
  376. this.reset();
  377. this.open = true;
  378. this.title = "添加字典类型";
  379. },
  380. // 多选框选中数据
  381. handleSelectionChange(selection) {
  382. this.ids = selection.map((item) => item.dictId);
  383. this.single = selection.length != 1;
  384. this.multiple = !selection.length;
  385. },
  386. /** 修改按钮操作 */
  387. handleUpdate(row) {
  388. this.reset();
  389. const dictId = row.dictId || this.ids;
  390. getType(dictId).then((response) => {
  391. this.form = response.data;
  392. this.open = true;
  393. this.title = "修改字典类型";
  394. });
  395. },
  396. /** 提交按钮 */
  397. submitForm: function () {
  398. this.$refs["form"].validate((valid) => {
  399. if (valid) {
  400. if (this.form.dictId != undefined) {
  401. updateType(this.form).then((response) => {
  402. this.$modal.msgSuccess("修改成功");
  403. this.open = false;
  404. this.getList();
  405. });
  406. } else {
  407. addType(this.form).then((response) => {
  408. this.$modal.msgSuccess("新增成功");
  409. this.open = false;
  410. this.getList();
  411. });
  412. }
  413. }
  414. });
  415. },
  416. /** 删除按钮操作 */
  417. handleDelete(row) {
  418. const dictIds = row.dictId || this.ids;
  419. this.$modal
  420. .confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?')
  421. .then(function () {
  422. return delType(dictIds);
  423. })
  424. .then(() => {
  425. this.getList();
  426. this.$modal.msgSuccess("删除成功");
  427. })
  428. .catch(() => {});
  429. },
  430. /** 导出按钮操作 */
  431. handleExport() {
  432. const queryParams = this.queryParams;
  433. this.$modal
  434. .confirm("是否确认导出所有类型数据项?")
  435. .then(() => {
  436. this.exportLoading = true;
  437. return exportType(queryParams);
  438. })
  439. .then((response) => {
  440. this.$download.name(response.msg);
  441. this.exportLoading = false;
  442. })
  443. .catch(() => {});
  444. },
  445. /** 刷新缓存按钮操作 */
  446. handleRefreshCache() {
  447. refreshCache().then(() => {
  448. this.$modal.msgSuccess("刷新成功");
  449. });
  450. },
  451. },
  452. };
  453. </script>
  454. <style scoped>
  455. ::v-deep .el-tree-node__content {
  456. color: #fff;
  457. height: 30px;
  458. text-align: center;
  459. }
  460. ::v-deep .el-tree-node__content:hover {
  461. background-color: #004d86 !important;
  462. }
  463. /* 对话框背景颜色 */
  464. ::v-deep .el-dialog {
  465. background: #004d86 !important;
  466. }
  467. ::v-deep .el-textarea__inner {
  468. width: 930px;
  469. height: 104px;
  470. margin: auto !important;
  471. }
  472. ::v-deep .el-dialog__header {
  473. border-bottom: 1px solid #718a9d;
  474. }
  475. ::v-deep .el-dialog__title {
  476. color: #fff;
  477. font: 18px;
  478. }
  479. ::v-deep .el-dialog__headerbtn .el-dialog__close {
  480. color: #fff;
  481. }
  482. ::v-deep .el-form-item__label {
  483. font: 16px;
  484. color: #fff;
  485. width: 100px !important;
  486. }
  487. ::v-deep .el-input__inner {
  488. /* width: 200px !important;
  489. height: 36px; */
  490. background: transparent;
  491. color: #fff;
  492. }
  493. /* 单位框背景颜色 */
  494. ::v-deep .vue-treeselect__control {
  495. background: #004d86 !important;
  496. }
  497. /* 基本信息背景 */
  498. .jiben {
  499. width: 660px;
  500. height: 32px;
  501. background-image: url(../../../images/小标题底.png);
  502. margin-bottom: 25px;
  503. color: #fff;
  504. padding-left: 16px;
  505. line-height: 32px;
  506. }
  507. /*调整表单间距 */
  508. ::v-deep .el-form-item__content {
  509. width: 200px;
  510. }
  511. .contents {
  512. padding: 0px 40px !important;
  513. }
  514. /* 时间选择 */
  515. ::v-deep .el-input--small .el-input__inner {
  516. width: 200px;
  517. height: 36px;
  518. line-height: 36px;
  519. }
  520. .el-date-editor.el-input {
  521. width: 200px;
  522. height: 36px;
  523. line-height: 36px;
  524. }
  525. ::v-deep .el-date-editor.el-input .el-input__inner {
  526. height: 36px;
  527. line-height: 36px;
  528. }
  529. /* 单位框背景颜色 */
  530. ::v-deep .vue-treeselect__control {
  531. background: #004d86 !important;
  532. color: #fff;
  533. }
  534. /* 备注输入框 */
  535. .textareas ::v-deep .el-form-item__content {
  536. width: 100%;
  537. }
  538. /* 日期背景颜色 */
  539. ::v-deep .el-date-editor .el-range-input {
  540. background: #00365f;
  541. }
  542. ::v-deep .el-textarea__inner {
  543. width: 660px;
  544. height: 104px;
  545. margin: auto !important;
  546. }
  547. /* 状态 */
  548. .el-radio {
  549. color: rgb(204, 198, 198);
  550. }
  551. /* 分页按钮 */
  552. ::v-deep .el-pagination.is-background .el-pager li {
  553. background-color: #004d86;
  554. color: #fff;
  555. }
  556. ::v-deep .el-pagination.is-background .btn-next {
  557. background-color: #004d86;
  558. color: #fff;
  559. }
  560. ::v-deep .el-pagination.is-background .btn-prev,
  561. .el-pagination.is-background .btn-next,
  562. .el-pagination.is-background .el-pager li {
  563. background: #004d86 !important;
  564. color: #fff !important;
  565. }
  566. /* 调整输入框提示文字颜色 */
  567. ::v-deep .vue-treeselect__placeholder {
  568. color: #bdbdbd4f !important;
  569. }
  570. ::v-deep input::-webkit-input-placeholder {
  571. color: #bdbdbd4f !important;
  572. }
  573. ::v-deep input:-moz-placeholder {
  574. color: #bdbdbd4f !important;
  575. }
  576. </style>