index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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. >
  232. <div class="jiben">基本信息</div>
  233. <el-form
  234. ref="form"
  235. :model="form"
  236. :rules="rules"
  237. label-width="80px"
  238. :inline="true"
  239. >
  240. <el-form-item label="字典名称" prop="dictName">
  241. <el-input v-model="form.dictName" placeholder="请输入字典名称" />
  242. </el-form-item>
  243. <el-form-item label="字典类型" prop="dictType">
  244. <el-input v-model="form.dictType" placeholder="请输入字典类型" />
  245. </el-form-item>
  246. <el-form-item label="状态" prop="status">
  247. <el-radio-group v-model="form.status">
  248. <el-radio
  249. v-for="dict in dict.type.sys_normal_disable"
  250. :key="dict.value"
  251. :label="dict.value"
  252. >{{ dict.label }}</el-radio
  253. >
  254. </el-radio-group>
  255. </el-form-item>
  256. <div class="jiben">备注</div>
  257. <el-form-item label="" prop="remark" class="textareas" style="width: 100%">
  258. <el-input
  259. v-model="form.remark"
  260. type="textarea"
  261. placeholder="请输入内容"
  262. ></el-input>
  263. </el-form-item>
  264. </el-form>
  265. <div slot="footer" class="dialog-footer">
  266. <el-button type="primary" @click="submitForm">确 定</el-button>
  267. <el-button @click="cancel">取 消</el-button>
  268. </div>
  269. </el-dialog>
  270. </div>
  271. </template>
  272. <script>
  273. import {
  274. listType,
  275. getType,
  276. delType,
  277. addType,
  278. updateType,
  279. exportType,
  280. refreshCache,
  281. } from "@/api/system/dict/type";
  282. export default {
  283. name: "Dict",
  284. dicts: ["sys_normal_disable"],
  285. data() {
  286. return {
  287. // 遮罩层
  288. loading: true,
  289. // 导出遮罩层
  290. exportLoading: false,
  291. // 选中数组
  292. ids: [],
  293. // 非单个禁用
  294. single: true,
  295. // 非多个禁用
  296. multiple: true,
  297. // 显示搜索条件
  298. showSearch: true,
  299. // 总条数
  300. total: 0,
  301. // 字典表格数据
  302. typeList: [],
  303. // 弹出层标题
  304. title: "",
  305. // 是否显示弹出层
  306. open: false,
  307. // 日期范围
  308. dateRange: [],
  309. // 查询参数
  310. queryParams: {
  311. pageNum: 1,
  312. pageSize: 10,
  313. dictName: undefined,
  314. dictType: undefined,
  315. status: undefined,
  316. },
  317. // 表单参数
  318. form: {},
  319. // 表单校验
  320. rules: {
  321. dictName: [
  322. { required: true, message: "字典名称不能为空", trigger: "blur" },
  323. ],
  324. dictType: [
  325. { required: true, message: "字典类型不能为空", trigger: "blur" },
  326. ],
  327. },
  328. };
  329. },
  330. created() {
  331. this.getList();
  332. },
  333. methods: {
  334. /** 查询字典类型列表 */
  335. getList() {
  336. this.loading = true;
  337. listType(this.addDateRange(this.queryParams, this.dateRange)).then(
  338. (response) => {
  339. this.typeList = response.rows;
  340. this.total = response.total;
  341. this.loading = false;
  342. }
  343. );
  344. },
  345. // 取消按钮
  346. cancel() {
  347. this.open = false;
  348. this.reset();
  349. },
  350. // 表单重置
  351. reset() {
  352. this.form = {
  353. dictId: undefined,
  354. dictName: undefined,
  355. dictType: undefined,
  356. status: "0",
  357. remark: undefined,
  358. };
  359. this.resetForm("form");
  360. },
  361. /** 搜索按钮操作 */
  362. handleQuery() {
  363. this.queryParams.pageNum = 1;
  364. this.getList();
  365. },
  366. /** 重置按钮操作 */
  367. resetQuery() {
  368. this.dateRange = [];
  369. this.resetForm("queryForm");
  370. this.handleQuery();
  371. },
  372. /** 新增按钮操作 */
  373. handleAdd() {
  374. this.reset();
  375. this.open = true;
  376. this.title = "添加字典类型";
  377. },
  378. // 多选框选中数据
  379. handleSelectionChange(selection) {
  380. this.ids = selection.map((item) => item.dictId);
  381. this.single = selection.length != 1;
  382. this.multiple = !selection.length;
  383. },
  384. /** 修改按钮操作 */
  385. handleUpdate(row) {
  386. this.reset();
  387. const dictId = row.dictId || this.ids;
  388. getType(dictId).then((response) => {
  389. this.form = response.data;
  390. this.open = true;
  391. this.title = "修改字典类型";
  392. });
  393. },
  394. /** 提交按钮 */
  395. submitForm: function () {
  396. this.$refs["form"].validate((valid) => {
  397. if (valid) {
  398. if (this.form.dictId != undefined) {
  399. updateType(this.form).then((response) => {
  400. this.$modal.msgSuccess("修改成功");
  401. this.open = false;
  402. this.getList();
  403. });
  404. } else {
  405. addType(this.form).then((response) => {
  406. this.$modal.msgSuccess("新增成功");
  407. this.open = false;
  408. this.getList();
  409. });
  410. }
  411. }
  412. });
  413. },
  414. /** 删除按钮操作 */
  415. handleDelete(row) {
  416. const dictIds = row.dictId || this.ids;
  417. this.$modal
  418. .confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?')
  419. .then(function () {
  420. return delType(dictIds);
  421. })
  422. .then(() => {
  423. this.getList();
  424. this.$modal.msgSuccess("删除成功");
  425. })
  426. .catch(() => {});
  427. },
  428. /** 导出按钮操作 */
  429. handleExport() {
  430. const queryParams = this.queryParams;
  431. this.$modal
  432. .confirm("是否确认导出所有类型数据项?")
  433. .then(() => {
  434. this.exportLoading = true;
  435. return exportType(queryParams);
  436. })
  437. .then((response) => {
  438. this.$download.name(response.msg);
  439. this.exportLoading = false;
  440. })
  441. .catch(() => {});
  442. },
  443. /** 刷新缓存按钮操作 */
  444. handleRefreshCache() {
  445. refreshCache().then(() => {
  446. this.$modal.msgSuccess("刷新成功");
  447. });
  448. },
  449. },
  450. };
  451. </script>
  452. <style scoped>
  453. ::v-deep .el-tree-node__content {
  454. color: #fff;
  455. height: 30px;
  456. text-align: center;
  457. }
  458. ::v-deep .el-tree-node__content:hover {
  459. background-color: #004d86 !important;
  460. }
  461. /* 对话框背景颜色 */
  462. ::v-deep .el-dialog {
  463. background: #004d86 !important;
  464. }
  465. ::v-deep .el-textarea__inner {
  466. width: 930px;
  467. height: 104px;
  468. margin: auto !important;
  469. }
  470. ::v-deep .el-dialog__header {
  471. border-bottom: 1px solid #718a9d;
  472. }
  473. ::v-deep .el-dialog__title {
  474. color: #fff;
  475. font: 18px;
  476. }
  477. ::v-deep .el-dialog__headerbtn .el-dialog__close {
  478. color: #fff;
  479. }
  480. ::v-deep .el-form-item__label {
  481. font: 16px;
  482. color: #fff;
  483. width: 100px !important;
  484. }
  485. ::v-deep .el-input__inner {
  486. /* width: 200px !important;
  487. height: 36px; */
  488. background: transparent;
  489. color: #fff;
  490. }
  491. /* 单位框背景颜色 */
  492. ::v-deep .vue-treeselect__control {
  493. background: #004d86 !important;
  494. }
  495. /* 基本信息背景 */
  496. .jiben {
  497. width: 660px;
  498. height: 32px;
  499. background-image: url(../../../images/小标题底.png);
  500. margin-bottom: 25px;
  501. color: #fff;
  502. padding-left: 16px;
  503. line-height: 32px;
  504. }
  505. /*调整表单间距 */
  506. ::v-deep .el-form-item__content {
  507. width: 200px;
  508. }
  509. .contents {
  510. padding: 0px 40px !important;
  511. }
  512. /* 时间选择 */
  513. ::v-deep .el-input--small .el-input__inner {
  514. width: 200px;
  515. height: 36px;
  516. line-height: 36px;
  517. }
  518. .el-date-editor.el-input {
  519. width: 200px;
  520. height: 36px;
  521. line-height: 36px;
  522. }
  523. ::v-deep .el-date-editor.el-input .el-input__inner {
  524. height: 36px;
  525. line-height: 36px;
  526. }
  527. /* 单位框背景颜色 */
  528. ::v-deep .vue-treeselect__control {
  529. background: #004d86 !important;
  530. color: #fff;
  531. }
  532. /* 备注输入框 */
  533. .textareas ::v-deep .el-form-item__content {
  534. width: 100%;
  535. }
  536. /* 日期背景颜色 */
  537. ::v-deep .el-date-editor .el-range-input {
  538. background: #00365f;
  539. }
  540. ::v-deep .el-textarea__inner {
  541. width: 660px;
  542. height: 104px;
  543. margin: auto !important;
  544. }
  545. /* 状态 */
  546. .el-radio {
  547. color: rgb(204, 198, 198);
  548. }
  549. /* 分页按钮 */
  550. ::v-deep .el-pagination.is-background .el-pager li {
  551. background-color: #004d86;
  552. color: #fff;
  553. }
  554. ::v-deep .el-pagination.is-background .btn-next {
  555. background-color: #004d86;
  556. color: #fff;
  557. }
  558. ::v-deep .el-pagination.is-background .btn-prev,
  559. .el-pagination.is-background .btn-next,
  560. .el-pagination.is-background .el-pager li {
  561. background: #004d86 !important;
  562. color: #fff !important;
  563. }
  564. </style>