This commit is contained in:
linfso 2024-05-21 13:45:55 +08:00
parent 5cb9431f33
commit 00958d0444

View File

@ -190,8 +190,11 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="寄件公司" prop="sender.company"> <el-form-item label="寄件公司" prop="sender.company"
<el-input v-model="form.sender.company" placeholder="" /> :rules="form.paymentType != 2 ? rules.sender.company : []"
>
<el-input
v-model="form.sender.company" placeholder="" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
@ -252,7 +255,9 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="收件公司" prop="reciever.company"> <el-form-item label="收件公司" prop="reciever.company"
:rules="form.paymentType != 4 ? rules.reciever.company : []"
>
<el-input v-model="form.reciever.company" placeholder="" /> <el-input v-model="form.reciever.company" placeholder="" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -318,7 +323,7 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="总件数" prop="parcelQty" label-width="70px"> <el-form-item label="总件数" prop="parcelQty" label-width="70px">
<el-input v-model="form.parcelQty" style="text-align: right;" @blur="handleGenGoods" @keyup.enter.native="handleGenGoods" placeholder="" /> <el-input v-model="form.parcelQty" style="text-align: right;" @blur="handleInitGenGoods" @keyup.enter.native="handleInitGenGoods" placeholder="" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -380,7 +385,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="cargoQty" label="件数" align="center" width="60"> <el-table-column prop="cargoQty" label="件数" align="center" width="60">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.cargoQty" size="mini" placeholder=""></el-input> <el-input v-model="scope.row.cargoQty" @blur="(val)=>handleCargoQtyChange(val,scope.row)" @keyup.enter.native="(val)=>handleCargoQtyChange(val,scope.row)" size="mini" placeholder=""></el-input>
</template> </template>
</el-table-column> </el-table-column>
@ -393,9 +398,26 @@
<el-table-column label="操作" align="left" min-width="50"> <el-table-column label="操作" align="left" min-width="50">
<template slot-scope="scope"> <template slot-scope="scope">
<!-- <span style="cursor: pointer;font-size: 21px;color: #6e6e6e;" title="删除"
@click="()=>{deleteGoodsItem(scope.row);event.stopPropagation()}"
>
<i class="el-icon-delete" />
</span>
<span style="cursor: pointer;font-size: 21px;color: #6e6e6e;" title="复制"
@click="()=>{copyGoodsItem(scope.row);event.stopPropagation()}"
>
<i class="el-icon-copy-document" />
</span> -->
<span class="icon iconfont" <span class="icon iconfont"
style="cursor: pointer;font-size: 21px;color: #6e6e6e;" style="cursor: pointer;font-size: 21px;color: #6e6e6e;"
@click="()=>deleteGoodsItem(scope.row)">&#xe7ae;</span> @click="()=>deleteGoodsItem(scope.row,scope.$index)">&#xe7ae;</span>
<span class="icon iconfont"
style="cursor: pointer;font-size: 21px;color: #6e6e6e;"
@click="()=>copyGoodsItem(scope.row,scope.$index)">&#xe620;</span>
</template> </template>
</el-table-column> </el-table-column>
@ -644,10 +666,6 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-col> </el-col>
@ -824,6 +842,9 @@ data() {
province: [ province: [
{ required: true, message: "省不能为空", trigger: ["blur",'change'] } { required: true, message: "省不能为空", trigger: ["blur",'change'] }
], ],
company: [
{ required: true, message: "发件公司不能为空", trigger: ["blur",'change'] }
],
// city: [ // city: [
// { required: true, message: "市不能为空", trigger: "blur" } // { required: true, message: "市不能为空", trigger: "blur" }
// ], // ],
@ -847,6 +868,10 @@ data() {
province: [ province: [
{ required: true, message: "寄件省不能为空", trigger: ["blur",'change'] } { required: true, message: "寄件省不能为空", trigger: ["blur",'change'] }
], ],
company: [
{ required: true, message: "发件公司不能为空", trigger: ["blur",'change'] }
],
// city: [ // city: [
// { required: true, message: "寄件市不能为空", trigger: "blur" } // { required: true, message: "寄件市不能为空", trigger: "blur" }
// ], // ],
@ -1180,20 +1205,7 @@ methods: {
}) })
}, },
deleteGoodsItem(row){
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
let newList = this.form.cargoList.filter(item => item.goodsName !== row.goodsName);
this.form.cargoList=newList;
this.handleCalcQty();
this.handleCalcVolume();
}).catch(() => {
})
},
lpadZero(val,len) { lpadZero(val,len) {
return (new Array(len + 1).join('0') + val).slice(-len); return (new Array(len + 1).join('0') + val).slice(-len);
}, },
@ -1203,10 +1215,10 @@ methods: {
for(let i=1;i<=this.form.parcelQty;i++){ for(let i=1;i<=this.form.parcelQty;i++){
let subBillCode = this.form.billCode+""+this.lpadZero(i,4); let subBillCode = this.form.billCode+""+this.lpadZero(i,4);
billSubCodeStr=billSubCodeStr+subBillCode+"," billSubCodeStr=billSubCodeStr+subBillCode+","
console.log(billSubCodeStr); // console.log(billSubCodeStr);
} }
// let billSubCodeStr = this.form.billCode+"["+this.lpadZero(1,3)+"-"+this.lpadZero(this.form.parcelQty,3)+"]"; // let billSubCodeStr = this.form.billCode+"["+this.lpadZero(1,3)+"-"+this.lpadZero(this.form.parcelQty,3)+"]";
console.log(billSubCodeStr); // console.log(billSubCodeStr);
this.form.billCodeSub=billSubCodeStr; this.form.billCodeSub=billSubCodeStr;
}else{ }else{
this.form.billCodeSub=null; this.form.billCodeSub=null;
@ -1254,7 +1266,7 @@ methods: {
this.isNeedSave=true; this.isNeedSave=true;
this.form.printTypeCheckList=[1,5], this.form.printTypeCheckList=[1,5],
this.handleGenGoods(); this.handleInitGenGoods();
} }
@ -1464,7 +1476,7 @@ methods: {
let totalVolume=0.0; let totalVolume=0.0;
if(row!=null){ if(row!=null){
let volume=parseFloat(row.length)*parseFloat(row.width)*parseFloat(row.height); let volume=parseFloat(row.length)*parseFloat(row.width)*parseFloat(row.height);
row.volume=parseFloat((volume/1000000).toFixed(5)); row.volume=parseFloat((volume/1000000).toFixed(5))*parseFloat(row.cargoQty);
} }
this.form.cargoList.forEach(item=>{ this.form.cargoList.forEach(item=>{
@ -1473,21 +1485,7 @@ methods: {
this.form.totalVolume = parseFloat(totalVolume.toFixed(5)); this.form.totalVolume = parseFloat(totalVolume.toFixed(5));
}, },
handleCalcQty(val,row){
let totalCargoQty=0;
let goodsInfo='';
this.form.cargoList.forEach(item=>{
totalCargoQty=totalCargoQty+parseInt(item.cargoQty);
goodsInfo=goodsInfo+item.goodsName+"x"+item.cargoQty+",";
});
this.form.parcelQty = totalCargoQty;
this.handleGenSubbill();
},
handleCalcFeeItem(val,row){ handleCalcFeeItem(val,row){
if(row!=null){ if(row!=null){
@ -1608,53 +1606,21 @@ methods: {
this.form.goodsInfo = selNameStr; this.form.goodsInfo = selNameStr;
}, },
handleGenGoods(){ handleInitGenGoods(){
if(this.form.parcelQty>0){ if(this.form.parcelQty>0){
let currentParcelQty = 0;
this.form.cargoList.forEach(item=>{
currentParcelQty = currentParcelQty+parseInt(item.cargoQty);
});
// 新件数大于 // 新件数大于
if(this.form.parcelQty>=this.form.cargoList.length){ if(this.form.parcelQty>currentParcelQty){
console.log() let len=this.form.parcelQty-currentParcelQty;
let len=this.form.parcelQty-this.form.cargoList.length; if(this.form.parcelQty>20){
for(let i=0;i<len;i++){
let cargo={ let cargo={
"goodsCode": "", "goodsCode": "",
"goodsName": "", "goodsName": "",
"cargoQty": 1, "cargoQty": len,
"length": 0,
"width": 0,
"height": 0,
"volume": 0,
}
this.form.cargoList.push(cargo);
}
}
else{
let newList=[];
for(let i=0;i<this.form.parcelQty;i++){
newList.push(this.form.cargoList[i])
}
this.form.cargoList=newList;
}
}else{
this.form.cargoList=[];
}
},
onGoodsChange_old(goodsName){
if(goodsName&& goodsName!='') {
// 旧map
let nameOldMap = new Map();
if(this.form.cargoList!=null&& this.form.cargoList.length>0){
this.form.cargoList.forEach(item=>{
nameOldMap[item.goodsName]=item;
});
}
if(!(goodsName in nameOldMap)){
let cargo={
"goodsCode": goodsName,
"goodsName": goodsName,
"cargoQty": 1,
"length": 0, "length": 0,
"width": 0, "width": 0,
"height": 0, "height": 0,
@ -1662,10 +1628,81 @@ methods: {
} }
this.form.cargoList.push(cargo); this.form.cargoList.push(cargo);
} }
else{
this.handleCalcQty(); for(let i=0;i<len;i++){
this.handleCalcVolume(); let cargo={
"goodsCode": "",
"goodsName": "",
"cargoQty": 1,
"length": 0,
"width": 0,
"height": 0,
"volume": 0,
}
this.form.cargoList.push(cargo);
}
}
} }
else{
let newList=[];
let incQty=0;
let zeroItem=null;
for(let i=0;i<this.form.cargoList.length;i++){
let item=this.form.cargoList[i];
// 忽略未填写体积的数据
if(item.length==0&&item.width==0&&item.height==0){
zeroItem=item;
zeroItem.cargoQty=1;
continue;
}
if((incQty+parseInt(item.cargoQty))<this.form.parcelQty){
incQty = incQty+parseInt(item.cargoQty);
newList.push(item)
}else{
item.cargoQty=this.form.parcelQty-incQty;
newList.push(item)
incQty = incQty+parseInt(item.cargoQty);
break;
}
}
// 补足数量
let bzLen=this.form.parcelQty-incQty;
for(let i=0;i<bzLen;i++){
let newItem=Object.assign({},zeroItem);
newList.push(newItem);
}
this.form.cargoList=newList;
}
}else{
this.form.cargoList=[];
}
},
handleCargoQtyChange(){
this.handleInitGenGoods();
this.handleCalcVolume();
},
deleteGoodsItem(row,index){
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// let newList = this.form.cargoList.filter(item => item.goodsName !== row.goodsName);
// this.form.cargoList=newList;
console.log(index);
this.form.cargoList.splice(index,1)
this.handleCalcVolume();
}).catch(() => {
})
},
copyGoodsItem(row,index){
let newItem = Object.assign({},row);
newItem.cargoQty=1;
this.form.cargoList.splice(index+1, 0, newItem);
// this.form.cargoList.push(newItem);
handleCargoQtyChange();
}, },
showLocalTime(){ showLocalTime(){