selectWorkOrder.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <template>
  2. <ele-modal
  3. :title="title"
  4. :visible.sync="visible"
  5. :close-on-click-modal="false"
  6. @close="handleClose"
  7. resizable
  8. maxable
  9. append-to-body
  10. width="90%"
  11. >
  12. <div>
  13. <seek-page
  14. :seekList="seekList"
  15. :maxLength="4"
  16. @search="search"
  17. ></seek-page>
  18. <ele-pro-table
  19. ref="table"
  20. key="id"
  21. :columns="basicColumns"
  22. :datasource="datasource"
  23. row-key="code"
  24. :selection.sync="selection"
  25. autoAmendPage
  26. :cache-key="cacheKeyUrl"
  27. >
  28. <template v-slot:radio="{ row }">
  29. <el-radio
  30. class="radio"
  31. :label="row.id"
  32. v-model="currentId"
  33. @change="
  34. () => {
  35. currentObj = row;
  36. }
  37. "
  38. >
  39. <i></i
  40. ></el-radio>
  41. </template>
  42. <template v-slot:code="{ row }">
  43. <el-link type="primary" :underline="false" @click="goDetail(row)">
  44. {{ row.code }}
  45. </el-link>
  46. </template>
  47. <template v-slot:QRcode="{ row }">
  48. <el-link type="primary" :underline="false" @click="handleQRcode(row)">
  49. 生成二维码
  50. </el-link>
  51. </template>
  52. <template v-slot:apsWorkOrderCode="{ row }">
  53. <label>{{ row.apsWorkOrderCode || '' }}</label>
  54. </template>
  55. <template v-slot:formingNum="{ row }">
  56. <span> {{ row.formingNum }} </span>
  57. </template>
  58. <template v-slot:formingWeight="{ row }">
  59. <span> {{ row.formingWeight }} {{ row.weightUnit }} </span>
  60. </template>
  61. <template v-slot:singleReport="{ row }">
  62. <span v-if="row.singleReport == 0">批量报工</span>
  63. <span v-if="row.singleReport == 1">单个报工</span>
  64. </template>
  65. <template v-slot:outsourceStatus="{ row }">
  66. <div v-if="row.outsourceStatus">
  67. <span v-if="row.outsourceStatus == 1">未委外</span>
  68. <span v-if="row.outsourceStatus == 2">委外中</span>
  69. <span v-if="row.outsourceStatus == 3">完成委外</span>
  70. </div>
  71. </template>
  72. <template v-slot:status="{ row }">
  73. <span :class="{ 'ele-text-danger': row.status == 3 }">
  74. {{ statusFormatter(row.status) }}
  75. </span>
  76. </template>
  77. </ele-pro-table>
  78. </div>
  79. <template v-slot:footer>
  80. <el-button type="primary" @click="submit">选 择</el-button>
  81. <el-button @click="handleClose">取 消</el-button>
  82. </template>
  83. </ele-modal>
  84. </template>
  85. <script>
  86. import dictMixins from '@/mixins/dictMixins';
  87. import tableColumnsMixin from '@/mixins/tableColumnsMixin';
  88. import { pageOrderByProduct } from '@/api/produce/workOrder.js';
  89. export default {
  90. mixins: [dictMixins, tableColumnsMixin],
  91. props: {
  92. // 额外的过滤条件
  93. where: {
  94. type: Object,
  95. default: () => ({})
  96. },
  97. // 选择后是否自动关闭弹窗
  98. autoClose: {
  99. type: Boolean,
  100. default: true
  101. },
  102. // 是否多选
  103. multiple: {
  104. type: Boolean,
  105. default: true
  106. }
  107. },
  108. data() {
  109. return {
  110. visible: false,
  111. title: '选择生产工单',
  112. statusOpt: {
  113. first: [
  114. { label: '所有状态', value: '5,4' },
  115. { label: '待生产', value: '4' },
  116. { label: '生产中', value: '5' }
  117. // { label: '已延期', value: '7' }
  118. ],
  119. second: [{ label: '已完成', value: '6' }]
  120. },
  121. planType: [
  122. { label: '所有计划类型', value: null },
  123. { label: '内销计划', value: '1' },
  124. { label: '外销计划', value: '2' },
  125. { label: '预制计划', value: '3' }
  126. ],
  127. cacheKeyUrl: 'public-2025926-select-work-order',
  128. selection: [],
  129. currentId: '',
  130. currentObj: null
  131. };
  132. },
  133. computed: {
  134. // 表格列配置
  135. seekList() {
  136. return [
  137. {
  138. label: '关键字:',
  139. value: 'keyWord',
  140. type: 'input',
  141. placeholder: ''
  142. },
  143. {
  144. label: '产品编码',
  145. value: 'productCode',
  146. type: 'input',
  147. placeholder: '',
  148. width: 240
  149. },
  150. {
  151. label: '产品名称:',
  152. value: 'productName',
  153. type: 'input',
  154. placeholder: '',
  155. width: 240
  156. },
  157. // {
  158. // label: '批次号:',
  159. // value: 'batchNo',
  160. // type: 'input',
  161. // placeholder: '',
  162. // width: 240
  163. // },
  164. {
  165. label: '型号',
  166. value: 'model',
  167. type: 'input',
  168. placeholder: '',
  169. width: 240
  170. },
  171. {
  172. label: '生产工单号:',
  173. value: 'code',
  174. type: 'input',
  175. placeholder: '',
  176. labelWidth: '100'
  177. },
  178. {
  179. label: '生产订单号:',
  180. value: 'apsWorkOrderCode',
  181. type: 'input',
  182. labelWidth: '100'
  183. },
  184. {
  185. label: '计划编号:',
  186. value: 'productionPlanCode',
  187. type: 'input',
  188. width: 240
  189. },
  190. {
  191. label: '计划类型:',
  192. value: 'planType',
  193. type: 'select',
  194. placeholder: '',
  195. width: 240,
  196. // 加载状态
  197. planList: this.planType
  198. },
  199. {
  200. label: '工艺路线',
  201. value: 'produceRoutingName',
  202. type: 'input',
  203. placeholder: '',
  204. width: 240
  205. },
  206. {
  207. label: '牌号',
  208. value: 'brandNo',
  209. type: 'input',
  210. placeholder: '',
  211. width: 240
  212. },
  213. // {
  214. // label: '班组:',
  215. // value: 'teamId',
  216. // type: 'select',
  217. // multiple: false, // 是否多选
  218. // filterable: true, // 是否可搜索
  219. // placeholder: '',
  220. // width: 240,
  221. // // 加载状态
  222. // planList: this.statusOpt.first
  223. // },
  224. {
  225. label: '创建时间:',
  226. value: 'createTime',
  227. type: 'date',
  228. dateType: 'daterange',
  229. placeholder: '',
  230. width: 240,
  231. // 加载状态
  232. planList: this.statusOpt.first
  233. }
  234. ];
  235. },
  236. basicColumns() {
  237. const list = [
  238. {
  239. slot: 'code',
  240. label: '生产工单号',
  241. align: 'center',
  242. minWidth: 150,
  243. showOverflowTooltip: true
  244. },
  245. // {
  246. // prop: 'originalCode',
  247. // label: '原始工单号',
  248. // align: 'center',
  249. // minWidth: 110
  250. // },
  251. {
  252. prop: 'productCode',
  253. label: '产品编码',
  254. align: 'center',
  255. minWidth: 150,
  256. showOverflowTooltip: true
  257. },
  258. {
  259. prop: 'productName',
  260. label: '产品名称',
  261. align: 'center',
  262. minWidth: 150,
  263. showOverflowTooltip: true
  264. },
  265. {
  266. prop: 'batchNo',
  267. label: '批次号',
  268. align: 'center',
  269. minWidth: 150,
  270. showOverflowTooltip: true
  271. },
  272. {
  273. prop: 'model',
  274. label: '型号',
  275. align: 'center',
  276. minWidth: 150,
  277. showOverflowTooltip: true
  278. },
  279. {
  280. prop: 'specification',
  281. label: '规格',
  282. align: 'center',
  283. showOverflowTooltip: true
  284. },
  285. {
  286. prop: 'productionCodes',
  287. label: '生产编号',
  288. align: 'center',
  289. minWidth: 150,
  290. showOverflowTooltip: true
  291. },
  292. {
  293. label: '生产订单号',
  294. slot: 'apsWorkOrderCode',
  295. align: 'center',
  296. minWidth: 110,
  297. showOverflowTooltip: true
  298. },
  299. {
  300. prop: 'productionPlanCode',
  301. label: '计划编号',
  302. align: 'center',
  303. minWidth: 110,
  304. showOverflowTooltip: true
  305. },
  306. {
  307. prop: 'planType',
  308. label: '计划类型',
  309. align: 'center',
  310. showOverflowTooltip: true,
  311. formatter: (row) => {
  312. const obj = this.planType.find((i) => i.value == row.planType);
  313. return obj && obj.label;
  314. }
  315. },
  316. {
  317. prop: 'bomType',
  318. label: '生产类型',
  319. align: 'center',
  320. width: 120,
  321. formatter: (row) => {
  322. if (row.bomType == 1) {
  323. return '产品(PBOM)';
  324. }
  325. if (row.bomType == 2) {
  326. return '加工(MBOM)';
  327. }
  328. if (row.bomType == 3) {
  329. return '装配(ABOM)';
  330. }
  331. // if (row.bomType == 4) {
  332. // return '装配(EBOM)';
  333. // }
  334. return '';
  335. }
  336. },
  337. {
  338. prop: 'bomCategoryName',
  339. label: 'BOM版本',
  340. align: 'center',
  341. width: 130,
  342. showOverflowTooltip: true,
  343. formatter: (row) => {
  344. if (row.bomCategoryName) {
  345. return `${row.bomCategoryName} (V${row.bomCategoryVersions}.0)`;
  346. }
  347. return '';
  348. }
  349. },
  350. {
  351. prop: 'produceRoutingName',
  352. label: '工艺路线',
  353. align: 'center',
  354. showOverflowTooltip: true
  355. },
  356. {
  357. prop: 'lineNumber',
  358. label: '行号',
  359. align: 'center',
  360. minWidth: 130,
  361. showOverflowTooltip: true
  362. },
  363. {
  364. prop: 'brandNo',
  365. label: '牌号',
  366. align: 'center'
  367. },
  368. {
  369. prop: 'taskName',
  370. label: '工序进度',
  371. align: 'center'
  372. },
  373. {
  374. prop: 'singleReport',
  375. slot: 'singleReport',
  376. label: '报工类型',
  377. align: 'center'
  378. },
  379. {
  380. prop: 'outsourceStatus',
  381. label: '委外状态',
  382. align: 'center',
  383. slot: 'outsourceStatus',
  384. showOverflowTooltip: true
  385. },
  386. {
  387. prop: 'formingNum',
  388. label: '要求生产数量',
  389. align: 'center',
  390. slot: 'formingNum',
  391. showOverflowTooltip: true,
  392. minWidth: 110
  393. },
  394. {
  395. prop: 'formingWeight',
  396. label: '要求生产重量',
  397. slot: 'formingWeight',
  398. align: 'center',
  399. showOverflowTooltip: true,
  400. minWidth: 110
  401. },
  402. {
  403. prop: 'formedNum',
  404. label: '已生产数量',
  405. align: 'center',
  406. showOverflowTooltip: true,
  407. minWidth: 110
  408. },
  409. {
  410. prop: 'formedWeight',
  411. label: '已生产重量',
  412. align: 'center',
  413. showOverflowTooltip: true,
  414. minWidth: 110
  415. },
  416. {
  417. prop: 'planStartTime',
  418. label: '计划开始时间',
  419. align: 'center',
  420. showOverflowTooltip: true,
  421. minWidth: 150
  422. },
  423. {
  424. prop: 'planCompleteTime',
  425. label: '计划结束时间',
  426. align: 'center',
  427. showOverflowTooltip: true,
  428. minWidth: 150
  429. },
  430. {
  431. prop: 'startTime',
  432. label: '实际开始时间',
  433. align: 'center',
  434. showOverflowTooltip: true,
  435. minWidth: 150
  436. },
  437. {
  438. prop: 'completeTime',
  439. label: '实际完成时间',
  440. align: 'center',
  441. showOverflowTooltip: true,
  442. minWidth: 150
  443. },
  444. {
  445. prop: 'createTime',
  446. label: '创建时间',
  447. align: 'center',
  448. showOverflowTooltip: true,
  449. minWidth: 150
  450. },
  451. // {
  452. // prop: 'status',
  453. // slot: 'status',
  454. // label: '状态',
  455. // align: 'center',
  456. // formatter: (row) => {
  457. // const obj = this.statusOpt[this.activeName].find(
  458. // (i) => i.value == row.status
  459. // );
  460. // return obj && obj.label;
  461. // }
  462. // },
  463. {
  464. prop: 'deviceName',
  465. slot: 'deviceName',
  466. label: '设备名称',
  467. align: 'center',
  468. showOverflowTooltip: true
  469. },
  470. {
  471. prop: 'crewNames',
  472. slot: 'crewNames',
  473. label: '报工人员',
  474. align: 'center',
  475. showOverflowTooltip: true
  476. },
  477. {
  478. prop: 'teamName',
  479. label: '班组',
  480. align: 'center',
  481. showOverflowTooltip: true
  482. }
  483. ];
  484. if (this.multiple) {
  485. list.unshift({
  486. width: 45,
  487. type: 'selection',
  488. columnKey: 'selection',
  489. align: 'center',
  490. fixed: 'left'
  491. });
  492. } else {
  493. list.unshift({
  494. width: 50,
  495. slot: 'radio',
  496. columnKey: 'selection',
  497. align: 'center',
  498. fixed: 'left'
  499. });
  500. }
  501. return list;
  502. }
  503. },
  504. methods: {
  505. // 外部调用,打开弹窗
  506. open(data) {
  507. this.visible = true;
  508. },
  509. // 关闭时清理表单
  510. handleClose() {
  511. this.currentId = '';
  512. this.currentObj = null;
  513. this.visible = false;
  514. },
  515. // 提交 选择
  516. submit() {
  517. console.log('this.selection', this.selection);
  518. if (this.multiple) {
  519. if (this.selection.length == 0) {
  520. this.$message.warning('请至少选择一条工单');
  521. return;
  522. }
  523. this.$emit('confirm', this.selection);
  524. } else {
  525. if (!this.currentObj) {
  526. this.$message.warning('请选择工单');
  527. return;
  528. }
  529. this.$emit('confirm', this.currentObj);
  530. }
  531. if (this.autoClose) {
  532. this.handleClose();
  533. }
  534. },
  535. /* 表格数据源 */
  536. datasource({ page, limit, where, order }) {
  537. return pageOrderByProduct({
  538. ...where,
  539. ...order,
  540. pageNum: page,
  541. size: limit,
  542. ...this.where
  543. });
  544. },
  545. /* 刷新表格 */
  546. reload(where = {}) {
  547. this.$refs.table.reload({ page: 1, where });
  548. },
  549. search(e) {
  550. if (Array.isArray(e.createTime) && e.createTime.length) {
  551. e.createTimeStart = e.createTime[0];
  552. e.createTimeEnd = e.createTime[1];
  553. }
  554. this.reload(e);
  555. }
  556. }
  557. };
  558. </script>
  559. <style scoped lang="scss"></style>