new_produceOrder.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. <template>
  2. <div>
  3. <ele-pro-table
  4. ref="table"
  5. :columns="columns"
  6. height="calc(100vh - 280px)"
  7. width="100%"
  8. :datasource="datasource"
  9. :selection.sync="selection"
  10. @selection-change="handleSelectionChange"
  11. @cell-click="cellClick"
  12. highlight-current-row
  13. @select="cellClick"
  14. :need-page="false"
  15. @sort-change="onSortChange"
  16. @columns-change="handleColumnChange"
  17. :cache-key="cacheKeyUrl"
  18. :row-class-name="tableRowClassName"
  19. >
  20. <!-- <template v-slot:toolbar>
  21. <div class="rx-bc">
  22. <div class="c_title">工单列表 </div>
  23. <div>
  24. <el-input
  25. style="width: 180px"
  26. clearable
  27. v-model="code"
  28. placeholder="请输入工单号"
  29. />
  30. <el-button size="mini" type="primary" style="margin: 0 5px" @click="handleSearch">查询</el-button>
  31. </div>
  32. </div>
  33. </template> -->
  34. <template v-slot:code="{ row }">
  35. <el-link type="primary" @click="handRoute(row)" :underline="false">{{
  36. row.code
  37. }}</el-link>
  38. </template>
  39. <template v-slot:singleReport="{ row }">
  40. <el-tag size="mini">
  41. {{ row.singleReport == 1 ? '单个报工' : '批量报工' }}</el-tag
  42. >
  43. </template>
  44. <template v-slot:productUnitWeight="{ row }">
  45. <span> {{ row.productUnitWeight }}{{ row.weightUnit }}</span>
  46. </template>
  47. <template v-slot:taskName="{ row }">
  48. <span> {{ row.taskName }}</span>
  49. </template>
  50. <template v-slot:sourceType="{ row }">
  51. <span v-if="row.sourceType == 1">生产计划</span>
  52. <span v-if="row.sourceType == 2">临时生产计划</span>
  53. <span v-if="row.sourceType == 3">受托转订单</span>
  54. </template>
  55. <template v-slot:outsourceStatus="{ row }">
  56. <div v-if="row.outsourceStatus">
  57. <span v-if="row.outsourceStatus == 1">未委外</span>
  58. <span v-if="row.outsourceStatus == 2">委外中</span>
  59. <span v-if="row.outsourceStatus == 3">完成委外</span>
  60. </div>
  61. </template>
  62. <template v-slot:entrustStatus="{ row }">
  63. <div v-if="row.entrustStatus">
  64. <span v-if="row.entrustStatus == 1">未请托</span>
  65. <span v-if="row.entrustStatus == 2">请托中</span>
  66. <span v-if="row.entrustStatus == 3">请托完成</span>
  67. </div>
  68. </template>
  69. <template v-slot:workOrderType="{ row }">
  70. <span v-if="row.workOrderType == 1">普通订单</span>
  71. <span v-if="row.workOrderType == 2">临时订单</span>
  72. <span v-if="row.workOrderType == 3">受托订单</span>
  73. </template>
  74. <template v-slot:status="{ row }">
  75. <span> {{ sumStatus(row) }}</span>
  76. </template>
  77. <template v-slot:formingNum="{ row }">
  78. <span> {{ row.formingNum }} {{ row.unit }} </span>
  79. </template>
  80. <template v-slot:formingWeight="{ row }">
  81. <span> {{ row.formingWeight }} {{ row.weightUnit }} </span>
  82. </template>
  83. </ele-pro-table>
  84. <!-- //工单列表 -->
  85. <routings
  86. v-if="routingShow"
  87. :routeObj="routeObj"
  88. @closeRoute="closeRoute"
  89. ></routings>
  90. </div>
  91. </template>
  92. <script>
  93. import { workorderPage2 } from '@/api/produce/workOrder.js';
  94. import routings from './routings.vue';
  95. import { isFullscreen } from 'ele-admin';
  96. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  97. import {
  98. getList,
  99. removeItem,
  100. updateCertificateNumber
  101. } from '@/api/inspectionWork';
  102. export default {
  103. components: { routings },
  104. mixins: [tableColumnsMixin],
  105. emits: ['changeIsPreProductionResult'],
  106. props: {
  107. produceTaskInfo: {
  108. type: Object,
  109. default: () => {
  110. return null;
  111. }
  112. }
  113. },
  114. data() {
  115. return {
  116. loading: false,
  117. selection: [],
  118. routeObj: {},
  119. routingShow: false,
  120. code: '',
  121. internalIsFullscreen: isFullscreen(), // 初始值
  122. cacheKeyUrl: 'mes-145878-mes-produce',
  123. columnsVersion: 0
  124. };
  125. },
  126. computed: {
  127. // 表格列配置
  128. columns() {
  129. let columnsVersion = this.columnsVersion;
  130. return [
  131. {
  132. width: 45,
  133. type: 'selection',
  134. columnKey: 'selection',
  135. align: 'center',
  136. fixed: true
  137. },
  138. {
  139. columnKey: 'index',
  140. label: '序号',
  141. type: 'index',
  142. width: 55,
  143. align: 'center',
  144. showOverflowTooltip: true
  145. },
  146. {
  147. prop: 'batchNo',
  148. label: '批次号',
  149. align: 'center',
  150. showOverflowTooltip: true
  151. },
  152. {
  153. prop: 'code',
  154. slot: 'code',
  155. label: '生产工单号',
  156. align: 'center',
  157. minWidth: '160',
  158. showOverflowTooltip: true
  159. },
  160. {
  161. prop: 'produceRoutingName',
  162. label: '工艺路线',
  163. align: 'center',
  164. minWidth: '160',
  165. showOverflowTooltip: true
  166. },
  167. {
  168. prop: 'productCode',
  169. label: '编码',
  170. align: 'center',
  171. minWidth: '160',
  172. showOverflowTooltip: true
  173. },
  174. {
  175. prop: 'productName',
  176. label: '名称',
  177. align: 'center',
  178. showOverflowTooltip: true
  179. },
  180. {
  181. prop: 'sourceType',
  182. label: '来源类型',
  183. slot: 'sourceType',
  184. align: 'center',
  185. minWidth: 110,
  186. showOverflowTooltip: true
  187. },
  188. {
  189. prop: 'workOrderType',
  190. label: '订单类型',
  191. slot: 'workOrderType',
  192. align: 'center',
  193. minWidth: 110,
  194. showOverflowTooltip: true
  195. },
  196. {
  197. prop: 'singleReport',
  198. slot: 'singleReport',
  199. label: '报工类型',
  200. align: 'center',
  201. filters: [
  202. { text: '单个报工', value: 1 },
  203. { text: '批量报工', value: 0 }
  204. ],
  205. filterMethod: this.filterMethod,
  206. width: 100
  207. },
  208. {
  209. prop: 'model',
  210. label: '型号',
  211. align: 'center',
  212. showOverflowTooltip: true
  213. },
  214. {
  215. prop: 'specification',
  216. label: '规格',
  217. align: 'center',
  218. showOverflowTooltip: true
  219. },
  220. {
  221. prop: 'outsourceStatus',
  222. label: '委外状态',
  223. align: 'center',
  224. slot: 'outsourceStatus',
  225. showOverflowTooltip: true
  226. },
  227. {
  228. prop: 'entrustStatus',
  229. label: '请托状态',
  230. align: 'center',
  231. slot: 'entrustStatus',
  232. showOverflowTooltip: true
  233. },
  234. {
  235. prop: 'productionCodes',
  236. label: '生产编号',
  237. align: 'center',
  238. minWidth: 150,
  239. showOverflowTooltip: true
  240. },
  241. {
  242. prop: 'brandNo',
  243. label: '牌号',
  244. align: 'center',
  245. showOverflowTooltip: true
  246. },
  247. {
  248. prop: 'productUnitWeight',
  249. slot: 'productUnitWeight',
  250. label: '单重',
  251. align: 'center',
  252. showOverflowTooltip: true
  253. },
  254. {
  255. prop: 'priority',
  256. label: '优先级',
  257. align: 'center',
  258. minWidth: 120
  259. },
  260. {
  261. prop: 'formingNum',
  262. label: '要求生产数量',
  263. align: 'center',
  264. slot: 'formingNum',
  265. showOverflowTooltip: true,
  266. minWidth: 110
  267. },
  268. {
  269. prop: 'formingWeight',
  270. label: '要求生产重量',
  271. slot: 'formingWeight',
  272. align: 'center',
  273. showOverflowTooltip: true,
  274. minWidth: 110
  275. },
  276. {
  277. prop: 'formedNum',
  278. label: '已生产数量',
  279. align: 'center',
  280. showOverflowTooltip: true,
  281. minWidth: 110
  282. },
  283. {
  284. prop: 'formedWeight',
  285. label: '已生产重量',
  286. align: 'center',
  287. showOverflowTooltip: true,
  288. minWidth: 110
  289. },
  290. {
  291. slot: 'taskName',
  292. prop: 'taskName',
  293. label: '工序进度',
  294. align: 'center',
  295. showOverflowTooltip: true,
  296. sortable: 'custom',
  297. minWidth: 110
  298. },
  299. {
  300. slot: 'status',
  301. prop: 'status',
  302. label: '最新工单状态',
  303. align: 'center',
  304. showOverflowTooltip: true,
  305. minWidth: 110
  306. },
  307. {
  308. prop: 'colorKey',
  309. label: '颜色',
  310. align: 'center',
  311. showOverflowTooltip: true,
  312. minWidth: 110
  313. },
  314. {
  315. prop: 'modelKey',
  316. label: '机型',
  317. align: 'center',
  318. showOverflowTooltip: true,
  319. minWidth: 110
  320. },
  321. {
  322. prop: 'planStartTime',
  323. label: '计划开始时间',
  324. align: 'center',
  325. showOverflowTooltip: true,
  326. minWidth: 130,
  327. sortable: true
  328. },
  329. {
  330. prop: 'planCompleteTime',
  331. label: '计划结束时间',
  332. align: 'center',
  333. showOverflowTooltip: true,
  334. minWidth: 130,
  335. sortable: true
  336. },
  337. {
  338. prop: 'startTime',
  339. label: '实际开始时间',
  340. align: 'center',
  341. showOverflowTooltip: true,
  342. minWidth: 130,
  343. sortable: true
  344. },
  345. {
  346. prop: 'completeTime',
  347. label: '实际完成时间',
  348. align: 'center',
  349. showOverflowTooltip: true,
  350. minWidth: 130,
  351. sortable: true
  352. },
  353. {
  354. prop: 'createTime',
  355. label: '创建时间',
  356. align: 'center',
  357. showOverflowTooltip: true,
  358. minWidth: 130,
  359. sortable: true
  360. }
  361. ];
  362. },
  363. taskObj() {
  364. return this.$store.state.user.taskObj;
  365. },
  366. current() {
  367. console.log(this.$store.state.user, 'this.$store.state.user');
  368. return this.$store.state.user.currentObj.id;
  369. }
  370. },
  371. watch: {
  372. taskObj: {
  373. handler(val) {
  374. console.log('123');
  375. this.reload();
  376. },
  377. // immediate: true,
  378. deep: true
  379. },
  380. current: {
  381. handler(val) {
  382. console.log('456');
  383. this.reload();
  384. },
  385. // immediate: true,
  386. deep: true
  387. }
  388. },
  389. created() {},
  390. mounted() {
  391. // 添加窗口resize事件监听器
  392. window.addEventListener('resize', this.handleResize);
  393. },
  394. beforeDestroy() {
  395. // 组件销毁前移除事件监听器,防止内存泄漏
  396. window.removeEventListener('resize', this.handleResize);
  397. },
  398. methods: {
  399. filterMethod(value, row, column) {
  400. if (value == row.singleReport) {
  401. return row;
  402. }
  403. },
  404. sumStatus(row) {
  405. if (row.reportStatus === 1) {
  406. return '已报工';
  407. }
  408. if (row.feedStatus === 1) {
  409. return '已投料';
  410. }
  411. // {{ row.reportStatus }} {{ row.feedStatus }}
  412. },
  413. tableRowClassName({ row, rowIndex }) {
  414. if (row.outsourceStatus == 2) {
  415. return 'warning-row';
  416. }
  417. if (row.entrustStatus == 2) {
  418. return 'ent-row';
  419. }
  420. },
  421. /* 表格数据源 */
  422. datasource({ page, where }) {
  423. if (!this.taskObj?.id) {
  424. return [];
  425. }
  426. console.log(this.taskObj?.id);
  427. // if (this.taskObj?.id == '1916800744740663298') {
  428. // return getList({
  429. // pageNum: page,
  430. // size: 1000
  431. // });
  432. // } else {
  433. return workorderPage2({
  434. pageNum: page,
  435. size: 5000,
  436. workOrderId: this.$route.query.workOrderId
  437. ? this.$route.query.workOrderId
  438. : null,
  439. taskId: this.taskObj && this.taskObj.id,
  440. deviceId: this.current && this.current.deviceId,
  441. keyWord: this.keyWord,
  442. taskName: this.taskName,
  443. ...where
  444. });
  445. // }
  446. },
  447. onSortChange(e) {
  448. console.log(e);
  449. let sort = {
  450. orderBy: e.order,
  451. sortName: e.prop
  452. };
  453. this.where = sort;
  454. this.reload();
  455. },
  456. handleSearch(obj) {
  457. this.keyWord = obj.keyWord;
  458. this.taskName = obj.taskName;
  459. this.reload();
  460. },
  461. /* 刷新表格 */
  462. reload(where) {
  463. this.$nextTick(() => {
  464. this.$refs.table.reload({ page: 1, where });
  465. });
  466. },
  467. async handleSelectionChange(val) {
  468. console.log('val 选择的工单列表', val);
  469. console.log('this.produceTaskInfo', this.produceTaskInfo);
  470. let initReportValue = val[0] && val[0].singleReport;
  471. let allSame = true;
  472. val.forEach((item) => {
  473. if (item.singleReport !== initReportValue) {
  474. allSame = false;
  475. }
  476. });
  477. if (!allSame) {
  478. return this.$message.warning('请选择报工类型相同的工单');
  479. }
  480. let ids = [];
  481. ids = val.map((item) => {
  482. return item.id;
  483. });
  484. this.$emit('workSelect', { ids: ids, list: val });
  485. },
  486. rowClick(e) {
  487. this.$emit('rowClick', e, this.taskObj.id);
  488. },
  489. cellClick() {
  490. this.$nextTick(() => {
  491. this.$emit('getTaskName', this.selection);
  492. });
  493. },
  494. handRoute(row) {
  495. this.routeObj = row;
  496. this.routingShow = true;
  497. },
  498. closeRoute() {
  499. this.routingShow = false;
  500. },
  501. handleResize() {
  502. this.internalIsFullscreen = isFullscreen();
  503. }
  504. }
  505. };
  506. </script>
  507. <style lang="scss" scoped>
  508. ::v-deep .el-table .warning-row {
  509. background: #39d9ac;
  510. // color: #39d9ac;
  511. }
  512. ::v-deep .el-table .ent-row {
  513. background: #5419d4;
  514. // color: #39d9ac;
  515. }
  516. ::v-deep .el-table .success-row {
  517. background: #f0f9eb;
  518. }
  519. </style>