2c33302af897a9e73e30433ab7884b34bf1e735b.svn-base 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 左侧面板 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="searchQuery">
  6. <a-row :gutter="12">
  7. <a-col :md="7" :sm="8">
  8. <a-form-item label="字典名称" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
  9. <a-input placeholder="请输入字典名称" v-model="queryParam.dictName"></a-input>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="7" :sm="8">
  13. <a-form-item label="字典编号" :labelCol="{span: 6}" :wrapperCol="{span: 14, offset: 1}">
  14. <a-input placeholder="请输入字典编号" v-model="queryParam.dictCode"></a-input>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="7" :sm="8">
  18. <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
  19. <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
  20. <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
  21. </span>
  22. </a-col>
  23. </a-row>
  24. </a-form>
  25. <div class="table-operator" style="border-top: 5px">
  26. <a-button @click="handleAdd" type="primary" icon="plus">添加</a-button>
  27. <a-button type="primary" icon="download" @click="handleExportXls('字典信息')">导出</a-button>
  28. <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
  29. <a-button type="primary" icon="import">导入</a-button>
  30. </a-upload>
  31. <a-button type="primary" icon="sync" @click="refleshCache()">刷新缓存</a-button>
  32. <a-button type="primary" icon="hdd" @click="openDeleteList">回收站</a-button>
  33. </div>
  34. <a-table
  35. ref="table"
  36. rowKey="id"
  37. size="middle"
  38. :columns="columns"
  39. :dataSource="dataSource"
  40. :pagination="ipagination"
  41. :loading="loading"
  42. @change="handleTableChange">
  43. <span slot="action" slot-scope="text, record">
  44. <a @click="handleEdit(record)">
  45. <a-icon type="edit"/>
  46. 编辑
  47. </a>
  48. <a-divider type="vertical"/>
  49. <a @click="editDictItem(record)"><a-icon type="setting"/> 字典配置</a>
  50. <a-divider type="vertical"/>
  51. <a-popconfirm title="确定删除吗?" @confirm="() =>handleDelete(record.id)">
  52. <a>删除</a>
  53. </a-popconfirm>
  54. </span>
  55. </a-table>
  56. </div>
  57. <dict-modal ref="modalForm" @ok="modalFormOk"></dict-modal> <!-- 字典类型 -->
  58. <dict-item-list ref="dictItemList"></dict-item-list>
  59. <dict-delete-list ref="dictDeleteList" @refresh="() =>loadData()"></dict-delete-list>
  60. </a-card>
  61. </template>
  62. <script>
  63. import { filterObj } from '@/utils/util';
  64. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  65. import DictModal from './modules/DictModal'
  66. import DictItemList from './DictItemList'
  67. import DictDeleteList from './DictDeleteList'
  68. import { getAction } from '@/api/manage'
  69. import { UI_CACHE_DB_DICT_DATA } from "@/store/mutation-types"
  70. import Vue from 'vue'
  71. export default {
  72. name: "DictList",
  73. mixins:[JeecgListMixin],
  74. components: {DictModal, DictItemList,DictDeleteList},
  75. data() {
  76. return {
  77. description: '这是数据字典页面',
  78. visible: false,
  79. // 查询条件
  80. queryParam: {
  81. dictCode: "",
  82. dictName: "",
  83. },
  84. // 表头
  85. columns: [
  86. {
  87. title: '#',
  88. dataIndex: '',
  89. key: 'rowIndex',
  90. width: 120,
  91. align: "center",
  92. customRender: function (t, r, index) {
  93. return parseInt(index) + 1;
  94. }
  95. },
  96. {
  97. title: '字典名称',
  98. align: "left",
  99. dataIndex: 'dictName',
  100. },
  101. {
  102. title: '字典编号',
  103. align: "left",
  104. dataIndex: 'dictCode',
  105. },
  106. {
  107. title: '描述',
  108. align: "left",
  109. dataIndex: 'description',
  110. },
  111. {
  112. title: '操作',
  113. dataIndex: 'action',
  114. align: "center",
  115. scopedSlots: {customRender: 'action'},
  116. }
  117. ],
  118. dict: "",
  119. labelCol: {
  120. xs: {span: 8},
  121. sm: {span: 5},
  122. },
  123. wrapperCol: {
  124. xs: {span: 16},
  125. sm: {span: 19},
  126. },
  127. url: {
  128. list: "/sys/dict/list",
  129. delete: "/sys/dict/delete",
  130. exportXlsUrl: "sys/dict/exportXls",
  131. importExcelUrl: "sys/dict/importExcel",
  132. refleshCache: "sys/dict/refleshCache",
  133. queryAllDictItems: "sys/dict/queryAllDictItems",
  134. },
  135. }
  136. },
  137. computed: {
  138. importExcelUrl: function () {
  139. return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
  140. }
  141. },
  142. methods: {
  143. getQueryParams() {
  144. var param = Object.assign({}, this.queryParam, this.isorter);
  145. param.field = this.getQueryField();
  146. param.pageNo = this.ipagination.current;
  147. param.pageSize = this.ipagination.pageSize;
  148. if (this.superQueryParams) {
  149. param['superQueryParams'] = encodeURI(this.superQueryParams)
  150. param['superQueryMatchType'] = this.superQueryMatchType
  151. }
  152. return filterObj(param);
  153. },
  154. //取消选择
  155. cancelDict() {
  156. this.dict = "";
  157. this.visible = false;
  158. this.loadData();
  159. },
  160. //编辑字典数据
  161. editDictItem(record) {
  162. this.$refs.dictItemList.edit(record);
  163. },
  164. // 重置字典类型搜索框的内容
  165. searchReset() {
  166. var that = this;
  167. that.queryParam.dictName = "";
  168. that.queryParam.dictCode = "";
  169. that.loadData(this.ipagination.current);
  170. },
  171. openDeleteList(){
  172. this.$refs.dictDeleteList.show()
  173. },
  174. refleshCache(){
  175. getAction(this.url.refleshCache).then((res) => {
  176. if (res.success) {
  177. //重新加载缓存
  178. getAction(this.url.queryAllDictItems).then((res) => {
  179. if (res.success) {
  180. Vue.ls.remove(UI_CACHE_DB_DICT_DATA)
  181. Vue.ls.set(UI_CACHE_DB_DICT_DATA, res.result, 7 * 24 * 60 * 60 * 1000)
  182. }
  183. })
  184. this.$message.success("刷新缓存完成!");
  185. }
  186. }).catch(e=>{
  187. this.$message.warn("刷新缓存失败!");
  188. console.log("刷新失败",e)
  189. })
  190. }
  191. },
  192. watch: {
  193. openKeys(val) {
  194. console.log('openKeys', val)
  195. },
  196. },
  197. }
  198. </script>
  199. <style scoped>
  200. @import '~@assets/less/common.less'
  201. </style>