| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003 |
- <template>
- <ele-modal
- :visible.sync="visible"
- title="物品信息"
- width="80vw"
- :maxable="true"
- >
- <el-form :model="searchForm" label-width="100px">
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="列表维度:" prop="dimension">
- <template>
- <el-select
- style="width: 100%"
- @change="changeDimensionHandler"
- @keyup.enter.native="doSearch"
- v-model="dimension"
- placeholder="请选择"
- >
- <!-- <el-option label="物料维度" value="4"> </el-option> -->
- <el-option label="包装维度" value="3"> </el-option>
- <el-option label="批次维度" value="2"> </el-option>
- <el-option label="物品维度" value="1"> </el-option>
- </el-select>
- </template>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="物品编码:">
- <el-input
- type="text"
- placeholder="搜索物品编码"
- v-model="searchForm.categoryCode"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="物品名称:">
- <el-input
- type="text"
- placeholder="搜索物品名称"
- v-model="searchForm.categoryName"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="批次号:">
- <el-input
- type="text"
- placeholder="搜索批次号"
- v-model="searchForm.batchNo"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6" v-if="dimension != 1">
- <el-form-item label="系统批次:">
- <el-input
- clearable
- type="text"
- placeholder="请输入完整系统内部批次号"
- v-model.trim="searchForm.systemBatchNo"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="刻码">
- <el-input
- type="text"
- placeholder="搜索物品刻码"
- v-model="searchForm.engrave"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="物料代号">
- <el-input
- type="text"
- placeholder="搜索物料代号"
- v-model="searchForm.materielDesignation"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="发货码">
- <el-input
- type="text"
- placeholder="搜索发货码"
- v-model="searchForm.barcodes"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="牌号">
- <el-input
- type="text"
- placeholder="搜索牌号"
- v-model="searchForm.brandNum"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="所属工厂" prop="factoryId">
- <el-select
- filterable
- placeholder="请选择"
- v-model="searchForm.factoryId"
- clearable
- class="w100"
- @keyup.enter.native="doSearch"
- @change="getWarehouseListHandle"
- >
- <el-option
- v-for="item in factoryList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- ></el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="仓库">
- <el-select
- clearable
- style="width: 100%"
- v-model="searchForm.warehouseId"
- placeholder="请选择"
- @keyup.enter.native="doSearch"
- >
- <el-option
- v-for="item in warehouseList"
- :label="item.name"
- :value="item.id"
- :key="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="关键字">
- <el-input
- clearable
- type="text"
- placeholder="请输入"
- v-model="searchForm.keyWord"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="颜色">
- <el-input
- clearable
- type="text"
- placeholder="请输入"
- v-model="searchForm.colorKey"
- @keyup.enter.native="doSearch"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col>
- <div style="float: right">
- <el-button type="primary" @click="doSearch">搜索</el-button>
- <el-button icon="el-icon-refresh-left" @click="reset"
- >重置</el-button
- >
- </div>
- </el-col>
- </el-row>
- </el-form>
- <el-container class="assets-dialog">
- <el-aside width="200px" class="wrapper-assets">
- <AssetTree
- ref="treeList"
- :treeIds="treeIds"
- @handleNodeClick="handleNodeClick"
- />
- </el-aside>
- <el-main>
- <ele-pro-table
- row-key="id"
- :selection.sync="selectionList"
- ref="table"
- class="table"
- :columns="columns"
- :datasource="datasource"
- height="calc(100vh - 550px)"
- full-height="calc(100vh - 116px)"
- tool-class="ele-toolbar-form"
- :pageSize="20"
- @columns-change="handleColumnChange"
- :cache-key="cacheKeyUrl"
- >
- <template v-slot:outboundNum="{ row }">
- <el-input
- type="text"
- placeholder="请输入"
- v-model="row.outboundNum"
- @input="handleInput(row, $event)"
- :disabled="inputDisabled(row)"
- ></el-input>
- </template>
- </ele-pro-table>
- </el-main>
- </el-container>
- <div slot="footer">
- <el-button type="primary" @click="confirm">确定</el-button>
- <el-button @click="cancel">关闭</el-button>
- </div>
- </ele-modal>
- </template>
- <script>
- import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
- import storageApi from '@/api/warehouseManagement';
- import AssetTree from '../stockManagement/components/assetTree.vue';
- import { getWarehouseList } from '@/api/classifyManage/itemInformation';
- import { getDetailById, quantityDelivery } from '@/api/classifyManage';
- import tabMixins from '@/mixins/tableColumnsMixin';
- export default {
- mixins: [tabMixins],
- components: { AssetTree },
- props: {
- treeIds: { type: Array, default: () => [] }
- },
- data() {
- return {
- factoryList: [],
- newColumns: [], // 动态表头
- isShowTable: true,
- qualityResultOption: [
- {
- value: 0,
- label: '合格'
- },
- {
- value: 1,
- label: '不合格'
- }
- ],
- qualityStatusOption: [
- {
- value: 1,
- label: '已质检'
- },
- {
- value: 0,
- label: '未质检'
- }
- ],
- visible: false,
- tableData: [],
- total: 0,
- categoryLevelId: '',
- searchForm: {
- categoryCode: '',
- categoryName: '',
- batchNo: '',
- systemBatchNo: '',
- factoryId: '',
- brandNum: '',
- engrave: '',
- barcodes: '',
- categoryLevelId: '',
- warehouseId: '',
- pageNum: 1,
- size: 20,
- colorKey: ''
- },
- selectionList: [],
- materialType: '',
- warehouseList: [],
- allWarehouseList:[],
- dimension: '1',
- productLists: [],
- columnsVersion: 1,
- diffCacheKeyUrl: 'wms-warehouseManagement-components-AssetsDialog',
- cacheKeyUrl: 'wms-warehouseManagement-components-AssetsDialog1',
- selection: []
- };
- },
- created() {
- console.log('created');
- this.getFieldModel();
- this.getWarehouse();
- this.getFactoryList();
- },
- mounted() {
- // this.$nextTick(() => {
- // this.$refs.table.reload();
- // });
- },
- computed: {
- inputDisabled() {
- let _this = this;
- return (row) => {
- // console.log(row);
- return (
- _this.productLists.some((it) => it.categoryId == row.categoryId) ||
- _this.dimension == '3' || row.availableQuantity == 0
- );
- };
- },
- columns() {
- const _this = this;
- const version = this.columnsVersion;
- let kk = [];
- let jj = [];
- if (this.dimension == 1) {
- kk = this.newColumns.map((item) => {
- return {
- label: item.label,
- align: item.align,
- prop: item.prop,
- showOverflowTooltip: item.showOverflowTooltip
- };
- });
- } else {
- kk = [
- {
- label: '批次号',
- prop: 'batchNo',
- showOverflowTooltip: true
- },
- {
- label: '系统内部批次号',
- prop: 'systemBatchNo',
- minWidth: 180,
- showOverflowTooltip: true,
- formatter: (row) => row.systemBatchNo || '-'
- }
- ];
- }
- if (this.dimension == 3) {
- jj = [
- {
- label: '包装编码',
- prop: 'packageNo',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '包装数量',
- prop: 'packingQuantity',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '包装单位',
- prop: 'packingUnit',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '发货条码',
- prop: 'barcodes',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '物料代号',
- prop: 'materielDesignation',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '客户代号',
- prop: 'clientCode',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '刻码',
- prop: 'engrave',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- label: '仓库',
- prop: 'warehouseName',
- align: 'center',
- showOverflowTooltip: true
- }
- ];
- }
- let arr = [
- this.dimension == 1
- ? {
- width: 55,
- type: 'selection',
- columnKey: 'selection',
- fixed: 'left',
- align: 'center',
- reserveSelection: true,
- selectable: (row) => {
- return (
- !_this.productLists.some((item) =>
- _this.isSameStockRecord(item, row)
- ) && row.availableQuantity != 0
- );
- }
- }
- : {
- width: 55,
- type: 'selection',
- columnKey: 'selection',
- fixed: 'left',
- align: 'center',
- reserveSelection: true,
- selectable: (row) => {
- return (
- !_this.productLists.some((item) =>
- _this.isSameStockRecord(item, row)
- ) && row.availableQuantity != 0
- );
- }
- },
- {
- columnKey: 'index',
- type: 'index',
- width: 50,
- align: 'center',
- label: '序号',
- showOverflowTooltip: true,
- fixed: 'left'
- },
- {
- fixed: 'left',
- prop: 'categoryCode',
- label: '物品编码',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- fixed: 'left',
- prop: 'categoryName',
- label: '物品名称',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'outboundNum',
- label: '出库数量',
- align: 'center',
- minWidth: '100',
- showOverflowTooltip: true,
- slot: 'outboundNum'
- },
- {
- prop: 'lockQuantity',
- label: '锁定数量',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'availableQuantity',
- label: '可用数量',
- align: 'center',
- showOverflowTooltip: true,
- // formatter: (row) => {
- // // 使用整数运算避免浮点数精度丢失
- // const measure = Number(row.measureQuantity) || 0;
- // const lock = Number(row.lockQuantity) || 0;
- // const result = (measure * 100 - lock * 100) / 100;
- // return Math.round(result * 100) / 100;
- // }
- },
- {
- prop: 'inventoryCycle',
- label: '存货周期(天)',
- align: 'center',
- width: 150,
- sortable: true,
- showOverflowTooltip: true,
- hide: this.dimension == 1
- },
- {
- prop: 'brandNum',
- label: '牌号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'modelKey',
- label: '机型',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'colorKey',
- label: '颜色',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'categoryModel',
- label: '型号',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'specification',
- label: '规格',
- align: 'center',
- showOverflowTooltip: true
- },
- ...kk,
- {
- prop: 'level',
- label: '级别',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'measureQuantity',
- label: '计量数量',
- align: 'center',
- showOverflowTooltip: true,
- formatter: (row) =>
- this.dimension == 2 ? row.stockCountBase : row.measureQuantity
- },
- {
- prop: 'measureUnit',
- label: '计量单位',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'weight',
- label: '重量',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'weightUnit',
- label: '重量单位',
- align: 'center',
- showOverflowTooltip: true
- },
- ...jj,
- {
- prop: 'supplierName',
- label: '供应商',
- align: 'center',
- showOverflowTooltip: true
- },
- {
- prop: 'supplierCode',
- label: '供应商代号',
- align: 'center',
- showOverflowTooltip: true
- }
- ];
- return arr.filter((item) => !item.hide);
- }
- },
- watch: {},
- methods: {
- isSameStockRecord(source, target) {
- if (source.id && target.id) {
- return source.id == target.id;
- }
- return (
- source.categoryId == target.categoryId &&
- source.warehouseId == target.warehouseId &&
- source.batchNo == target.batchNo &&
- (source.systemBatchNo || '') == (target.systemBatchNo || '')
- );
- },
- //获取工厂列表
- async getFactoryList() {
- const res = await warehouseDefinition.getFactoryarea({
- pageNum: 1,
- size: 9999,
- type: 1
- });
- this.factoryList = res.list;
- },
- async getWarehouse() {
- const { data } = await getWarehouseList();
- this.allWarehouseList = data;
- },
- getWarehouseListHandle(val) {
- this.searchForm.warehouseId = '';
- this.warehouseList = this.allWarehouseList.filter(
- (item) => item.factoryId === val
- );
- },
- // 获取动态表头
- getFieldModel() {
- storageApi.fieldModel({ fieldModel: 't_main_category' }).then((res) => {
- let newRes = res.map((m) => {
- return {
- prop: 'extField.' + m.prop,
- label: m.label,
- align: 'center',
- showOverflowTooltip: true
- };
- });
- this.newColumns = [...newRes];
- });
- },
- // 出库数量限制
- handleInput(row, value) {
- if (row.outboundNum <= row.availableQuantity) {
- // return (row.outboundNum = value.replace(/^(0+)|[^\d]+/g, ''));
- // 过滤掉非数字和小数点的字符
- const filteredValue = value.replace(/[^0-9.]/g, '');
- // 限制只能有一个小数点
- const singleDotValue = filteredValue.replace(/(\..*)\./g, '$1');
- let finalValue = '';
- const dotIndex = singleDotValue.indexOf('.');
- if (dotIndex !== -1) {
- // 截取小数点后最多两位
- finalValue = singleDotValue.slice(0, dotIndex + 3);
- } else {
- finalValue = singleDotValue;
- }
- row.outboundNum = finalValue;
- const currentIndex = this.selectionList.findIndex(item => item.id === row.id)
- if(currentIndex > -1) {
- this.$set(this.selectionList, currentIndex, row);
- }
- return
- } else {
- row.outboundNum = row.availableQuantity;
- const currentIndex = this.selectionList.findIndex(item => item.id === row.id)
- if(currentIndex > -1) {
- this.$set(this.selectionList, currentIndex, row);
- }
- }
- },
- // 切换维度
- changeDimensionHandler(e) {
- this.searchForm.pageNum = 1;
- this.selectionList = [];
- if (this.$refs.table) {
- this.$refs.table.clearSelection();
- }
- this.cacheKeyUrl = this.diffCacheKeyUrl + e;
- this.getTabColumns();
- this.reload();
- },
- async changeDimension(e) {
- this.dimension = e;
- if (this.dimension == 1) {
- // 物品维度
- const data = await storageApi.getProductList({
- ...this.searchForm,
- isEnabled: 1
- });
- this.tableData = data.list.map(item => {
- const measure = Number(item.measureQuantity) || 0;
- const lock = Number(item.lockQuantity) || 0;
- const result = (measure * 100 - lock * 100) / 100;
- return {
- ...item,
- availableQuantity: Math.round(result * 100) / 100
- }
- });
- this.total = data.count;
- } else if (this.dimension == 2) {
- // 批次维度
- const data = await storageApi.getBatchList(this.searchForm);
- for (let i = 0; i < data.list.length; i++) {
- const item = data.list[i];
- // 入库计量数量不会随出库变化,可用数量必须使用当前批次库存余额计算
- const inventoryBalance = Number(item.availableCountBase) || 0;
- const lock = Number(item.lockQuantity) || 0;
- const result = (inventoryBalance * 100 - lock * 100) / 100;
- item.availableQuantity = Math.round(result * 100) / 100;
- item.outboundNum = item.availableQuantity;
- }
- this.tableData = data.list;
- this.total = data.count;
- } else if (this.dimension == 4) {
- // 物料维度
- const data = await storageApi.getMaterialList({
- ...this.searchForm
- });
- this.tableData = data.list.map(item => {
- const measure = Number(item.measureQuantity) || 0;
- const lock = Number(item.lockQuantity) || 0;
- const result = (measure * 100 - lock * 100) / 100;
- return {
- ...item,
- availableQuantity: Math.round(result * 100) / 100
- }
- });
- this.total = data.count;
- } else {
- // 包装维度
- const data = await storageApi.getPackingList(this.searchForm);
- for (let i = 0; i < data.list.length; i++) {
- const measure = Number(item.measureQuantity) || 0;
- const lock = Number(item.lockQuantity) || 0;
- const result = (measure * 100 - lock * 100) / 100;
- data.list[i].availableQuantity = Math.round(result * 100) / 100;
- data.list[i].outboundNum = data.list[i].packingQuantity;
- }
- this.tableData = data.list;
- this.total = data.count;
- }
- console.log(this.tableData);
- this.updateProductOutboundNums(this.tableData);
- },
- updateProductOutboundNums(list) {
- console.log(this.productLists, 'this.productLists');
- console.log(this.dimension);
- // 物品时有bug,可能有多条,不用find,用filter
- if (this.dimension == 1) {
- //物品层
- for (let i = 0; i < list.length; i++) {
- const item = list[i];
- const matchedProduct = this.productLists.filter(
- (product) => product.categoryId === item.categoryId
- );
- let num = matchedProduct.reduce(
- (pre, cur) => pre + cur.measureQuantity,
- 0
- );
- // console.log(matchedProduct);
- if (matchedProduct.length) {
- this.$set(item, 'outboundNum', num);
- }
- const isSelection = this.selectionList.find(
- (product) => product.categoryId === item.categoryId
- );
- if (isSelection) {
- this.$set(item, 'outboundNum', isSelection.outboundNum);
- }
- }
- } else {
- for (let i = 0; i < list.length; i++) {
- const item = list[i];
- const matchedProduct = this.productLists.find(
- (product) => product.id === item.id
- );
- if (matchedProduct) {
- this.$set(item, 'outboundNum', matchedProduct.measureQuantity);
- }
- const isSelection = this.selectionList.find(
- (product) => product.id === item.id
- );
- if (isSelection) {
- this.$set(item, 'outboundNum', isSelection.outboundNum);
- }
- }
- }
- },
- open(val) {
- let that = this;
- this.productLists = val || [];
- this.visible = true;
- this.$nextTick(() => {
- this.$refs.treeList.getTreeData().then((data) => {
- // that.$nextTick(() => {
- // that.categoryLevelId = data.id;
- // that.searchForm.categoryLevelId = data.id;
- // that.doSearch();
- // });
- this.handleNodeClick(data);
- });
- });
- },
- async confirm() {
- console.log(this.selectionList);
- if (!this.selectionList.length) {
- this.$message.error('请至少选择一条数据!');
- return;
- }
- if (this.dimension == 1) {
- let boolen = this.selectionList.every((item) => item.outboundNum > 0);
- if (!boolen) {
- this.$message.error('请输入出库数量!');
- return;
- }
- }
- console.log(this.selectionList);
- let data = null;
- if (this.dimension == 3) {
- data = await storageApi.getHierarchyList({
- ids: this.selectionList.map((item) => item.id).join(','),
- type: this.dimension,
- warehouseId: this.searchForm.warehouseId,
- });
- } else if (this.dimension == 2) {
- data = await storageApi.getHierarchyFifo({
- type: this.dimension,
- ids: this.selectionList.map((item) => item.id),
- builders: this.selectionList.map((item) => {
- return {
- warehouseId: this.searchForm.warehouseId,
- categoryId: item.categoryId,
- batchNo: item.batchNo,
- // 历史数据保持空值,由后端按外部批次号兼容匹配
- systemBatchNo: item.systemBatchNo || '',
- num: item.outboundNum,
- id: item.id
- };
- })
- });
- } else if (this.dimension == 1) {
- data = await storageApi.getHierarchyFifo({
- type: this.dimension,
- builders: this.selectionList.map((item) => {
- return {
- warehouseId: this.searchForm.warehouseId,
- categoryId: item.categoryId,
- num: item.outboundNum
- };
- })
- });
- }
- console.log('data-------------------', data);
- this.$emit('detailData', data, this.dimension);
- this.cancel();
- },
- cancel() {
- this.selectionList = [];
- // this.$refs.multipleTable.clearSelection();
- this.visible = false;
- },
- handleSelectionChange(val) {
- this.selectionList = val;
- },
- handleNodeClick(data) {
- // console.log(data);
- this.categoryLevelId = data.id;
- this.searchForm.categoryLevelId = data.id;
- this.doSearch();
- },
- handleCurrentChange() {
- this.changeDimension(this.dimension);
- },
- reset() {
- this.searchForm = {
- categoryCode: '',
- categoryName: '',
- batchNo: '',
- systemBatchNo: '',
- brandNum: '',
- engrave: '',
- barcodes: '',
- warehouseId: '',
- factoryId: '',
- categoryLevelId: this.categoryLevelId,
- pageNum: 1,
- size: 20
- };
- this.doSearch();
- },
- doSearch() {
- this.searchForm.pageNum = 1;
- this.$refs.table.reload();
- this.$refs.table.reRenderTable();
- },
- handleSizeChange() {
- this.searchForm.pageNum = 1;
- this.changeDimension(this.dimension, 'page');
- },
- // 翻页时,输入的数量会重置
- updateSelect(data) {
- if (!this.selectionList.length) {
- return data;
- }
- let ids = this.selectionList.map((item) => item.id);
- data.list.forEach((item) => {
- let id = ids.find((id) => item.id === id);
- if (id) {
- item.outboundNum = this.selectionList.find(
- (item) => item.id === id
- ).outboundNum;
- }
- });
- return data;
- },
- async datasource({ page, limit, where, order }) {
- const dimension = this.dimension;
- let data;
- // console.log(this.searchForm);
- // console.log(dimension);
- if (dimension == 1) {
- data = await storageApi.getProductList({
- ...where,
- ...order,
- ...this.searchForm,
- pageNum: page,
- size: limit
- });
- // console.log(data);
- // let result = this.updateSelect(data);
- // return result;
- data.list.forEach(item => {
- // 使用整数运算避免浮点数精度丢失
- const measure = Number(item.measureQuantity) || 0;
- const lock = Number(item.lockQuantity) || 0;
- const result = (measure * 100 - lock * 100) / 100;
-
- item.availableQuantity = Math.round(result * 100) / 100;
- });
- console.log('dimension == 1~~~', data.list);
- this.updateProductOutboundNums(data.list);
- return data;
- }
- if (dimension == 2) {
- data = await storageApi.getBatchList({
- ...where,
- ...order,
- ...this.searchForm,
- pageNum: page,
- size: limit
- });
- data.list.forEach((item) => {
- // 入库计量数量不会随出库变化,可用数量必须使用当前批次库存余额计算
- const inventoryBalance = Number(item.availableCountBase) || 0;
- const lock = Number(item.lockQuantity) || 0;
- const result = (inventoryBalance * 100 - lock * 100) / 100;
- item.availableQuantity = Math.round(result * 100) / 100;
- item.outboundNum = item.availableQuantity;
- });
- return data;
- }
- if (dimension == 3) {
- data = await storageApi.getPackingList({
- ...where,
- ...order,
- ...this.searchForm,
- pageNum: page,
- size: limit
- });
- data.list.forEach((item) => {
- const measure = Number(item.measureQuantity) || 0;
- const lock = Number(item.lockQuantity) || 0;
- const result = (measure * 100 - lock * 100) / 100;
-
- item.availableQuantity = Math.round(result * 100) / 100;
- item.outboundNum = item.packingQuantity;
- });
- this.updateProductOutboundNums(data.list);
- return data;
- }
- },
- reload(where) {
- this.$refs.table.reload({
- pageNum: 1
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .el-dialog__wrapper {
- ::v-deep .el-aside {
- background-color: #fff !important;
- border: 1px solid #ccc;
- }
- }
- .wrapper-assets {
- max-height: 53vh;
- overflow: auto;
- }
- </style>
|