index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <matter-search @search="reload"> </matter-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. cache-key="systemRoleTable13"
  11. >
  12. <!-- 表头工具栏 -->
  13. <template v-slot:toolbar>
  14. <el-button
  15. size="small"
  16. type="primary"
  17. icon="el-icon-plus"
  18. class="ele-btn-icon"
  19. @click="openEdit('add')"
  20. >
  21. 新建
  22. </el-button>
  23. </template>
  24. <!-- 编码列 -->
  25. <template v-slot:code="{ row }">
  26. <el-link type="primary" :underline="false" @click="goDetail(row)">
  27. {{ row.code }}
  28. </el-link>
  29. </template>
  30. <!-- 操作列 -->
  31. <template v-slot:action="{ row }">
  32. <el-link
  33. type="primary"
  34. :underline="false"
  35. icon="el-icon-finished"
  36. @click="openEdit('clone', row)"
  37. >
  38. 克隆
  39. </el-link>
  40. <el-link
  41. type="primary"
  42. :underline="false"
  43. icon="el-icon-edit"
  44. @click="openEdit('edit', row)"
  45. >
  46. 修改
  47. </el-link>
  48. <el-popconfirm
  49. class="ele-action"
  50. title="确定要删除此条数据吗?"
  51. @confirm="remove(row)"
  52. >
  53. <template v-slot:reference>
  54. <el-link type="danger" :underline="false" icon="el-icon-delete">
  55. 删除
  56. </el-link>
  57. </template>
  58. </el-popconfirm>
  59. </template>
  60. </ele-pro-table>
  61. </el-card>
  62. <!-- 新建或编辑弹窗 -->
  63. <matter-add
  64. ref="addMatterRulesRef"
  65. :pageType="pageType"
  66. :dialogTitle="dialogTitle"
  67. @done="reload"
  68. />
  69. </div>
  70. </template>
  71. <script>
  72. import MatterSearch from './components/matter-search.vue';
  73. import MatterAdd from './components/matter-add.vue';
  74. import { getList, getDetail, removeRule } from '@/api/ruleManagement/matter';
  75. import dictMixins from '@/mixins/dictMixins';
  76. export default {
  77. mixins: [dictMixins],
  78. components: {
  79. MatterSearch,
  80. MatterAdd
  81. },
  82. data() {
  83. return {
  84. // 表格列配置
  85. columns: [
  86. {
  87. columnKey: 'index',
  88. label: '序号',
  89. type: 'index',
  90. width: 55,
  91. align: 'center',
  92. showOverflowTooltip: true,
  93. fixed: 'left'
  94. },
  95. {
  96. prop: 'code',
  97. label: '规则编码',
  98. align: 'center',
  99. showOverflowTooltip: true,
  100. minWidth: 110,
  101. slot: 'code'
  102. },
  103. {
  104. prop: 'status',
  105. label: '状态',
  106. align: 'center',
  107. showOverflowTooltip: true,
  108. minWidth: 110,
  109. formatter: (_row, _column, cellValue) => {
  110. return this.getDictValue('规则状态', _row.status);
  111. }
  112. },
  113. {
  114. prop: 'ruleType',
  115. label: '规则类型',
  116. align: 'center',
  117. showOverflowTooltip: true,
  118. slot: 'enable',
  119. minWidth: 110,
  120. formatter: (_row, _column, cellValue) => {
  121. return this.getDictValue('规则类型', _row.ruleType);
  122. }
  123. },
  124. {
  125. prop: 'name',
  126. label: '规则名称',
  127. align: 'center',
  128. showOverflowTooltip: true,
  129. minWidth: 110
  130. },
  131. {
  132. prop: 'cycle',
  133. label: '周期',
  134. align: 'center',
  135. showOverflowTooltip: true,
  136. minWidth: 110,
  137. formatter: (_row, _column, cellValue) => {
  138. return this.getDictValue('规则周期', _row.cycleType);
  139. }
  140. },
  141. {
  142. prop: 'createUserName',
  143. label: '创建人',
  144. align: 'center',
  145. showOverflowTooltip: true,
  146. minWidth: 110
  147. },
  148. {
  149. prop: 'createTime',
  150. label: '创建时间',
  151. align: 'center',
  152. showOverflowTooltip: true,
  153. minWidth: 110,
  154. formatter: (_row, _column, cellValue) => {
  155. return this.$util.toDateString(cellValue);
  156. }
  157. },
  158. {
  159. columnKey: 'action',
  160. label: '操作',
  161. width: 230,
  162. align: 'center',
  163. resizable: false,
  164. slot: 'action',
  165. showOverflowTooltip: true
  166. }
  167. ],
  168. // 加载状态
  169. loading: false,
  170. pageType: 'add',
  171. dialogTitle: ''
  172. };
  173. },
  174. computed: {},
  175. created() {
  176. this.requestDict('规则周期');
  177. this.requestDict('规则类型');
  178. this.requestDict('规则状态');
  179. },
  180. methods: {
  181. /* 表格数据源 */
  182. datasource({ page, limit, where, order }) {
  183. return getList({ pageNum: page, size: limit, ...where });
  184. },
  185. /* 刷新表格 */
  186. reload(where) {
  187. this.$refs.table.reload({ page: 1, where });
  188. },
  189. remove(row) {
  190. removeRule([row.id]).then((res) => {
  191. this.$message.success('删除成功!');
  192. this.reload();
  193. });
  194. },
  195. openEdit(type, row) {
  196. this.pageType = type;
  197. this.dialogTitle =
  198. type == 'add' ? '新建规则' : type == 'edit' ? '编辑规则' : '克隆规则';
  199. this.$refs.addMatterRulesRef.openDialog(row, type);
  200. },
  201. goDetail({ id }) {
  202. this.$router.push({
  203. path: '/rulesManagement/matterRules/details',
  204. query: { id }
  205. });
  206. }
  207. }
  208. };
  209. </script>
  210. <style lang="scss" scoped></style>