batchRevokeDialog.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <ele-modal
  3. title="批量撤回工单"
  4. :visible.sync="visible"
  5. :before-close="handleCancel"
  6. :close-on-click-modal="false"
  7. :close-on-press-escape="false"
  8. append-to-body
  9. width="70%"
  10. :maxable="true"
  11. >
  12. <el-card shadow="never">
  13. <seek-page
  14. :seekList="seekList"
  15. @search="search"
  16. :maxLength="4"
  17. style="margin-bottom: 15px"
  18. ></seek-page>
  19. <ele-pro-table
  20. ref="table"
  21. row-key="id"
  22. :columns="columns"
  23. :datasource="datasource"
  24. :selection.sync="selection"
  25. :cache-key="cacheKeyUrl"
  26. height="calc(100vh - 520px)"
  27. @selection-change="handleSelectionChange"
  28. :page-size="defPageSize"
  29. :initLoad="false"
  30. >
  31. </ele-pro-table>
  32. </el-card>
  33. <div slot="footer" class="dialog-footer">
  34. <el-button @click="handleCancel">取消</el-button>
  35. <el-button
  36. type="primary"
  37. :loading="revokeLoading"
  38. @click="handleBatchRevoke"
  39. >批量撤回</el-button
  40. >
  41. </div>
  42. </ele-modal>
  43. </template>
  44. <script>
  45. import {
  46. producetaskrulerecordQueryRecordWorkOrderPage,
  47. batchRevokeOrder
  48. } from '@/api/recordRules/index';
  49. import { getteampage } from '@/api/main/index.js';
  50. import { getFactoryarea } from '@/api/factoryModel/index';
  51. export default {
  52. props: {
  53. pageName: {
  54. type: String,
  55. default: 'productionRecords'
  56. }
  57. },
  58. data() {
  59. return {
  60. visible: false,
  61. revokeLoading: false,
  62. selection: [],
  63. planTypeList: {
  64. productionRecords: 2,
  65. steamInjectionInspectionRecord: 3,
  66. solidWasteRecord: 4,
  67. qualityTestRecords: 5,
  68. QualityInspection: 7,
  69. boilerOperationRecord: 6,
  70. HaulSlag: 8,
  71. TransportAsh: 9
  72. },
  73. planCode: 0,
  74. columns: [
  75. {
  76. type: 'selection',
  77. width: 50,
  78. align: 'center',
  79. fixed: 'left'
  80. },
  81. {
  82. columnKey: 'index',
  83. label: '序号',
  84. type: 'index',
  85. width: 55,
  86. align: 'center',
  87. showOverflowTooltip: true,
  88. fixed: 'left'
  89. },
  90. {
  91. prop: 'code',
  92. label: '工单单号',
  93. align: 'center',
  94. minWidth: 150,
  95. showOverflowTooltip: true
  96. },
  97. {
  98. prop: 'planCode',
  99. label: '计划单号',
  100. align: 'center',
  101. showOverflowTooltip: true,
  102. minWidth: 150
  103. },
  104. {
  105. prop: 'ruleName',
  106. label: '记录规则名称',
  107. align: 'center',
  108. showOverflowTooltip: true,
  109. minWidth: 110
  110. },
  111. {
  112. prop: 'productLineName',
  113. label: '场站名称',
  114. align: 'center',
  115. showOverflowTooltip: true,
  116. minWidth: 110
  117. },
  118. {
  119. prop: 'teamName',
  120. label: '班组',
  121. align: 'center',
  122. showOverflowTooltip: true,
  123. minWidth: 110
  124. },
  125. {
  126. prop: 'createTime',
  127. label: '工单生成时间',
  128. align: 'center',
  129. showOverflowTooltip: true,
  130. minWidth: 110
  131. },
  132. {
  133. prop: '',
  134. label: '执行人',
  135. align: 'center',
  136. showOverflowTooltip: true,
  137. minWidth: 110,
  138. formatter: (row) => {
  139. if (row.executeUsers) {
  140. return row.executeUsers.map((i) => i.userName).join(',');
  141. }
  142. return '';
  143. }
  144. },
  145. {
  146. prop: 'status',
  147. label: '状态',
  148. align: 'center',
  149. showOverflowTooltip: true,
  150. minWidth: 110,
  151. formatter: (row) => {
  152. const statusMap = {
  153. 0: '未报工',
  154. 1: '执行中',
  155. 2: '已执行'
  156. };
  157. return statusMap[row.status] || '';
  158. }
  159. }
  160. ],
  161. cacheKeyUrl: `pcs-2511241029-${this.pageName + ''}-batchRevoke`,
  162. teamList: [],
  163. productLineList: []
  164. };
  165. },
  166. computed: {
  167. seekList() {
  168. return [
  169. {
  170. label: '关键字',
  171. value: 'keyword',
  172. type: 'input',
  173. width: '280px',
  174. placeholder: '工单单号,计划单号,记录规则名称'
  175. },
  176. {
  177. label: '场站',
  178. value: 'productLineId',
  179. type: 'select',
  180. planList: this.productLineList,
  181. placeholder: '请选择'
  182. },
  183. {
  184. label: '班组',
  185. value: 'teamId',
  186. type: 'select',
  187. planList: this.teamList,
  188. placeholder: '请选择'
  189. },
  190. {
  191. label: '状态',
  192. value: 'status',
  193. type: 'select',
  194. placeholder: '请输入',
  195. planList: [
  196. { value: 0, label: '未报工' },
  197. { value: 1, label: '执行中' },
  198. { value: 2, label: '已执行' }
  199. ]
  200. },
  201. {
  202. label: '创建时间:',
  203. value: 'createTime',
  204. type: 'date',
  205. dateType: 'datetimerange',
  206. placeholder: '',
  207. width: 380,
  208. valueAr: ['createTimeStart', 'createTimeEnd']
  209. }
  210. ];
  211. }
  212. },
  213. created() {
  214. getteampage({
  215. pageNum: 1,
  216. size: -1
  217. }).then((res) => {
  218. this.teamList =
  219. res.list.map((item) => {
  220. return {
  221. value: item.id,
  222. label: item.name
  223. };
  224. }) || [];
  225. });
  226. getFactoryarea({
  227. pageNum: 1,
  228. size: 999,
  229. type: 4
  230. }).then((res) => {
  231. this.productLineList =
  232. res.list.map((item) => {
  233. return {
  234. value: item.id,
  235. label: item.name
  236. };
  237. }) || [];
  238. });
  239. },
  240. methods: {
  241. open(planCode) {
  242. this.visible = true;
  243. this.selection = [];
  244. this.planCode = planCode;
  245. this.$nextTick(() => {
  246. this.$refs.table.reload();
  247. });
  248. },
  249. reload(where = {}) {
  250. this.$refs.table.reload({ where });
  251. },
  252. datasource({ page, limit, where, order }) {
  253. const body = {
  254. ...where,
  255. ...order,
  256. pageNum: page,
  257. size: limit,
  258. keyword: this.planCode,
  259. status: 1,
  260. planType: this.planTypeList[this.pageName]
  261. };
  262. return producetaskrulerecordQueryRecordWorkOrderPage(body);
  263. },
  264. search(where) {
  265. if (where.time) {
  266. where.createTimeStart = where.time[0];
  267. where.createTimeEnd = where.time[1];
  268. where.time = null;
  269. }
  270. this.reload(where);
  271. },
  272. handleSelectionChange(selection) {
  273. this.selection = selection;
  274. },
  275. handleCancel() {
  276. this.visible = false;
  277. this.selection = [];
  278. },
  279. async handleBatchRevoke() {
  280. if (!this.selection.length) {
  281. this.$message.warning('请至少选择一条工单');
  282. return;
  283. }
  284. try {
  285. this.revokeLoading = true;
  286. const ids = this.selection.map((item) => item.id);
  287. await batchRevokeOrder(ids);
  288. this.$message.success('批量撤回成功');
  289. this.visible = false;
  290. this.selection = [];
  291. this.$emit('refresh');
  292. } catch (error) {
  293. this.$message.error('批量撤回失败');
  294. } finally {
  295. this.revokeLoading = false;
  296. }
  297. }
  298. }
  299. };
  300. </script>
  301. <style lang="scss" scoped>
  302. .dialog-footer {
  303. text-align: right;
  304. }
  305. </style>