index.vue 27 KB

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