select-release-rules.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. <!-- 单选列 -->
  21. <template v-slot:radio="{ row }">
  22. <el-radio
  23. class="radio"
  24. v-model="currentRowId"
  25. :label="row.id"
  26. @change="radioChange($event, row)"
  27. ><i></i
  28. ></el-radio>
  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 search from './search.vue';
  40. import {
  41. recordrulesPage,
  42. recordrulesNotProduceTaskConfigRecordRulesPage
  43. } from '@/api/recordRules/index';
  44. import tabMixins from '@/mixins/tableColumnsMixin';
  45. import dictMixins from '@/mixins/dictMixins';
  46. export default {
  47. components: { search },
  48. mixins: [tabMixins, dictMixins],
  49. props: {
  50. // NotProduceTaskConfig bool 是否排除已配置的记录规则 过程监测传true
  51. notProduceTaskConfig: {
  52. type: Boolean,
  53. default: false
  54. },
  55. // 是否多选
  56. multiple: {
  57. type: Boolean,
  58. default: false
  59. }
  60. },
  61. computed: {
  62. columns() {
  63. const list = [
  64. {
  65. columnKey: 'index',
  66. label: '序号',
  67. type: 'index',
  68. width: 55,
  69. align: 'center',
  70. showOverflowTooltip: true
  71. },
  72. {
  73. prop: 'code',
  74. label: '记录规则编码',
  75. align: 'center',
  76. showOverflowTooltip: true,
  77. minWidth: 110
  78. },
  79. {
  80. prop: 'name',
  81. label: '记录规则名称',
  82. align: 'center',
  83. showOverflowTooltip: true,
  84. minWidth: 110
  85. },
  86. {
  87. prop: 'classify',
  88. label: '记录规则分类',
  89. align: 'center',
  90. showOverflowTooltip: true,
  91. minWidth: 110,
  92. formatter: (row) => {
  93. return this.getDictValue('记录规则类型', row.classify);
  94. }
  95. },
  96. {
  97. prop: 'reportWorkType',
  98. label: '模块分类',
  99. align: 'center',
  100. showOverflowTooltip: true,
  101. minWidth: 110,
  102. formatter: (row) => {
  103. return this.getDictValue('记录规则报工类型', row.reportWorkType);
  104. }
  105. },
  106. {
  107. prop: 'version',
  108. label: '版本号',
  109. align: 'center',
  110. showOverflowTooltip: true,
  111. minWidth: 110,
  112. formatter: (row) => {
  113. return `${row.versionSymbol}${row.bigVersion}${row.versionMark}${row.smallVersion}`;
  114. }
  115. },
  116. {
  117. prop: 'fromName',
  118. label: '来源版本',
  119. align: 'center',
  120. showOverflowTooltip: true,
  121. minWidth: 150
  122. },
  123. {
  124. prop: 'startDate',
  125. label: '启用日期',
  126. align: 'center',
  127. showOverflowTooltip: true,
  128. minWidth: 110
  129. },
  130. {
  131. prop: 'stopDate',
  132. label: '停用日期',
  133. align: 'center',
  134. showOverflowTooltip: true,
  135. minWidth: 110
  136. },
  137. {
  138. prop: '',
  139. label: '周期',
  140. align: 'center',
  141. showOverflowTooltip: true,
  142. formatter: (row) => {
  143. return (
  144. row.frequencyValue +
  145. this.getDictValue('规则周期', row.frequencyUnit + '')
  146. );
  147. }
  148. },
  149. {
  150. prop: 'createUserName',
  151. label: '创建人',
  152. align: 'center',
  153. showOverflowTooltip: true,
  154. minWidth: 110
  155. },
  156. {
  157. prop: 'createTime',
  158. label: '创建时间',
  159. align: 'center',
  160. showOverflowTooltip: true,
  161. minWidth: 110
  162. },
  163. {
  164. prop: 'enable',
  165. label: '是否启用',
  166. align: 'center',
  167. showOverflowTooltip: true,
  168. minWidth: 110,
  169. formatter: (row) => {
  170. return row.enable ? '启用' : '停用';
  171. }
  172. },
  173. {
  174. prop: 'publishStatus',
  175. label: '状态',
  176. align: 'center',
  177. showOverflowTooltip: true,
  178. minWidth: 110,
  179. formatter: (row) => {
  180. switch (row.publishStatus) {
  181. case 0:
  182. return '草稿';
  183. case 1:
  184. return '已发布';
  185. case 2:
  186. return '已撤销';
  187. default:
  188. return '';
  189. }
  190. }
  191. }
  192. ];
  193. if (this.multiple) {
  194. list.unshift({
  195. type: 'selection',
  196. width: 50,
  197. align: 'center',
  198. fixed: 'left'
  199. });
  200. } else {
  201. list.unshift({
  202. prop: 'radio',
  203. width: 50,
  204. align: 'center',
  205. fixed: 'left',
  206. slot: 'radio'
  207. });
  208. }
  209. return list;
  210. }
  211. },
  212. data() {
  213. return {
  214. loading: false,
  215. visible: false,
  216. selection: [],
  217. produceTaskId: '',
  218. reportWorkType: '', // 记录规则报工类型 产前、过程、产后
  219. currentRowId: null,
  220. currentRow: null
  221. };
  222. },
  223. created() {
  224. this.requestDict('记录规则类型');
  225. this.requestDict('规则周期');
  226. },
  227. methods: {
  228. open(reportWorkType, produceTaskId) {
  229. console.log('reportWorkType', reportWorkType);
  230. console.log('produceTaskId', produceTaskId);
  231. this.visible = true;
  232. this.selection = [];
  233. this.currentRowId = null;
  234. this.currentRow = null;
  235. this.reportWorkType = reportWorkType || '';
  236. this.produceTaskId = produceTaskId || '';
  237. this.reload(); // 刷新表格
  238. },
  239. updateVisible(val) {
  240. this.visible = val;
  241. },
  242. /* 表格数据源 */
  243. datasource({ page, limit, where }) {
  244. const API = this.notProduceTaskConfig
  245. ? recordrulesNotProduceTaskConfigRecordRulesPage
  246. : recordrulesPage;
  247. return API({
  248. pageNum: page,
  249. size: limit,
  250. // 已发布
  251. publishStatus: 1,
  252. // 启用
  253. enable: 1,
  254. ...where,
  255. reportWorkType: this.reportWorkType,
  256. produceTaskId: this.produceTaskId
  257. });
  258. },
  259. /* 刷新表格 */
  260. reload(where) {
  261. this.$refs.tableRef?.reload({
  262. page: 1, // 已发布
  263. where
  264. });
  265. },
  266. confirmSelection() {
  267. if (this.multiple && this.selection.length === 0) {
  268. this.$message.warning('请先选择记录规则');
  269. return;
  270. }
  271. if (!this.multiple && !this.currentRow) {
  272. this.$message.warning('请先选择记录规则');
  273. return;
  274. }
  275. this.$emit(
  276. 'chooseRules',
  277. this.multiple ? this.selection : this.currentRow
  278. );
  279. this.visible = false;
  280. },
  281. radioChange(_, row) {
  282. this.currentRow = row;
  283. }
  284. }
  285. };
  286. </script>