index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  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:workorder:teamScheduling')"
  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. orderSchedulingTeamMap: {},
  320. crewList: [],
  321. current: null,
  322. cacheKeyUrl: '3cbbdff9-aps-workOrder-index',
  323. columnsVersion: 1,
  324. dispatchRow: {},
  325. dispatchVisible: false,
  326. selectionMap: {},
  327. detailsVisible: false,
  328. tabMixinsInit: false,
  329. tabValue: '1',
  330. currentOrderListWhere: {},
  331. treeId: [],
  332. tableHeight: 'calc(100vh - 345px)',
  333. userWorkCenter: this.$store.state.user.info.workCenterIds,
  334. planDotLine: false,
  335. planDotLineVisible: false
  336. };
  337. },
  338. computed: {
  339. // 派单按钮显示
  340. dispatchPermission() {
  341. return (row) => {
  342. if (!row.firstTaskId) {
  343. return false;
  344. }
  345. return (
  346. (row.isSplit != 1 &&
  347. this.clientEnvironmentId != '4' &&
  348. row.status == 8) ||
  349. (this.clientEnvironmentId == '4' &&
  350. !row.productName.includes('板材') &&
  351. row.status == 8)
  352. );
  353. };
  354. },
  355. // 删除按钮显示
  356. removeShow() {
  357. return (row) => {
  358. return row.originalCode && !row.mesStatus;
  359. };
  360. },
  361. // 拆单按钮显示
  362. unpackShow() {
  363. return (row) => {
  364. if (row.originalCode) return false;
  365. return (
  366. (this.clientEnvironmentId != '4' && row.status == 8) ||
  367. (this.clientEnvironmentId == '4' &&
  368. !row.productName.includes('板材') &&
  369. row.status == 8)
  370. );
  371. };
  372. },
  373. teamId() {
  374. return this.$store.state.user.info.teamId;
  375. },
  376. clientEnvironmentId() {
  377. return this.$store.state.user.info.clientEnvironmentId;
  378. },
  379. checkRowData() {
  380. return (row) => {
  381. return row.checkedata ? true : false;
  382. };
  383. }
  384. },
  385. created() {
  386. this.setColumns();
  387. this.getFieldModel();
  388. this.getPlanDotLine();
  389. },
  390. methods: {
  391. getPlanDotLine() {
  392. parameterGetByCode({
  393. code: 'plan_dot_line'
  394. }).then((res) => {
  395. if (res) {
  396. this.planDotLine = res.value == '1' ? true : false;
  397. }
  398. });
  399. },
  400. setColumns() {
  401. this.columns = [
  402. {
  403. width: 45,
  404. type: 'selection',
  405. columnKey: 'selection',
  406. align: 'center',
  407. slot: 'selection',
  408. fixed: 'left',
  409. headerSlot: 'selectionHeader'
  410. // selectable: (row, index) => {
  411. // if (row.children) {
  412. // }
  413. // return this.dispatchPermission(row);
  414. // }
  415. },
  416. {
  417. columnKey: 'index',
  418. slot: 'index',
  419. label: '序号',
  420. type: 'index',
  421. width: 55,
  422. align: 'center',
  423. showOverflowTooltip: true,
  424. fixed: 'left'
  425. },
  426. {
  427. slot: 'code',
  428. label: '生产订单号',
  429. align: 'center',
  430. minWidth: 220,
  431. sortable: true,
  432. showOverflowTooltip: true
  433. },
  434. {
  435. prop: 'lineNumber',
  436. label: '行号',
  437. align: 'center',
  438. minWidth: 100,
  439. showOverflowTooltip: true
  440. },
  441. {
  442. prop: 'factoryName',
  443. label: '所属工厂',
  444. align: 'center',
  445. minWidth: 100
  446. },
  447. {
  448. prop: 'taskName',
  449. action: 'taskName',
  450. label: '工序进度',
  451. align: 'center',
  452. minWidth: 160
  453. },
  454. {
  455. prop: 'werks',
  456. slot: 'werks',
  457. label: '库存',
  458. align: 'center',
  459. minWidth: 160
  460. },
  461. {
  462. prop: 'mesStatusName',
  463. label: '状态',
  464. align: 'center',
  465. minWidth: 160
  466. },
  467. {
  468. prop: 'list',
  469. label: '派单对象',
  470. align: 'center',
  471. minWidth: 160,
  472. formatter: (row) => {
  473. if (row?.list?.length) {
  474. let assignees = row.list.map((item) => item.assignees)?.flat();
  475. return assignees?.map((item) => item.assigneeName).join(',');
  476. }
  477. },
  478. showOverflowTooltip: true
  479. },
  480. {
  481. prop: 'productionPlanCode',
  482. label: '计划编号',
  483. align: 'center',
  484. minWidth: 150,
  485. showOverflowTooltip: true
  486. },
  487. {
  488. prop: 'productType',
  489. label: 'BOM类型',
  490. align: 'center',
  491. width: 120,
  492. formatter: (row) => {
  493. if (row.produceType == 1) {
  494. return 'PBOM';
  495. }
  496. if (row.produceType == 2) {
  497. return 'MBOM';
  498. }
  499. if (row.produceType == 3) {
  500. return 'ABOM';
  501. }
  502. }
  503. },
  504. {
  505. prop: 'bomCategoryName',
  506. label: 'BOM版本',
  507. align: 'center',
  508. width: 130,
  509. showOverflowTooltip: true,
  510. formatter: (row) => {
  511. if (row.bomCategoryName) {
  512. return `${row.bomCategoryName} (V${row.bomCategoryVersions}.0)`;
  513. }
  514. return '';
  515. }
  516. },
  517. {
  518. prop: 'produceRoutingName',
  519. label: '工艺路线',
  520. align: 'center',
  521. minWidth: 170,
  522. showOverflowTooltip: true
  523. },
  524. {
  525. prop: 'modelKey',
  526. label: '机型',
  527. align: 'center',
  528. minWidth: 120,
  529. showOverflowTooltip: true
  530. },
  531. {
  532. prop: 'colorKey',
  533. label: '颜色',
  534. align: 'center',
  535. minWidth: 120,
  536. showOverflowTooltip: true
  537. },
  538. {
  539. prop: 'productCode',
  540. label: '编码',
  541. align: 'center',
  542. minWidth: 120,
  543. showOverflowTooltip: true
  544. },
  545. {
  546. prop: 'productName',
  547. label: '名称',
  548. align: 'center',
  549. minWidth: 170,
  550. showOverflowTooltip: true
  551. },
  552. {
  553. prop: 'productionCodes',
  554. label: '生产编号',
  555. align: 'center',
  556. minWidth: 150,
  557. showOverflowTooltip: true
  558. },
  559. {
  560. prop: 'productionRequirements',
  561. label: '生产要求',
  562. align: 'center',
  563. minWidth: 200,
  564. showOverflowTooltip: true
  565. },
  566. {
  567. prop: 'brandNo',
  568. label: '牌号',
  569. align: 'center',
  570. showOverflowTooltip: true
  571. },
  572. {
  573. prop: 'teamName',
  574. label: '首工序班组',
  575. align: 'center',
  576. minWidth: 120,
  577. showOverflowTooltip: true
  578. },
  579. {
  580. prop: 'teamLeaderUserName',
  581. label: '班组长',
  582. align: 'center',
  583. minWidth: 120,
  584. showOverflowTooltip: true
  585. },
  586. {
  587. prop: 'batchNo',
  588. label: '批次号',
  589. align: 'center',
  590. minWidth: 100,
  591. showOverflowTooltip: true
  592. },
  593. {
  594. prop: 'model',
  595. label: '型号',
  596. align: 'center',
  597. showOverflowTooltip: true
  598. },
  599. {
  600. prop: 'specification',
  601. label: '规格',
  602. align: 'center',
  603. showOverflowTooltip: true
  604. },
  605. {
  606. prop: 'priority',
  607. label: '优先级',
  608. align: 'center',
  609. minWidth: 120,
  610. slot: 'priority',
  611. sortable: 'custom'
  612. },
  613. {
  614. prop: 'formingNum',
  615. label: '要求生产数量',
  616. formatter: (row) => {
  617. if (row.measuringUnit) {
  618. return `${row.formingNum} ${row.measuringUnit}`;
  619. } else {
  620. return row.formingNum;
  621. }
  622. },
  623. align: 'center',
  624. showOverflowTooltip: true,
  625. minWidth: 110
  626. },
  627. {
  628. prop: 'formingWeight',
  629. label: '要求生产重量',
  630. align: 'center',
  631. showOverflowTooltip: true,
  632. minWidth: 110,
  633. slot: 'formingWeight'
  634. },
  635. {
  636. prop: 'sourceType',
  637. label: '来源类型',
  638. slot: 'sourceType',
  639. align: 'center',
  640. minWidth: 110,
  641. showOverflowTooltip: true
  642. },
  643. {
  644. prop: 'sourceCode',
  645. label: '来源编码',
  646. align: 'center',
  647. minWidth: 110,
  648. showOverflowTooltip: true
  649. },
  650. {
  651. prop: 'workOrderType',
  652. label: '订单类型',
  653. slot: 'workOrderType',
  654. align: 'center',
  655. minWidth: 110,
  656. showOverflowTooltip: true
  657. },
  658. {
  659. prop: 'planStartTime',
  660. label: '计划开始时间',
  661. align: 'center',
  662. showOverflowTooltip: true,
  663. minWidth: 110
  664. },
  665. {
  666. prop: 'planCompleteTime',
  667. label: '计划结束时间',
  668. align: 'center',
  669. showOverflowTooltip: true,
  670. minWidth: 110
  671. },
  672. {
  673. prop: 'workCenterName',
  674. label: '工作中心',
  675. align: 'center',
  676. minWidth: 110,
  677. showOverflowTooltip: true
  678. },
  679. {
  680. prop: 'firstTaskName',
  681. label: '首工序',
  682. align: 'center',
  683. minWidth: 110,
  684. showOverflowTooltip: true
  685. },
  686. {
  687. prop: 'createTime',
  688. label: '创建时间',
  689. align: 'center',
  690. showOverflowTooltip: true,
  691. minWidth: 110,
  692. sortable: 'custom'
  693. },
  694. // {
  695. // slot: 'status',
  696. // label: '状态',
  697. // align: 'center',
  698. // formatter: (row) => {
  699. // const obj = this.statusOpt.find((i) => i.value == row.status);
  700. // return obj && obj.label;
  701. // }
  702. // },
  703. {
  704. prop: 'customerName',
  705. label: '客户名称',
  706. align: 'center',
  707. showOverflowTooltip: true
  708. },
  709. {
  710. prop: 'serialNo',
  711. label: '客户代号',
  712. align: 'center',
  713. showOverflowTooltip: true
  714. },
  715. {
  716. prop: 'simpleName',
  717. label: '客户简称',
  718. align: 'center',
  719. showOverflowTooltip: true
  720. }
  721. ];
  722. },
  723. // 进入详情
  724. openDetails(row) {
  725. let dispatchRow = { ...row };
  726. this.dispatchRow = { ...row };
  727. dispatchRow.initialWeight = row.formingWeight
  728. ? row.formingWeight + row.newWeightUnit
  729. : '';
  730. this.dispatchRow = dispatchRow;
  731. this.detailsVisible = true;
  732. },
  733. // 全选/取消全选
  734. selectAll(selection) {
  735. if (selection.length == 0) {
  736. // 取消全选
  737. let list = this.$refs.table._data.tableData;
  738. list.map((el) => {
  739. this.$set(el, 'checkedata', false);
  740. if (el.children && el.children.length > 0) {
  741. el.children.map((item) => {
  742. this.$set(item, 'checkedata', false);
  743. delete this.selectionMap[item.id];
  744. });
  745. }
  746. delete this.selectionMap[el.id];
  747. });
  748. return;
  749. }
  750. // 全选
  751. let list = [];
  752. selection.map((item) => {
  753. let flag = this.dispatchPermission(item);
  754. this.$set(item, 'checkedata', flag);
  755. if (flag) {
  756. list.push(item);
  757. }
  758. if (item.children && item.children.length > 0) {
  759. item.children.map((el) => {
  760. let flags = this.dispatchPermission(el);
  761. this.$set(el, 'checkedata', flags);
  762. if (flags) {
  763. list.push(el);
  764. }
  765. });
  766. }
  767. list.map((row) => {
  768. this.selectionMap[row.id] = {
  769. id: row.id,
  770. firstTaskId: row.firstTaskId,
  771. productionPlanId: row.productionPlanId,
  772. productName: row.productName,
  773. productCode: row.productCode,
  774. code: row.code,
  775. productionPlanCode: row.productionPlanCode,
  776. batchNo: row.batchNo,
  777. formingNum: row.formingNum,
  778. productionCodes: row.productionCodes,
  779. planStartTime: row.planStartTime,
  780. planCompleteTime: row.planCompleteTime,
  781. firstTaskName: row.firstTaskName,
  782. workCenterName: row.workCenterName,
  783. workCenterId: row.workCenterId,
  784. productionRequirements: row.productionRequirements,
  785. specification: row.specification,
  786. model: row.model,
  787. brandNo: row.brandNo,
  788. bomCategoryId: row.bomCategoryId,
  789. produceRoutingId: row.produceRoutingId,
  790. produceRoutingName: row.produceRoutingName
  791. };
  792. });
  793. });
  794. },
  795. // 单选数据
  796. selectRow(e, row) {
  797. this.$set(row, 'checkedata', e);
  798. if (e) {
  799. this.selectionMap[row.id] = {
  800. id: row.id,
  801. firstTaskId: row.firstTaskId,
  802. productionPlanId: row.productionPlanId,
  803. productName: row.productName,
  804. productCode: row.productCode,
  805. code: row.code,
  806. productionPlanCode: row.productionPlanCode,
  807. batchNo: row.batchNo,
  808. formingNum: row.formingNum,
  809. productionCodes: row.productionCodes,
  810. planStartTime: row.planStartTime,
  811. planCompleteTime: row.planCompleteTime,
  812. firstTaskName: row.firstTaskName,
  813. workCenterName: row.workCenterName,
  814. workCenterId: row.workCenterId,
  815. productionRequirements: row.productionRequirements,
  816. specification: row.specification,
  817. model: row.model,
  818. brandNo: row.brandNo,
  819. bomCategoryId: row.bomCategoryId,
  820. produceRoutingId: row.produceRoutingId,
  821. produceRoutingName: row.produceRoutingName
  822. };
  823. } else {
  824. delete this.selectionMap[row.id];
  825. }
  826. },
  827. // 批量派单
  828. batchDispatch() {
  829. let list = Object.values(this.selectionMap);
  830. if (list.length === 0) {
  831. this.$message.warning('请至少选择一条派单的数据');
  832. return;
  833. }
  834. if (list.length > 1) {
  835. for (let i = 1; i < list.length; i++) {
  836. let el = list[i];
  837. if (list[0].firstTaskId !== el.firstTaskId) {
  838. this.$message.warning('请选择首工序相同的数据进行批量派单');
  839. return;
  840. }
  841. }
  842. }
  843. this.$refs.batchRef.open(list);
  844. },
  845. getCurrentMonthCreateTimeRange() {
  846. const now = new Date();
  847. const year = now.getFullYear();
  848. const month = String(now.getMonth() + 1).padStart(2, '0');
  849. const lastDay = String(
  850. new Date(year, now.getMonth() + 1, 0).getDate()
  851. ).padStart(2, '0');
  852. return {
  853. createTimeStart: `${year}-${month}-01 00:00:00`,
  854. createTimeEnd: `${year}-${month}-${lastDay} 23:59:59`
  855. };
  856. },
  857. getOrderCreateTimeRange(dateRange) {
  858. if (!Array.isArray(dateRange) || dateRange.length !== 2) {
  859. return this.getCurrentMonthCreateTimeRange();
  860. }
  861. const [startDate, endDate] = dateRange;
  862. if (!startDate || !endDate) {
  863. return this.getCurrentMonthCreateTimeRange();
  864. }
  865. const start = String(startDate).slice(0, 10);
  866. const end = String(endDate).slice(0, 10);
  867. return {
  868. createTimeStart: `${start} 00:00:00`,
  869. createTimeEnd: `${end} 23:59:59`
  870. };
  871. },
  872. buildCurrentMonthOrderWhere(dateRange) {
  873. const createTimeRange = this.getOrderCreateTimeRange(dateRange);
  874. const where = {
  875. ...(this.currentOrderListWhere || {})
  876. };
  877. delete where.createTime;
  878. delete where.createTimeStart;
  879. delete where.createTimeEnd;
  880. Object.assign(where, createTimeRange);
  881. if (where.status) {
  882. where.statusList = [where.status];
  883. delete where.status;
  884. }
  885. return where;
  886. },
  887. getSingleTeamId(value = this.teamId) {
  888. if (Array.isArray(value)) {
  889. return value.length ? this.getSingleTeamId(value[0]) : '';
  890. }
  891. if (value === null || value === undefined) {
  892. return '';
  893. }
  894. const text = String(value).trim();
  895. return text.includes(',') ? text.split(',')[0].trim() : text;
  896. },
  897. async getDefaultTeamByWorkCenter(workCenterId) {
  898. if (!workCenterId) {
  899. return null;
  900. }
  901. const key = String(workCenterId);
  902. if (this.orderSchedulingTeamMap[key] !== undefined) {
  903. return this.orderSchedulingTeamMap[key];
  904. }
  905. try {
  906. const list = await listByWorkCenterId(workCenterId);
  907. const teams = Array.isArray(list) ? list : [];
  908. const userTeamId = this.getSingleTeamId();
  909. const matchedTeam = teams.find(
  910. (item) => String(item.id) === String(userTeamId)
  911. );
  912. const team = matchedTeam || teams[0] || null;
  913. this.$set(this.orderSchedulingTeamMap, key, team);
  914. return team;
  915. } catch {
  916. this.$set(this.orderSchedulingTeamMap, key, null);
  917. return null;
  918. }
  919. },
  920. async fillOrderSchedulingTeamInfo(list = []) {
  921. const rows = Array.isArray(list) ? list : [];
  922. const result = await Promise.all(
  923. rows.map(async (row) => {
  924. if (row.teamId && row.teamName) {
  925. return row;
  926. }
  927. const team = await this.getDefaultTeamByWorkCenter(
  928. row.workCenterId
  929. );
  930. if (!team) {
  931. return row;
  932. }
  933. return {
  934. ...row,
  935. teamId: row.teamId || team.id,
  936. teamName: row.teamName || team.name
  937. };
  938. })
  939. );
  940. return result;
  941. },
  942. async loadCurrentMonthOrderList(dateRange, extraWhere = {}) {
  943. const URL = this.tabValue == '1' ? getList : getListStop;
  944. const data = await URL({
  945. pageNum: 1,
  946. size: -1,
  947. ...this.buildCurrentMonthOrderWhere(dateRange),
  948. ...extraWhere,
  949. ...this.sort
  950. });
  951. return this.fillOrderSchedulingTeamInfo(data?.list || []);
  952. },
  953. async openFactoryScheduling() {
  954. const loading = this.$loading({ text: '加载当月订单数据中...' });
  955. let list = [];
  956. try {
  957. list = await this.loadCurrentMonthOrderList();
  958. } catch (e) {
  959. this.$message.error(e.message || '获取当月订单数据失败');
  960. return;
  961. } finally {
  962. loading.close();
  963. }
  964. const ids = Array.from(
  965. new Set(
  966. list
  967. .map((item) => item.productionPlanId)
  968. .filter((id) => id !== null && id !== undefined && id !== '')
  969. )
  970. );
  971. // 班组排程入口:
  972. // 显式传 mode = order,让排程弹窗切换到工单表格、工位/设备页签,
  973. // 并启用“工序配置按任务派单逻辑筛选工位”的专属处理。
  974. // 订单表格不再取勾选缓存,统一使用订单列表接口返回的当月订单数据。
  975. this.$refs.newFactoryProductionSchedulingRef.open({
  976. ids,
  977. readonly: true,
  978. mode: 'order',
  979. selectedWorkOrders: list,
  980. orderListLoader: (dateRange, extraWhere) =>
  981. this.loadCurrentMonthOrderList(dateRange, extraWhere)
  982. });
  983. },
  984. // 删除拆单数据
  985. remove(row) {
  986. unpackDel(row.id).then((res) => {
  987. if (res) {
  988. this.$message.success('操作成功');
  989. this.createSuccess();
  990. }
  991. });
  992. },
  993. // assignTypeFn(e) {},
  994. statusFormatter(status) {
  995. const obj = this.statusOpt.find((i) => i.value == status);
  996. return obj && obj.label;
  997. },
  998. /* 表格数据源 */
  999. datasource({ page, limit, where }) {
  1000. this.selectionMap = {};
  1001. const requestWhere = { ...(where || {}) };
  1002. this.currentOrderListWhere = { ...requestWhere };
  1003. if (requestWhere.status) {
  1004. requestWhere.statusList = [];
  1005. requestWhere.statusList.push(requestWhere.status);
  1006. delete requestWhere.status;
  1007. }
  1008. const URL = this.tabValue == '1' ? getList : getListStop;
  1009. return URL({
  1010. pageNum: page,
  1011. size: limit,
  1012. ...requestWhere,
  1013. ...this.sort
  1014. });
  1015. },
  1016. /* 数据转为树形结构 */
  1017. parseData(data) {
  1018. const obj = {
  1019. ...data,
  1020. list: this.$util.toTreeData({
  1021. data: data.list,
  1022. count: data.total,
  1023. idField: 'code',
  1024. parentIdField: 'originalCode'
  1025. })
  1026. };
  1027. return obj;
  1028. },
  1029. getFieldModel() {
  1030. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  1031. const privateColumn = [
  1032. {
  1033. columnKey: 'action',
  1034. label: '操作',
  1035. width: 260,
  1036. align: 'center',
  1037. resizable: false,
  1038. fixed: 'right',
  1039. slot: 'action'
  1040. }
  1041. ];
  1042. let newRes = res.map((m) => {
  1043. return {
  1044. prop: 'extField.' + m.prop,
  1045. label: m.label,
  1046. align: 'center',
  1047. showOverflowTooltip: true
  1048. };
  1049. });
  1050. this.columns = [...this.columns, ...newRes, ...privateColumn];
  1051. this.getTabColumns();
  1052. // this.$forceUpdate();
  1053. });
  1054. },
  1055. productionPreparations(row) {
  1056. this.$refs.checkProductionPreparationsRef.open(row);
  1057. },
  1058. // 下达
  1059. toRelease(row) {
  1060. this.current = row;
  1061. this.visible = true;
  1062. this.FirstTaskIdFn();
  1063. this.WorkCenterIdFn();
  1064. this.form.singleReport = this.clientEnvironmentId == 2 ? 0 : 1;
  1065. },
  1066. // 下达
  1067. confirm() {
  1068. this.$refs.form.validate((valid) => {
  1069. if (valid) {
  1070. const loading = this.$loading({ text: '加载中...' });
  1071. if (this.form.assignType * 1 == 2) {
  1072. this.form.workstationIds = [];
  1073. } else {
  1074. this.form.crewIds = [];
  1075. }
  1076. releaseWorkOrder({
  1077. id: this.current.id,
  1078. ...this.form
  1079. })
  1080. .then((res) => {
  1081. if (res) {
  1082. this.$message.success('成功');
  1083. this.reData();
  1084. this.reload();
  1085. this.visible = false;
  1086. }
  1087. })
  1088. .finally(() => {
  1089. loading.close();
  1090. });
  1091. }
  1092. });
  1093. },
  1094. close() {
  1095. this.visible = false;
  1096. this.reData();
  1097. },
  1098. reData() {
  1099. this.form = {
  1100. assignType: 1,
  1101. crewIds: '',
  1102. workstationIds: '',
  1103. teamId: '',
  1104. singleReport: this.clientEnvironmentId == 2 ? 0 : 1
  1105. };
  1106. },
  1107. /* 刷新表格 */
  1108. reload(where) {
  1109. this.currentOrderListWhere = { ...(where || {}) };
  1110. this.$nextTick(() => {
  1111. this.$refs.table.reload({ page: 1, where });
  1112. });
  1113. },
  1114. handleTabClick(e) {
  1115. console.log(e.name);
  1116. this.tabValue = e.name;
  1117. this.reload();
  1118. },
  1119. onSortChange(e) {
  1120. let sort = {
  1121. orderBy: e.order,
  1122. sortName: e.prop
  1123. };
  1124. this.sort = sort;
  1125. this.reload();
  1126. },
  1127. sortTop(row) {
  1128. row.priority = Number(row.priority) + 1;
  1129. this.priorityChange(row);
  1130. },
  1131. sortBottom(row) {
  1132. if (row.priority <= 1) {
  1133. return;
  1134. }
  1135. row.priority = Number(row.priority) - 1;
  1136. this.priorityChange(row);
  1137. },
  1138. FirstTaskIdFn() {
  1139. listByFirstTaskId(this.current.firstTaskId).then((res) => {
  1140. this.stationList = res;
  1141. });
  1142. },
  1143. WorkCenterIdFn() {
  1144. listByWorkCenterId(this.current.workCenterId).then((res) => {
  1145. this.teamsList = res;
  1146. this.$nextTick(() => {
  1147. if (this.teamId) {
  1148. this.$set(this.form, 'teamId', this.teamId);
  1149. this.stationChange();
  1150. }
  1151. // this.$refs.form.clearValidate();
  1152. });
  1153. });
  1154. },
  1155. // 拆分
  1156. toUnpack(row) {
  1157. this.$refs.unpackRef.open(row);
  1158. },
  1159. //派单
  1160. toReleaseOpen(row) {
  1161. this.dispatchRow = { ...row };
  1162. this.dispatchRow.initialWeight = row.formingWeight
  1163. ? row.formingWeight + row.newWeightUnit
  1164. : '';
  1165. if (!this.planDotLine) {
  1166. this.dispatchVisible = true;
  1167. } else {
  1168. this.planDotLineVisible = true;
  1169. }
  1170. // getTaskIdByInstanceId(row.firstTaskId)
  1171. // .then((res) => {
  1172. // if (res) {
  1173. // }
  1174. // })
  1175. // .catch((err) => {
  1176. // this.$message.error(err.message);
  1177. // });
  1178. },
  1179. createSuccess() {
  1180. this.reload();
  1181. },
  1182. checkInventory(item) {
  1183. this.treeId.push(item.rootCategoryLevelId);
  1184. this.$refs.assetsRef.open(item);
  1185. },
  1186. stationChange() {
  1187. this.crewList = [];
  1188. this.crewIds = [];
  1189. listUserByIds([this.form.teamId]).then((res) => {
  1190. this.crewList = res;
  1191. });
  1192. },
  1193. priorityChange(row) {
  1194. if (row.priority > 10) {
  1195. row.priority = 10; // 如果大于 10,则设置为 10
  1196. } else if (row.priority < 0) {
  1197. row.priority = 0; // 如果小于 0,则设置为 0
  1198. }
  1199. this.priorityFn(row);
  1200. },
  1201. priorityFn: debounce(function (row) {
  1202. let params = {
  1203. id: row.id,
  1204. priority: row.priority
  1205. };
  1206. updatePriority(params).then((res) => {});
  1207. }, 800)
  1208. }
  1209. };
  1210. </script>
  1211. <style lang="scss" scoped>
  1212. // ::v-deep .el-table__row {
  1213. // height: 51px !important;
  1214. // }
  1215. .btn_box {
  1216. margin-bottom: 6px;
  1217. }
  1218. </style>