AssetsDialog.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. <template>
  2. <ele-modal
  3. :visible.sync="visible"
  4. title="物品信息"
  5. width="80vw"
  6. :maxable="true"
  7. >
  8. <el-form :model="searchForm" label-width="100px">
  9. <el-row :gutter="20">
  10. <el-col :span="6">
  11. <el-form-item label="列表维度:" prop="dimension">
  12. <template>
  13. <el-select
  14. style="width: 100%"
  15. @change="changeDimensionHandler"
  16. @keyup.enter.native="doSearch"
  17. v-model="dimension"
  18. placeholder="请选择"
  19. >
  20. <!-- <el-option label="物料维度" value="4"> </el-option> -->
  21. <el-option label="包装维度" value="3"> </el-option>
  22. <el-option label="批次维度" value="2"> </el-option>
  23. <el-option label="物品维度" value="1"> </el-option>
  24. </el-select>
  25. </template>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="6">
  29. <el-form-item label="物品编码:">
  30. <el-input
  31. type="text"
  32. placeholder="搜索物品编码"
  33. v-model="searchForm.categoryCode"
  34. @keyup.enter.native="doSearch"
  35. ></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="6">
  39. <el-form-item label="物品名称:">
  40. <el-input
  41. type="text"
  42. placeholder="搜索物品名称"
  43. v-model="searchForm.categoryName"
  44. @keyup.enter.native="doSearch"
  45. ></el-input>
  46. </el-form-item>
  47. </el-col>
  48. <el-col :span="6">
  49. <el-form-item label="批次号:">
  50. <el-input
  51. type="text"
  52. placeholder="搜索批次号"
  53. v-model="searchForm.batchNo"
  54. @keyup.enter.native="doSearch"
  55. ></el-input>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="6">
  59. <el-form-item label="刻码">
  60. <el-input
  61. type="text"
  62. placeholder="搜索物品刻码"
  63. v-model="searchForm.engrave"
  64. @keyup.enter.native="doSearch"
  65. ></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="6">
  69. <el-form-item label="物料代号">
  70. <el-input
  71. type="text"
  72. placeholder="搜索物料代号"
  73. v-model="searchForm.materielDesignation"
  74. @keyup.enter.native="doSearch"
  75. ></el-input>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="6">
  79. <el-form-item label="发货码">
  80. <el-input
  81. type="text"
  82. placeholder="搜索发货码"
  83. v-model="searchForm.barcodes"
  84. @keyup.enter.native="doSearch"
  85. ></el-input>
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="6">
  89. <el-form-item label="牌号">
  90. <el-input
  91. type="text"
  92. placeholder="搜索牌号"
  93. v-model="searchForm.brandNum"
  94. @keyup.enter.native="doSearch"
  95. ></el-input>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="6">
  99. <el-form-item label="所属工厂" prop="factoryId">
  100. <el-select
  101. filterable
  102. placeholder="请选择"
  103. v-model="searchForm.factoryId"
  104. clearable
  105. class="w100"
  106. @keyup.enter.native="doSearch"
  107. @change="getWarehouseListHandle"
  108. >
  109. <el-option
  110. v-for="item in factoryList"
  111. :key="item.id"
  112. :label="item.name"
  113. :value="item.id"
  114. ></el-option>
  115. </el-select>
  116. </el-form-item>
  117. </el-col>
  118. <el-col :span="6">
  119. <el-form-item label="仓库">
  120. <el-select
  121. clearable
  122. style="width: 100%"
  123. v-model="searchForm.warehouseId"
  124. placeholder="请选择"
  125. @keyup.enter.native="doSearch"
  126. >
  127. <el-option
  128. v-for="item in warehouseList"
  129. :label="item.name"
  130. :value="item.id"
  131. :key="item.id"
  132. >
  133. </el-option>
  134. </el-select>
  135. </el-form-item>
  136. </el-col>
  137. <el-col :span="6">
  138. <el-form-item label="关键字">
  139. <el-input
  140. clearable
  141. type="text"
  142. placeholder="请输入"
  143. v-model="searchForm.keyWord"
  144. @keyup.enter.native="doSearch"
  145. ></el-input>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="6">
  149. <el-form-item label="颜色">
  150. <el-input
  151. clearable
  152. type="text"
  153. placeholder="请输入"
  154. v-model="searchForm.colorKey"
  155. @keyup.enter.native="doSearch"
  156. ></el-input>
  157. </el-form-item>
  158. </el-col>
  159. <el-col>
  160. <div style="float: right">
  161. <el-button type="primary" @click="doSearch">搜索</el-button>
  162. <el-button icon="el-icon-refresh-left" @click="reset"
  163. >重置</el-button
  164. >
  165. </div>
  166. </el-col>
  167. </el-row>
  168. </el-form>
  169. <el-container class="assets-dialog">
  170. <el-aside width="200px" class="wrapper-assets">
  171. <AssetTree
  172. ref="treeList"
  173. :treeIds="treeIds"
  174. @handleNodeClick="handleNodeClick"
  175. />
  176. </el-aside>
  177. <el-main>
  178. <ele-pro-table
  179. row-key="id"
  180. :selection.sync="selectionList"
  181. ref="table"
  182. class="table"
  183. :columns="columns"
  184. :datasource="datasource"
  185. height="calc(100vh - 550px)"
  186. full-height="calc(100vh - 116px)"
  187. tool-class="ele-toolbar-form"
  188. :pageSize="20"
  189. @columns-change="handleColumnChange"
  190. :cache-key="cacheKeyUrl"
  191. >
  192. <template v-slot:outboundNum="{ row }">
  193. <el-input
  194. type="text"
  195. placeholder="请输入"
  196. v-model="row.outboundNum"
  197. @input="handleInput(row, $event)"
  198. :disabled="inputDisabled(row)"
  199. ></el-input>
  200. </template>
  201. </ele-pro-table>
  202. </el-main>
  203. </el-container>
  204. <div slot="footer">
  205. <el-button type="primary" @click="confirm">确定</el-button>
  206. <el-button @click="cancel">关闭</el-button>
  207. </div>
  208. </ele-modal>
  209. </template>
  210. <script>
  211. import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
  212. import storageApi from '@/api/warehouseManagement';
  213. import AssetTree from '../stockManagement/components/assetTree.vue';
  214. import { getWarehouseList } from '@/api/classifyManage/itemInformation';
  215. import { getDetailById, quantityDelivery } from '@/api/classifyManage';
  216. import tabMixins from '@/mixins/tableColumnsMixin';
  217. export default {
  218. mixins: [tabMixins],
  219. components: { AssetTree },
  220. props: {
  221. treeIds: { type: Array, default: () => [] }
  222. },
  223. data() {
  224. return {
  225. factoryList: [],
  226. newColumns: [], // 动态表头
  227. isShowTable: true,
  228. qualityResultOption: [
  229. {
  230. value: 0,
  231. label: '合格'
  232. },
  233. {
  234. value: 1,
  235. label: '不合格'
  236. }
  237. ],
  238. qualityStatusOption: [
  239. {
  240. value: 1,
  241. label: '已质检'
  242. },
  243. {
  244. value: 0,
  245. label: '未质检'
  246. }
  247. ],
  248. visible: false,
  249. tableData: [],
  250. total: 0,
  251. categoryLevelId: '',
  252. searchForm: {
  253. categoryCode: '',
  254. categoryName: '',
  255. batchNo: '',
  256. factoryId: '',
  257. brandNum: '',
  258. engrave: '',
  259. barcodes: '',
  260. categoryLevelId: '',
  261. warehouseId: '',
  262. pageNum: 1,
  263. size: 20,
  264. colorKey: ''
  265. },
  266. selectionList: [],
  267. materialType: '',
  268. warehouseList: [],
  269. allWarehouseList:[],
  270. dimension: '1',
  271. productLists: [],
  272. columnsVersion: 1,
  273. diffCacheKeyUrl: 'wms-warehouseManagement-components-AssetsDialog',
  274. cacheKeyUrl: 'wms-warehouseManagement-components-AssetsDialog1',
  275. selection: []
  276. };
  277. },
  278. created() {
  279. console.log('created');
  280. this.getFieldModel();
  281. this.getWarehouse();
  282. this.getFactoryList();
  283. },
  284. mounted() {
  285. // this.$nextTick(() => {
  286. // this.$refs.table.reload();
  287. // });
  288. },
  289. computed: {
  290. inputDisabled() {
  291. let _this = this;
  292. return (row) => {
  293. // console.log(row);
  294. return (
  295. _this.productLists.some((it) => it.categoryId == row.categoryId) ||
  296. _this.dimension == '3'
  297. );
  298. };
  299. },
  300. columns() {
  301. const _this = this;
  302. const version = this.columnsVersion;
  303. let kk = [];
  304. let jj = [];
  305. if (this.dimension == 1) {
  306. kk = this.newColumns.map((item) => {
  307. return {
  308. label: item.label,
  309. align: item.align,
  310. prop: item.prop,
  311. showOverflowTooltip: item.showOverflowTooltip
  312. };
  313. });
  314. } else {
  315. kk = [
  316. {
  317. label: '批次号',
  318. prop: 'batchNo',
  319. showOverflowTooltip: true
  320. }
  321. ];
  322. }
  323. if (this.dimension == 3) {
  324. jj = [
  325. {
  326. label: '包装编码',
  327. prop: 'packageNo',
  328. align: 'center',
  329. showOverflowTooltip: true
  330. },
  331. {
  332. label: '包装数量',
  333. prop: 'packingQuantity',
  334. align: 'center',
  335. showOverflowTooltip: true
  336. },
  337. {
  338. label: '包装单位',
  339. prop: 'packingUnit',
  340. align: 'center',
  341. showOverflowTooltip: true
  342. },
  343. {
  344. label: '发货条码',
  345. prop: 'barcodes',
  346. align: 'center',
  347. showOverflowTooltip: true
  348. },
  349. {
  350. label: '物料代号',
  351. prop: 'materielDesignation',
  352. align: 'center',
  353. showOverflowTooltip: true
  354. },
  355. {
  356. label: '客户代号',
  357. prop: 'clientCode',
  358. align: 'center',
  359. showOverflowTooltip: true
  360. },
  361. {
  362. label: '刻码',
  363. prop: 'engrave',
  364. align: 'center',
  365. showOverflowTooltip: true
  366. },
  367. {
  368. label: '仓库',
  369. prop: 'warehouseName',
  370. align: 'center',
  371. showOverflowTooltip: true
  372. }
  373. ];
  374. }
  375. let arr = [
  376. this.dimension == 1
  377. ? {
  378. width: 55,
  379. type: 'selection',
  380. columnKey: 'selection',
  381. fixed: 'left',
  382. align: 'center',
  383. reserveSelection: true,
  384. selectable: (row) => {
  385. return !_this.productLists.some(
  386. (it) => it.categoryId == row.categoryId
  387. );
  388. }
  389. }
  390. : {
  391. width: 55,
  392. type: 'selection',
  393. columnKey: 'selection',
  394. fixed: 'left',
  395. align: 'center',
  396. reserveSelection: true,
  397. selectable: (row) => {
  398. return !_this.productLists.some(
  399. (it) => it.categoryId == row.categoryId
  400. );
  401. }
  402. },
  403. {
  404. columnKey: 'index',
  405. type: 'index',
  406. width: 50,
  407. align: 'center',
  408. label: '序号',
  409. showOverflowTooltip: true,
  410. fixed: 'left'
  411. },
  412. {
  413. fixed: 'left',
  414. prop: 'categoryCode',
  415. label: '物品编码',
  416. align: 'center',
  417. showOverflowTooltip: true
  418. },
  419. {
  420. fixed: 'left',
  421. prop: 'categoryName',
  422. label: '物品名称',
  423. align: 'center',
  424. showOverflowTooltip: true
  425. },
  426. {
  427. prop: 'outboundNum',
  428. label: '出库数量',
  429. align: 'center',
  430. minWidth: '100',
  431. showOverflowTooltip: true,
  432. slot: 'outboundNum'
  433. },
  434. {
  435. prop: 'inventoryCycle',
  436. label: '存货周期(天)',
  437. align: 'center',
  438. width: 150,
  439. sortable: true,
  440. showOverflowTooltip: true,
  441. hide: this.dimension == 1
  442. },
  443. {
  444. prop: 'brandNum',
  445. label: '牌号',
  446. align: 'center',
  447. showOverflowTooltip: true
  448. },
  449. {
  450. prop: 'modelKey',
  451. label: '机型',
  452. align: 'center',
  453. showOverflowTooltip: true
  454. },
  455. {
  456. prop: 'colorKey',
  457. label: '颜色',
  458. align: 'center',
  459. showOverflowTooltip: true
  460. },
  461. {
  462. prop: 'categoryModel',
  463. label: '型号',
  464. align: 'center',
  465. showOverflowTooltip: true
  466. },
  467. {
  468. prop: 'specification',
  469. label: '规格',
  470. align: 'center',
  471. showOverflowTooltip: true
  472. },
  473. ...kk,
  474. {
  475. prop: 'level',
  476. label: '级别',
  477. align: 'center',
  478. showOverflowTooltip: true
  479. },
  480. {
  481. prop: 'measureQuantity',
  482. label: '计量数量',
  483. align: 'center',
  484. showOverflowTooltip: true
  485. },
  486. {
  487. prop: 'measureUnit',
  488. label: '计量单位',
  489. align: 'center',
  490. showOverflowTooltip: true
  491. },
  492. {
  493. prop: 'weight',
  494. label: '重量',
  495. align: 'center',
  496. showOverflowTooltip: true
  497. },
  498. {
  499. prop: 'weightUnit',
  500. label: '重量单位',
  501. align: 'center',
  502. showOverflowTooltip: true
  503. },
  504. ...jj,
  505. {
  506. prop: 'supplierName',
  507. label: '供应商',
  508. align: 'center',
  509. showOverflowTooltip: true
  510. },
  511. {
  512. prop: 'supplierCode',
  513. label: '供应商代号',
  514. align: 'center',
  515. showOverflowTooltip: true
  516. }
  517. ];
  518. return arr.filter((item) => !item.hide);
  519. }
  520. },
  521. watch: {},
  522. methods: {
  523. //获取工厂列表
  524. async getFactoryList() {
  525. const res = await warehouseDefinition.getFactoryarea({
  526. pageNum: 1,
  527. size: 9999,
  528. type: 1
  529. });
  530. this.factoryList = res.list;
  531. },
  532. async getWarehouse() {
  533. const { data } = await getWarehouseList();
  534. this.allWarehouseList = data;
  535. },
  536. getWarehouseListHandle(val) {
  537. this.searchForm.warehouseId = '';
  538. this.warehouseList = this.allWarehouseList.filter(
  539. (item) => item.factoryId === val
  540. );
  541. },
  542. // 获取动态表头
  543. getFieldModel() {
  544. storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
  545. let newRes = res.map((m) => {
  546. return {
  547. prop: 'extField.' + m.prop,
  548. label: m.label,
  549. align: 'center',
  550. showOverflowTooltip: true
  551. };
  552. });
  553. this.newColumns = [...newRes];
  554. });
  555. },
  556. // 出库数量限制
  557. handleInput(row, value) {
  558. if (row.outboundNum <= row.measureQuantity) {
  559. // return (row.outboundNum = value.replace(/^(0+)|[^\d]+/g, ''));
  560. // 过滤掉非数字和小数点的字符
  561. const filteredValue = value.replace(/[^0-9.]/g, '');
  562. // 限制只能有一个小数点
  563. const singleDotValue = filteredValue.replace(/(\..*)\./g, '$1');
  564. let finalValue = '';
  565. const dotIndex = singleDotValue.indexOf('.');
  566. if (dotIndex !== -1) {
  567. // 截取小数点后最多两位
  568. finalValue = singleDotValue.slice(0, dotIndex + 3);
  569. } else {
  570. finalValue = singleDotValue;
  571. }
  572. row.outboundNum = finalValue;
  573. const currentIndex = this.selectionList.findIndex(item => item.id === row.id)
  574. if(currentIndex > -1) {
  575. this.$set(this.selectionList, currentIndex, row);
  576. }
  577. return
  578. } else {
  579. row.outboundNum = row.measureQuantity;
  580. const currentIndex = this.selectionList.findIndex(item => item.id === row.id)
  581. if(currentIndex > -1) {
  582. this.$set(this.selectionList, currentIndex, row);
  583. }
  584. }
  585. },
  586. // 切换维度
  587. changeDimensionHandler(e) {
  588. this.searchForm.pageNum = 1;
  589. this.selectionList = [];
  590. this.cacheKeyUrl = this.diffCacheKeyUrl + e;
  591. this.getTabColumns();
  592. this.reload();
  593. },
  594. async changeDimension(e) {
  595. this.dimension = e;
  596. if (this.dimension == 1) {
  597. // 物品维度
  598. const data = await storageApi.getProductList({
  599. ...this.searchForm,
  600. isEnabled: 1
  601. });
  602. this.tableData = data.list;
  603. this.total = data.count;
  604. } else if (this.dimension == 2) {
  605. // 批次维度
  606. const data = await storageApi.getBatchList(this.searchForm);
  607. for (let i = 0; i < data.list.length; i++) {
  608. data.list[i].outboundNum = data.list[i].measureQuantity;
  609. }
  610. this.tableData = data.list;
  611. this.total = data.count;
  612. } else if (this.dimension == 4) {
  613. // 物料维度
  614. const data = await storageApi.getMaterialList({
  615. ...this.searchForm
  616. });
  617. this.tableData = data.list;
  618. this.total = data.count;
  619. } else {
  620. // 包装维度
  621. const data = await storageApi.getPackingList(this.searchForm);
  622. for (let i = 0; i < data.list.length; i++) {
  623. data.list[i].outboundNum = data.list[i].packingQuantity;
  624. }
  625. this.tableData = data.list;
  626. this.total = data.count;
  627. }
  628. console.log(this.tableData);
  629. this.updateProductOutboundNums(this.tableData);
  630. },
  631. updateProductOutboundNums(list) {
  632. console.log(this.productLists, 'this.productLists');
  633. console.log(this.dimension);
  634. // 物品时有bug,可能有多条,不用find,用filter
  635. if (this.dimension == 1) {
  636. //物品层
  637. for (let i = 0; i < list.length; i++) {
  638. const item = list[i];
  639. const matchedProduct = this.productLists.filter(
  640. (product) => product.categoryId === item.categoryId
  641. );
  642. let num = matchedProduct.reduce(
  643. (pre, cur) => pre + cur.measureQuantity,
  644. 0
  645. );
  646. // console.log(matchedProduct);
  647. if (matchedProduct.length) {
  648. this.$set(item, 'outboundNum', num);
  649. }
  650. const isSelection = this.selectionList.find(
  651. (product) => product.categoryId === item.categoryId
  652. );
  653. if (isSelection) {
  654. this.$set(item, 'outboundNum', isSelection.outboundNum);
  655. }
  656. }
  657. } else {
  658. for (let i = 0; i < list.length; i++) {
  659. const item = list[i];
  660. const matchedProduct = this.productLists.find(
  661. (product) => product.id === item.id
  662. );
  663. if (matchedProduct) {
  664. this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
  665. }
  666. const isSelection = this.selectionList.find(
  667. (product) => product.id === item.id
  668. );
  669. if (isSelection) {
  670. this.$set(item, 'outboundNum', isSelection.outboundNum);
  671. }
  672. }
  673. }
  674. },
  675. open(val) {
  676. let that = this;
  677. this.productLists = val || [];
  678. this.visible = true;
  679. this.$nextTick(() => {
  680. this.$refs.treeList.getTreeData().then((data) => {
  681. // that.$nextTick(() => {
  682. // that.categoryLevelId = data.id;
  683. // that.searchForm.categoryLevelId = data.id;
  684. // that.doSearch();
  685. // });
  686. this.handleNodeClick(data);
  687. });
  688. });
  689. },
  690. async confirm() {
  691. console.log(this.selectionList);
  692. if (!this.selectionList.length) {
  693. this.$message.error('请至少选择一条数据!');
  694. return;
  695. }
  696. if (this.dimension == 1) {
  697. let boolen = this.selectionList.every((item) => item.outboundNum > 0);
  698. if (!boolen) {
  699. this.$message.error('请输入出库数量!');
  700. return;
  701. }
  702. }
  703. console.log(this.selectionList);
  704. let data = null;
  705. if (this.dimension == 3) {
  706. data = await storageApi.getHierarchyList({
  707. ids: this.selectionList.map((item) => item.id).join(','),
  708. type: this.dimension,
  709. warehouseId: this.searchForm.warehouseId,
  710. });
  711. } else if (this.dimension == 2) {
  712. data = await storageApi.getHierarchyFifo({
  713. type: this.dimension,
  714. ids: this.selectionList.map((item) => item.id),
  715. builders: this.selectionList.map((item) => {
  716. return {
  717. warehouseId: this.searchForm.warehouseId,
  718. categoryId: item.categoryId,
  719. num: item.outboundNum,
  720. id: item.id
  721. };
  722. })
  723. });
  724. } else if (this.dimension == 1) {
  725. data = await storageApi.getHierarchyFifo({
  726. type: this.dimension,
  727. builders: this.selectionList.map((item) => {
  728. return {
  729. warehouseId: this.searchForm.warehouseId,
  730. categoryId: item.categoryId,
  731. num: item.outboundNum
  732. };
  733. })
  734. });
  735. }
  736. console.log('data-------------------', data);
  737. this.$emit('detailData', data, this.dimension);
  738. this.cancel();
  739. },
  740. cancel() {
  741. this.selectionList = [];
  742. // this.$refs.multipleTable.clearSelection();
  743. this.visible = false;
  744. },
  745. handleSelectionChange(val) {
  746. this.selectionList = val;
  747. },
  748. handleNodeClick(data) {
  749. // console.log(data);
  750. this.categoryLevelId = data.id;
  751. this.searchForm.categoryLevelId = data.id;
  752. this.doSearch();
  753. },
  754. handleCurrentChange() {
  755. this.changeDimension(this.dimension);
  756. },
  757. reset() {
  758. this.searchForm = {
  759. categoryCode: '',
  760. categoryName: '',
  761. batchNo: '',
  762. brandNum: '',
  763. engrave: '',
  764. barcodes: '',
  765. warehouseId: '',
  766. factoryId: '',
  767. categoryLevelId: this.categoryLevelId,
  768. pageNum: 1,
  769. size: 20
  770. };
  771. this.doSearch();
  772. },
  773. doSearch() {
  774. this.searchForm.pageNum = 1;
  775. this.$refs.table.reload();
  776. this.$refs.table.reRenderTable();
  777. },
  778. handleSizeChange() {
  779. this.searchForm.pageNum = 1;
  780. this.changeDimension(this.dimension, 'page');
  781. },
  782. // 翻页时,输入的数量会重置
  783. updateSelect(data) {
  784. if (!this.selectionList.length) {
  785. return data;
  786. }
  787. let ids = this.selectionList.map((item) => item.id);
  788. data.list.forEach((item) => {
  789. let id = ids.find((id) => item.id === id);
  790. if (id) {
  791. item.outboundNum = this.selectionList.find(
  792. (item) => item.id === id
  793. ).outboundNum;
  794. }
  795. });
  796. return data;
  797. },
  798. async datasource({ page, limit, where, order }) {
  799. const dimension = this.dimension;
  800. let data;
  801. // console.log(this.searchForm);
  802. // console.log(dimension);
  803. if (dimension == 1) {
  804. data = await storageApi.getProductList({
  805. ...where,
  806. ...order,
  807. ...this.searchForm,
  808. pageNum: page,
  809. size: limit
  810. });
  811. // console.log(data);
  812. // let result = this.updateSelect(data);
  813. // return result;
  814. this.updateProductOutboundNums(data.list);
  815. return data;
  816. }
  817. if (dimension == 2) {
  818. data = await storageApi.getBatchList({
  819. ...where,
  820. ...order,
  821. ...this.searchForm,
  822. pageNum: page,
  823. size: limit
  824. });
  825. data.list.forEach((item) => {
  826. item.outboundNum = item.measureQuantity;
  827. });
  828. return data;
  829. }
  830. if (dimension == 3) {
  831. data = await storageApi.getPackingList({
  832. ...where,
  833. ...order,
  834. ...this.searchForm,
  835. pageNum: page,
  836. size: limit
  837. });
  838. data.list.forEach((item) => {
  839. item.outboundNum = item.packingQuantity;
  840. });
  841. this.updateProductOutboundNums(data.list);
  842. return data;
  843. }
  844. },
  845. reload(where) {
  846. this.$refs.table.reload({
  847. pageNum: 1
  848. });
  849. }
  850. }
  851. };
  852. </script>
  853. <style lang="scss" scoped>
  854. .el-dialog__wrapper {
  855. ::v-deep .el-aside {
  856. background-color: #fff !important;
  857. border: 1px solid #ccc;
  858. }
  859. }
  860. .wrapper-assets {
  861. max-height: 53vh;
  862. overflow: auto;
  863. }
  864. </style>