index.vue 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. <template>
  2. <div class="ele-body">
  3. <el-card v-loading="loading" shadow="never">
  4. <order-search ref="searchRef" @search="reload"></order-search>
  5. <div class="btn_box">
  6. <el-button
  7. class="ele-btn-icon"
  8. icon="el-icon-truck"
  9. size="small"
  10. type="primary"
  11. v-if="
  12. $hasPermission('aps:batchReleaseWorkOrder:release') && !planDotLine
  13. "
  14. @click="batchDispatch"
  15. >批量派单
  16. <!-- -->
  17. </el-button>
  18. <el-button
  19. class="ele-btn-icon"
  20. size="small"
  21. type="primary"
  22. v-if="$hasPermission('aps:productionplan:scheduling‌')"
  23. @click="openFactoryScheduling"
  24. >工厂排产
  25. </el-button>
  26. </div>
  27. <el-tabs v-model="tabValue" type="card" @tab-click="handleTabClick">
  28. <el-tab-pane label="全部订单" name="1"></el-tab-pane>
  29. <el-tab-pane label="暂停/终止订单" name="2"></el-tab-pane>
  30. <!-- <el-tab-pane label="我的任务" name="1"></el-tab-pane>
  31. <el-tab-pane label="全部任务" name="2"></el-tab-pane> -->
  32. </el-tabs>
  33. <!-- <el-tabs v-model="activeName" type="card">
  34. <el-tab-pane label="未完成工单" name="first"></el-tab-pane>
  35. <el-tab-pane label="已完成工单" name="second"></el-tab-pane>
  36. </el-tabs> -->
  37. <!-- 数据表格 -->
  38. <!-- <plan-statistics></plan-statistics> -->
  39. <!-- <ele-pro-table
  40. ref="table"
  41. :columns="newColumns"
  42. :datasource="datasource"
  43. cache-key="workOrderTable"
  44. row-key="code"
  45. @sort-change="onSortChange"
  46. height="calc(100vh - 380px)"
  47. autoAmendPage
  48. :parse-data="parseData"
  49. <el-link
  50. :underline="false"
  51. type="primary"
  52. @click="checkInventory(row)"
  53. >
  54. 库存
  55. </el-link>
  56. > -->
  57. <ele-pro-table
  58. ref="table"
  59. :cache-key="cacheKeyUrl"
  60. :columns="columns"
  61. :datasource="datasource"
  62. :parse-data="parseData"
  63. autoAmendPage
  64. row-key="id"
  65. @sort-change="onSortChange"
  66. @columns-change="handleColumnChange"
  67. @select-all="selectAll"
  68. default-expand-all
  69. :height="tableHeight"
  70. full-height="calc(100vh - 116px)"
  71. :page-size="20"
  72. >
  73. <!-- :key="activeName" -->
  74. <!-- :selection.sync="selection" -->
  75. <!-- @update:selection="handleSelectionChange" -->
  76. <template v-slot:toolbar> </template>
  77. <template v-slot:selection="{ row }">
  78. <el-checkbox
  79. :disabled="!dispatchPermission(row)"
  80. :value="checkRowData(row)"
  81. class="batch_checked"
  82. @change="(e) => selectRow(e, row)"
  83. ></el-checkbox>
  84. </template>
  85. <template v-slot:code="{ row }">
  86. <el-link
  87. type="primary"
  88. :underline="false"
  89. style="padding-left: 16px"
  90. @click="openDetails(row)"
  91. >
  92. <el-tag type="success" size="mini" v-if="row.originalCode">
  93. 拆</el-tag
  94. >
  95. {{ row.code }}
  96. </el-link>
  97. </template>
  98. <template v-slot:formingWeight="{ row }">
  99. {{ row.formingWeight }} {{ row.newWeightUnit }}
  100. </template>
  101. <template v-slot:priority="{ row }">
  102. <div style="display: flex">
  103. <el-input
  104. v-model="row.priority"
  105. :max="10"
  106. :min="0"
  107. size="mini"
  108. style="width: 80px"
  109. type="number"
  110. @change="priorityChange(row)"
  111. ></el-input>
  112. <el-popover
  113. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  114. placement="right"
  115. trigger="hover"
  116. width="200"
  117. >
  118. <div slot="reference" class="sort-wrap">
  119. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  120. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  121. </div>
  122. </el-popover>
  123. </div>
  124. </template>
  125. <template v-slot:werks="{ row }">
  126. <el-link
  127. :underline="false"
  128. type="primary"
  129. @click="checkInventory(row)"
  130. >查看库存</el-link
  131. >
  132. </template>
  133. <template v-slot:sourceType="{ row }">
  134. <span v-if="row.sourceType == 1">生产计划</span>
  135. <span v-if="row.sourceType == 2">临时生产计划</span>
  136. <span v-if="row.sourceType == 3">受托转订单</span>
  137. </template>
  138. <template v-slot:workOrderType="{ row }">
  139. <span v-if="row.workOrderType == 1">普通订单</span>
  140. <span v-if="row.workOrderType == 2">临时订单</span>
  141. <span v-if="row.workOrderType == 3">受托订单</span>
  142. </template>
  143. <template v-slot:status="{ row }">
  144. <span :class="{ 'ele-text-danger': row.status == 3 }">
  145. {{ statusFormatter(row.status) }}
  146. </span>
  147. </template>
  148. <!-- 操作列 -->
  149. <template v-slot:selectionHeader="{ column }">
  150. <span>123</span>
  151. </template>
  152. <template v-slot:action="{ row }">
  153. <el-link
  154. v-if="
  155. dispatchPermission(row) &&
  156. $hasPermission('aps:workorder:dispatch') &&
  157. row.workCenterId &&
  158. userWorkCenter &&
  159. userWorkCenter.includes(row.workCenterId)
  160. "
  161. :underline="false"
  162. icon="el-icon-truck"
  163. type="primary"
  164. @click="toReleaseOpen(row)"
  165. >
  166. 首工序派单
  167. </el-link>
  168. <el-link
  169. v-if="
  170. unpackShow(row) &&
  171. row.splitResidue !== 0 &&
  172. $hasPermission('aps:workorder:ordersplitting') &&
  173. !planDotLine
  174. "
  175. :underline="false"
  176. type="primary"
  177. @click="toUnpack(row)"
  178. >
  179. 拆单
  180. </el-link>
  181. <el-link
  182. type="primary"
  183. :underline="false"
  184. @click="productionPreparations(row)"
  185. >
  186. 生产准备
  187. </el-link>
  188. <el-popconfirm
  189. class="ele-action"
  190. title="确定要删除此子单吗?"
  191. @confirm="remove(row)"
  192. v-if="removeShow(row) && $hasPermission('aps:workorder:delete')"
  193. >
  194. <template v-slot:reference>
  195. <el-link type="danger" :underline="false" icon="el-icon-delete">
  196. 删除
  197. </el-link>
  198. </template>
  199. </el-popconfirm>
  200. </template>
  201. </ele-pro-table>
  202. </el-card>
  203. <unpackDialog ref="unpackRef" @success="createSuccess" />
  204. <releaseDialog
  205. v-if="dispatchVisible"
  206. ref="releaseRef"
  207. :current="dispatchRow"
  208. :dispatchVisible.sync="dispatchVisible"
  209. @createSuccess="createSuccess"
  210. />
  211. <planDotLinReleaseDialog
  212. v-if="planDotLineVisible"
  213. ref="planDotLinReleaseDialogRef"
  214. :current="dispatchRow"
  215. :dispatchVisible.sync="planDotLineVisible"
  216. @createSuccess="createSuccess"
  217. />
  218. <BatchDialog ref="batchRef" @createSuccess="createSuccess" />
  219. <Details
  220. ref="detailsRef"
  221. v-if="detailsVisible"
  222. :current="dispatchRow"
  223. :detailsVisible.sync="detailsVisible"
  224. />
  225. <AssetsDialog ref="assetsRef" :treeIds="treeId"></AssetsDialog>
  226. <checkProductionPreparations
  227. ref="checkProductionPreparationsRef"
  228. type="order"
  229. @update="reload"
  230. />
  231. <newFactoryProductionScheduling ref="newFactoryProductionSchedulingRef" />
  232. </div>
  233. </template>
  234. <script>
  235. import {
  236. getList,
  237. releaseWorkOrder,
  238. updatePriority,
  239. unpackDel,
  240. getListStop
  241. } from '@/api/workOrder/index.js';
  242. import {
  243. listByFirstTaskId,
  244. listByWorkCenterId,
  245. listUserByIds
  246. } from '@/api/mainData/index.js';
  247. import OrderSearch from './components/order-search.vue';
  248. import unpackDialog from './components/unpackDialog.vue';
  249. import releaseDialog from './components/releaseDialog.vue';
  250. import { fieldModel } from '@/api/saleOrder';
  251. import { debounce } from 'lodash';
  252. import PlanStatistics from '@/components/statistics/PlanStatistics.vue';
  253. import tabMixins from '@/mixins/tableColumnsMixin';
  254. import BatchDialog from '@/views/workOrder/components/batchDialog.vue';
  255. import Details from './components/details.vue';
  256. import AssetsDialog from './components/AssetsDialog.vue';
  257. import checkProductionPreparations from '@/views/productionPlan/components/checkProductionPreparations.vue';
  258. import newFactoryProductionScheduling from '@/views/productionPlan/components/newFactoryProductionScheduling.vue';
  259. import { getProductPlanDetail } from '@/api/productionPlan/index';
  260. import { parameterGetByCode } from '@/api/mainData/index';
  261. import planDotLinReleaseDialog from './components/planDotLinReleaseDialog.vue';
  262. export default {
  263. mixins: [tabMixins],
  264. components: {
  265. PlanStatistics,
  266. OrderSearch,
  267. unpackDialog,
  268. releaseDialog,
  269. BatchDialog,
  270. Details,
  271. AssetsDialog,
  272. checkProductionPreparations,
  273. planDotLinReleaseDialog,
  274. newFactoryProductionScheduling
  275. },
  276. data() {
  277. return {
  278. visible: false,
  279. loading: false,
  280. form: {
  281. assignType: 1,
  282. crewIds: '',
  283. workstationIds: '',
  284. teamId: '',
  285. singleReport: ''
  286. },
  287. rules: {
  288. singleReport: [
  289. {
  290. required: true,
  291. message: '请选择报工类型',
  292. trigger: ['blur', 'change']
  293. }
  294. ],
  295. workstationIds: [
  296. {
  297. required: true,
  298. message: '请选择工位',
  299. trigger: ['blur']
  300. }
  301. ],
  302. teamId: [
  303. {
  304. required: true,
  305. message: '请选择班组',
  306. trigger: ['blur']
  307. }
  308. ]
  309. },
  310. teamList: [],
  311. statusOpt: [
  312. { label: '待生产', value: 4 },
  313. { label: '生产中', value: 5 },
  314. { label: '待下达', value: 8 }
  315. ],
  316. columns: [],
  317. stationList: [],
  318. teamsList: [],
  319. crewList: [],
  320. current: null,
  321. cacheKeyUrl: '3cbbdff9-aps-workOrder-index',
  322. columnsVersion: 1,
  323. dispatchRow: {},
  324. dispatchVisible: false,
  325. selectionMap: {},
  326. detailsVisible: false,
  327. tabMixinsInit: false,
  328. tabValue: '1',
  329. treeId: [],
  330. tableHeight: 'calc(100vh - 345px)',
  331. userWorkCenter: this.$store.state.user.info.workCenterIds,
  332. planDotLine: false,
  333. planDotLineVisible: false
  334. };
  335. },
  336. computed: {
  337. // 派单按钮显示
  338. dispatchPermission() {
  339. return (row) => {
  340. if (!row.firstTaskId) {
  341. return false;
  342. }
  343. return (
  344. (row.isSplit != 1 &&
  345. this.clientEnvironmentId != '4' &&
  346. row.status == 8) ||
  347. (this.clientEnvironmentId == '4' &&
  348. !row.productName.includes('板材') &&
  349. row.status == 8)
  350. );
  351. };
  352. },
  353. // 删除按钮显示
  354. removeShow() {
  355. return (row) => {
  356. return row.originalCode && !row.mesStatus;
  357. };
  358. },
  359. // 拆单按钮显示
  360. unpackShow() {
  361. return (row) => {
  362. if (row.originalCode) return false;
  363. return (
  364. (this.clientEnvironmentId != '4' && row.status == 8) ||
  365. (this.clientEnvironmentId == '4' &&
  366. !row.productName.includes('板材') &&
  367. row.status == 8)
  368. );
  369. };
  370. },
  371. teamId() {
  372. return this.$store.state.user.info.teamId;
  373. },
  374. clientEnvironmentId() {
  375. return this.$store.state.user.info.clientEnvironmentId;
  376. },
  377. checkRowData() {
  378. return (row) => {
  379. return row.checkedata ? true : false;
  380. };
  381. }
  382. },
  383. created() {
  384. this.setColumns();
  385. this.getFieldModel();
  386. this.getPlanDotLine();
  387. },
  388. methods: {
  389. getPlanDotLine() {
  390. parameterGetByCode({
  391. code: 'plan_dot_line'
  392. }).then((res) => {
  393. if (res) {
  394. this.planDotLine = res.value == '1' ? true : false;
  395. }
  396. });
  397. },
  398. setColumns() {
  399. this.columns = [
  400. {
  401. width: 45,
  402. type: 'selection',
  403. columnKey: 'selection',
  404. align: 'center',
  405. slot: 'selection',
  406. fixed: 'left',
  407. headerSlot: 'selectionHeader'
  408. // selectable: (row, index) => {
  409. // if (row.children) {
  410. // }
  411. // return this.dispatchPermission(row);
  412. // }
  413. },
  414. {
  415. columnKey: 'index',
  416. slot: 'index',
  417. label: '序号',
  418. type: 'index',
  419. width: 55,
  420. align: 'center',
  421. showOverflowTooltip: true,
  422. fixed: 'left'
  423. },
  424. {
  425. slot: 'code',
  426. label: '生产订单号',
  427. align: 'center',
  428. minWidth: 220,
  429. sortable: true,
  430. showOverflowTooltip: true
  431. },
  432. {
  433. prop: 'lineNumber',
  434. label: '行号',
  435. align: 'center',
  436. minWidth: 100,
  437. showOverflowTooltip: true
  438. },
  439. {
  440. prop: 'factoryName',
  441. label: '所属工厂',
  442. align: 'center',
  443. minWidth: 100
  444. },
  445. {
  446. prop: 'taskName',
  447. action: 'taskName',
  448. label: '工序进度',
  449. align: 'center',
  450. minWidth: 160
  451. },
  452. {
  453. prop: 'werks',
  454. slot: 'werks',
  455. label: '库存',
  456. align: 'center',
  457. minWidth: 160
  458. },
  459. {
  460. prop: 'mesStatusName',
  461. label: '状态',
  462. align: 'center',
  463. minWidth: 160
  464. },
  465. {
  466. prop: 'list',
  467. label: '派单对象',
  468. align: 'center',
  469. minWidth: 160,
  470. formatter: (row) => {
  471. if (row?.list?.length) {
  472. let assignees = row.list.map((item) => item.assignees)?.flat();
  473. return assignees?.map((item) => item.assigneeName).join(',');
  474. }
  475. }
  476. },
  477. {
  478. prop: 'productionPlanCode',
  479. label: '计划编号',
  480. align: 'center',
  481. minWidth: 150,
  482. showOverflowTooltip: true
  483. },
  484. {
  485. prop: 'productType',
  486. label: 'BOM类型',
  487. align: 'center',
  488. width: 120,
  489. formatter: (row) => {
  490. if (row.produceType == 1) {
  491. return 'PBOM';
  492. }
  493. if (row.produceType == 2) {
  494. return 'MBOM';
  495. }
  496. if (row.produceType == 3) {
  497. return 'ABOM';
  498. }
  499. }
  500. },
  501. {
  502. prop: 'bomCategoryName',
  503. label: 'BOM版本',
  504. align: 'center',
  505. width: 130,
  506. showOverflowTooltip: true,
  507. formatter: (row) => {
  508. if (row.bomCategoryName) {
  509. return `${row.bomCategoryName} (V${row.bomCategoryVersions}.0)`;
  510. }
  511. return '';
  512. }
  513. },
  514. {
  515. prop: 'produceRoutingName',
  516. label: '工艺路线',
  517. align: 'center',
  518. minWidth: 170,
  519. showOverflowTooltip: true
  520. },
  521. {
  522. prop: 'modelKey',
  523. label: '机型',
  524. align: 'center',
  525. minWidth: 120,
  526. showOverflowTooltip: true
  527. },
  528. {
  529. prop: 'colorKey',
  530. label: '颜色',
  531. align: 'center',
  532. minWidth: 120,
  533. showOverflowTooltip: true
  534. },
  535. {
  536. prop: 'productCode',
  537. label: '编码',
  538. align: 'center',
  539. minWidth: 120,
  540. showOverflowTooltip: true
  541. },
  542. {
  543. prop: 'productName',
  544. label: '名称',
  545. align: 'center',
  546. minWidth: 170,
  547. showOverflowTooltip: true
  548. },
  549. {
  550. prop: 'productionCodes',
  551. label: '生产编号',
  552. align: 'center',
  553. minWidth: 150,
  554. showOverflowTooltip: true
  555. },
  556. {
  557. prop: 'productionRequirements',
  558. label: '生产要求',
  559. align: 'center',
  560. minWidth: 200,
  561. showOverflowTooltip: true
  562. },
  563. {
  564. prop: 'brandNo',
  565. label: '牌号',
  566. align: 'center',
  567. showOverflowTooltip: true
  568. },
  569. {
  570. prop: 'teamName',
  571. label: '首工序班组',
  572. align: 'center',
  573. minWidth: 120,
  574. showOverflowTooltip: true
  575. },
  576. {
  577. prop: 'teamLeaderUserName',
  578. label: '班组长',
  579. align: 'center',
  580. minWidth: 120,
  581. showOverflowTooltip: true
  582. },
  583. {
  584. prop: 'batchNo',
  585. label: '批次号',
  586. align: 'center',
  587. minWidth: 100,
  588. showOverflowTooltip: true
  589. },
  590. {
  591. prop: 'model',
  592. label: '型号',
  593. align: 'center',
  594. showOverflowTooltip: true
  595. },
  596. {
  597. prop: 'specification',
  598. label: '规格',
  599. align: 'center',
  600. showOverflowTooltip: true
  601. },
  602. {
  603. prop: 'priority',
  604. label: '优先级',
  605. align: 'center',
  606. minWidth: 120,
  607. slot: 'priority',
  608. sortable: 'custom'
  609. },
  610. {
  611. prop: 'formingNum',
  612. label: '要求生产数量',
  613. formatter: (row) => {
  614. if (row.measuringUnit) {
  615. return `${row.formingNum} ${row.measuringUnit}`;
  616. } else {
  617. return row.formingNum;
  618. }
  619. },
  620. align: 'center',
  621. showOverflowTooltip: true,
  622. minWidth: 110
  623. },
  624. {
  625. prop: 'formingWeight',
  626. label: '要求生产重量',
  627. align: 'center',
  628. showOverflowTooltip: true,
  629. minWidth: 110,
  630. slot: 'formingWeight'
  631. },
  632. {
  633. prop: 'sourceType',
  634. label: '来源类型',
  635. slot: 'sourceType',
  636. align: 'center',
  637. minWidth: 110,
  638. showOverflowTooltip: true
  639. },
  640. {
  641. prop: 'sourceCode',
  642. label: '来源编码',
  643. align: 'center',
  644. minWidth: 110,
  645. showOverflowTooltip: true
  646. },
  647. {
  648. prop: 'workOrderType',
  649. label: '订单类型',
  650. slot: 'workOrderType',
  651. align: 'center',
  652. minWidth: 110,
  653. showOverflowTooltip: true
  654. },
  655. {
  656. prop: 'planStartTime',
  657. label: '计划开始时间',
  658. align: 'center',
  659. showOverflowTooltip: true,
  660. minWidth: 110
  661. },
  662. {
  663. prop: 'planCompleteTime',
  664. label: '计划结束时间',
  665. align: 'center',
  666. showOverflowTooltip: true,
  667. minWidth: 110
  668. },
  669. {
  670. prop: 'workCenterName',
  671. label: '工作中心',
  672. align: 'center',
  673. minWidth: 110,
  674. showOverflowTooltip: true
  675. },
  676. {
  677. prop: 'firstTaskName',
  678. label: '首工序',
  679. align: 'center',
  680. minWidth: 110,
  681. showOverflowTooltip: true
  682. },
  683. {
  684. prop: 'createTime',
  685. label: '创建时间',
  686. align: 'center',
  687. showOverflowTooltip: true,
  688. minWidth: 110,
  689. sortable: 'custom'
  690. },
  691. // {
  692. // slot: 'status',
  693. // label: '状态',
  694. // align: 'center',
  695. // formatter: (row) => {
  696. // const obj = this.statusOpt.find((i) => i.value == row.status);
  697. // return obj && obj.label;
  698. // }
  699. // },
  700. {
  701. prop: 'customerName',
  702. label: '客户名称',
  703. align: 'center',
  704. showOverflowTooltip: true
  705. },
  706. {
  707. prop: 'serialNo',
  708. label: '客户代号',
  709. align: 'center',
  710. showOverflowTooltip: true
  711. },
  712. {
  713. prop: 'simpleName',
  714. label: '客户简称',
  715. align: 'center',
  716. showOverflowTooltip: true
  717. }
  718. ];
  719. },
  720. // 进入详情
  721. openDetails(row) {
  722. let dispatchRow = { ...row };
  723. this.dispatchRow = { ...row };
  724. dispatchRow.initialWeight = row.formingWeight
  725. ? row.formingWeight + row.newWeightUnit
  726. : '';
  727. this.dispatchRow = dispatchRow;
  728. this.detailsVisible = true;
  729. },
  730. // 全选/取消全选
  731. selectAll(selection) {
  732. if (selection.length == 0) {
  733. // 取消全选
  734. let list = this.$refs.table._data.tableData;
  735. list.map((el) => {
  736. this.$set(el, 'checkedata', false);
  737. if (el.children && el.children.length > 0) {
  738. el.children.map((item) => {
  739. this.$set(item, 'checkedata', false);
  740. delete this.selectionMap[item.id];
  741. });
  742. }
  743. delete this.selectionMap[el.id];
  744. });
  745. return;
  746. }
  747. // 全选
  748. let list = [];
  749. selection.map((item) => {
  750. let flag = this.dispatchPermission(item);
  751. this.$set(item, 'checkedata', flag);
  752. if (flag) {
  753. list.push(item);
  754. }
  755. if (item.children && item.children.length > 0) {
  756. item.children.map((el) => {
  757. let flags = this.dispatchPermission(el);
  758. this.$set(el, 'checkedata', flags);
  759. if (flags) {
  760. list.push(el);
  761. }
  762. });
  763. }
  764. list.map((row) => {
  765. this.selectionMap[row.id] = {
  766. id: row.id,
  767. firstTaskId: row.firstTaskId,
  768. productionPlanId: row.productionPlanId,
  769. productName: row.productName,
  770. productCode: row.productCode,
  771. code: row.code,
  772. productionPlanCode: row.productionPlanCode,
  773. batchNo: row.batchNo,
  774. formingNum: row.formingNum
  775. };
  776. });
  777. });
  778. },
  779. // 单选数据
  780. selectRow(e, row) {
  781. this.$set(row, 'checkedata', e);
  782. if (e) {
  783. this.selectionMap[row.id] = {
  784. id: row.id,
  785. firstTaskId: row.firstTaskId,
  786. productionPlanId: row.productionPlanId,
  787. productName: row.productName,
  788. productCode: row.productCode,
  789. code: row.code,
  790. productionPlanCode: row.productionPlanCode,
  791. batchNo: row.batchNo,
  792. formingNum: row.formingNum
  793. };
  794. } else {
  795. delete this.selectionMap[row.id];
  796. }
  797. },
  798. // 批量派单
  799. batchDispatch() {
  800. let list = Object.values(this.selectionMap);
  801. if (list.length === 0) {
  802. this.$message.warning('请至少选择一条派单的数据');
  803. return;
  804. }
  805. if (list.length > 1) {
  806. for (let i = 1; i < list.length; i++) {
  807. let el = list[i];
  808. if (list[0].firstTaskId !== el.firstTaskId) {
  809. this.$message.warning('请选择首工序相同的数据进行批量派单');
  810. return;
  811. }
  812. }
  813. }
  814. this.$refs.batchRef.open(list);
  815. },
  816. openFactoryScheduling() {
  817. const list = Object.values(this.selectionMap);
  818. if (list.length === 0) {
  819. this.$message.warning('请至少选择一条工厂排产的数据');
  820. return;
  821. }
  822. const ids = Array.from(
  823. new Set(
  824. list
  825. .map((item) => item.productionPlanId)
  826. .filter((id) => id !== null && id !== undefined && id !== '')
  827. )
  828. );
  829. if (ids.length === 0) {
  830. this.$message.warning('所选数据未关联生产计划,无法打开工厂排产');
  831. return;
  832. }
  833. this.$refs.newFactoryProductionSchedulingRef.open({
  834. ids,
  835. readonly: true
  836. });
  837. },
  838. // 删除拆单数据
  839. remove(row) {
  840. unpackDel(row.id).then((res) => {
  841. if (res) {
  842. this.$message.success('操作成功');
  843. this.createSuccess();
  844. }
  845. });
  846. },
  847. // assignTypeFn(e) {},
  848. statusFormatter(status) {
  849. const obj = this.statusOpt.find((i) => i.value == status);
  850. return obj && obj.label;
  851. },
  852. /* 表格数据源 */
  853. datasource({ page, limit, where }) {
  854. this.selectionMap = {};
  855. if (where.status) {
  856. where.statusList = [];
  857. where.statusList.push(where.status);
  858. delete where.status;
  859. }
  860. const URL = this.tabValue == '1' ? getList : getListStop;
  861. return URL({
  862. pageNum: page,
  863. size: limit,
  864. ...where,
  865. ...this.sort
  866. });
  867. },
  868. /* 数据转为树形结构 */
  869. parseData(data) {
  870. const obj = {
  871. ...data,
  872. list: this.$util.toTreeData({
  873. data: data.list,
  874. count: data.total,
  875. idField: 'code',
  876. parentIdField: 'originalCode'
  877. })
  878. };
  879. return obj;
  880. },
  881. getFieldModel() {
  882. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  883. const privateColumn = [
  884. {
  885. columnKey: 'action',
  886. label: '操作',
  887. width: 260,
  888. align: 'center',
  889. resizable: false,
  890. fixed: 'right',
  891. slot: 'action'
  892. }
  893. ];
  894. let newRes = res.map((m) => {
  895. return {
  896. prop: 'extField.' + m.prop,
  897. label: m.label,
  898. align: 'center',
  899. showOverflowTooltip: true
  900. };
  901. });
  902. this.columns = [...this.columns, ...newRes, ...privateColumn];
  903. this.getTabColumns();
  904. // this.$forceUpdate();
  905. });
  906. },
  907. productionPreparations(row) {
  908. this.$refs.checkProductionPreparationsRef.open(row);
  909. },
  910. // 下达
  911. toRelease(row) {
  912. this.current = row;
  913. this.visible = true;
  914. this.FirstTaskIdFn();
  915. this.WorkCenterIdFn();
  916. this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
  917. },
  918. // 下达
  919. confirm() {
  920. this.$refs.form.validate((valid) => {
  921. if (valid) {
  922. const loading = this.$loading({ text: '加载中...' });
  923. if (this.form.assignType * 1 == 2) {
  924. this.form.workstationIds = [];
  925. } else {
  926. this.form.crewIds = [];
  927. }
  928. releaseWorkOrder({
  929. id: this.current.id,
  930. ...this.form
  931. })
  932. .then((res) => {
  933. if (res) {
  934. this.$message.success('成功');
  935. this.reData();
  936. this.reload();
  937. this.visible = false;
  938. }
  939. })
  940. .finally(() => {
  941. loading.close();
  942. });
  943. }
  944. });
  945. },
  946. close() {
  947. this.visible = false;
  948. this.reData();
  949. },
  950. reData() {
  951. this.form = {
  952. assignType: 1,
  953. crewIds: '',
  954. workstationIds: '',
  955. teamId: '',
  956. singleReport: this.clientEnvironmentId == 2 ? 0 : 1
  957. };
  958. },
  959. /* 刷新表格 */
  960. reload(where) {
  961. this.$nextTick(() => {
  962. this.$refs.table.reload({ page: 1, where });
  963. });
  964. },
  965. handleTabClick(e) {
  966. console.log(e.name);
  967. this.tabValue = e.name;
  968. this.reload();
  969. },
  970. onSortChange(e) {
  971. let sort = {
  972. orderBy: e.order,
  973. sortName: e.prop
  974. };
  975. this.sort = sort;
  976. this.reload();
  977. },
  978. sortTop(row) {
  979. row.priority = Number(row.priority) + 1;
  980. this.priorityChange(row);
  981. },
  982. sortBottom(row) {
  983. if (row.priority <= 1) {
  984. return;
  985. }
  986. row.priority = Number(row.priority) - 1;
  987. this.priorityChange(row);
  988. },
  989. FirstTaskIdFn() {
  990. listByFirstTaskId(this.current.firstTaskId).then((res) => {
  991. this.stationList = res;
  992. });
  993. },
  994. WorkCenterIdFn() {
  995. listByWorkCenterId(this.current.workCenterId).then((res) => {
  996. this.teamsList = res;
  997. this.$nextTick(() => {
  998. if (this.teamId) {
  999. this.$set(this.form, 'teamId', this.teamId);
  1000. this.stationChange();
  1001. }
  1002. // this.$refs.form.clearValidate();
  1003. });
  1004. });
  1005. },
  1006. // 拆分
  1007. toUnpack(row) {
  1008. this.$refs.unpackRef.open(row);
  1009. },
  1010. //派单
  1011. toReleaseOpen(row) {
  1012. this.dispatchRow = { ...row };
  1013. this.dispatchRow.initialWeight = row.formingWeight
  1014. ? row.formingWeight + row.newWeightUnit
  1015. : '';
  1016. if (!this.planDotLine) {
  1017. this.dispatchVisible = true;
  1018. } else {
  1019. this.planDotLineVisible = true;
  1020. }
  1021. // getTaskIdByInstanceId(row.firstTaskId)
  1022. // .then((res) => {
  1023. // if (res) {
  1024. // }
  1025. // })
  1026. // .catch((err) => {
  1027. // this.$message.error(err.message);
  1028. // });
  1029. },
  1030. createSuccess() {
  1031. this.reload();
  1032. },
  1033. checkInventory(item) {
  1034. this.treeId.push(item.rootCategoryLevelId);
  1035. this.$refs.assetsRef.open(item);
  1036. },
  1037. stationChange() {
  1038. this.crewList = [];
  1039. this.crewIds = [];
  1040. listUserByIds([this.form.teamId]).then((res) => {
  1041. this.crewList = res;
  1042. });
  1043. },
  1044. priorityChange(row) {
  1045. if (row.priority > 10) {
  1046. row.priority = 10; // 如果大于 10,则设置为 10
  1047. } else if (row.priority < 0) {
  1048. row.priority = 0; // 如果小于 0,则设置为 0
  1049. }
  1050. this.priorityFn(row);
  1051. },
  1052. priorityFn: debounce(function (row) {
  1053. let params = {
  1054. id: row.id,
  1055. priority: row.priority
  1056. };
  1057. updatePriority(params).then((res) => {});
  1058. }, 800)
  1059. }
  1060. };
  1061. </script>
  1062. <style lang="scss" scoped>
  1063. // ::v-deep .el-table__row {
  1064. // height: 51px !important;
  1065. // }
  1066. .btn_box {
  1067. margin-bottom: 6px;
  1068. }
  1069. </style>