index.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <productionPlan-search
  5. @search="reload"
  6. ref="searchRef"
  7. :statusOpt="statusOpt"
  8. :planType="planType"
  9. :activeName="activeName"
  10. >
  11. </productionPlan-search>
  12. <div class="statistics">
  13. <el-row :gutter="24">
  14. <el-col :span="cardSpan">
  15. <el-card shadow="hover" class="cardItem">
  16. <div>
  17. <div class="cardText">待排产计划数量</div>
  18. <div class="cardNum">{{ planStatistics.waitPlanNum }}</div>
  19. </div>
  20. </el-card>
  21. </el-col>
  22. <el-col :span="cardSpan">
  23. <el-card shadow="hover" class="cardItem">
  24. <div>
  25. <div class="cardText">计划生产数量</div>
  26. <div class="cardNum">{{ planStatistics.planNum }}</div>
  27. </div>
  28. </el-card>
  29. </el-col>
  30. <el-col :span="cardSpan">
  31. <el-card shadow="hover" class="cardItem">
  32. <div>
  33. <div class="cardText">已下发生产数量</div>
  34. <div class="cardNum">{{ planStatistics.issueNum }}</div>
  35. </div>
  36. </el-card>
  37. </el-col>
  38. <el-col :span="cardSpan">
  39. <el-card shadow="hover" class="cardItem">
  40. <div>
  41. <div class="cardText">待派工数量</div>
  42. <div class="cardNum">0</div>
  43. </div>
  44. </el-card>
  45. </el-col>
  46. <el-col :span="cardSpan">
  47. <el-card shadow="hover" class="cardItem">
  48. <div>
  49. <div class="cardText">待完工生产数量</div>
  50. <div class="cardNum">{{ planStatistics.waitFinishNum }}</div>
  51. </div>
  52. </el-card>
  53. </el-col>
  54. <el-col :span="cardSpan">
  55. <el-card shadow="hover" class="cardItem">
  56. <div>
  57. <div class="cardText">待领料数量</div>
  58. <div class="cardNum">0</div>
  59. </div>
  60. </el-card>
  61. </el-col>
  62. <el-col :span="cardSpan">
  63. <el-card shadow="hover" class="cardItem">
  64. <div>
  65. <div class="cardText">已完工数量</div>
  66. <div class="cardNum">{{ planStatistics.finishNum }}</div>
  67. </div>
  68. </el-card>
  69. </el-col>
  70. <el-col :span="cardSpan">
  71. <el-card shadow="hover" class="cardItem">
  72. <div>
  73. <div class="cardText">已入库数量</div>
  74. <div class="cardNum">{{ planStatistics.stockNum }}</div>
  75. </div>
  76. </el-card>
  77. </el-col>
  78. </el-row>
  79. </div>
  80. <div class="btn_box">
  81. <el-button type="success" size="mini" @click="homogeneityInspect"
  82. >齐套性检查</el-button
  83. >
  84. <el-button type="primary" size="mini" @click="disassemblePlan"
  85. >计划分解</el-button
  86. >
  87. <el-button type="primary" size="mini">补单计划</el-button>
  88. <el-button type="info" size="mini">计划行事历</el-button>
  89. <el-button type="warning" size="mini">预警设置</el-button>
  90. <el-button type="primary" size="mini" @click="handleMerge"
  91. >合批</el-button
  92. >
  93. <el-button type="danger" size="mini">延期申请</el-button>
  94. <el-button type="danger" size="mini">变更申请</el-button>
  95. <el-button
  96. type="success"
  97. size="mini"
  98. v-if="timeDimensionPlanType == 3"
  99. @click="factAdd(1)"
  100. >新增</el-button
  101. >
  102. </div>
  103. <el-tabs v-model="activeName" type="card" size="mini">
  104. <el-tab-pane label="未发布" name="first"></el-tab-pane>
  105. <el-tab-pane label="已发布" name="second"></el-tab-pane>
  106. <el-tab-pane label="已变更" name="change"></el-tab-pane>
  107. </el-tabs>
  108. <!-- 数据表格 -->
  109. <ele-pro-table
  110. ref="table"
  111. :key="activeName"
  112. :initLoad="false"
  113. :columns="newColumns"
  114. :datasource="datasource"
  115. row-key="code"
  116. :selection.sync="selection"
  117. :cache-key="`${activeName}ProductionPlanTable`"
  118. @sort-change="onSortChange"
  119. autoAmendPage
  120. :parse-data="parseData"
  121. @update:selection="handleSelectionChange"
  122. >
  123. <template v-slot:batchNo="{ row }">
  124. <el-link type="primary" :underline="false">
  125. <!-- @click.stop="splitDetails(1, row)" -->
  126. <el-tag type="success" size="mini" v-if="row.joinPlanCode">
  127. 拆</el-tag
  128. >
  129. <el-tag
  130. type="danger"
  131. size="mini"
  132. v-if="row.splitBatch == 2"
  133. @click.stop="splitDetails(2, row)"
  134. >
  135. 合</el-tag
  136. >
  137. {{ row.batchNo }}
  138. </el-link>
  139. </template>
  140. <template v-slot:selection="{ row }">
  141. <div class="check_box" @click="handOneSelection(row)">
  142. <div class="check act_check" v-if="selectionFilter(row)">
  143. <i class="el-icon-check"></i>
  144. </div>
  145. <div class="check" v-else></div>
  146. </div>
  147. </template>
  148. <template v-slot:code="{ row }">
  149. <el-link type="primary" :underline="false" @click="goDetail(row)">
  150. {{ row.code }}
  151. </el-link>
  152. </template>
  153. <template v-slot:salesCode="{ row }">
  154. {{ row.salesCode }}
  155. </template>
  156. <template v-slot:priority="{ row }">
  157. <div style="display: flex">
  158. <el-input
  159. v-model="row.priority"
  160. type="number"
  161. size="mini"
  162. :min="0"
  163. :max="10"
  164. @change="priorityChange(row)"
  165. style="width: 80px"
  166. >
  167. </el-input>
  168. <el-popover
  169. placement="right"
  170. width="200"
  171. trigger="hover"
  172. content="数值越大优先级越高(0-3普通, 4-6优先, 7-10紧急)"
  173. >
  174. <div class="sort-wrap" slot="reference">
  175. <i class="el-icon-caret-top" @click="sortTop(row)"></i>
  176. <i class="el-icon-caret-bottom" @click="sortBottom(row)"></i>
  177. </div>
  178. </el-popover>
  179. </div>
  180. </template>
  181. <template v-slot:productNum="{ row }">
  182. {{ row.productNum }} {{ row.unit }}
  183. </template>
  184. <template v-slot:productWeight="{ row }">
  185. {{ row.productWeight }} {{ row.weightUnit }}
  186. </template>
  187. <template v-slot:requiredFormingNum="{ row }">
  188. {{ row.requiredFormingNum }} {{ row.unit }}
  189. </template>
  190. <template v-slot:newSumOrderWeight="{ row }">
  191. {{ row.newSumOrderWeight }} {{ row.newWeightUnit }}
  192. </template>
  193. <template v-slot:status="{ row }">
  194. <span :class="{ 'ele-text-danger': row.status == 3 }">
  195. {{ statusFormatter(row.status) }}
  196. </span>
  197. </template>
  198. <!-- 操作列 -->
  199. <template v-slot:action="{ row }">
  200. <el-link
  201. type="primary"
  202. :underline="false"
  203. v-if="row.status == 2 && row.splitBatch != 1"
  204. @click="handleOrderPublish(1, row)"
  205. >
  206. 发布
  207. </el-link>
  208. <el-link
  209. type="primary"
  210. v-if="row.status == 3"
  211. :underline="false"
  212. @click="handleOrderPublish(2, row)"
  213. >
  214. 重新发布
  215. </el-link>
  216. <el-link
  217. v-if="
  218. row.splitBatch != 2 &&
  219. row.splitBatch != 1 &&
  220. !row.joinPlanCode &&
  221. activeName == 'first'
  222. "
  223. type="primary"
  224. :underline="false"
  225. @click="planEdit(row)"
  226. >
  227. 修改
  228. </el-link>
  229. <el-link
  230. v-if="row.joinPlanCode && activeName == 'first' && row.status != 4"
  231. type="danger"
  232. :underline="false"
  233. @click="handleDel(row)"
  234. >
  235. 删除
  236. </el-link>
  237. <el-link
  238. v-if="
  239. clientEnvironmentId != 4 &&
  240. activeName == 'first' &&
  241. row.splitBatch != 2 &&
  242. !row.joinPlanCode
  243. "
  244. type="primary"
  245. :underline="false"
  246. @click="toUnpack(row)"
  247. >
  248. 拆批
  249. </el-link>
  250. </template>
  251. </ele-pro-table>
  252. </el-card>
  253. <unpackDialog ref="unpackRef" @success="reload" />
  254. <mergeDialog ref="mergeRef" @success="reload"></mergeDialog>
  255. <unpackDetails ref="DetailsRef"></unpackDetails>
  256. <homogeneityInspectDialog
  257. ref="homogeneityInspectDialog"
  258. @success="reload"
  259. />
  260. <homogeneityInspectInstallDialog
  261. ref="homogeneityInspectInstallDialog"
  262. @success="reload"
  263. />
  264. <disassemblePlanPop
  265. ref="disassemblePlanRef"
  266. @close="reload"
  267. ></disassemblePlanPop>
  268. <factoryAdd
  269. v-if="factoryShow"
  270. :factoryType="factoryType"
  271. :factoryObj="factoryObj"
  272. @close="factoryClose"
  273. ></factoryAdd>
  274. </div>
  275. </template>
  276. <script>
  277. import {
  278. getList,
  279. del,
  280. updatePriority,
  281. getPlanStatistics
  282. } from '@/api/productionPlan/index.js';
  283. import productionPlanSearch from './components/productionPlan-search.vue';
  284. import unpackDialog from './components/unpackDialog.vue';
  285. import mergeDialog from './components/mergeDialog.vue';
  286. import homogeneityInspectDialog from './components/homogeneityInspectDialog.vue';
  287. import homogeneityInspectInstallDialog from './components/homogeneityInspectInstallDialog.vue';
  288. import unpackDetails from './components/unpackDetails.vue';
  289. import disassemblePlanPop from './components/disassemblePlanPop.vue';
  290. import factoryAdd from './components/factoryAdd/index.vue';
  291. import { release } from '@/api/productionPlan/order.js';
  292. import { getCode } from '@/api/codeManagement';
  293. import { fieldModel } from '@/api/saleOrder';
  294. import { debounce } from 'lodash';
  295. export default {
  296. components: {
  297. productionPlanSearch,
  298. unpackDialog,
  299. mergeDialog,
  300. unpackDetails,
  301. disassemblePlanPop,
  302. factoryAdd,
  303. homogeneityInspectDialog,
  304. homogeneityInspectInstallDialog
  305. },
  306. props: {
  307. timeDimensionPlanType: { type: Number, default: 1 }
  308. },
  309. data() {
  310. return {
  311. planStatistics: {
  312. waitPlanNum: 0,
  313. planNum: 0,
  314. issueNum: 0,
  315. waitFinishNum: 0,
  316. finishNum: 0,
  317. stockNum: 0
  318. },
  319. activeName: 'first',
  320. // 加载状态
  321. loading: false,
  322. pageType: 'add',
  323. dialogTitle: '',
  324. isBindPlan: false,
  325. statusOpt: {
  326. first: [
  327. { label: '所有状态', value: '3,2' },
  328. { label: '待发布', value: '2' },
  329. { label: '发布失败', value: '3' },
  330. { label: '已发布', value: '4' }
  331. ],
  332. second: [
  333. { label: '所有状态', value: '7,4,5,6' },
  334. { label: '待生产', value: '4' },
  335. { label: '生产中', value: '5' },
  336. { label: '已完成', value: '6' },
  337. { label: '已延期', value: '7' }
  338. ],
  339. change: [{ label: '已变更', value: '9' }]
  340. },
  341. planType: [
  342. { label: '所有计划类型', value: null },
  343. { label: '内销计划', value: '1' },
  344. { label: '外销计划', value: '2' },
  345. { label: '预制计划', value: '3' }
  346. ],
  347. newColumns: [],
  348. selection: [],
  349. factoryShow: false,
  350. factoryType: 1,
  351. factoryObj: {},
  352. cardSpan: 3
  353. };
  354. },
  355. computed: {
  356. clientEnvironmentId() {
  357. return this.$store.state.user.info.clientEnvironmentId;
  358. },
  359. // 表格列配置
  360. columns() {
  361. const opt = {
  362. first: [],
  363. second: [
  364. {
  365. prop: 'releaseTime',
  366. label: '工单发布日期',
  367. align: 'center',
  368. minWidth: 110
  369. },
  370. {
  371. prop: 'planFormingTime',
  372. label: '预测生产日期',
  373. align: 'center',
  374. minWidth: 110
  375. },
  376. {
  377. prop: 'deliveryTime',
  378. label: '预测交货日期',
  379. align: 'center',
  380. minWidth: 110
  381. },
  382. {
  383. prop: 'formingTime',
  384. label: '实际交货日期',
  385. align: 'center',
  386. minWidth: 110
  387. }
  388. ],
  389. change: []
  390. };
  391. return [
  392. {
  393. width: 45,
  394. type: 'selection',
  395. columnKey: 'selection',
  396. align: 'center',
  397. slot: 'selection'
  398. },
  399. {
  400. columnKey: 'index',
  401. label: '序号',
  402. type: 'index',
  403. width: 55,
  404. align: 'center',
  405. showOverflowTooltip: true
  406. },
  407. {
  408. slot: 'batchNo',
  409. prop: 'batchNo',
  410. label: '批次号',
  411. align: 'center',
  412. minWidth: 140,
  413. sortable: true
  414. },
  415. {
  416. slot: 'code',
  417. prop: 'code',
  418. action: 'code',
  419. label: '计划编号',
  420. align: 'center',
  421. minWidth: 160,
  422. sortable: true
  423. },
  424. {
  425. prop: 'salesCode',
  426. action: 'salesCode',
  427. label: '销售订单号',
  428. align: 'center',
  429. minWidth: 160
  430. },
  431. {
  432. prop: 'productCode',
  433. label: '编码',
  434. align: 'center',
  435. minWidth: 140
  436. },
  437. {
  438. prop: 'productName',
  439. label: '名称',
  440. align: 'center',
  441. minWidth: 140
  442. },
  443. {
  444. prop: 'brandNo',
  445. label: '牌号',
  446. align: 'center',
  447. showOverflowTooltip: true
  448. },
  449. {
  450. prop: 'specification',
  451. label: '规格',
  452. align: 'center',
  453. minWidth: 150,
  454. showOverflowTooltip: true
  455. },
  456. {
  457. prop: 'model',
  458. label: '型号',
  459. align: 'center',
  460. showOverflowTooltip: true
  461. },
  462. {
  463. prop: 'priority',
  464. label: '优先级',
  465. align: 'center',
  466. minWidth: 120,
  467. slot: 'priority',
  468. sortable: 'custom'
  469. },
  470. {
  471. prop: 'produceRoutingName',
  472. label: '工艺路线',
  473. align: 'center',
  474. width: 140,
  475. showOverflowTooltip: true
  476. },
  477. {
  478. prop: 'productNum',
  479. label: '计划数量',
  480. align: 'center',
  481. slot: 'productNum'
  482. },
  483. {
  484. prop: 'productWeight',
  485. label: '计划重量',
  486. align: 'center',
  487. slot: 'productWeight'
  488. },
  489. {
  490. prop: 'requiredFormingNum',
  491. label: '要求生产数量',
  492. align: 'center',
  493. slot: 'requiredFormingNum'
  494. },
  495. {
  496. prop: 'newSumOrderWeight',
  497. label: '要求生产重量',
  498. align: 'center',
  499. slot: 'newSumOrderWeight'
  500. },
  501. {
  502. prop: 'scheduleStatusName',
  503. label: '进度状态',
  504. align: 'center',
  505. minWidth: 100
  506. },
  507. {
  508. prop: '',
  509. label: '已排产数量',
  510. align: 'center',
  511. showOverflowTooltip: true
  512. },
  513. {
  514. prop: '',
  515. label: '未排产数量',
  516. align: 'center',
  517. showOverflowTooltip: true
  518. },
  519. {
  520. prop: '',
  521. label: '已生产数量',
  522. align: 'center',
  523. showOverflowTooltip: true
  524. },
  525. {
  526. prop: '',
  527. label: '未生产数量',
  528. align: 'center',
  529. showOverflowTooltip: true
  530. },
  531. {
  532. prop: 'factoryName',
  533. label: '所属工厂',
  534. align: 'center'
  535. },
  536. {
  537. prop: '',
  538. label: '合格品数',
  539. align: 'center'
  540. },
  541. {
  542. prop: '',
  543. label: '不合格品数',
  544. align: 'center'
  545. },
  546. {
  547. prop: '',
  548. label: '合格率',
  549. align: 'center'
  550. },
  551. {
  552. prop: 'moCount',
  553. label: '模数',
  554. align: 'center',
  555. show: this.clientEnvironmentId == '4'
  556. },
  557. {
  558. prop: 'blockCount',
  559. label: '块数',
  560. align: 'center',
  561. show: this.clientEnvironmentId == '4'
  562. },
  563. {
  564. prop: 'noWordCount',
  565. label: '未排程块数',
  566. align: 'center',
  567. show: this.clientEnvironmentId == '4',
  568. minWidth: 110
  569. },
  570. {
  571. prop: 'reqMoldTime',
  572. label: '计划完成日期',
  573. align: 'center',
  574. width: 110,
  575. showOverflowTooltip: true
  576. },
  577. {
  578. prop: 'startTime',
  579. label: '计划开始日期',
  580. align: 'center',
  581. width: 110,
  582. showOverflowTooltip: true
  583. },
  584. {
  585. prop: 'endTime',
  586. label: '计划结束日期',
  587. align: 'center',
  588. width: 110,
  589. showOverflowTooltip: true
  590. },
  591. {
  592. prop: 'orderType',
  593. label: '计划类型',
  594. align: 'center',
  595. formatter: (row) => {
  596. const obj = this.planType.find((i) => i.value == row.planType);
  597. return obj && obj.label;
  598. }
  599. },
  600. {
  601. prop: 'version',
  602. label: '版本',
  603. align: 'center',
  604. minWidth: 80
  605. },
  606. {
  607. prop: 'createTime',
  608. label: '创建时间',
  609. align: 'center',
  610. width: 110,
  611. showOverflowTooltip: true
  612. },
  613. {
  614. columnKey: 'status',
  615. slot: 'status',
  616. label: '状态',
  617. align: 'center',
  618. formatter: (row) => {
  619. const obj = this.statusOpt[this.activeName].find(
  620. (i) => i.value == row.status
  621. );
  622. return obj && obj.label;
  623. }
  624. }
  625. ];
  626. }
  627. },
  628. created() {
  629. this.getFieldModel();
  630. },
  631. mounted() {
  632. this.getPlanStatistics();
  633. },
  634. methods: {
  635. async getPlanStatistics() {
  636. let res = await getPlanStatistics();
  637. console.log(res);
  638. this.planStatistics = res;
  639. },
  640. homogeneityInspect() {
  641. if (this.selection.length == 0) {
  642. this.$message.warning('请至少选择一条计划!');
  643. return;
  644. }
  645. let flag = false;
  646. let type = 0;
  647. for (let item of this.selection) {
  648. type = item.produceType;
  649. for (let ele of this.selection) {
  650. if (item.produceType != ele.produceType) {
  651. flag = true;
  652. break;
  653. }
  654. }
  655. }
  656. if (flag) {
  657. this.$message.warning('请选择加工方式相同的计划!');
  658. return;
  659. }
  660. console.log(type);
  661. if (type == 2) {
  662. this.$refs.homogeneityInspectDialog.open(this.selection);
  663. } else if (type == 3) {
  664. this.$refs.homogeneityInspectInstallDialog.open(this.selection);
  665. } else {
  666. this.$message.warning('请确认加工方式!');
  667. }
  668. },
  669. statusFormatter(status) {
  670. const obj = this.statusOpt[this.activeName].find(
  671. (i) => i.value == status
  672. );
  673. return obj && obj.label;
  674. },
  675. /* 表格数据源 */
  676. datasource({ page, limit, where }) {
  677. return getList({
  678. pageNum: page,
  679. timeDimensionPlanType: this.timeDimensionPlanType,
  680. size: limit,
  681. ...where,
  682. ...this.sort
  683. });
  684. },
  685. // 发布工单
  686. handleOrderPublish(type, row) {
  687. if (!row.produceRoutingName) {
  688. return this.$message.error('请先选择工艺路线!');
  689. }
  690. this.$confirm('发布工单后不可撤回,确定发布吗?', '发布确认')
  691. .then(async () => {
  692. const loading = this.$loading({
  693. lock: true,
  694. fullscreen: true,
  695. text: '工单发布中...'
  696. });
  697. try {
  698. let code = row.workOrderCode;
  699. if (!code) {
  700. code = await getCode('product_order_code');
  701. }
  702. // 反显对象会报错 status
  703. const data = await release([row.id]);
  704. if (data || data === 0) {
  705. this.$message.success('发布成功!');
  706. } else {
  707. this.$message.error('发布失败,请重新发布!');
  708. }
  709. this.reload();
  710. } catch (error) {
  711. console.error(error);
  712. }
  713. loading.close();
  714. })
  715. .catch((err) => {
  716. console.error(err);
  717. });
  718. // this.$router.push({
  719. // path: '/productionPlan/workOrderPublish',
  720. // query: {
  721. // type,
  722. // id: row.id
  723. // }
  724. // });
  725. },
  726. // 修改计划
  727. planEdit(row) {
  728. if (row.timeDimensionPlanType == 3) {
  729. this.factoryObj = row;
  730. this.factoryType = 2;
  731. this.factoryShow = true;
  732. } else {
  733. this.$router.push({
  734. path: '/saleOrder/salesToProduction',
  735. query: {
  736. type: 'edit',
  737. id: row.id
  738. }
  739. });
  740. }
  741. },
  742. getFieldModel() {
  743. fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  744. const privateColumn = [];
  745. if (this.activeName == 'first') {
  746. privateColumn.push({
  747. columnKey: 'action',
  748. label: '操作',
  749. width: 148,
  750. align: 'center',
  751. resizable: false,
  752. fixed: 'right',
  753. slot: 'action'
  754. });
  755. } else {
  756. privateColumn = [];
  757. }
  758. let newRes = res.map((m) => {
  759. return {
  760. prop: 'extField.' + m.prop,
  761. label: m.label,
  762. align: 'center',
  763. showOverflowTooltip: true
  764. };
  765. });
  766. this.newColumns = [...this.columns, ...newRes, ...privateColumn];
  767. this.$forceUpdate();
  768. });
  769. },
  770. handleTabChange() {
  771. this.$refs.searchRef.reset();
  772. },
  773. /* 刷新表格 */
  774. reload(where) {
  775. this.$nextTick(() => {
  776. this.$refs.table.reload({ page: 1, where });
  777. });
  778. },
  779. /* 数据转为树形结构 */
  780. parseData(data) {
  781. return {
  782. ...data,
  783. list: this.$util.toTreeData({
  784. data: data.list,
  785. count: data.total,
  786. idField: 'code',
  787. parentIdField: 'joinPlanCode'
  788. })
  789. };
  790. },
  791. handleDel(row) {
  792. this.$confirm('确定删除当前数据?', '提示')
  793. .then(() => {
  794. del(row.id).then((res) => {
  795. this.reload();
  796. this.$message.success('删除成功');
  797. });
  798. })
  799. .catch(() => {});
  800. },
  801. handleSelectionChange(list) {
  802. if (list.length > 1) {
  803. let _list = [];
  804. list.forEach((e) => {
  805. if (e.childList.length > 0 && e.splitBatch != 2) {
  806. _list.push(...e.childList);
  807. } else {
  808. _list.push(e);
  809. }
  810. });
  811. this.selection = _list;
  812. } else {
  813. this.selection = [];
  814. }
  815. },
  816. handOneSelection(row) {
  817. const index = this.selection.findIndex((item) => item.id == row.id);
  818. if (index >= 0) {
  819. this.selection.splice(index, 1);
  820. } else {
  821. this.selection.push(row);
  822. }
  823. },
  824. selectionFilter(row) {
  825. return this.selection.findIndex((item) => item.id == row.id) >= 0;
  826. },
  827. goDetail({ id }) {
  828. this.$router.push({
  829. path: '/productionPlan/detail',
  830. query: { id }
  831. });
  832. },
  833. // 计划分解
  834. disassemblePlan() {
  835. if (this.selection.length != 1) {
  836. return this.$message.warning('计划分解只能选择一个计划!');
  837. }
  838. this.$refs.disassemblePlanRef.open(this.selection[0]);
  839. },
  840. // 拆批
  841. toUnpack(row) {
  842. if (!row.batchNo) {
  843. return this.$message.error('请先填写批次号!');
  844. }
  845. this.$refs.unpackRef.open(row);
  846. },
  847. // 合并
  848. handleMerge() {
  849. if (this.selection.length <= 1) {
  850. return this.$message.warning('请先勾选二个或多个计划!');
  851. }
  852. const productCode = this.selection[0].productCode;
  853. const produceRoutingId = this.selection[0].produceRoutingId;
  854. for (var i = 0; i < this.selection.length; i++) {
  855. if (productCode != this.selection[i].productCode) {
  856. return this.$message.warning('产品编码不一致!');
  857. }
  858. if (produceRoutingId != this.selection[i].produceRoutingId) {
  859. return this.$message.warning('工艺路线不一致!');
  860. }
  861. }
  862. this.$refs.mergeRef.open(this.selection);
  863. console.log(this.selection);
  864. },
  865. splitDetails(type, row) {
  866. this.$refs.DetailsRef.open(type, row);
  867. },
  868. factAdd(type) {
  869. this.factoryType = type;
  870. this.factoryShow = true;
  871. },
  872. factoryClose(val) {
  873. this.factoryShow = false;
  874. if (val) {
  875. this.reload();
  876. }
  877. },
  878. onSortChange(e) {
  879. let sort = {
  880. orderBy: e.order,
  881. sortName: e.prop
  882. };
  883. this.sort = sort;
  884. this.reload();
  885. },
  886. sortTop(row) {
  887. row.priority = Number(row.priority) + 1;
  888. this.priorityChange(row);
  889. },
  890. sortBottom(row) {
  891. if (row.priority <= 1) {
  892. return;
  893. }
  894. row.priority = Number(row.priority) - 1;
  895. this.priorityChange(row);
  896. },
  897. priorityChange(row) {
  898. if (row.priority > 10) {
  899. row.priority = 10; // 如果大于 10,则设置为 10
  900. } else if (row.priority < 0) {
  901. row.priority = 0; // 如果小于 0,则设置为 0
  902. }
  903. this.priorityFn(row);
  904. },
  905. priorityFn: debounce(function (row) {
  906. let params = {
  907. id: row.id,
  908. priority: row.priority
  909. };
  910. updatePriority(params).then((res) => {});
  911. }, 800)
  912. }
  913. };
  914. </script>
  915. <style lang="scss" scoped>
  916. .btn_box {
  917. margin-bottom: 6px;
  918. }
  919. .check_box {
  920. width: 100%;
  921. display: flex;
  922. align-items: center;
  923. justify-content: center;
  924. cursor: pointer;
  925. }
  926. .check {
  927. width: 14px;
  928. height: 14px;
  929. border: 1px solid #dddddd;
  930. display: flex;
  931. align-items: center;
  932. justify-content: center;
  933. }
  934. .act_check {
  935. border: 1px solid #409eff;
  936. background: #409eff;
  937. .el-icon-check {
  938. color: #fff;
  939. font-size: 10px;
  940. }
  941. }
  942. .statistics {
  943. padding: 10px 10px 20px;
  944. }
  945. .cardItem {
  946. border: 1px solid rgb(225, 225, 225);
  947. text-align: center;
  948. color: white;
  949. background-color: rgba(24, 144, 255, 0.8);
  950. overflow: hidden;
  951. padding: 10px;
  952. }
  953. .cardText {
  954. font-size: 16px;
  955. white-space: nowrap;
  956. text-overflow: ellipsis;
  957. overflow: hidden;
  958. }
  959. .cardNum {
  960. font-size: 32px;
  961. font-style: italic;
  962. white-space: nowrap;
  963. text-overflow: ellipsis;
  964. overflow: hidden;
  965. }
  966. @media (max-width: 768px) {
  967. .cardText {
  968. font-size: 14px;
  969. }
  970. .cardNum {
  971. font-size: 24px;
  972. }
  973. }
  974. ::v-deep .el-card__body {
  975. padding: 17px 12px !important;
  976. }
  977. </style>