select-release-rules.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. <search @search="reload" />
  14. <ele-pro-table
  15. ref="tableRef"
  16. :columns="columns"
  17. :datasource="datasource"
  18. :selection.sync="selection"
  19. >
  20. </ele-pro-table>
  21. </el-card>
  22. <template v-slot:footer>
  23. <el-button type="primary" @click="confirmSelection"> 选择 </el-button>
  24. <el-button @click="visible = false">关闭</el-button>
  25. </template>
  26. </ele-modal>
  27. </template>
  28. <script>
  29. import search from './search.vue';
  30. import {
  31. recordrulesPage,
  32. recordrulesNotProduceTaskConfigRecordRulesPage
  33. } from '@/api/recordRules/index';
  34. import tabMixins from '@/mixins/tableColumnsMixin';
  35. import dictMixins from '@/mixins/dictMixins';
  36. export default {
  37. components: { search },
  38. mixins: [tabMixins, dictMixins],
  39. props: {
  40. // 是否多选
  41. multiple: {
  42. type: Boolean,
  43. default: false
  44. },
  45. // NotProduceTaskConfig bool 是否排除已配置的记录规则 过程监测传true
  46. notProduceTaskConfig: {
  47. type: Boolean,
  48. default: false
  49. }
  50. },
  51. computed: {
  52. columns() {
  53. return [
  54. {
  55. columnKey: 'index',
  56. label: '序号',
  57. type: 'index',
  58. width: 55,
  59. align: 'center',
  60. showOverflowTooltip: true,
  61. fixed: 'left'
  62. },
  63. {
  64. width: 45,
  65. type: 'selection',
  66. columnKey: 'selection',
  67. align: 'center'
  68. },
  69. {
  70. prop: 'code',
  71. label: '记录规则编码',
  72. align: 'center',
  73. showOverflowTooltip: true,
  74. minWidth: 110
  75. },
  76. {
  77. prop: 'name',
  78. label: '记录规则名称',
  79. align: 'center',
  80. showOverflowTooltip: true,
  81. minWidth: 110
  82. },
  83. {
  84. prop: 'classify',
  85. label: '记录规则分类',
  86. align: 'center',
  87. showOverflowTooltip: true,
  88. minWidth: 110,
  89. formatter: (row) => {
  90. return this.getDictValue('记录规则类型', row.classify);
  91. }
  92. },
  93. {
  94. prop: 'version',
  95. label: '版本号',
  96. align: 'center',
  97. showOverflowTooltip: true,
  98. minWidth: 110,
  99. formatter: (row) => {
  100. return row.version ? `V${row.version.toFixed(1)}` : '';
  101. }
  102. },
  103. {
  104. prop: 'fromName',
  105. label: '来源版本',
  106. align: 'center',
  107. showOverflowTooltip: true,
  108. minWidth: 150
  109. },
  110. {
  111. prop: 'startDate',
  112. label: '启用日期',
  113. align: 'center',
  114. showOverflowTooltip: true,
  115. minWidth: 110
  116. },
  117. {
  118. prop: 'stopDate',
  119. label: '停用日期',
  120. align: 'center',
  121. showOverflowTooltip: true,
  122. minWidth: 110
  123. },
  124. {
  125. prop: '',
  126. label: '周期',
  127. align: 'center',
  128. showOverflowTooltip: true,
  129. formatter: (row) => {
  130. return (
  131. row.frequencyValue +
  132. this.getDictValue('规则周期', row.frequencyUnit + '')
  133. );
  134. }
  135. },
  136. {
  137. prop: 'createUserName',
  138. label: '创建人',
  139. align: 'center',
  140. showOverflowTooltip: true,
  141. minWidth: 110
  142. },
  143. {
  144. prop: 'createTime',
  145. label: '创建时间',
  146. align: 'center',
  147. showOverflowTooltip: true,
  148. minWidth: 110
  149. },
  150. {
  151. prop: 'enable',
  152. label: '是否启用',
  153. align: 'center',
  154. showOverflowTooltip: true,
  155. minWidth: 110,
  156. formatter: (row) => {
  157. return row.enable ? '启用' : '停用';
  158. }
  159. },
  160. {
  161. prop: 'publishStatus',
  162. label: '状态',
  163. align: 'center',
  164. showOverflowTooltip: true,
  165. minWidth: 110,
  166. formatter: (row) => {
  167. switch (row.publishStatus) {
  168. case 0:
  169. return '草稿';
  170. case 1:
  171. return '已发布';
  172. case 2:
  173. return '已撤销';
  174. default:
  175. return '';
  176. }
  177. }
  178. }
  179. ];
  180. }
  181. },
  182. data() {
  183. return {
  184. loading: false,
  185. visible: false,
  186. selection: []
  187. };
  188. },
  189. mounted() {
  190. this.requestDict('记录规则类型');
  191. this.requestDict('规则周期');
  192. },
  193. methods: {
  194. open() {
  195. this.visible = true;
  196. this.selection = [];
  197. this.reload({}); // 刷新表格
  198. },
  199. updateVisible(val) {
  200. this.visible = val;
  201. },
  202. /* 表格数据源 */
  203. datasource({ page, limit, where }) {
  204. const API = this.notProduceTaskConfig
  205. ? recordrulesNotProduceTaskConfigRecordRulesPage
  206. : recordrulesPage;
  207. return API({
  208. pageNum: page,
  209. size: limit,
  210. // 已发布
  211. publishStatus: 1,
  212. // 启用
  213. enable: 1,
  214. ...where
  215. });
  216. },
  217. /* 刷新表格 */
  218. reload(where) {
  219. this.$refs.tableRef?.reload({
  220. page: 1, // 已发布
  221. publishStatus: 1,
  222. // 启用
  223. enable: 1,
  224. where
  225. });
  226. },
  227. confirmSelection() {
  228. if (this.selection.length == 0) {
  229. this.$message.warning('请选择记录规则!');
  230. return;
  231. }
  232. if (this.multiple) {
  233. this.$emit('chooseRules', this.selection);
  234. } else {
  235. if (this.selection.length > 1) {
  236. this.$message.warning('只能选择一条记录规则');
  237. return;
  238. }
  239. this.$emit('chooseRules', this.selection[0]);
  240. }
  241. this.visible = false;
  242. }
  243. }
  244. };
  245. </script>