index.vue 4.9 KB

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