Browse Source

getPartPackageProperties

java8
han\hanst 3 months ago
parent
commit
635c8806d8
  1. 3
      src/api/ecss/ecss.js
  2. 246
      src/views/modules/ecss/codelnotifyConfirm.vue

3
src/api/ecss/ecss.js

@ -141,5 +141,8 @@ export const updateCodelPalletHeaderPalletQty = data => createAPI(`/ecss/coDel/u
// PDF导出接口
export const downloadAllPdf = data => createAPI(`/ecss/coDel/downloadAllPdf`,'post',data)
// 获取物料包装属性(每卷数量、每箱卷数、箱重量)
export const getPartPackageProperties = data => createAPI(`/ecss/coDel/getPartPackageProperties`,'post',data)

246
src/views/modules/ecss/codelnotifyConfirm.vue

@ -343,18 +343,18 @@
<el-form label-position="top" class="box-info-form">
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="毛重">
<el-input v-model="palletModelData.grossWeight" type="number" placeholder="请输入毛重"></el-input>
<el-form-item label="箱数">
<el-input v-model="palletModelData.boxQty" type="number" placeholder="请输入箱数" @input="calculateWeightsByBoxQty"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="重">
<el-input v-model="palletModelData.netWeight" type="number" placeholder="请输入净重"></el-input>
<el-form-item label="重">
<el-input v-model="palletModelData.grossWeight" type="number" placeholder="自动计算"></el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="箱数">
<el-input v-model="palletModelData.boxQty" type="number" placeholder="请输入箱数"></el-input>
<el-form-item label="净重">
<el-input v-model="palletModelData.netWeight" type="number" placeholder="自动计算"></el-input>
</el-form-item>
</el-col>
</el-row>
@ -380,12 +380,12 @@
<el-table-column prop="surplusQty" label="可装箱数量" align="right" width="80"></el-table-column>
<el-table-column label="装箱数量" align="center" width="80">
<template slot-scope="scope">
<el-input v-model.number="scope.row.useQty" type="number" :min="0" :max="999999" size="mini"></el-input>
<el-input v-model.number="scope.row.useQty" type="number" :min="0" :max="999999" size="mini" @input="calculateRolls(scope.row)"></el-input>
</template>
</el-table-column>
<el-table-column label="Rolls" align="center" width="80">
<template slot-scope="scope">
<el-input v-model.number="scope.row.rolls" type="number" :min="0" :max="999999" size="mini"></el-input>
<el-input v-model.number="scope.row.rolls" type="number" :min="0" :max="999999" size="mini" placeholder="自动计算"></el-input>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="70">
@ -627,7 +627,8 @@
getNotifyPartDetail,
searchPalletList,
updateExportFlag,
updateCodelPalletHeaderPalletQty
updateCodelPalletHeaderPalletQty,
getPartPackageProperties
}from "@/api/ecss/ecss.js"
import {getBuList}from '@/api/factory/site.js'
import excel from "@/utils/excel-util.js";
@ -2322,6 +2323,231 @@
},
fillUseQty(row) {
row.useQty = row.surplusQty || 0;
// rolls
this.calculateRolls(row);
},
/**
* 根据装箱数量自动计算Rolls卷数
* 计算公式Rolls = 装箱数量 / 每卷数量
* @param row 当前行数据
*/
calculateRolls(row) {
// 0rolls
if (!row.useQty || row.useQty <= 0) {
this.$set(row, 'rolls', null);
//
this.calculateTotalBoxQtyAndWeights();
return;
}
//
if (row.rollQtyCache && row.rollQtyCache > 0) {
const rolls = row.useQty / row.rollQtyCache;
this.$set(row, 'rolls', parseFloat(rolls.toFixed(4)));
//
this.calculateTotalBoxQtyAndWeights();
return;
}
// API
const params = {
site: this.currentRow.site,
buNo: this.currentRow.buNo,
partNo: row.partNo
};
getPartPackageProperties(params).then(({data}) => {
if (data && data.code === 0 && data.data) {
const rollQty = data.data.rollQty;
if (rollQty && rollQty > 0) {
// row
this.$set(row, 'rollQtyCache', rollQty);
this.$set(row, 'boxRollsCache', data.data.boxRolls);
this.$set(row, 'boxWeightCache', data.data.boxWeight);
// rolls /
const rolls = row.useQty / rollQty;
this.$set(row, 'rolls', parseFloat(rolls.toFixed(4)));
//
this.calculateTotalBoxQtyAndWeights();
} else {
this.$message.warning(`物料 ${row.partNo} 未配置每卷数量(ROLLQTY)属性,无法自动计算Rolls`);
this.$set(row, 'rolls', null);
}
} else {
console.error('获取物料包装属性失败:', data ? data.msg : '未知错误');
//
this.$set(row, 'rolls', null);
}
}).catch(error => {
console.error('获取物料包装属性异常:', error);
//
this.$set(row, 'rolls', null);
});
},
/**
* 根据物料装箱数量自动计算总箱数毛重和净重
*/
calculateTotalBoxQtyAndWeights() {
//
const selectedRows = this.dataList8.filter(item => item.useQty && item.useQty > 0);
if (selectedRows.length === 0) {
//
this.palletModelData.boxQty = null;
this.palletModelData.grossWeight = null;
this.palletModelData.netWeight = null;
return;
}
//
const allHaveCache = selectedRows.every(row =>
row.rollQtyCache && row.boxRollsCache && row.boxWeightCache
);
if (!allHaveCache) {
//
return;
}
//
let totalBoxQty = 0;
let totalGrossWeight = 0;
selectedRows.forEach(row => {
// EA = ×
const eaPerBox = row.rollQtyCache * row.boxRollsCache;
//
const partBoxQty = Math.ceil(row.useQty / eaPerBox);
// = ×
const partGrossWeight = partBoxQty * row.boxWeightCache;
totalBoxQty += partBoxQty;
totalGrossWeight += partGrossWeight;
});
// = - ( / 2)
const totalNetWeight = totalGrossWeight - (totalBoxQty / 2);
//
this.palletModelData.boxQty = totalBoxQty;
this.palletModelData.grossWeight = parseFloat(totalGrossWeight.toFixed(2));
this.palletModelData.netWeight = parseFloat(totalNetWeight.toFixed(2));
},
/**
* 根据箱数自动计算毛重和净重
* 计算公式来自后端代码2991-2992
* 毛重 = 箱数 × 箱重量
* 净重 = 毛重 - (箱数 / 2)
*/
calculateWeightsByBoxQty() {
// 0
if (!this.palletModelData.boxQty || this.palletModelData.boxQty <= 0) {
this.palletModelData.grossWeight = null;
this.palletModelData.netWeight = null;
return;
}
//
const selectedRows = this.dataList8.filter(item => item.useQty && item.useQty > 0);
if (selectedRows.length === 0) {
//
return;
}
//
const needFetchProperties = selectedRows.filter(row => !row.boxWeightCache);
if (needFetchProperties.length === 0) {
//
this.calculateWeightsWithCache(selectedRows);
} else {
//
this.fetchBoxWeightsAndCalculate(selectedRows, needFetchProperties);
}
},
/**
* 使用缓存的箱重量计算毛重和净重
*/
calculateWeightsWithCache(selectedRows) {
//
let totalWeight = 0;
let totalQty = 0;
selectedRows.forEach(row => {
if (row.boxWeightCache && row.boxWeightCache > 0 && row.rollQtyCache && row.rollQtyCache > 0 && row.boxRollsCache && row.boxRollsCache > 0) {
// EA = ×
const eaPerBox = row.rollQtyCache * row.boxRollsCache;
//
const partBoxQty = Math.ceil(row.useQty / eaPerBox);
//
totalWeight += partBoxQty * row.boxWeightCache;
totalQty += partBoxQty;
}
});
if (totalQty > 0) {
//
const avgBoxWeight = totalWeight / totalQty;
this.calculateFinalWeights(avgBoxWeight);
} else {
// 使
const firstRow = selectedRows.find(row => row.boxWeightCache && row.boxWeightCache > 0);
if (firstRow) {
this.calculateFinalWeights(firstRow.boxWeightCache);
}
}
},
/**
* 获取物料箱重量并计算毛重净重
*/
fetchBoxWeightsAndCalculate(selectedRows, needFetchProperties) {
//
const promises = needFetchProperties.map(row => {
const params = {
site: this.currentRow.site,
buNo: this.currentRow.buNo,
partNo: row.partNo
};
return getPartPackageProperties(params).then(({data}) => {
if (data && data.code === 0 && data.data) {
//
this.$set(row, 'rollQtyCache', data.data.rollQty);
this.$set(row, 'boxRollsCache', data.data.boxRolls);
this.$set(row, 'boxWeightCache', data.data.boxWeight);
return true;
}
return false;
}).catch(error => {
console.error(`获取物料 ${row.partNo} 属性失败:`, error);
return false;
});
});
Promise.all(promises).then(() => {
//
this.calculateWeightsWithCache(selectedRows);
});
},
/**
* 计算最终的毛重和净重
* @param avgBoxWeight 平均箱重量
*/
calculateFinalWeights(avgBoxWeight) {
const boxQty = parseFloat(this.palletModelData.boxQty);
// = ×
const grossWeight = boxQty * avgBoxWeight;
// = - ( / 2)
const netWeight = grossWeight - (boxQty / 2);
// 2
this.palletModelData.grossWeight = parseFloat(grossWeight.toFixed(2));
this.palletModelData.netWeight = parseFloat(netWeight.toFixed(2));
},
savePalletHeader(type) {
// useQty > 0
@ -2810,7 +3036,7 @@
.warning-row td{
color: darkred !important;
}
/deep/ .zxClass .cell {
.zxClass .cell {
line-height: 24px;
font-size: 12px;
height: 24px;

Loading…
Cancel
Save