select-matter-rules.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <ele-modal
  3. :visible="visible"
  4. :append-to-body="true"
  5. :close-on-click-modal="false"
  6. custom-class="ele-dialog-form"
  7. title="选择事项规则"
  8. @update:visible="updateVisible"
  9. :maxable="true"
  10. width="90%"
  11. >
  12. <el-card shadow="never" v-loading="loading">
  13. <matter-search @search="reload" :filterType="filterType"> </matter-search>
  14. <!-- 数据表格 -->
  15. <ele-pro-table
  16. ref="table"
  17. :columns="columns"
  18. :datasource="datasource"
  19. :page-size="pageSize"
  20. @columns-change="handleColumnChange"
  21. :cache-key="cacheKeyUrl"
  22. :selection.sync="selection"
  23. >
  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. </ele-pro-table>
  31. </el-card>
  32. <template v-slot:footer>
  33. <el-button type="primary" @click="confirmSelection"> 选择 </el-button>
  34. <el-button @click="visible = false">关闭</el-button>
  35. </template>
  36. </ele-modal>
  37. </template>
  38. <script>
  39. import tabMixins from '@/mixins/tableColumnsMixin';
  40. import MatterSearch from './matter-search.vue';
  41. import { getList, removeRule } from '@/api/ruleManagement/matter';
  42. import dictMixins from '@/mixins/dictMixins';
  43. export default {
  44. mixins: [dictMixins, tabMixins],
  45. emits: ['chooseRules'],
  46. props: {
  47. filterType: {
  48. type: Array,
  49. default: () => {
  50. return [];
  51. }
  52. },
  53. // 是否多选
  54. multiple: {
  55. type: Boolean,
  56. default: false
  57. }
  58. },
  59. components: {
  60. MatterSearch
  61. },
  62. data() {
  63. return {
  64. // 表格列配置
  65. columns: [
  66. {
  67. columnKey: 'index',
  68. label: '序号',
  69. type: 'index',
  70. width: 55,
  71. align: 'center',
  72. showOverflowTooltip: true,
  73. fixed: 'left'
  74. },
  75. {
  76. width: 45,
  77. type: 'selection',
  78. columnKey: 'selection',
  79. align: 'center'
  80. },
  81. {
  82. prop: 'code',
  83. label: '规则编码',
  84. align: 'center',
  85. showOverflowTooltip: true,
  86. minWidth: 110,
  87. slot: 'code'
  88. },
  89. {
  90. prop: 'status',
  91. label: '状态',
  92. align: 'center',
  93. showOverflowTooltip: true,
  94. minWidth: 110,
  95. formatter: (_row) => {
  96. return this.getDictValue('规则状态', _row.status);
  97. }
  98. },
  99. {
  100. prop: 'ruleType',
  101. label: '规则类型',
  102. align: 'center',
  103. showOverflowTooltip: true,
  104. slot: 'enable',
  105. minWidth: 110,
  106. formatter: (_row) => {
  107. return this.getDictValue('规则类型', _row.ruleType);
  108. }
  109. },
  110. {
  111. prop: 'name',
  112. label: '规则名称',
  113. align: 'center',
  114. showOverflowTooltip: true,
  115. minWidth: 110
  116. },
  117. {
  118. prop: 'cycle',
  119. label: '周期',
  120. align: 'center',
  121. showOverflowTooltip: true,
  122. minWidth: 110,
  123. formatter: (_row) => {
  124. return this.getDictValue('规则周期', _row.cycleType);
  125. }
  126. },
  127. {
  128. prop: 'createUserName',
  129. label: '创建人',
  130. align: 'center',
  131. showOverflowTooltip: true,
  132. minWidth: 110
  133. },
  134. {
  135. prop: 'createTime',
  136. label: '创建时间',
  137. align: 'center',
  138. showOverflowTooltip: true,
  139. minWidth: 110,
  140. formatter: (_row, _column, cellValue) => {
  141. return this.$util.toDateString(cellValue);
  142. }
  143. }
  144. ],
  145. // 加载状态
  146. loading: false,
  147. pageType: 'add',
  148. dialogTitle: '',
  149. pageSize: this.$store.state.tablePageSize,
  150. cacheKeyUrl: '0c40331c-rulesManagement-matterRules',
  151. visible: false,
  152. selection: [],
  153. produceTaskOptions: []
  154. };
  155. },
  156. computed: {},
  157. mounted() {
  158. this.requestDict('规则周期');
  159. this.requestDict('规则类型');
  160. this.requestDict('规则状态');
  161. },
  162. methods: {
  163. open(selection = []) {
  164. this.visible = true;
  165. this.selection = selection;
  166. this.reload();
  167. },
  168. updateVisible(val) {
  169. this.visible = val;
  170. },
  171. /* 表格数据源 */
  172. datasource({ page, limit, where }) {
  173. return getList({
  174. pageNum: page,
  175. size: limit,
  176. ...where,
  177. types: this.filterType
  178. });
  179. },
  180. /* 刷新表格 */
  181. reload(where = {}) {
  182. this.$refs.table?.reload({ page: 1, where, types: this.filterType });
  183. },
  184. remove(row) {
  185. removeRule([row.id]).then(() => {
  186. this.$message.success('删除成功!');
  187. this.reload();
  188. });
  189. },
  190. openEdit(type, row) {
  191. this.pageType = type;
  192. this.dialogTitle =
  193. type == 'add' ? '新建规则' : type == 'edit' ? '编辑规则' : '克隆规则';
  194. this.$refs.addMatterRulesRef.openDialog(row, type);
  195. },
  196. goDetail({ id }) {
  197. this.$router.push({
  198. path: '/rulesManagement/matterRules/details',
  199. query: { id }
  200. });
  201. },
  202. confirmSelection() {
  203. if (this.selection.length == 0) {
  204. this.$message.warning('请选择事项规则!');
  205. return;
  206. }
  207. if (this.multiple) {
  208. this.$emit('chooseRules', this.selection);
  209. } else {
  210. if (this.selection.length > 1) {
  211. this.$message.warning('只能选择一条事项规则');
  212. return;
  213. }
  214. this.$emit('chooseRules', this.selection[0]);
  215. }
  216. this.visible = false;
  217. }
  218. }
  219. };
  220. </script>
  221. <style lang="scss" scoped></style>