item-list.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011
  1. <template>
  2. <div class="itemList">
  3. <!-- 数据表格 -->
  4. <item-search
  5. @search="reload"
  6. ref="refSeavch"
  7. :type="type"
  8. @handledime="handledime"
  9. ></item-search>
  10. <ele-pro-table
  11. ref="table"
  12. class="table"
  13. :columns="columns"
  14. :datasource="datasource"
  15. height="calc(100vh - 325px)"
  16. full-height="calc(100vh - 116px)"
  17. tool-class="ele-toolbar-form"
  18. :pageSize="20"
  19. @select="selectChange"
  20. @select-all="changeSelectAll"
  21. @columns-change="handleColumnChange"
  22. :cache-key="cacheKeyUrl"
  23. :summary-method="getSummaries"
  24. show-summary
  25. >
  26. <!-- 表头工具栏 -->
  27. <template v-slot:toolbar="{ row }">
  28. <div class="upload">
  29. <el-button
  30. v-if="selectedDime == 3"
  31. size="small"
  32. :disabled="checkRadioData.length == 0"
  33. icon="el-icon-set-up"
  34. class="ele-btn-icon"
  35. @click="allPrinting()"
  36. >
  37. 打印条码
  38. </el-button>
  39. <!-- <el-upload
  40. v-if="!isLoading"
  41. :show-file-list="false"
  42. class="upload-demo"
  43. action=""
  44. :before-upload="beforeUpload"
  45. :on-success="successUpload"
  46. :on-error="errorUpload"
  47. >
  48. <slot>
  49. <el-button
  50. type="primary"
  51. size="small"
  52. plain
  53. icon="el-icon-upload2"
  54. >导入</el-button
  55. >
  56. </slot>
  57. </el-upload> -->
  58. <el-button
  59. type="primary"
  60. size="small"
  61. icon="el-icon-upload2"
  62. plain
  63. @click="uploadFile"
  64. >导入</el-button
  65. >
  66. <exportButton
  67. fileName="库存台账"
  68. :apiUrl="exportApiUrl"
  69. :params="params"
  70. v-if="selectedDime == 2"
  71. ></exportButton>
  72. </div>
  73. <!-- <el-button
  74. v-if="selectedDime == 2 || selectedDime == 3"
  75. size="small"
  76. :disabled="checkRadioData.length == 0"
  77. icon="el-icon-set-up"
  78. class="ele-btn-icon"
  79. @click="showAllot()"
  80. >
  81. 调拨
  82. </el-button> -->
  83. </template>
  84. <template v-slot:result="{ row }">
  85. <span>{{ qualityResults[row.result] }}</span>
  86. </template>
  87. <template v-slot:status="{ row }">
  88. <span>{{ qualityStatus[row.status] }}</span>
  89. </template>
  90. <!-- -->
  91. <!-- 物品名称 -->
  92. <template v-slot:categoryName="{ row }">
  93. <el-link type="primary" @click="details(row)">
  94. {{ row.categoryName }}
  95. </el-link>
  96. </template>
  97. <!-- 批次号 -->
  98. <template v-slot:batchNo="{ row }">
  99. <el-popover placement="right-start" width="800" trigger="hover">
  100. <el-table :data="row.outInBatchDetailsVOList">
  101. <el-table-column
  102. width="150"
  103. property="bizNo"
  104. label="入库单号"
  105. ></el-table-column>
  106. <el-table-column
  107. width="100"
  108. property="bizType"
  109. label="入库场景"
  110. ></el-table-column>
  111. <el-table-column
  112. width="120"
  113. property="count"
  114. label="入库数量"
  115. ></el-table-column>
  116. <el-table-column
  117. width="80"
  118. property="measuringUnit"
  119. label="计量单位"
  120. ></el-table-column>
  121. <el-table-column
  122. width="100"
  123. property="packageCount"
  124. label="包装数量"
  125. ></el-table-column>
  126. <el-table-column
  127. width="80"
  128. property="packingUnit"
  129. label="包装单位"
  130. ></el-table-column>
  131. <el-table-column
  132. width="330"
  133. property="position"
  134. label="库位"
  135. ></el-table-column>
  136. <el-table-column
  137. width="160"
  138. property="createTime"
  139. label="入库时间"
  140. ></el-table-column>
  141. </el-table>
  142. <span slot="reference"> {{ row.batchNo }}</span>
  143. </el-popover>
  144. </template>
  145. <template v-slot:QRCode="{ row }">
  146. <el-link type="primary" @click="openQRCode(row, 3)"> 查看 </el-link>
  147. </template>
  148. <!-- 最小包装单元 -->
  149. <template v-slot:minPackingCount="{ row }">
  150. <span v-if="row.minPackingCount">
  151. {{ row.minPackingCount }}
  152. {{ row.measuringUnit }}/{{ row.minUnit }}
  153. </span>
  154. </template>
  155. <!-- 库存保质期 -->
  156. <template v-slot:expirationDate="{ row }">
  157. <span v-if="row.expirationDate">
  158. {{ row.expirationDate ? row.expirationDate : '-' }}
  159. {{
  160. row.expirationDateUnit == 'year'
  161. ? '年'
  162. : row.expirationDateUnit == 'month'
  163. ? '月'
  164. : '日'
  165. }}
  166. </span>
  167. </template>
  168. <!-- 质检状态 -->
  169. <template v-slot:qualityStatus="{ row }">
  170. <span v-if="row.qualityResult == 0 || row.qualityResult == 1"
  171. >已检</span
  172. >
  173. <span v-else-if="row.qualityStatus == 1">已检</span>
  174. <span v-else-if="row.qualityStatus == 0">未检</span>
  175. <span v-else>-</span>
  176. </template>
  177. <!-- 质检结果 -->
  178. <template v-slot:qualityResult="{ row }">
  179. <span v-if="row.qualityResult == 0 || row.qualityResult == ''"
  180. >合格</span
  181. >
  182. <span v-else-if="row.qualityResult == 1">不合格</span>
  183. <span v-else-if="row.qualityResult == 3">让步接收</span>
  184. <span v-else>-</span>
  185. </template>
  186. </ele-pro-table>
  187. <print :openBarCode.sync="openWindows" :config="config"></print>
  188. <!-- <print ref="printRef" :dimension="selectedDime"></print> -->
  189. <!-- <printSr ref="printSrRef" :dimension="selectedDime"></printSr>
  190. <printTg ref="printTgRef" :dimension="selectedDime"></printTg> -->
  191. <allot ref="allotRef" :dimension="selectedDime"></allot>
  192. <!-- 导入错误弹框 -->
  193. <el-dialog
  194. title="导入失败"
  195. :visible.sync="exportErrorDioalogVisible"
  196. width="60%"
  197. >
  198. <el-table :data="errorData" style="width: 100%">
  199. <el-table-column label="名称" prop="name"> </el-table-column>
  200. <el-table-column label="型号" prop="modeType"> </el-table-column>
  201. <el-table-column label="编号" prop="codeNo"> </el-table-column>
  202. <el-table-column label="物料组" prop="code"> </el-table-column>
  203. <el-table-column label="失败原因" prop="remark"> </el-table-column>
  204. </el-table>
  205. <span slot="footer" class="dialog-footer">
  206. <el-button @click="exportErrorDioalogVisible = false">取 消</el-button>
  207. <el-button type="primary" @click="exportErrorDioalogVisible = false"
  208. >确 定</el-button
  209. >
  210. </span>
  211. </el-dialog>
  212. <printQRCode ref="printQRCodeRef"></printQRCode>
  213. <importDialog
  214. :defModule="moudleName"
  215. ref="importDialogRef"
  216. :fileUrl="'/wms/outintwo/importTemplate'"
  217. fileName="库存导入模板"
  218. @success="reload"
  219. />
  220. </div>
  221. </template>
  222. <script>
  223. import print from '@/components/print/indexMultiple.vue';
  224. import allot from './allot.vue';
  225. import importDialog from '@/components/upload/import-dialogNew.vue';
  226. // import print from './print.vue';
  227. // import printSr from './printSr.vue';
  228. // import printTg from './printTg.vue';
  229. import ItemSearch from './item-search.vue';
  230. // import {
  231. // getUserPage,
  232. // removePersonnel,
  233. // unbindLoginName
  234. // } from '@/api/system/organization';
  235. import {
  236. pageeLedgerMain,
  237. removeItem,
  238. getWarehouseList
  239. } from '@/api/classifyManage/itemInformation';
  240. import barCode from '@/api/main/barCode';
  241. import storageApi from '@/api/warehouseManagement';
  242. import { getBatchDetails } from '@/api/classifyManage/index';
  243. import tabMixins from '@/mixins/tableColumnsMixin';
  244. import { qualityStatus, qualityResults } from '@/utils/dict/index';
  245. import { parameterGetByCode } from '@/api/sys/index.js';
  246. import exportButton from '@/components/upload/exportButton.vue';
  247. import printQRCode from '@/views/warehouseManagement/stockManagement/components/printQRCode.vue';
  248. export default {
  249. mixins: [tabMixins],
  250. components: {
  251. ItemSearch,
  252. print,
  253. allot,
  254. importDialog,
  255. exportButton,
  256. printQRCode
  257. },
  258. props: {
  259. // 机构id
  260. organizationId: [Number, String],
  261. // 全部机构
  262. organizationList: Array,
  263. current: {
  264. type: Object,
  265. default: () => ({})
  266. },
  267. type: {
  268. type: String,
  269. default: ''
  270. }
  271. },
  272. data() {
  273. return {
  274. params: {},
  275. moudleName: 'stock',
  276. totalMoney: '',
  277. qualityStatus,
  278. qualityResults,
  279. config: [],
  280. openWindows: false,
  281. newColumns: [],
  282. checkRadioData: [],
  283. searchForm: {
  284. dimension: '1'
  285. },
  286. selectedDime: '2',
  287. diffCacheKeyUrl:
  288. 'eos-439decaa-warehouseManagement-stockLedger-products',
  289. cacheKeyUrl: 'eos-439decaa-warehouseManagement-stockLedger-products2', //默认查询key值
  290. columnsVersion: 1,
  291. isLoading: false,
  292. exportErrorDioalogVisible: false,
  293. errorData: [],
  294. isPrice: 1
  295. };
  296. },
  297. created() {
  298. this.getFieldModel();
  299. //仓库出入库是否显示金额(0:不显示 1:显示)
  300. parameterGetByCode({
  301. code: 'wms_price'
  302. }).then((res) => {
  303. this.isPrice = res.value;
  304. });
  305. },
  306. computed: {
  307. // 表格列配置
  308. columns() {
  309. // 当columnsVersion变化时会重新计算
  310. const version = this.columnsVersion;
  311. // selectedDime 1物品维度 2批次维度 3包装维度 4物料维度
  312. let arr = [
  313. this.selectedDime == 3
  314. ? {
  315. width: 45,
  316. type: 'selection',
  317. columnKey: 'selection',
  318. align: 'center'
  319. }
  320. : '',
  321. {
  322. columnKey: 'index',
  323. type: 'index',
  324. width: 50,
  325. align: 'center',
  326. label: '序号',
  327. showOverflowTooltip: true,
  328. fixed: 'left'
  329. },
  330. {
  331. width: 80,
  332. prop: 'QRCode',
  333. slot: 'QRCode',
  334. align: 'center',
  335. label: '二维码',
  336. showOverflowTooltip: true
  337. },
  338. this.selectedDime != 1
  339. ? {
  340. prop: 'batchNo',
  341. label: '批次号',
  342. align: 'center'
  343. }
  344. : '',
  345. {
  346. prop: 'categoryCode',
  347. label: '物品编码',
  348. align: 'center',
  349. showOverflowTooltip: true
  350. },
  351. {
  352. slot: 'categoryName',
  353. prop: 'categoryName',
  354. label: '物品名称',
  355. align: 'center',
  356. showOverflowTooltip: true,
  357. minWidth: 200
  358. },
  359. this.selectedDime != 1
  360. ? {
  361. prop: 'inventoryCycle',
  362. label: '存货周期(天)',
  363. align: 'center',
  364. width: 150,
  365. sortable: true,
  366. showOverflowTooltip: true
  367. }
  368. : '',
  369. {
  370. prop: 'brandNum',
  371. label: '牌号',
  372. align: 'center',
  373. showOverflowTooltip: true
  374. },
  375. {
  376. prop: 'categoryModel',
  377. label: '型号',
  378. align: 'center',
  379. showOverflowTooltip: true
  380. },
  381. {
  382. prop: 'specification',
  383. label: '规格',
  384. align: 'center',
  385. showOverflowTooltip: true
  386. },
  387. {
  388. prop: 'modelKey',
  389. label: '机型',
  390. align: 'center',
  391. showOverflowTooltip: true
  392. },
  393. {
  394. prop: 'colorKey',
  395. label: '颜色',
  396. align: 'center',
  397. showOverflowTooltip: true
  398. },
  399. {
  400. prop: 'level',
  401. label: '级别',
  402. align: 'center',
  403. showOverflowTooltip: true
  404. },
  405. {
  406. prop: 'lockQuantity',
  407. label: '锁定数量',
  408. align: 'center',
  409. showOverflowTooltip: true
  410. },
  411. {
  412. prop: 'availableQuantity',
  413. label: '可用数量',
  414. align: 'center',
  415. showOverflowTooltip: true,
  416. formatter: (row) => {
  417. // 使用整数运算避免浮点数精度丢失
  418. const measure = Number(row.measureQuantity) || 0;
  419. const lock = Number(row.lockQuantity) || 0;
  420. const result = (measure * 100 - lock * 100) / 100;
  421. return Math.round(result * 100) / 100;
  422. }
  423. },
  424. {
  425. prop: 'measureQuantity',
  426. label: '计量数量',
  427. sortable: 'custom',
  428. showOverflowTooltip: true,
  429. width: 130,
  430. align: 'center'
  431. },
  432. // {
  433. // prop: 'supplierName',
  434. // label: '供应商',
  435. // showOverflowTooltip: true,
  436. // width: 130,
  437. // align: 'center'
  438. // },
  439. {
  440. prop: 'measureUnit',
  441. label: '计量单位',
  442. align: 'center'
  443. },
  444. {
  445. prop: 'weight',
  446. label: '重量',
  447. showOverflowTooltip: true
  448. },
  449. {
  450. prop: 'weightUnit',
  451. label: '重量单位',
  452. showOverflowTooltip: true
  453. },
  454. this.selectedDime == 1
  455. ? {
  456. prop: 'secureInventory',
  457. label: '安全库存',
  458. showOverflowTooltip: true
  459. }
  460. : '',
  461. this.selectedDime == 1
  462. ? {
  463. prop: 'minInventory',
  464. label: '最小库存',
  465. showOverflowTooltip: true
  466. }
  467. : '',
  468. this.selectedDime == 1
  469. ? {
  470. prop: 'maxInventory',
  471. label: '最大库存',
  472. showOverflowTooltip: true
  473. }
  474. : '',
  475. this.selectedDime == 3
  476. ? {
  477. prop: 'packageNo',
  478. label: '包装编码',
  479. showOverflowTooltip: true
  480. }
  481. : '',
  482. this.selectedDime == 3
  483. ? {
  484. prop: 'packingQuantity',
  485. label: '包装数量 ',
  486. showOverflowTooltip: true
  487. }
  488. : '',
  489. this.selectedDime == 3
  490. ? {
  491. prop: 'packingUnit',
  492. label: '包装单位 ',
  493. showOverflowTooltip: true
  494. }
  495. : '',
  496. this.selectedDime == 3
  497. ? {
  498. prop: 'result',
  499. slot: 'result',
  500. label: '质检结果',
  501. showOverflowTooltip: true
  502. }
  503. : '',
  504. this.selectedDime == 3
  505. ? {
  506. prop: 'status',
  507. slot: 'status',
  508. label: '质检状态',
  509. showOverflowTooltip: true
  510. }
  511. : '',
  512. this.selectedDime == 3 || this.selectedDime == 2
  513. ? {
  514. prop: 'warehouseName',
  515. label: '仓库名称',
  516. showOverflowTooltip: true
  517. }
  518. : '',
  519. this.selectedDime == 3
  520. ? {
  521. prop: 'areaName',
  522. label: '库区 ',
  523. showOverflowTooltip: true
  524. }
  525. : '',
  526. this.selectedDime == 3
  527. ? {
  528. prop: 'goodsAllocationName',
  529. label: '货架',
  530. showOverflowTooltip: true
  531. }
  532. : '',
  533. this.selectedDime == 3
  534. ? {
  535. prop: 'goodsShelfName',
  536. label: '货位',
  537. showOverflowTooltip: true
  538. }
  539. : '',
  540. this.selectedDime == 3
  541. ? {
  542. prop: 'productionDate',
  543. label: '生产日期',
  544. showOverflowTooltip: true
  545. }
  546. : '',
  547. this.selectedDime == 3
  548. ? {
  549. prop: 'purchaseDate',
  550. label: '采购日期',
  551. showOverflowTooltip: true
  552. }
  553. : '',
  554. this.selectedDime == 3 || this.selectedDime == 4
  555. ? {
  556. prop: 'barcodes',
  557. label: '发货条码 ',
  558. showOverflowTooltip: true
  559. }
  560. : '',
  561. this.selectedDime == 3 || this.selectedDime == 4
  562. ? {
  563. prop: 'clientCode',
  564. label: '客户代号',
  565. showOverflowTooltip: true
  566. }
  567. : '',
  568. this.selectedDime == 3 || this.selectedDime == 2
  569. ? {
  570. prop: 'customerNames',
  571. label: '客户名称',
  572. showOverflowTooltip: true,
  573. width: 120,
  574. formatter: (row) => {
  575. return row.saleOrderInfo?.customerNames || '';
  576. }
  577. }
  578. : '',
  579. this.selectedDime == 3 || this.selectedDime == 2
  580. ? {
  581. prop: 'saleOrderNos',
  582. label: '销售订单号',
  583. showOverflowTooltip: true,
  584. width: 120,
  585. formatter: (row) => {
  586. return row.saleOrderInfo?.saleOrderNos || '';
  587. }
  588. }
  589. : '',
  590. this.selectedDime == 3 || this.selectedDime == 4
  591. ? {
  592. prop: 'engrave',
  593. label: '刻码 ',
  594. showOverflowTooltip: true
  595. }
  596. : '',
  597. this.selectedDime == 3 || this.selectedDime == 4
  598. ? {
  599. prop: 'materielDesignation',
  600. label: '物料代号',
  601. width: 120,
  602. showOverflowTooltip: true
  603. }
  604. : '',
  605. this.selectedDime != 1 ?
  606. {
  607. prop: 'supplierName',
  608. label: '供应商',
  609. width: 120,
  610. showOverflowTooltip: true
  611. } : '',
  612. this.selectedDime != 1 ?
  613. {
  614. prop: 'supplierCode',
  615. label: '供应商代号',
  616. width: 120,
  617. showOverflowTooltip: true
  618. } : '',
  619. // this.selectedDime == 1
  620. // ? {
  621. // prop: 'provenance',
  622. // label: '产地',
  623. // showOverflowTooltip: true
  624. // }
  625. // : '',
  626. this.isPrice == 1
  627. ? {
  628. prop: 'unitPrice',
  629. label: '单价',
  630. showOverflowTooltip: true
  631. }
  632. : '',
  633. this.isPrice == 1
  634. ? {
  635. prop: 'totalMoney',
  636. label: '金额',
  637. showOverflowTooltip: true
  638. }
  639. : '',
  640. this.selectedDime == 2
  641. ? {
  642. prop: 'createTime',
  643. width: 120,
  644. label: '入库时间',
  645. showOverflowTooltip: true
  646. }
  647. : ''
  648. ];
  649. if (this.selectedDime == 1) {
  650. return arr.filter((item) => item != '').concat(this.newColumns);
  651. } else {
  652. return arr.filter((item) => item != '');
  653. }
  654. },
  655. clientEnvironmentId() {
  656. return this.$store.state.user.info.clientEnvironmentId;
  657. },
  658. exportApiUrl() {
  659. return '/wms/statement/exportStockExcel';
  660. }
  661. },
  662. methods: {
  663. openQRCode(row, type) {
  664. this.$refs.printQRCodeRef.open(row, type);
  665. },
  666. getFieldModel() {
  667. storageApi.fieldModel({ relevance: 't_main_category' }).then((res) => {
  668. let newRes = res.map((m) => {
  669. return {
  670. prop: 'extField.' + m.prop,
  671. label: m.label,
  672. align: 'center',
  673. showOverflowTooltip: true
  674. };
  675. });
  676. this.newColumns = [...newRes];
  677. });
  678. },
  679. // 调拨
  680. showAllot() {
  681. this.$refs.allotRef.open(this.checkRadioData);
  682. },
  683. // 全选
  684. changeSelectAll(arr) {
  685. console.log(arr);
  686. if (arr.length != 0) {
  687. this.checkRadioData = arr;
  688. } else {
  689. this.checkRadioData = [];
  690. }
  691. },
  692. selectChange(selection, row) {
  693. if (selection.length != 0) {
  694. this.checkRadioData = selection;
  695. } else {
  696. this.checkRadioData = [];
  697. }
  698. },
  699. allPrinting() {
  700. if (this.checkRadioData?.length > 0) {
  701. let params = this.checkRadioData.map((m) => {
  702. return {
  703. bizId: m.id,
  704. qrcodeType: 6
  705. };
  706. });
  707. barCode.batchBarPrint(params).then((res) => {
  708. console.log('--------res---------------');
  709. console.log(res);
  710. this.config = [];
  711. res.map((item, index) => {
  712. let obj = {
  713. putType: item.putType,
  714. sizeWide: item.sizeWide,
  715. sizeLong: item.sizeLong,
  716. value: this.checkRadioData[index].packageNo + '/6',
  717. useModeList: item.useModeList
  718. };
  719. obj.useModeList = obj.useModeList.sort((a, b) => {
  720. return a.barAvg.substr(4) - b.barAvg.substr(4);
  721. });
  722. this.config.push(obj);
  723. });
  724. console.log('this.config--------', this.config);
  725. this.openWindows = true;
  726. });
  727. } else {
  728. return this.$message.warning('请选择要打印的数据!');
  729. }
  730. // if (this.clientEnvironmentId == 2) {
  731. // this.$refs.printSrRef.open(this.checkRadioData);
  732. // } else if (this.clientEnvironmentId == 3) {
  733. // this.$refs.printTgRef.open(this.checkRadioData);
  734. // } else {
  735. // this.$refs.printRef.open(this.checkRadioData);
  736. // }
  737. },
  738. handledime(val) {
  739. console.log(val, 'val');
  740. this.selectedDime = val;
  741. // this.reload();
  742. this.reload(this.$refs.refSeavch.params);
  743. //每次切换维度查询列表配置信息,固定列配置 val 1 为物品维度,2 为批次维度,3 为包装维度。如果val值发生变化。请适配之前的维度
  744. this.cacheKeyUrl = this.diffCacheKeyUrl + val;
  745. this.getTabColumns();
  746. },
  747. setCacheKeyUrl(val) {
  748. this.cacheKeyUrl = val;
  749. this.getTabColumns();
  750. },
  751. getSummaries(param) {
  752. let key = ['totalMoney'];
  753. const { columns, data } = param;
  754. const sums = [];
  755. columns.forEach((column, index) => {
  756. if (index === 0) {
  757. sums[index] = '合计';
  758. return;
  759. }
  760. if (key.includes(column.property)) {
  761. const values = data.map((item) => Number(item[column.property]));
  762. // console.log(values);
  763. if (!values.every((value) => isNaN(value))) {
  764. sums[index] = values.reduce((prev, curr) => {
  765. const value = Number(curr);
  766. if (!isNaN(value)) {
  767. return prev + curr;
  768. } else {
  769. return prev;
  770. }
  771. }, 0);
  772. sums[index] = parseFloat(sums[index])
  773. .toFixed(3)
  774. .replace(/\.?0+$/, '');
  775. } else {
  776. sums[index] = '';
  777. }
  778. } else {
  779. sums[index] = '';
  780. }
  781. });
  782. // console.log('sums', sums);
  783. return sums;
  784. },
  785. /* 表格数据源 */
  786. datasource({ page, limit, where, order }) {
  787. console.log('where~~~~~~~~~~~~~~~', where);
  788. console.log('this.selectedDime-----------', this.selectedDime);
  789. const dimension = this.$refs.refSeavch.dimension;
  790. console.log('this.dimension-----------', dimension);
  791. const treeId = this.$parent.$parent.$parent.current.id;
  792. if (dimension == 1) {
  793. // 物品维度
  794. const data = storageApi.getProductList({
  795. ...where,
  796. ...order,
  797. pageNum: page,
  798. size: limit
  799. });
  800. return data;
  801. } else if (dimension == 2) {
  802. // 批次维度
  803. const params = {
  804. categoryLevelId: treeId,
  805. ...where,
  806. ...order
  807. };
  808. this.params = {
  809. ...params,
  810. pageNum: page,
  811. size: limit
  812. };
  813. console.log('this.params----~~~', this.params);
  814. const data = storageApi.getBatchList(this.params);
  815. return data;
  816. } else if (dimension == 4) {
  817. // 物料维度
  818. const params = {
  819. categoryLevelId: treeId,
  820. ...where,
  821. ...order
  822. };
  823. const data = storageApi.getMaterialList({
  824. ...params,
  825. pageNum: page,
  826. size: limit,
  827. isEnabled: 1
  828. });
  829. return data;
  830. } else {
  831. // 包装维度
  832. let params = {};
  833. if (this.type === 'products') {
  834. params = {
  835. categoryLevelId: treeId,
  836. ...where,
  837. ...order
  838. };
  839. } else {
  840. console.log('this.current----', this.current.data);
  841. params = {
  842. warehouseId:
  843. this.current.data?.level == 0 ? this.current.data.id : '',
  844. warehouseAreaId:
  845. this.current.data?.level == 1 ? this.current.data.id : '',
  846. warehouseAreaGoodsId:
  847. this.current.data?.level == 2 ? this.current.data.id : '',
  848. warehouseAreaGoodsShelvesId:
  849. this.current.data?.level == 3 ? this.current.data.id : '',
  850. ...where,
  851. ...order
  852. };
  853. }
  854. console.log('params~~~~~~', params);
  855. const data = storageApi.getPackingList({
  856. ...params,
  857. pageNum: page,
  858. size: limit
  859. });
  860. console.log(data, 'data');
  861. // this.totalMoney=data
  862. return data;
  863. }
  864. },
  865. /* 刷新表格 */
  866. reload(where) {
  867. this.$nextTick(() => {
  868. console.log('this.current----', this.current);
  869. let params = {};
  870. if (this.type === 'products') {
  871. params = {
  872. ...where,
  873. categoryLevelId: this.current.data?.id || this.current?.id
  874. };
  875. } else {
  876. params = {
  877. ...where,
  878. warehouseId:
  879. this.current.data?.level == 0 ? this.current.data.id : '',
  880. warehouseAreaId:
  881. this.current.data?.level == 1 ? this.current.data.id : '',
  882. warehouseAreaGoodsId:
  883. this.current.data?.level == 2 ? this.current.data.id : '',
  884. warehouseAreaGoodsShelvesId:
  885. this.current.data?.level == 3 ? this.current.data.id : '',
  886. };
  887. }
  888. this.$refs.table.reload({
  889. pageNum: 1,
  890. where: params
  891. });
  892. });
  893. },
  894. details(row) {
  895. const key = Date.now();
  896. this.$store.commit('stockManagement/CLEAR_BASEINFO');
  897. this.$store.commit('stockManagement/CHANGE_BASEINFO', {
  898. key,
  899. value: row
  900. });
  901. const url =
  902. this.$refs.refSeavch.dimension == 1
  903. ? '/warehouseManagement/stockLedger/allBatchDetails'
  904. : '/warehouseManagement/stockLedger/batchDetails';
  905. this.$router.push({
  906. path: url,
  907. query: {
  908. key,
  909. dimension: this.$refs.refSeavch.dimension,
  910. // id: this.$refs.refSeavch.dimension != 3 ? row.id : row.categoryId,
  911. id: row.categoryId,
  912. assetId: row.assetId,
  913. batchNo: row.batchNo,
  914. categoryCode: row.categoryCode
  915. }
  916. });
  917. },
  918. beforeUpload(file) {
  919. if (file.size / 1024 / 1024 > this.size) {
  920. this.$message.error(`大小不能超过 ${this.size}MB`);
  921. return false;
  922. }
  923. if (this.limit > 0 && this.fileList.length === this.limit) {
  924. this.$message.error(`最多上传 ${this.limit}个文件`);
  925. return false;
  926. }
  927. let formData = new FormData();
  928. formData.append('file', file);
  929. this.isLoading = true;
  930. return importCategorySparePart(formData).then((res) => {
  931. if (res.data.length > 0) {
  932. this.exportErrorDioalogVisible = true;
  933. this.errorData = res.data;
  934. } else {
  935. this.$message.success('导入成功!');
  936. }
  937. this.isLoading = false;
  938. return false;
  939. });
  940. },
  941. successUpload(response) {
  942. this.isLoading = false;
  943. },
  944. errorUpload(response) {
  945. this.isLoading = false;
  946. },
  947. uploadFile() {
  948. this.$refs.importDialogRef.open();
  949. }
  950. },
  951. watch: {
  952. // 监听机构id变化
  953. current: {
  954. handler() {
  955. console.log('this.current----', this.current);
  956. this.reload();
  957. }
  958. },
  959. type: {
  960. handler() {
  961. if (this.type === 'warehouse') {
  962. this.selectedDime = '3';
  963. } else {
  964. this.selectedDime = '2';
  965. }
  966. this.reload();
  967. }
  968. }
  969. }
  970. };
  971. </script>
  972. <style lang="scss" scoped>
  973. .upload {
  974. display: flex;
  975. width: 100%;
  976. margin-left: 10px;
  977. }
  978. .header_view {
  979. display: flex;
  980. flex: 1;
  981. justify-content: flex-end;
  982. }
  983. </style>