selectPlanRules.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. :before-close="handleClose"
  12. >
  13. <el-card shadow="never" v-loading="loading">
  14. <seekPage :seekList="seekList" @search="reload" :maxLength="4"></seekPage>
  15. <ele-pro-table
  16. ref="tableRef"
  17. :columns="columns"
  18. :datasource="datasource"
  19. :selection.sync="selection"
  20. cache-key="select-plan-rules-table-2511141448"
  21. >
  22. <!-- 单选列 -->
  23. <template v-slot:radio="{ row }">
  24. <el-radio
  25. class="radio"
  26. v-model="currentRowId"
  27. :label="row.id"
  28. @change="radioChange($event, row)"
  29. ><i></i
  30. ></el-radio>
  31. </template>
  32. </ele-pro-table>
  33. </el-card>
  34. <template v-slot:footer>
  35. <el-button type="primary" @click="confirmSelection"> 选择 </el-button>
  36. <el-button @click="visible = false">关闭</el-button>
  37. </template>
  38. </ele-modal>
  39. </template>
  40. <script>
  41. import tabMixins from '@/mixins/tableColumnsMixin';
  42. import dictMixins from '@/mixins/dictMixins';
  43. import { planConfigPage } from '@/api/ruleManagement/plan.js';
  44. export default {
  45. components: {},
  46. mixins: [tabMixins, dictMixins],
  47. props: {
  48. // 是否多选
  49. multiple: {
  50. type: Boolean,
  51. default: false
  52. },
  53. // 默认 筛选条件
  54. where: {
  55. type: Object,
  56. default: () => ({
  57. // 生效
  58. status: 1
  59. })
  60. },
  61. // 1巡点检 2保养
  62. ruleTypes: {
  63. type: Array,
  64. default: () => {
  65. return [1, 2];
  66. }
  67. }
  68. },
  69. computed: {
  70. columns() {
  71. const list = [
  72. {
  73. columnKey: 'index',
  74. label: '序号',
  75. type: 'index',
  76. width: 55,
  77. align: 'center',
  78. showOverflowTooltip: true,
  79. fixed: 'left'
  80. },
  81. {
  82. prop: 'code',
  83. label: '计划配置单号',
  84. align: 'center',
  85. showOverflowTooltip: true,
  86. minWidth: 110,
  87. slot: 'code'
  88. },
  89. {
  90. prop: 'name',
  91. label: '计划配置名称',
  92. align: 'center',
  93. showOverflowTooltip: true,
  94. minWidth: 110
  95. },
  96. ...[
  97. this.ruleType == 1
  98. ? {
  99. prop: 'groupName',
  100. label: '巡点检部门',
  101. align: 'center',
  102. showOverflowTooltip: true,
  103. minWidth: 110,
  104. slot: 'groupName'
  105. }
  106. : {
  107. prop: 'groupName',
  108. label: '部门',
  109. align: 'center',
  110. showOverflowTooltip: true,
  111. minWidth: 110,
  112. slot: 'groupName'
  113. }
  114. ],
  115. {
  116. prop: 'categoryName',
  117. label: '设备分类',
  118. align: 'center',
  119. showOverflowTooltip: true,
  120. minWidth: 110
  121. },
  122. {
  123. prop: 'ruleName',
  124. label: '规则名称',
  125. align: 'center',
  126. showOverflowTooltip: true,
  127. minWidth: 110
  128. },
  129. {
  130. prop: 'autoOrder',
  131. label: '自动派单',
  132. align: 'center',
  133. showOverflowTooltip: true,
  134. minWidth: 110,
  135. formatter: (_row) => {
  136. let autoOrder =
  137. _row.autoOrder == 1 ? '是' : _row.autoOrder == 0 ? '否' : '-';
  138. return autoOrder;
  139. }
  140. },
  141. {
  142. //修改此prop名称时,请同步修改columnKey属性和下方selectType方法
  143. prop: 'status',
  144. label: '状态',
  145. align: 'center',
  146. showOverflowTooltip: true,
  147. minWidth: 110,
  148. formatter: (_row) => {
  149. return this.getDictValue('规则状态', _row.status);
  150. },
  151. filters: [
  152. { value: 1, text: '生效' },
  153. { value: 0, text: '失效' }
  154. ],
  155. filterMultiple: false,
  156. columnKey: 'status'
  157. },
  158. {
  159. prop: 'createUserName',
  160. label: '创建人',
  161. align: 'center',
  162. showOverflowTooltip: true,
  163. minWidth: 110
  164. },
  165. {
  166. prop: 'createTime',
  167. label: '创建时间',
  168. align: 'center',
  169. showOverflowTooltip: true,
  170. minWidth: 110,
  171. formatter: (_row, _column, cellValue) => {
  172. return this.$util.toDateString(cellValue);
  173. }
  174. }
  175. ];
  176. if (this.multiple) {
  177. list.unshift({
  178. type: 'selection',
  179. width: 50,
  180. align: 'center',
  181. fixed: 'left'
  182. });
  183. } else {
  184. list.unshift({
  185. prop: 'radio',
  186. width: 50,
  187. align: 'center',
  188. fixed: 'left',
  189. slot: 'radio'
  190. });
  191. }
  192. return list;
  193. },
  194. seekList() {
  195. return [
  196. {
  197. label: '规则名称:',
  198. value: 'name',
  199. type: 'input',
  200. placeholder: '规则名称'
  201. },
  202. {
  203. label: '规则编码:',
  204. value: 'code',
  205. type: 'input',
  206. placeholder: '规则编码'
  207. }
  208. ];
  209. }
  210. },
  211. data() {
  212. return {
  213. loading: false,
  214. visible: false,
  215. selection: [],
  216. produceTaskId: '',
  217. reportWorkType: '', // 事项报工类型 产前、过程、产后
  218. currentRowId: null,
  219. currentRow: null
  220. };
  221. },
  222. created() {
  223. this.requestDict('事项类型');
  224. this.requestDict('规则周期');
  225. },
  226. methods: {
  227. open() {
  228. this.visible = true;
  229. this.reload(); // 刷新表格
  230. },
  231. updateVisible(val) {
  232. this.visible = val;
  233. },
  234. /* 表格数据源 */
  235. datasource({ page, limit, where }) {
  236. return planConfigPage({
  237. pageNum: page,
  238. size: limit,
  239. ...where,
  240. ...this.where,
  241. ruleTypes: this.ruleTypes
  242. });
  243. },
  244. /* 刷新表格 */
  245. reload(where = {}) {
  246. this.$refs.tableRef?.reload({
  247. page: 1, // 已发布
  248. where
  249. });
  250. },
  251. confirmSelection() {
  252. if (this.multiple && this.selection.length === 0) {
  253. this.$message.warning('请先选择事项');
  254. return;
  255. }
  256. if (!this.multiple && !this.currentRow) {
  257. this.$message.warning('请先选择事项');
  258. return;
  259. }
  260. this.$emit(
  261. 'chooseRules',
  262. this.multiple ? this.selection : this.currentRow
  263. );
  264. this.handleClose();
  265. },
  266. radioChange(_, row) {
  267. this.currentRow = row;
  268. },
  269. handleClose() {
  270. this.selection = [];
  271. this.currentRowId = null;
  272. this.currentRow = null;
  273. this.visible = false;
  274. }
  275. }
  276. };
  277. </script>