product-list.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902
  1. <template>
  2. <ele-modal
  3. title="选择物品"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :before-close="handleClose"
  7. top="5vh"
  8. append-to-body
  9. width="70%"
  10. :maxable="true"
  11. >
  12. <el-card shadow="never">
  13. <searchProduct v-if="dataSources == '1'" @search="reload"></searchProduct>
  14. <el-form
  15. :model="searchForm"
  16. label-width="100px"
  17. @submit.native.prevent
  18. v-else
  19. >
  20. <el-row>
  21. <el-row>
  22. <!-- <el-col :span="6">
  23. <el-form-item label="仓库名称:">
  24. <el-select v-model="searchForm.warehouseId" style="width: 100%">
  25. <el-option
  26. v-for="item in warehouseList"
  27. :key="item.id"
  28. :value="item.id"
  29. :label="item.name"
  30. ></el-option>
  31. </el-select>
  32. </el-form-item>
  33. </el-col> -->
  34. <el-col :span="6">
  35. <el-form-item label="牌号">
  36. <el-input
  37. type="text"
  38. placeholder="搜索牌号"
  39. v-model="searchForm.brandNum"
  40. ></el-input>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="6" style="height: 43px">
  44. <el-form-item label="列表维度:" prop="dimension">
  45. <template>
  46. <el-select
  47. style="width: 100%"
  48. @change="changeDimensionHandler"
  49. v-model="dimension"
  50. placeholder="请选择"
  51. >
  52. <el-option label="物料维度" value="4"></el-option>
  53. <el-option label="包装维度" value="3"></el-option>
  54. <el-option label="批次维度" value="2"></el-option>
  55. <el-option label="物品维度" value="1"></el-option>
  56. </el-select>
  57. </template>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="6">
  61. <el-form-item label="物品编码:">
  62. <el-input
  63. style="width: 100%"
  64. type="text"
  65. placeholder="搜索物品编码"
  66. v-model="searchForm.categoryCode"
  67. ></el-input>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="6">
  71. <el-form-item label="物品名称:">
  72. <el-input
  73. style="width: 100%"
  74. type="text"
  75. placeholder="搜索物品名称"
  76. v-model="searchForm.categoryName"
  77. ></el-input>
  78. </el-form-item>
  79. </el-col>
  80. <el-col style="text-align: right; margin-bottom: 10px">
  81. <el-button type="primary" @click="doSearch">搜索</el-button>
  82. <el-button icon="el-icon-refresh-left" @click="reset"
  83. >重置</el-button
  84. >
  85. </el-col>
  86. </el-row>
  87. <el-row>
  88. <el-col :span="6">
  89. <el-form-item label="批次号:">
  90. <el-input
  91. type="text"
  92. placeholder="搜索批次号"
  93. v-model="searchForm.batchNo"
  94. ></el-input>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="6">
  98. <el-form-item label="型号:">
  99. <el-input
  100. type="text"
  101. placeholder="搜索型号"
  102. v-model="searchForm.categoryModel"
  103. ></el-input>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="6">
  107. <el-form-item label="规格:">
  108. <el-input
  109. type="text"
  110. placeholder="搜索规格"
  111. v-model="searchForm.specification"
  112. ></el-input>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="6">
  116. <el-form-item label="颜色:">
  117. <el-input
  118. type="text"
  119. placeholder="搜索颜色"
  120. v-model="searchForm.colorKey"
  121. ></el-input>
  122. </el-form-item>
  123. </el-col>
  124. </el-row>
  125. </el-row>
  126. </el-form>
  127. <ele-split-layout
  128. width="244px"
  129. allow-collapse
  130. :right-style="{ overflow: 'hidden' }"
  131. >
  132. <div class="ele-border-lighter split-layout-right-content">
  133. <productTree
  134. @handleNodeClick="handleNodeClick"
  135. :isFirstRefreshTable="isFirstRefreshTable"
  136. ref="treeList"
  137. :ids="ids"
  138. :typeIds="typeIds"
  139. :itemType="itemType"
  140. />
  141. </div>
  142. <!-- 表格 -->
  143. <template v-slot:content>
  144. <ele-pro-table
  145. ref="table"
  146. :columns="columns"
  147. :datasource="datasource"
  148. @row-dblclick="handleDoubleClick"
  149. row-key="id"
  150. height="calc(100vh - 480px)"
  151. class="dict-table"
  152. @cell-click="cellClick"
  153. :selection.sync="selection"
  154. @done="tableDone"
  155. :row-class-name="tableRowClassName"
  156. :initLoad="!isFirstRefreshTable"
  157. @columns-change="handleColumnChange"
  158. :cache-key="cacheKeyUrl"
  159. :page-size="20"
  160. >
  161. <!-- 表头工具栏 -->
  162. <template v-slot:action="{ row }">
  163. <!-- <el-radio class="radio" v-model="radio" :label="row.code"></el-radio> -->
  164. <el-radio class="radio" v-model="radio" :label="row.id">
  165. <i></i>
  166. </el-radio>
  167. </template>
  168. <template v-slot:saleCount="{ row }">
  169. <el-input
  170. v-model="row.saleCount"
  171. style="width: 100%"
  172. placeholder="请输入"
  173. type="number"
  174. :min="0"
  175. ></el-input>
  176. </template>
  177. <template v-slot:cz="{ row }">
  178. <el-button type="text" @click="handleDoubleClick(row)"
  179. >选择PBom</el-button
  180. >
  181. </template>
  182. </ele-pro-table>
  183. </template>
  184. </ele-split-layout>
  185. </el-card>
  186. <div slot="footer">
  187. <el-button
  188. type="primary"
  189. size="small"
  190. :loading="selecting"
  191. @click="selected"
  192. >选择</el-button
  193. >
  194. <el-button size="small" @click="handleClose">关闭</el-button>
  195. </div>
  196. <c-bom-list
  197. v-if="cBomListDialogFlag"
  198. :cBomListDialogFlag.sync="cBomListDialogFlag"
  199. :current-row="current"
  200. ref="cBomRef"
  201. @changeParent="getSelectionCbom"
  202. ></c-bom-list>
  203. </ele-modal>
  204. </template>
  205. <script>
  206. import {
  207. getOutindetailtwoList,
  208. getBatchList,
  209. getMaterialList,
  210. getPackingList
  211. } from '@/api/wms';
  212. import {
  213. getProductList,
  214. queryLastContractProductList
  215. } from '@/api/saleManage/quotation';
  216. import searchProduct from './searchProduct.vue';
  217. import productTree from '@/components/productTree';
  218. import {
  219. getInventoryTotalAPI,
  220. getCategoryPackageDisposition
  221. } from '@/api/wms';
  222. import cBomList from './cBom-list.vue';
  223. import { getByCode } from '@/api/system/dictionary-data';
  224. import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
  225. import { lbjtList } from '@/enum/dict.js';
  226. import tabMixins from '@/mixins/tableColumnsMixin';
  227. import { levelList } from '@/enum/dict.js';
  228. import dictMixins from '@/mixins/dictMixins';
  229. export default {
  230. mixins: [tabMixins, dictMixins],
  231. components: {
  232. productTree,
  233. searchProduct,
  234. cBomList
  235. },
  236. props: {
  237. /*是否需要获取仓库产品数量*/
  238. isGetInventoryTotal: {
  239. type: Boolean,
  240. default: false
  241. },
  242. // 是否回传库存数量
  243. showStockCount: {
  244. type: Boolean,
  245. default: false
  246. },
  247. /*已选择的产品*/
  248. data: {
  249. type: Array,
  250. default: () => []
  251. },
  252. /*是否需要cBom*/
  253. isShowCBom: {
  254. type: Boolean,
  255. default: false
  256. },
  257. /*是否需要供应商*/
  258. isSupplier: {
  259. type: Boolean,
  260. default: false
  261. },
  262. //获取上一次销售记录 1销售合同 2采购合同
  263. isSalesRecord: {
  264. default: ''
  265. },
  266. typeIds: {
  267. type: Array,
  268. default: () => []
  269. },
  270. isFirstRefreshTable: {
  271. type: Boolean,
  272. default: false
  273. },
  274. ids: {
  275. type: Array,
  276. default: () => []
  277. },
  278. itemType: {
  279. type: String,
  280. default: '1'
  281. },
  282. // 是否需要显示可填采购数量的输入框
  283. showSaleCount: {
  284. type: Boolean,
  285. default: false
  286. }
  287. },
  288. data() {
  289. return {
  290. visible: false,
  291. selecting: false,
  292. currentIndex: null,
  293. radio: null,
  294. cBomListDialogFlag: null,
  295. dictList: {},
  296. selection: [],
  297. isColorId: [],
  298. dataSources: '1', // 0:仓库;1:主数据
  299. dimension: '1',
  300. cacheKeyUrl: 'product-list-cache-key',
  301. searchForm: {
  302. categoryCode: '',
  303. categoryName: '',
  304. batchNo: '',
  305. brandNum: '',
  306. engrave: '',
  307. barcodes: '',
  308. categoryModel: '',
  309. specification: '',
  310. colorKey: '',
  311. categoryLevelId: '',
  312. warehouseId: '',
  313. pageNum: 1,
  314. size: 10
  315. },
  316. datasourceList: [],
  317. columnsVersion: 1
  318. };
  319. },
  320. watch: {},
  321. computed: {
  322. columns() {
  323. let columnsVersion = this.columnsVersion;
  324. let data = null;
  325. if (this.currentIndex != -1) {
  326. data = {
  327. action: 'action',
  328. slot: 'action',
  329. align: 'center',
  330. label: '选择',
  331. reserveSelection: true
  332. };
  333. }
  334. if (this.currentIndex == -1) {
  335. data = {
  336. label: '选择',
  337. width: 45,
  338. type: 'selection',
  339. columnKey: 'selection',
  340. align: 'center',
  341. reserveSelection: true
  342. };
  343. }
  344. const tempData = [
  345. data,
  346. {
  347. columnKey: 'index',
  348. type: 'index',
  349. width: 50,
  350. align: 'center',
  351. showOverflowTooltip: true,
  352. label: '序号'
  353. },
  354. {
  355. prop: 'code',
  356. label: '编码',
  357. align: 'center',
  358. showOverflowTooltip: true,
  359. minWidth: 110
  360. },
  361. {
  362. prop: 'name',
  363. label: '名称',
  364. align: 'center',
  365. showOverflowTooltip: true,
  366. minWidth: 110
  367. },
  368. {
  369. prop: 'saleCount',
  370. slot: 'saleCount',
  371. label: '订单数量',
  372. showOverflowTooltip: true,
  373. align: 'center',
  374. minWidth: 120,
  375. hide: !this.showSaleCount
  376. },
  377. {
  378. prop: 'imgCode',
  379. align: 'center',
  380. label: '图号/件号',
  381. showOverflowTooltip: true,
  382. minWidth: 110
  383. },
  384. {
  385. prop: 'componentAttribute',
  386. align: 'center',
  387. label: '属性类型',
  388. showOverflowTooltip: true,
  389. formatter: (row, column) => {
  390. if (row.componentAttribute) {
  391. return row.componentAttribute
  392. .map((item) => {
  393. return lbjtList[item];
  394. })
  395. .toString();
  396. }
  397. },
  398. minWidth: 110
  399. },
  400. {
  401. prop: 'level',
  402. align: 'center',
  403. label: '级别',
  404. showOverflowTooltip: true,
  405. minWidth: 110
  406. },
  407. {
  408. prop: 'extField.packingSpecification',
  409. align: 'center',
  410. label: '包装规格',
  411. showOverflowTooltip: true,
  412. minWidth: 110
  413. },
  414. {
  415. prop: 'brandNum',
  416. align: 'center',
  417. label: '牌号',
  418. showOverflowTooltip: true
  419. },
  420. {
  421. prop: 'modelType',
  422. label: '型号',
  423. align: 'center',
  424. showOverflowTooltip: true
  425. },
  426. {
  427. prop: 'specification',
  428. label: '规格',
  429. align: 'center',
  430. showOverflowTooltip: true
  431. },
  432. {
  433. prop: 'modelKey',
  434. label: '机型',
  435. align: 'center',
  436. showOverflowTooltip: true
  437. },
  438. {
  439. prop: 'colorKey',
  440. label: '颜色',
  441. align: 'center',
  442. showOverflowTooltip: true
  443. },
  444. {
  445. prop: 'voltage',
  446. label: '电压',
  447. align: 'center',
  448. showOverflowTooltip: true,
  449. formatter: (row, column) => {
  450. return row.extField?.voltage || '';
  451. }
  452. },
  453. {
  454. prop: 'layBy',
  455. label: '贮藏',
  456. align: 'center',
  457. showOverflowTooltip: true,
  458. formatter: (row, column) => {
  459. return row.extField?.layBy
  460. ? this.getDictValue('贮藏', row.extField?.layBy)
  461. : '';
  462. }
  463. },
  464. {
  465. prop: 'warrantyPeriod',
  466. label: '保质期',
  467. align: 'center',
  468. showOverflowTooltip: true,
  469. formatter: (row, column) => {
  470. let unit = '';
  471. if (row.warrantyPeriodUnit) {
  472. unit = this.getDictValue('保质期单位', row.warrantyPeriodUnit);
  473. }
  474. return row.warrantyPeriod ? row.warrantyPeriod + unit : '';
  475. }
  476. },
  477. {
  478. prop: 'purchaseOrigins',
  479. label: '产地',
  480. align: 'center',
  481. showOverflowTooltip: true,
  482. formatter: (row, column) => {
  483. return row.purchaseOrigins && row.purchaseOrigins.length
  484. ? row.purchaseOrigins
  485. .map((item) => this.getDictValue('产地', item))
  486. .join(',')
  487. : '';
  488. }
  489. },
  490. {
  491. prop: 'measuringUnit',
  492. label: '计量单位',
  493. showOverflowTooltip: true,
  494. align: 'center',
  495. minWidth: 90,
  496. formatter: (row, column) => {
  497. return row.measuringUnit || row.measureUnit;
  498. }
  499. },
  500. {
  501. prop: 'weightUnit',
  502. label: '重量单位',
  503. showOverflowTooltip: true,
  504. align: 'center',
  505. minWidth: 90
  506. },
  507. {
  508. prop: 'roughWeight',
  509. label: '毛重',
  510. showOverflowTooltip: true,
  511. align: 'center',
  512. minWidth: 90
  513. },
  514. {
  515. prop: 'netWeight',
  516. label: '净重',
  517. showOverflowTooltip: true,
  518. align: 'center',
  519. minWidth: 90
  520. },
  521. {
  522. prop: 'packingUnit',
  523. align: 'center',
  524. label: '包装单位',
  525. showOverflowTooltip: true
  526. },
  527. {
  528. prop: 'categoryLevelPath',
  529. label: '分类',
  530. align: 'center',
  531. showOverflowTooltip: true
  532. },
  533. {
  534. slot: 'cz',
  535. align: 'center',
  536. minWidth: 90,
  537. fixed: 'right',
  538. label: '操作',
  539. show: this.isShowCBom
  540. }
  541. ];
  542. return tempData.filter((item) => !item.hide);
  543. }
  544. },
  545. created() {
  546. this.requestDict('保质期单位');
  547. this.requestDict('贮藏');
  548. this.requestDict('产地');
  549. this.requestDict('贮藏');
  550. },
  551. methods: {
  552. getDictV(code, val) {
  553. if (!this.dictList[code]) return '';
  554. return this.dictList[code].find((item) => item.value == val)?.label;
  555. },
  556. async getDictList(code) {
  557. let { data: res } = await getByCode(code);
  558. this.dictList[code] = res.map((item) => {
  559. let values = Object.keys(item);
  560. return {
  561. value: values[0],
  562. label: item[values[0]]
  563. };
  564. });
  565. console.log('code', this.dictList[code]);
  566. },
  567. open(item, currentIndex, value) {
  568. this.dataSources = value || '1';
  569. this.currentIndex = currentIndex;
  570. this.visible = true;
  571. this.getDictList('productionType');
  572. },
  573. /* 表格数据源 */
  574. datasource({ page, limit, where, order }) {
  575. if (this.dataSources == '0') {
  576. this.searchForm.pageNum = page;
  577. return this.changeDimension(this.dimension);
  578. }
  579. // isEnabled 1:查启用 0:查停用,不传该参数查所有
  580. return getProductList({
  581. pageNum: page,
  582. size: limit,
  583. ...where,
  584. isEnabled: 1
  585. });
  586. },
  587. async tableDone() {
  588. if (this.isSalesRecord == 1 || this.isSalesRecord == 2) {
  589. this.isColorId = await queryLastContractProductList(
  590. this.isSalesRecord
  591. );
  592. }
  593. },
  594. //上次销售记录 改变背景色
  595. tableRowClassName({ row }) {
  596. if (this.isColorId?.includes(row?.id)) {
  597. return 'success-row';
  598. }
  599. return '';
  600. },
  601. /* 刷新表格 */
  602. reload(where) {
  603. where.categoryLevelId = this.curNodeData?.id;
  604. this.searchForm.categoryLevelId = this.curNodeData?.id;
  605. this.$refs.table.reload({ pageNum: 1, where: where });
  606. },
  607. handleNodeClick(data, node) {
  608. this.curNodeData = data;
  609. this.$nextTick(() => {
  610. this.reload({ categoryLevelId: data.id });
  611. });
  612. },
  613. // 单击获取id
  614. cellClick(row) {
  615. if (this.currentIndex == -1) return;
  616. this.current = row;
  617. this.radio = row.id;
  618. },
  619. handleDoubleClick(row) {
  620. if (!this.isShowCBom) return;
  621. this.cBomListDialogFlag = true;
  622. this.current = row;
  623. this.$nextTick(() => {
  624. this.$refs.cBomRef.open(row);
  625. });
  626. },
  627. async getSelectionCbom(rows = []) {
  628. console.log(rows);
  629. let list = rows;
  630. //获取供应商
  631. if (this.isSupplier) {
  632. let supplierList = await this.getSupplierObj(list, 'categoryId');
  633. list.forEach((item) => {
  634. item['supplierList'] = supplierList[item.categoryId];
  635. // item['entrustedEnterpriseIdList'] = supplierList[item.categoryId];
  636. if (supplierList[item.categoryId]?.length) {
  637. // item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
  638. // item['supplierCode'] = supplierList[item.categoryId][0].code;
  639. // item['supplierId'] = supplierList[item.categoryId][0].id;
  640. // item['supplierName'] = supplierList[item.categoryId][0].name;
  641. item['supplierName'] =
  642. supplierList[item.categoryId].find(
  643. (i) => i.id == item.supplierId
  644. )?.name || '';
  645. }
  646. });
  647. }
  648. this.$emit('getSelectionCbom', list);
  649. this.handleClose();
  650. },
  651. handleClose() {
  652. this.visible = false;
  653. this.current = null;
  654. this.selection = [];
  655. this.$refs.table.clearSelection();
  656. this.radio = '';
  657. },
  658. async getSupplierObj(productList, queryName) {
  659. try {
  660. const categoryIds = [
  661. ...new Set(
  662. productList
  663. .filter((item) => item[queryName])
  664. .map((item) => item[queryName])
  665. )
  666. ];
  667. if (categoryIds.length > 0) {
  668. const supplierObj = await contactQueryByCategoryIdsAPI({
  669. categoryIds
  670. });
  671. // 同一物品的供应商列表去重,避免重复 id 渲染成多个 el-option
  672. Object.keys(supplierObj || {}).forEach((categoryId) => {
  673. const supplierIds = new Set();
  674. supplierObj[categoryId] = (supplierObj[categoryId] || []).filter(
  675. (supplier) => {
  676. const supplierId = String(supplier.id);
  677. if (supplierIds.has(supplierId)) {
  678. return false;
  679. }
  680. supplierIds.add(supplierId);
  681. return true;
  682. }
  683. );
  684. });
  685. return supplierObj;
  686. } else {
  687. return Promise.resolve({});
  688. }
  689. } catch (e) {
  690. return Promise.resolve({});
  691. }
  692. },
  693. async selected() {
  694. if (!this.current && !this.selection.length) {
  695. return this.$message.warning('请至少选择一条数据');
  696. }
  697. if (this.currentIndex != -1) {
  698. if (
  699. this.data
  700. .map((item) => item.productCode)
  701. .includes(this.current.code)
  702. ) {
  703. return this.$message.error('选择的物品已经存在列表了');
  704. }
  705. } else {
  706. if (
  707. this.selection.some((item) =>
  708. this.data.some((i) => i.productCode == item.code)
  709. )
  710. ) {
  711. return this.$message.error('选择的物品已经存在列表了');
  712. }
  713. }
  714. let list = this.currentIndex == -1 ? this.selection : [this.current];
  715. let codeList = list.map((item) => item.code);
  716. let idList = list.map((item) => item.id);
  717. this.selecting = true;
  718. try {
  719. // 库存、供应商、包装规格三个请求互不依赖,并行发起,避免串行等待多次往返
  720. const [inventoryTotalList, supplierList, packingSpecification] =
  721. await Promise.all([
  722. this.isGetInventoryTotal
  723. ? getInventoryTotalAPI(codeList)
  724. : Promise.resolve([]),
  725. this.isSupplier
  726. ? this.getSupplierObj(list, 'id')
  727. : Promise.resolve({}),
  728. getCategoryPackageDisposition({ categoryIds: idList })
  729. ]);
  730. //获取仓库库存
  731. if (this.isGetInventoryTotal) {
  732. list.forEach((item) => {
  733. let find =
  734. (inventoryTotalList || []).find(
  735. (key) => key.code == item.code
  736. ) || {};
  737. if (this.showStockCount) {
  738. item.stockCountBase = find.stockCountBase;
  739. item.lockQuantity = find.lockQuantity;
  740. }
  741. item.availableCountBase = find.availableCountBase;
  742. });
  743. }
  744. //获取供应商
  745. if (this.isSupplier) {
  746. list.forEach((item) => {
  747. item['supplierList'] = supplierList[item.id];
  748. item['entrustedEnterpriseIdList'] = supplierList[item.id];
  749. if (supplierList[item.id]?.length) {
  750. item['entrustedEnterpriseId'] = supplierList[item.id][0].id;
  751. item['supplierCode'] = supplierList[item.id][0].code;
  752. item['supplierId'] = supplierList[item.id][0].id;
  753. item['supplierName'] = supplierList[item.id][0].name;
  754. }
  755. });
  756. }
  757. // 获取包装规格
  758. const packageMap = (packingSpecification || []).reduce(
  759. (map, item) => {
  760. if (!item?.conversionUnit) return map;
  761. const mapList = map[item.categoryId] || [];
  762. mapList.push(item);
  763. map[item.categoryId] = mapList;
  764. return map;
  765. },
  766. {}
  767. );
  768. Object.keys(packageMap).forEach((key) => {
  769. packageMap[key].sort((a, b) => a.sort - b.sort);
  770. });
  771. list.forEach((item) => {
  772. item['packageDispositionList'] = packageMap[item.id] || [];
  773. if (item.level) {
  774. item['goodsLevel'] = levelList.find(
  775. (val) => val.label == item.level
  776. )?.value;
  777. }
  778. });
  779. // 先关弹框,再等浏览器把关闭动画画出来,最后才做回显计算
  780. const currentIndex = this.currentIndex;
  781. this.handleClose();
  782. requestAnimationFrame(() => {
  783. requestAnimationFrame(() => {
  784. this.$emit('changeParent', list, currentIndex);
  785. });
  786. });
  787. } finally {
  788. this.selecting = false;
  789. }
  790. },
  791. // 仓库查询
  792. doSearch() {
  793. // this.searchForm.pageNum = 1;
  794. this.reload({ pageNum: 1, where: this.searchForm });
  795. },
  796. // 仓库查询重置
  797. reset() {
  798. this.searchForm = {
  799. categoryCode: '',
  800. categoryName: '',
  801. batchNo: '',
  802. brandNum: '',
  803. engrave: '',
  804. barcodes: '',
  805. categoryModel: '',
  806. specification: '',
  807. colorKey: '',
  808. categoryLevelId: this.categoryLevelId,
  809. pageNum: 1,
  810. warehouseId: '',
  811. size: 10
  812. };
  813. this.doSearch();
  814. },
  815. // 切换维度
  816. changeDimensionHandler(e) {
  817. // this.searchForm.pageNum = 1;
  818. // this.selectionList = [];
  819. // this.$refs.multipleTable.clearSelection();
  820. this.reload({ pageNum: 1, where: this.searchForm });
  821. },
  822. // 仓库数据
  823. async changeDimension(e) {
  824. this.dimension = e;
  825. let data = [];
  826. if (this.dimension == 1) {
  827. // 物品维度
  828. data = await getOutindetailtwoList(this.searchForm);
  829. } else if (this.dimension == 2) {
  830. // 批次维度
  831. data = await getBatchList(this.searchForm);
  832. } else if (this.dimension == 4) {
  833. // 物料维度
  834. data = await getMaterialList(this.searchForm);
  835. } else {
  836. // 包装维度
  837. data = await getPackingList(this.searchForm);
  838. }
  839. data.list.map((el) => {
  840. el.modelType = el.categoryModel;
  841. el.name = el.categoryName;
  842. el.code = el.categoryCode;
  843. });
  844. return data;
  845. }
  846. }
  847. };
  848. </script>
  849. <style lang="scss" scoped>
  850. :deep(.success-row) {
  851. background: #f0f9eb;
  852. }
  853. .tree_col {
  854. border: 1px solid #eee;
  855. padding: 10px 0;
  856. box-sizing: border-box;
  857. height: 500px;
  858. overflow: auto;
  859. }
  860. .table_col {
  861. padding-left: 10px;
  862. ::v-deep .el-table th.el-table__cell {
  863. background: #f2f2f2;
  864. }
  865. }
  866. .pagination {
  867. text-align: right;
  868. padding: 10px 0;
  869. }
  870. .btns {
  871. text-align: center;
  872. padding: 10px 0;
  873. }
  874. .topsearch {
  875. margin-bottom: 15px;
  876. }
  877. </style>