details.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" class="tabs_box">
  4. <div class="page-title">
  5. <PageHeader title="详情"> </PageHeader>
  6. </div>
  7. <headerTitle style="margin-top: 10px" />
  8. <el-form
  9. ref="form"
  10. :model="form"
  11. :rules="rules"
  12. label-position="right"
  13. label-width="140px"
  14. >
  15. <el-row :gutter="10" class="basic">
  16. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  17. <el-form-item label="计划编号:">
  18. <el-input v-model="form.planCode" disabled></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  22. <el-form-item label="批次号:">
  23. <el-input v-model="form.batchNo" disabled></el-input>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  27. <el-form-item label="编码:">
  28. <el-input v-model="form.categoryCode" disabled></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  32. <el-form-item label="名称:">
  33. <el-input v-model="form.categoryName" disabled></el-input>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  37. <el-form-item label="零部件图号:">
  38. <el-input v-model="form.imgCode" disabled></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <!-- <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  42. <el-form-item label="计划数量:">
  43. <el-input v-model="form.order" disabled></el-input>
  44. </el-form-item>
  45. </el-col> -->
  46. <!-- <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  47. <el-form-item label="BOM类型:">
  48. <el-input v-model="form.order" disabled></el-input>
  49. </el-form-item>
  50. </el-col> -->
  51. <!-- <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  52. <el-form-item label="BOM版本:">
  53. <el-input v-model="form.order" disabled></el-input>
  54. </el-form-item>
  55. </el-col> -->
  56. <!-- <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  57. <el-form-item label="投料控制清单号:">
  58. <el-input v-model="form.order" disabled></el-input>
  59. </el-form-item>
  60. </el-col> -->
  61. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  62. <el-form-item label="需求订单号:">
  63. <el-input v-model="form.code" disabled></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  67. <el-form-item label="顶级产品编号:">
  68. <el-input v-model="form.topCategoryName" disabled></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :lg="8" :md="12" :sm="12" :xl="8" :xs="12">
  72. <el-form-item label="顶级产品名称:">
  73. <el-input v-model="form.topCategoryName" disabled></el-input>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. </el-form>
  78. <seek-page :seekList="seekList" @search="search"></seek-page>
  79. <div class="btn_box">
  80. <el-button type="success" size="mini" @click="borrowOrder">
  81. 领用申请
  82. </el-button>
  83. <el-button type="warning" size="mini" @click="pickOrder(2)">
  84. 领料申请
  85. </el-button>
  86. <el-button type="primary" size="mini" @click="pickOrder(1)">
  87. 下料申请
  88. </el-button>
  89. <el-button type="primary" size="mini" @click="inventoryQuery">
  90. 库存查询
  91. </el-button>
  92. <!-- <el-button type="danger" size="mini" @click="materialReturn">
  93. 退料申请
  94. </el-button> -->
  95. </div>
  96. <ele-pro-table
  97. ref="table"
  98. :columns="columns"
  99. :datasource="datasource"
  100. :selection.sync="selection"
  101. row-key="id"
  102. cache-key="entrust_list_data_2026_11"
  103. :height="tableHeight"
  104. :pageSize="20"
  105. @fullscreen-change="fullscreenChange"
  106. @refresh="refreshList"
  107. >
  108. <template #quantity="{ row }">
  109. <!-- 投料控制数量 / 定额数量:定额数量取「单个用量」= 基本数量,不是乘过需求数量的总量 -->
  110. <span
  111. >{{ row.feedingControlQty ? row.feedingControlQty : 0 }}/{{
  112. row.baseQuantity ? row.baseQuantity : 0
  113. }}</span
  114. >
  115. </template>
  116. <template #componentAttribute="{ row }">
  117. <el-tag size="small" v-if="row.componentAttribute">{{
  118. componentAttributeMap[row.componentAttribute] || ''
  119. }}</el-tag>
  120. <span v-else></span>
  121. </template>
  122. <template #attributeType="{ row }">
  123. <el-tag type="success" size="small" v-if="row.attributeType">{{
  124. attributeTypeMap[row.attributeType] || ''
  125. }}</el-tag>
  126. <span v-else></span>
  127. </template>
  128. <template #produceType="{ row }">
  129. <el-tag type="warning" size="small" v-if="row.produceType">{{
  130. produceTypeMap[row.produceType] || ''
  131. }}</el-tag>
  132. <span v-else></span>
  133. </template>
  134. </ele-pro-table>
  135. </el-card>
  136. <order-list ref="orderListRef" @refresh="refreshList" />
  137. <borrow-list ref="borrowListRef" />
  138. <picking-list ref="pickingListRef" />
  139. <stock-ledger-dialog ref="stockLedgerDialogRef" />
  140. </div>
  141. </template>
  142. <script>
  143. import {
  144. getRequirementListPlanDetail,
  145. getRequirementListPlanDetailPage,
  146. getStockLedger
  147. } from '@/api/requirementListPlan';
  148. import orderList from './components/orderList.vue';
  149. import borrowList from './components/borrowList.vue';
  150. import pickingList from './components/pickingList.vue';
  151. import stockLedgerDialog from './components/stockLedgerDialog.vue';
  152. import PageHeader from '@/components/PageHeader';
  153. const COMPONENT_ATTRIBUTE_MAP = {
  154. 1: '自制件',
  155. 2: '采购件',
  156. 3: '外协件',
  157. 4: '受托件'
  158. };
  159. const ATTRIBUTE_TYPE_MAP = {
  160. 1: '总装',
  161. 2: '部装',
  162. 3: '零件',
  163. 4: '原材料'
  164. };
  165. const PRODUCE_TYPE_MAP = {
  166. 1: '加工',
  167. 2: '装配',
  168. 3: '下料'
  169. };
  170. export default {
  171. components: {
  172. orderList,
  173. borrowList,
  174. pickingList,
  175. stockLedgerDialog,
  176. PageHeader
  177. },
  178. data() {
  179. return {
  180. form: {},
  181. rules: {},
  182. id: '',
  183. submitting: false,
  184. tableHeight: 'calc(100vh - 595px)',
  185. detailList: [],
  186. selection: [],
  187. searchWhere: {},
  188. componentAttributeMap: COMPONENT_ATTRIBUTE_MAP,
  189. attributeTypeMap: ATTRIBUTE_TYPE_MAP,
  190. produceTypeMap: PRODUCE_TYPE_MAP
  191. };
  192. },
  193. computed: {
  194. columns() {
  195. return [
  196. {
  197. columnKey: 'selection',
  198. type: 'selection',
  199. width: 45,
  200. align: 'center',
  201. fixed: 'left'
  202. },
  203. {
  204. columnKey: 'index',
  205. label: '序号',
  206. type: 'index',
  207. width: 55,
  208. align: 'center',
  209. showOverflowTooltip: true,
  210. fixed: 'left'
  211. },
  212. {
  213. label: '批次号',
  214. prop: 'batchNo',
  215. width: 100,
  216. align: 'center',
  217. showOverflowTooltip: true
  218. },
  219. {
  220. prop: 'categoryLevelName',
  221. label: '物料分类',
  222. width: 100,
  223. align: 'center',
  224. showOverflowTooltip: true
  225. },
  226. {
  227. prop: 'componentAttribute',
  228. label: '属性类型',
  229. width: 100,
  230. align: 'center',
  231. showOverflowTooltip: true,
  232. slot: 'componentAttribute'
  233. },
  234. {
  235. prop: 'attributeType',
  236. label: '存货类型',
  237. width: 100,
  238. align: 'center',
  239. showOverflowTooltip: true,
  240. slot: 'attributeType'
  241. },
  242. {
  243. prop: 'produceType',
  244. label: '生产类型',
  245. width: 100,
  246. align: 'center',
  247. showOverflowTooltip: true,
  248. slot: 'produceType'
  249. },
  250. {
  251. prop: 'categoryCode',
  252. label: '物料编码',
  253. width: 100,
  254. align: 'center',
  255. showOverflowTooltip: true
  256. },
  257. {
  258. prop: 'type',
  259. label: '需求订单号',
  260. width: 100,
  261. align: 'center',
  262. showOverflowTooltip: true,
  263. slot: 'type'
  264. },
  265. {
  266. prop: 'categoryName',
  267. label: '物料名称',
  268. width: 100,
  269. align: 'center',
  270. showOverflowTooltip: true
  271. },
  272. {
  273. prop: 'modelType',
  274. label: '型号',
  275. width: 100,
  276. align: 'center',
  277. showOverflowTooltip: true
  278. },
  279. {
  280. prop: 'specification',
  281. label: '规格',
  282. width: 100,
  283. align: 'center',
  284. showOverflowTooltip: true
  285. },
  286. {
  287. prop: 'categorySize',
  288. label: '尺寸',
  289. width: 100,
  290. align: 'center',
  291. showOverflowTooltip: true
  292. },
  293. {
  294. prop: 'baseQuantity',
  295. label: '基本数量',
  296. width: 100,
  297. align: 'center',
  298. showOverflowTooltip: true
  299. },
  300. {
  301. prop: 'quantity',
  302. label: '投料控制数量/定额数量',
  303. width: 190,
  304. align: 'center',
  305. showOverflowTooltip: true,
  306. slot: 'quantity'
  307. },
  308. {
  309. prop: 'measuringUnit',
  310. label: '计量单位',
  311. width: 100,
  312. align: 'center',
  313. showOverflowTooltip: true
  314. },
  315. {
  316. prop: 'brandNum',
  317. label: '牌号',
  318. width: 100,
  319. align: 'center',
  320. showOverflowTooltip: true
  321. },
  322. {
  323. prop: 'weight',
  324. label: '重量',
  325. width: 100,
  326. align: 'center',
  327. showOverflowTooltip: true
  328. },
  329. {
  330. prop: 'weightUnit',
  331. label: '重量单位',
  332. width: 100,
  333. align: 'center',
  334. showOverflowTooltip: true
  335. },
  336. {
  337. prop: 'pickQuantity',
  338. label: '申领数量',
  339. width: 100,
  340. align: 'center',
  341. showOverflowTooltip: true
  342. },
  343. {
  344. prop: 'unPickQuantity',
  345. label: '未领数量',
  346. width: 100,
  347. align: 'center',
  348. showOverflowTooltip: true
  349. },
  350. {
  351. prop: 'outQuantity',
  352. label: '已出库数量',
  353. width: 100,
  354. align: 'center',
  355. showOverflowTooltip: true
  356. },
  357. {
  358. prop: 'unOutQuantity',
  359. label: '未出库数量',
  360. width: 100,
  361. align: 'center',
  362. showOverflowTooltip: true
  363. },
  364. {
  365. prop: 'feedQuantity',
  366. label: '已投数量',
  367. width: 100,
  368. align: 'center',
  369. showOverflowTooltip: true
  370. },
  371. {
  372. prop: 'unFeedQuantity',
  373. label: '未投数量',
  374. width: 100,
  375. align: 'center',
  376. showOverflowTooltip: true
  377. },
  378. {
  379. prop: 'oddmentsQuantity',
  380. label: '余料数量',
  381. width: 100,
  382. align: 'center',
  383. showOverflowTooltip: true
  384. },
  385. {
  386. prop: 'createUserName',
  387. label: '创建人',
  388. width: 100,
  389. align: 'center',
  390. showOverflowTooltip: true
  391. },
  392. {
  393. prop: 'createTime',
  394. label: '创建时间',
  395. width: 100,
  396. align: 'center',
  397. showOverflowTooltip: true
  398. }
  399. ];
  400. },
  401. seekList() {
  402. return [
  403. {
  404. label: '编码:',
  405. value: 'categoryCode',
  406. type: 'input',
  407. labelWidth: 50
  408. }
  409. ];
  410. }
  411. },
  412. mounted() {
  413. this.initPage();
  414. },
  415. methods: {
  416. initPage() {
  417. const { id, type } = this.$route.query;
  418. if (!id || type !== 'plan') return;
  419. this.id = id;
  420. this.loadDetail(id);
  421. // this.loadDetailPage(id);
  422. },
  423. async loadDetail(id) {
  424. this.form = (await getRequirementListPlanDetail(id)) || {};
  425. },
  426. async loadDetailPage(id) {
  427. const res = await getRequirementListPlanDetailPage({
  428. materialRequirementsId: id
  429. });
  430. this.detailList = res?.list || [];
  431. this.selection = [];
  432. },
  433. async datasource({ page, limit, where }) {
  434. this.searchWhere = where || {};
  435. return await getRequirementListPlanDetailPage({
  436. ...where,
  437. pageNum: page,
  438. size: limit,
  439. materialRequirementsId: this.$route.query.id
  440. });
  441. // return res?.list || [];
  442. },
  443. async pickOrder(type) {
  444. if (!this.selection.length) {
  445. this.$message.warning('请选择一条数据');
  446. return;
  447. }
  448. // if (this.submitting) return;
  449. // this.submitting = true;
  450. // const isBorrow = type == 1;
  451. // const loading = this.$loading({
  452. // lock: true,
  453. // fullscreen: true,
  454. // text: isBorrow ? '领用中...' : '领料中...'
  455. // });
  456. const creatorFields = this.getCurrentCreatorFields();
  457. const detailList = this.selection.map((item) => ({
  458. ...item,
  459. ...creatorFields,
  460. quantity: item.unPickQuantity,
  461. id: undefined
  462. }));
  463. const params = {
  464. ...this.form,
  465. ...creatorFields,
  466. detailList,
  467. materialRequirements: this.form.code,
  468. type,
  469. remark: ''
  470. };
  471. this.$refs.orderListRef.open(params);
  472. // try {
  473. // const api = isBorrow ? saveBorrowOrder : savePickingOrder;
  474. // await api({
  475. // ...this.form,
  476. // detailList,
  477. // materialRequirements: this.form.code
  478. // });
  479. // this.$message.success(isBorrow ? '领用成功' : '领料成功');
  480. // this.selection = [];
  481. // this.loadDetailPage(this.id);
  482. // } catch (e) {
  483. // this.$message.error('操作失败,请稍后重试');
  484. // } finally {
  485. // loading.close();
  486. // this.submitting = false;
  487. // }
  488. },
  489. getCurrentCreatorFields() {
  490. const userInfo = this.$store.state.user.info || {};
  491. return {
  492. createUserId: userInfo.userId || userInfo.id,
  493. createUserName:
  494. userInfo.nickname ||
  495. userInfo.name ||
  496. userInfo.userName ||
  497. userInfo.loginName
  498. };
  499. },
  500. borrowOrder() {
  501. this.$refs.borrowListRef.open(this.form);
  502. },
  503. async inventoryQuery() {
  504. const loading = this.$loading({
  505. lock: true,
  506. fullscreen: true,
  507. text: '库存查询中...'
  508. });
  509. try {
  510. const res = await getRequirementListPlanDetailPage({
  511. ...this.searchWhere,
  512. pageNum: 1,
  513. size: -1,
  514. materialRequirementsId: this.$route.query.id
  515. });
  516. const materialCodes = [
  517. ...new Set(
  518. (res?.list || [])
  519. .map((item) => item.categoryCode)
  520. .filter(
  521. (code) => code !== undefined && code !== null && code !== ''
  522. )
  523. )
  524. ];
  525. if (!materialCodes.length) {
  526. this.$message.warning('暂无可查询的物料编码');
  527. return;
  528. }
  529. const stockList = await getStockLedger(materialCodes);
  530. this.$refs.stockLedgerDialogRef.open(stockList || []);
  531. } catch (e) {
  532. console.error(e);
  533. this.$message.error('库存查询失败,请稍后重试');
  534. } finally {
  535. loading.close();
  536. }
  537. },
  538. materialReturn() {
  539. if (!this.selection.length) {
  540. this.$message.warning('请选择一条数据');
  541. return;
  542. }
  543. for (let item of this.selection) {
  544. if (item.oddmentsQuantity <= 0) {
  545. this.$message.warning('所选物料存在有余料为0的情况,请重新选择');
  546. return;
  547. }
  548. }
  549. const detailList = this.selection.map((item) => ({
  550. ...item,
  551. quantity: item.oddmentsQuantity,
  552. id: undefined
  553. }));
  554. const params = {
  555. ...this.form,
  556. detailList,
  557. materialRequirements: this.form.code,
  558. type: 3,
  559. remark: ''
  560. };
  561. this.$refs.orderListRef.open(params);
  562. },
  563. refreshList() {
  564. // this.loadDetailPage(this.id);
  565. this.reload();
  566. },
  567. reload(where) {
  568. this.$refs.table.reload({ page: 1, where: where });
  569. },
  570. fullscreenChange(fullscreen) {
  571. this.tableHeight = fullscreen
  572. ? 'calc(100vh - 120px)'
  573. : 'calc(100vh - 595px)';
  574. },
  575. search(where) {
  576. this.searchWhere = where || {};
  577. this.reload(where);
  578. },
  579. closeDetail() {
  580. this.$router.back();
  581. }
  582. }
  583. };
  584. </script>
  585. <style scoped>
  586. ::v-deep .el-form-item {
  587. margin-bottom: 15px !important;
  588. }
  589. .btn_box {
  590. margin-bottom: 6px;
  591. }
  592. </style>