homogeneityInspectDialog.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. <template>
  2. <div>
  3. <ele-modal
  4. width="90vw"
  5. :visible.sync="visible"
  6. :close-on-click-modal="false"
  7. row-key="code"
  8. custom-class="ele-dialog-form"
  9. :title="'齐套性检查'"
  10. :maxable="true"
  11. >
  12. <div class="form-wrapper" v-loading="loading">
  13. <div v-show="leftShow" :style="{ width: leftWidth }">
  14. <el-tree
  15. ref="treeRef"
  16. :expand-on-click-node="false"
  17. :data="cardList"
  18. :props="treeProps"
  19. node-key="id"
  20. highlight-current
  21. @node-click="handleNodeClick"
  22. ></el-tree>
  23. </div>
  24. <div :style="{ width: rightWidth }">
  25. <div v-if="!leftShow" class="planInfo">
  26. <el-row style="width: 100%">
  27. <!-- <el-col
  28. :span="planInfo.salesCode ? 6 : planInfo.salesCode.length * 6"
  29. >
  30. <div style="color: blue; display: flex">
  31. <div>销售单号:</div
  32. ><div v-if="planInfo.salesCode"
  33. ><span v-for="item in planInfo.salesCode"
  34. > {{ item }}</span
  35. ></div
  36. >
  37. </div>
  38. </el-col> -->
  39. <!-- <el-col :span="6"> 批次号:{{ planInfo.batchNo }} </el-col> -->
  40. <el-col :span="6"> 名称:{{ planInfo.productName }} </el-col>
  41. <el-col :span="5"> 规格:{{ planInfo.specification }} </el-col>
  42. <el-col :span="5"> 型号:{{ planInfo.model }} </el-col>
  43. <el-col :span="2"> 牌号:{{ planInfo.brandNo }} </el-col>
  44. <el-col :span="4"> 计划编号:{{ planInfo.code }} </el-col>
  45. <el-col :span="2"> 计划数量:{{ planInfo.productNum }} </el-col>
  46. </el-row>
  47. <el-row> </el-row>
  48. </div>
  49. <div>
  50. <ele-pro-table
  51. ref="table"
  52. :needPage="false"
  53. :columns="columns"
  54. key="checkTable"
  55. :init-load="false"
  56. :datasource="datasourceList"
  57. >
  58. <template v-slot:toolbar>
  59. <!-- <el-button type="primary" @click="bulkPurchase" size="mini"
  60. >采购申请</el-button
  61. > -->
  62. </template>
  63. <template v-slot:toolkit>
  64. <el-form
  65. :inline="true"
  66. :model="formInline"
  67. class="demo-form-inline"
  68. >
  69. <el-form-item label="BOM类型">
  70. <el-select
  71. size="mini"
  72. v-model="formInline.bomType"
  73. placeholder="BOM类型"
  74. class="select-type"
  75. @change="bomTypeChange"
  76. >
  77. <el-option
  78. v-for="item in bomListType"
  79. :key="item.id"
  80. :label="item.bomName"
  81. :value="item.id"
  82. >
  83. </el-option>
  84. </el-select>
  85. </el-form-item>
  86. <el-form-item label="BOM版本">
  87. <el-select
  88. class="select-type"
  89. size="mini"
  90. v-model="formInline.bomId"
  91. placeholder="BOM版本"
  92. @change="bomVChange"
  93. >
  94. <el-option
  95. v-for="item in bomListV"
  96. :key="item.bomId"
  97. :label="item.versions"
  98. :value="item.bomId"
  99. >
  100. </el-option>
  101. </el-select>
  102. </el-form-item>
  103. <el-form-item label="最终状态">
  104. <el-select
  105. class="select-type"
  106. size="mini"
  107. v-model="formInline.finalState"
  108. placeholder="最终状态"
  109. @change="finalChange"
  110. >
  111. <el-option
  112. v-for="item in finalStateList"
  113. :key="item.value"
  114. :label="item.label"
  115. :value="item.value"
  116. >
  117. </el-option>
  118. </el-select>
  119. </el-form-item>
  120. </el-form>
  121. </template>
  122. <template v-slot:stockCount="{ row }">
  123. <el-link
  124. type="primary"
  125. :underline="false"
  126. @click="stockDetail(row)"
  127. >
  128. {{ row.stockCount }}
  129. </el-link>
  130. </template>
  131. <template v-slot:currentCount="{ row }">
  132. <el-link
  133. type="primary"
  134. :underline="false"
  135. @click="currentDetail(row)"
  136. >
  137. {{ row.currentCount }}
  138. </el-link>
  139. </template>
  140. <template v-slot:inventoryStatusText="{ row }">
  141. <div
  142. :class="
  143. row.inventoryStatusText == '缺料'
  144. ? 'statusRed'
  145. : 'statusGreen'
  146. "
  147. >
  148. {{ row.inventoryStatusText }}
  149. </div>
  150. </template>
  151. <template v-slot:inTransitStatusText="{ row }">
  152. <div
  153. :class="
  154. row.inTransitStatusText == '缺料'
  155. ? 'statusRed'
  156. : 'statusGreen'
  157. "
  158. >
  159. {{ row.inTransitStatusText }}
  160. </div>
  161. </template>
  162. <template v-slot:finalStateText="{ row }">
  163. <div
  164. :class="
  165. row.finalStateText == '缺料' ? 'statusRed' : 'statusGreen'
  166. "
  167. >
  168. {{ row.finalStateText }}
  169. </div>
  170. </template>
  171. <template v-slot:finishCount="{ row }">
  172. <div>
  173. <div v-if="row.finishCount > 0">{{ row.finishCount }}</div>
  174. <div v-else>-</div>
  175. </div>
  176. </template>
  177. <!-- <template v-slot:action="{ row }">
  178. <el-link
  179. type="primary"
  180. :underline="false"
  181. @click="purchase(row)"
  182. >
  183. 采购申请
  184. </el-link>
  185. </template> -->
  186. </ele-pro-table>
  187. </div>
  188. </div>
  189. </div>
  190. <div slot="footer">
  191. <el-button plain @click="cancel">取消</el-button>
  192. <!-- <el-button type="primary" @click="confirm">确定</el-button> -->
  193. </div>
  194. </ele-modal>
  195. <stockDetailDialog ref="stockDetailDialog" />
  196. <currentDetailDialog ref="currentDetailDialog" />
  197. <producePlan ref="produceRef" @success="reloads"></producePlan>
  198. <purchaseDialog ref="purchaseDialogRef" />
  199. </div>
  200. </template>
  201. <script>
  202. import {
  203. homogeneityInspect,
  204. homogeneityInspectMerge,
  205. findMaterialInfoByPlanId,
  206. findBomCategoryByCategoryId,
  207. getBom
  208. } from '@/api/productionPlan/index.js';
  209. import { listBomByPlanIdsOverride } from '@/api/materialPlan/index';
  210. import stockDetailDialog from './stockDetailDialog.vue';
  211. import currentDetailDialog from './currentDetailDialog.vue';
  212. import producePlan from '@/views/materialPlan/components/producePlan.vue';
  213. import purchaseDialog from './purchaseDialog.vue';
  214. export default {
  215. components: {
  216. stockDetailDialog,
  217. currentDetailDialog,
  218. producePlan,
  219. purchaseDialog
  220. },
  221. data() {
  222. return {
  223. visible: false,
  224. requiredFormingNum: 0,
  225. formInline: {
  226. finalState: 0
  227. },
  228. finalStateList: [
  229. {
  230. label: '全部',
  231. value: 0
  232. },
  233. {
  234. label: '齐套',
  235. value: 1
  236. },
  237. {
  238. label: '缺料',
  239. value: 2
  240. }
  241. ],
  242. // form: {
  243. // homogeneityInspect: []
  244. // },
  245. columns: [
  246. {
  247. columnKey: 'index',
  248. label: '序号',
  249. type: 'index',
  250. width: 55,
  251. align: 'center',
  252. fixed: 'left'
  253. },
  254. // {
  255. // width: 45,
  256. // type: 'selection',
  257. // columnKey: 'selection',
  258. // align: 'center',
  259. // slot: 'selection',
  260. // fixed: 'left'
  261. // },
  262. {
  263. prop: 'batchNo',
  264. label: '批次号',
  265. align: 'center',
  266. minWidth: 100,
  267. showOverflowTooltip: true
  268. },
  269. {
  270. prop: 'salesCode',
  271. label: '销售订单号',
  272. align: 'center',
  273. minWidth: 100,
  274. showOverflowTooltip: true
  275. },
  276. {
  277. prop: 'code',
  278. label: '物料编码',
  279. align: 'center',
  280. minWidth: 100,
  281. showOverflowTooltip: true
  282. },
  283. {
  284. prop: 'name',
  285. label: '物料名称',
  286. align: 'center',
  287. minWidth: 100,
  288. showOverflowTooltip: true
  289. },
  290. {
  291. prop: 'demandQuantity',
  292. label: '定额数量',
  293. showOverflowTooltip: true,
  294. align: 'center'
  295. },
  296. {
  297. prop: 'inventoryQuantity',
  298. label: '库存数量',
  299. showOverflowTooltip: true,
  300. align: 'center'
  301. },
  302. {
  303. prop: 'secureInventory',
  304. label: '安全库存',
  305. showOverflowTooltip: true,
  306. align: 'center'
  307. },
  308. {
  309. prop: 'lockQuantity',
  310. label: '锁库数量',
  311. showOverflowTooltip: true,
  312. align: 'center'
  313. },
  314. {
  315. slot: 'inventoryStatusText',
  316. prop: 'inventoryStatusText',
  317. label: '库存状态',
  318. align: 'center',
  319. minWidth: 80
  320. },
  321. {
  322. slot: 'inTransitNum',
  323. prop: 'inTransitNum',
  324. label: '在途数量',
  325. align: 'center',
  326. minWidth: 80
  327. },
  328. {
  329. prop: 'inTransitOrdersNum',
  330. label: '在途已关联数量 ',
  331. align: 'center',
  332. minWidth: 120
  333. },
  334. {
  335. slot: 'inTransitStatusText',
  336. prop: 'inTransitStatusText',
  337. label: '在途状态',
  338. align: 'center',
  339. minWidth: 80
  340. },
  341. {
  342. label: '最终可用数量',
  343. prop: 'finalAvailableQuantity',
  344. align: 'center',
  345. minWidth: 110
  346. },
  347. {
  348. label: '最终缺料数量',
  349. prop: 'finalShortageQuantity',
  350. align: 'center',
  351. minWidth: 120
  352. },
  353. {
  354. slot: 'finalStateText',
  355. prop: 'finalStateText',
  356. label: '最终状态',
  357. align: 'center',
  358. minWidth: 80
  359. }
  360. // {
  361. // columnKey: 'action',
  362. // label: '操作',
  363. // width: 120,
  364. // align: 'center',
  365. // resizable: false,
  366. // fixed: 'right',
  367. // slot: 'action'
  368. // }
  369. ],
  370. ids: [],
  371. leftShow: false,
  372. leftWidth: '0%',
  373. rightWidth: '100%',
  374. cardList: [],
  375. treeProps: {
  376. label: 'code',
  377. children: 'children'
  378. },
  379. planInfo: {
  380. salesCode: ''
  381. },
  382. datasourceAllList: [], // 表格物料全部数据
  383. datasourceList: [], // 表格物料数据
  384. bomListV: [], // BOM版本
  385. bomListType: [], // BOM 类型
  386. planId: '',
  387. selectNodeId: '',
  388. loading: false
  389. };
  390. },
  391. watch: {
  392. leftShow(newVal, oldVal) {
  393. if (newVal) {
  394. this.leftWidth = '230px';
  395. this.rightWidth = 'calc(100% - 230px)';
  396. } else {
  397. this.leftWidth = '0';
  398. this.rightWidth = '100%';
  399. }
  400. }
  401. },
  402. mounted() {},
  403. methods: {
  404. handleNodeClick(data) {
  405. this.clearData();
  406. this.getBomData(data);
  407. this.selectNodeId = data.id;
  408. this.planInfo = data;
  409. },
  410. reload(where) {
  411. this.$nextTick(() => {
  412. this.$refs.table.reload({ page: 1, where });
  413. });
  414. },
  415. reloads() {},
  416. /* 表格数据源 */
  417. // datasource({ page, limit, where }) {
  418. // return homogeneityInspect({
  419. // pageNum: page,
  420. // size: limit,
  421. // ...where
  422. // });
  423. // },
  424. stockDetail(row) {
  425. this.$refs.stockDetailDialog.open(row);
  426. },
  427. currentDetail(row) {
  428. this.$refs.currentDetailDialog.open(row);
  429. },
  430. // 选择BOM类型
  431. async bomTypeChange(e) {
  432. this.formInline.bomType = e;
  433. let data = this.bomListType.find((el) => el.id === e);
  434. if (!data) return;
  435. this.bomListV = data.bomList;
  436. await this.bomVChange(data.bomList[0].bomId);
  437. },
  438. // 选择BOM版本
  439. async bomVChange(e) {
  440. this.formInline.bomId = e;
  441. let data = this.bomListV.find((el) => el.bomId === e);
  442. if (!data) return;
  443. await this.getMaterialData(data);
  444. },
  445. // 获取物料数据信息
  446. async getMaterialData(data) {
  447. let params = { planId: this.planId, bomVersionId: data.bomId };
  448. const result = await findMaterialInfoByPlanId(params);
  449. result.map((item) => {
  450. item.batchNo = this.planInfo.batchNo;
  451. item.salesCode = this.planInfo.salesCode;
  452. item.finalState =
  453. item.finalStateText == '齐套'
  454. ? 1
  455. : item.finalStateText == '缺料'
  456. ? 2
  457. : '';
  458. });
  459. this.datasourceAllList = result;
  460. this.finalChange(0);
  461. },
  462. // 选择状态
  463. finalChange(e) {
  464. if (e === 0 || !e) {
  465. this.datasourceList = this.datasourceAllList;
  466. return;
  467. }
  468. this.datasourceList = this.datasourceAllList.filter(
  469. (item) => item.finalState === e
  470. );
  471. },
  472. // 批量采购
  473. async bulkPurchase(list) {
  474. if (list.length == 0) {
  475. return this.$message.warning('请至少选择一条数据');
  476. }
  477. // let planIds = list.map((item) => item.id);
  478. // let data = {
  479. // planIds: ['1948548495278911490', '1948548022580850689'],
  480. // demandType: '1'
  481. // };
  482. // this.$refs.produceRef.visible = true;
  483. const o = this.cardList.find((el) => el.id === this.selectNodeId);
  484. let obj = JSON.parse(JSON.stringify(o));
  485. obj.materialList = list;
  486. this.$nextTick(() => {
  487. this.$refs.purchaseDialogRef.open([obj], '生产计划');
  488. });
  489. // const result = await listBomByPlanIdsOverride(data);
  490. },
  491. // 采购申请
  492. purchase(row) {
  493. this.bulkPurchase([row]);
  494. },
  495. async open(dataList) {
  496. this.visible = true;
  497. this.cardList = dataList;
  498. if (dataList.length === 1) {
  499. this.leftShow = false;
  500. } else {
  501. this.leftShow = true;
  502. const firstNodeKey = dataList[0].id;
  503. this.$nextTick(() => {
  504. this.$refs.treeRef.setCurrentKey(firstNodeKey);
  505. });
  506. }
  507. this.handleNodeClick(dataList[0]);
  508. },
  509. cancel() {
  510. this.clearData();
  511. this.visible = false;
  512. },
  513. clearData() {
  514. this.formInline = {
  515. finalState: 0
  516. };
  517. this.bomListV = [];
  518. this.bomListType = [];
  519. this.datasourceList = [];
  520. this.datasourceAllList = [];
  521. },
  522. // 获取bom 数据
  523. async getBomData(data) {
  524. this.loading = true;
  525. try {
  526. this.planId = data.id;
  527. const res = await findBomCategoryByCategoryId(data.categoryId);
  528. if (!res || res.length == 0) {
  529. this.bomListD = [];
  530. this.datasourceList = [];
  531. return;
  532. }
  533. let obj = {};
  534. let bomMap = {
  535. 1: 'PBOM',
  536. 2: 'MBOM',
  537. 3: 'ABOM',
  538. 4: 'EBOM'
  539. };
  540. res.map((el) => {
  541. el.bomName = bomMap[el.bomType];
  542. let OBMINFO = {
  543. bomId: el.bomId,
  544. bomType: el.type,
  545. versions: `V${el.versions}.0`
  546. };
  547. if (obj[el.bomType]) {
  548. obj[el.bomType].bomList.unshift(OBMINFO);
  549. } else {
  550. obj[el.bomType] = { ...el, bomList: [OBMINFO] };
  551. }
  552. });
  553. let list = Object.values(obj);
  554. this.bomListType = list;
  555. await this.bomTypeChange(list[0].id);
  556. this.loading = false;
  557. } catch (err) {
  558. this.$message.error(err.message);
  559. this.loading = false;
  560. }
  561. },
  562. confirm() {
  563. this.visible = false;
  564. },
  565. async merge() {
  566. this.reload({ planIds: this.ids, productType: 1, merge: 2 });
  567. },
  568. tabClick() {
  569. this.reload({ planIds: this.ids, productType: 1 });
  570. }
  571. }
  572. };
  573. </script>
  574. <style lang="scss" scoped>
  575. .mt20 {
  576. margin-top: 20px;
  577. }
  578. .el-form-item {
  579. margin-bottom: 0 !important;
  580. }
  581. .optionButton {
  582. display: flex;
  583. justify-content: flex-end;
  584. padding-bottom: 3px;
  585. }
  586. .statusRed {
  587. color: red;
  588. }
  589. .statusGreen {
  590. color: green;
  591. }
  592. .planInfo {
  593. }
  594. .form-wrapper {
  595. display: flex;
  596. }
  597. .planInfo {
  598. // display: flex;
  599. font-size: 16px;
  600. }
  601. </style>