emis-frontend/src/views/emis/emisTmsSiteBatch/panel/ExpressBatchViewOnly.vue

1333 lines
49 KiB
Vue
Raw Normal View History

2024-11-16 10:37:22 +00:00
<template>
<XdPageContainer class="app-container">
<div style="margin-bottom: 20px;">
<el-descriptions :title="$t('批次信息')" size="mini" :column="4">
<el-descriptions-item label="批次号">{{ coData.batchNo }}</el-descriptions-item>
<el-descriptions-item label="批次名称">{{ coData.batchName }}</el-descriptions-item>
<el-descriptions-item label="目的国家">{{ coData.destCountry }}</el-descriptions-item>
<el-descriptions-item label="起始网点">{{ coData.startSiteName }}</el-descriptions-item>
<el-descriptions-item label="下一网点">{{ coData.nextSiteCode }}</el-descriptions-item>
<el-descriptions-item label="运输方式">{{ coData.transType }}</el-descriptions-item>
</el-descriptions>
</div>
</XdPageContainer>
</template>
<script>
export default {
name: "BigBatchViewOnly",
props: {
batchId: {
type:[Number,Array],
required: false
},
},
components: { },
dicts: ['emis_waybill_status', 'emis_payment_type', 'emis_biz_shipping_method', 'emis_qujian_fangshi', 'cebp_return_status'],
data() {
return {
// 遮罩层
loading: false,
loading2: false,
loadingWait: false,
loadingDone: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
coSingle: true,
coMultiple: true,
addWayBillDisabled: true,
// packDisabled: true,
activeName:'third',
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// TMS组批次表格数据
emisTmsPackList: [],
// 待组批次列表
emisTmsWaitPackList:[],
waitTotal:0,
// 已组批次列表
emisTmsDonePackList:[],
doneTotal:0,
waitPackList:[],//选择未组包的运单先保存起来,在后续新增组批次的弹框中使用
// 新增/修改弹窗数据
coData: {
},
coRules: {
siteCode: [
{ required: true, message: "网点编号不能为空", trigger: ["blur","change"] },
],
parentSiteCode: [
{ required: true, message: "所属网点不能为空", trigger: ["blur","change"] }
],
// cutOffTime: [
// { required: true, message: "截单时间不能为空", trigger: "blur" }
// ],
sizeCode2: [
{ required: true, message: "二字码不能为空", trigger: "blur" }
],
sizeCode3: [
{ required: true, message: "三字码不能为空", trigger: "blur" }
],
superiorFinanceCenterCode: [
{ required: true, message: "财务中心不能为空", trigger: ["blur","change"] }
],
siteType: [
{ required: true, message: "站点类型不能为空", trigger: "blur" }
],
scopeType: [
{ required: true, message: "加盟类型不能为空", trigger: "blur" }
],
countryCode: [
{ required: true, message: "国家不能为空", trigger: ["blur","change"]}
],
province: [
{ required: true, message: "省不能为空", trigger: "blur" }
],
},
openBatch: false,
titleBatch: "",
formBatchBillList:"",
// 新增/修改包详情数据
emisCoPackDetail:[],
blUnpack:"1",
// 追加的运单查询数据
wayBillData: {
pageNum: 1,
pageSize: 20,
params:{
dataTimeType: '1',
queryOrderType: '1'
}
},
// 追加的运单数据
emisWayBillList:[],
wayBillotal:0,
currentId:null,
openForm: false,
titleForm: "",
titleWayBill:null,
openWayBillForm:false,
tempCoPackList:[],
coSelection:[],
//区分当前是新增还是修改
coPackType:'',
// 临时存储已有组批次的运单号
tempExistCoPackWayBillList:[],
tempCoPackInfo:{},
// 弹出展示层
id:null,
titleView:"",
openView: false,
// 更新网点时间范围
daterangeCreateTime: [],
// 更新网点时间范围
daterangeUpdateTime: [],
tableData:[
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
],
tableDataId:[
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
billCode:null,
orderSN:null,
batchNo:null,
// packNo: null,
// packName: null,
// packDate: null,
destCountry: null,
destCountryName: null,
// blUnpack: null,
// sendSiteCode: null,
// totalParcelQty: null,
// totalWaybillQty: null,
// totalVolume: null,
// totalWeight: null,
// packStatus: null,
// opMan: null,
// remark: null,
// delFlag: null,
params:{
queryOrderType: '0',
queryOrderDateType: '1'
},
},
queryCoParams: {
params:{}
},
// 查询参数
queryWaitParams: {
pageNum: 1,
pageSize: 20,
packNo: null,
beginCreateTime: null,
endCreateTime: null,
params:{}
},
// 查询参数
queryDoneParams: {
pageNum: 1,
pageSize: 20,
packNo: null,
params:{}
},
};
},
created() {
this.initData();
},
mounted() {
const end = new Date()
const start = new Date()
start.setHours(0,0,0,0)
end.setHours(23,59,59,0)
this.dateTimeRange=[start,end];
// this.activeName="third";
},
methods: {
initData() {
if(this.batchId !=null) {
this.showBatchInfo(this.batchId);
}
},
async showBatchInfo(batchId){
this.coPackType="edit";
let response = await getEmisTmsSiteBatch(batchId);
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || "未知错误");
return;
}
let resData = response.data;
let time = {};
if(resData.transType == 2){
time.airTime = resData.etd;
}else if(resData.transType == 4){
time.shipTime = resData.etd;
}else{
time.carTime = resData.etd;
}
this.coData = {...resData, ...{batchDate:resData.createTime}, ...time};
this.emisCoPackDetail=[];
let resList = await listEmisTmsSiteBatchDtl({batchNo: resData.batchNo});
if(!resList || resList.code != 200){
this.$modal.msgError(resList && resList.msg || "未知错误");
return;
}
this.tempExistCoPackWayBillList = resList.rows;//临时存储,用于运单号校验
this.tempCoPackInfo = resData;
for(let p = 0; p < resList.rows.length;p++){
this.emisCoPackDetail.push(resList.rows[p].waybillDetail);
}
this.coData.packStatus = this.tempCoPackInfo.packStatus;
this.coData.scanDate = this.tempCoPackInfo.scanDate;
let resLoadingList = await listEmisTmsSiteBatchLoading({batchNo: resData.batchNo});
if(!resLoadingList || resLoadingList.code != 200){
this.$modal.msgError(resLoadingList && resLoadingList.msg || "未知错误");
return;
}
this.tempCoPackInfo.tableData = [
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
];
this.tempCoPackInfo.tableDataId=[
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
];
for(let p = 0; p < resLoadingList.rows.length;p++){
this.tempCoPackInfo.tableDataId[resLoadingList.rows[p].row][resLoadingList.rows[p].col] = resLoadingList.rows[p].id;
this.tempCoPackInfo.tableData[resLoadingList.rows[p].row][resLoadingList.rows[p].col] = resLoadingList.rows[p].posDesc;
this.tableData[resLoadingList.rows[p].row][resLoadingList.rows[p].col] = resLoadingList.rows[p].posDesc;
// this.emisCoPackDetail.push(resLoadingList.rows[p].waybillDetail);
}
this.computeTotal();
this.currentId=null;
this.openForm= true;
this.titleForm = "修改组批次";
},
getWaybillList(){
},
handleQueryWait(){
this.single = true;
this.multiple = true;
if(null != this.dateTimeRange && '' != this.dateTimeRange){
this.queryWaitParams.params.beginCreateTime = dateToStr(new Date(this.dateTimeRange[0]));
this.queryWaitParams.params.endCreateTime = dateToStr(new Date(this.dateTimeRange[1]));
}
// this.queryWaitParams.packNo = this.queryParams.packNo;
this.queryWaitParams.receiveCountry = this.queryParams.receiveCountry;
this.queryWaitParams.sendCountry = this.queryParams.sendCountry;
if(this.queryParams.billCode){
let qBillCode=formatSearchStr(this.queryParams.billCode);
let billArr = qBillCode.split(",");
let newBillCodeStr="";
billArr.forEach(item=>{
if(item.startsWith("T")){
let mainBillCode=item.substr(0,14);
newBillCodeStr=newBillCodeStr+mainBillCode+",";
}else if(item == ""){
}else{
newBillCodeStr=newBillCodeStr+item+",";
}
});
if(this.queryParams.params.queryOrderType == "0"){
this.queryWaitParams.batchNo=newBillCodeStr;
this.queryWaitParams.billCode=null;
}else{
// 处理子单号
this.queryWaitParams.billCode=newBillCodeStr;
this.queryWaitParams.batchNo=null;
}
}
this.loadingWait = true;
this.queryWaitParams.params.isNeedBatch = 1;
listEmisWaybill(this.queryWaitParams).then(response => {
this.loadingWait = false;
if(response.code != 200){
this.$modal.msgError(response.msg);
return;
}
this.emisTmsWaitPackList = response.rows;
// this.emisCoPackDetail = response.rows;
console.log(this)
this.waitTotal = response.total;
})
},
handleWaitSelectionChange(selection){
// selection.length > 0 ? this.packDisabled = false : this.packDisabled=true;
this.waitPackList = selection;
},
async handleQueryDone(){
this.single = true;
this.multiple = true;
this.loadingDone = true;
if(null != this.dateTimeRange && '' != this.dateTimeRange){
this.queryDoneParams.params.beginCreateTime = dateToStr(new Date(this.dateTimeRange[0]));
this.queryDoneParams.params.endCreateTime = dateToStr(new Date(this.dateTimeRange[1]));
}
// this.queryDoneParams.packNo = this.queryParams.packNo;
if(this.queryParams.billCode){
let qBillCode=formatSearchStr(this.queryParams.billCode);
let billArr = qBillCode.split(",");
let newBillCodeStr="";
billArr.forEach(item=>{
if(item.startsWith("T")){
let mainBillCode=item.substr(0,14);
newBillCodeStr=newBillCodeStr+mainBillCode+",";
}else if(item == ""){
}else{
newBillCodeStr=newBillCodeStr+item+",";
}
});
if(this.queryParams.params.queryOrderType == "0"){
this.queryDoneParams.batchNo=newBillCodeStr;
this.queryDoneParams.billCode=null;
}else{
// 处理子单号
this.queryDoneParams.billCode=newBillCodeStr;
this.queryDoneParams.batchNo=null;
}
}
this.queryDoneParams.receiveCountry = this.queryParams.receiveCountry;
this.queryDoneParams.sendCountry = this.queryParams.sendCountry;
let resList = await listEmisTmsSiteBatchDtl(this.queryDoneParams);
this.loadingDone = false;
if(!resList || resList.code != 200){
this.$modal.msgError(resList && resList.msg || "未知错误");
return;
}
//this.tempExistCoPackWayBillList = resList.rows;//临时存储,用于运单号校验
this.doneTotal = resList.total;
this.emisTmsDonePackList = [];
for(let p = 0; p < resList.rows.length;p++){
let obj = {...resList.rows[p].waybillDetail};
obj.packNo = resList.rows[p].packNo;
this.emisTmsDonePackList.push(obj);
}
},
handleDoneSelectionChange(){
},
handleQueryWayBill(){
this.loading2 = true;
if (null != this.wayBillData.dateTimeRange && '' != this.wayBillData.dateTimeRange) {
if(this.wayBillData.dataTimeType == '1'){
// 下单时间
this.wayBillData.params.beginOrderDate = dateToStr(new Date(this.wayBillData.dateTimeRange[0]));
this.wayBillData.params.endOrderDate = dateToStr(new Date(this.wayBillData.dateTimeRange[1]));
}else if(this.wayBillData.dataTimeType == '0'){
// 录单时间
this.wayBillData.params.beginCreateTime = dateToStr(new Date(this.wayBillData.dateTimeRange[0]));
this.wayBillData.params.endCreateTime = dateToStr(new Date(this.wayBillData.dateTimeRange[1]));
}
}
if(this.wayBillData.billCode){
let qBillCode=formatSearchStr(this.wayBillData.billCode);
let billArr = qBillCode.split(",");
let newBillCodeStr="";
billArr.forEach(item=>{
if(item.startsWith("T")){
let mainBillCode=item.substr(0,14);
newBillCodeStr=newBillCodeStr+mainBillCode+",";
}else if(item == ""){
}else{
newBillCodeStr=newBillCodeStr+item+",";
}
});
if(this.wayBillData.params.queryOrderType == "0"){
this.wayBillData.orderSN=newBillCodeStr;
this.wayBillData.billCode=null;
}else{
// 处理子单号
this.wayBillData.billCode=newBillCodeStr;
this.wayBillData.orderSN=null;
}
}
this.wayBillData.params.isNeedBatch = 1;
listEmisWaybill(this.wayBillData).then(response => {
this.loading2 = false;
if(response.code != 200){
this.$modal.msgError(response.msg);
return;
}
this.emisWayBillList = response.rows;
// this.emisCoPackDetail = response.rows;
console.log(this)
this.wayBillotal = response.total;
})
},
onSiteSelect(item){
if(!item){
this.coData.startSiteCode = null;
this.coData.startSiteName = null;
return;
}
this.coData.startSiteCode=item && item.siteCode;
this.coData.startSiteName=item && item.siteName;
},
onNextSiteSelect(item){
if(!item){
this.coData.nextSiteCode = null;
this.coData.nextSiteName = null;
return;
}
this.coData.nextSiteCode=item && item.siteCode;
this.coData.nextSiteName=item && item.siteName;
},
onDateSelect(value){
console.log("date picker---->", value)
this.dateTimeRange=value;
if(this.queryParams.params.queryOrderDateType == '1'){
// 下单时间
this.queryParams.params.beginCreateTime = dateToStr(new Date(this.dateTimeRange[0]));
this.queryParams.params.endCreateTime = dateToStr(new Date(this.dateTimeRange[1]));
}
},
onWayBillDateSelect(value){
console.log("date picker---->", value)
this.wayBillData.dateTimeRange=value;
},
async handleAddCoPack(){
if(!this.coData.batchName || !this.coData.destCountry || !this.coData.nextSiteCode || !this.coData.startSiteCode || !this.coData.transType
|| (this.coData.transType == "2" && (!this.coData.airBilllNo || !this.coData.airTime))
|| (this.coData.transType == "4" && (!this.coData.shipNo || !this.coData.shipTime))
|| ((this.coData.transType == "1" || this.coData.transType == "3" || this.coData.transType == "5") && (!this.coData.carNo || !this.coData.carTime))
){
this.$modal.msgError("请先选择必填项")
return;
}
if(this.emisCoPackDetail.length == 0){
this.$modal.msgError("请先选择至少一条运单信息")
return;
}
// let firstItemCountry = this.emisCoPackDetail.length > 0 ? this.emisCoPackDetail[0].receiveCountry : '';
// 将选中的“待组批次”的运单 置为 追加的运单号
// for(let p = 0; p < this.emisCoPackDetail.length;p++){
// if(this.emisCoPackDetail[p].receiveCountry != firstItemCountry){
// this.$modal.msgError("存在了不同的目的国家!");
// return ;
// }
// }
let coPackItem={
batchNo: this.coData.batchNo,
batchName: this.coData.batchName || '',
batchDate: this.coData.createTime,
batchType: this.coData.batchType || null,
transType: this.coData.transType || null,
destCountry: this.coData.destCountry || null,
startSiteCode: this.coData.startSiteCode || null,
startSiteName: this.coData.startSiteName || null,
nextSiteCode: this.coData.nextSiteCode || null,
nextSiteName: this.coData.nextSiteName || null,
airBilllNo: this.coData.airBilllNo || null,
carNo: this.coData.carNo || null,
shipNo: this.coData.shipNo || null,
clearanceResStatus: this.coData.clearanceResStatus || null,
declareResStatus: this.coData.declareResStatus || null,
destCountry: this.coData.destCountry || null,
destCountryName: this.coData.destCountryName || null,
totalParcelQty: this.coData.totalParcelQty || null,
totalWaybillQty: this.coData.totalWaybillQty || null,
totalVolume: this.coData.totalVolume || null,
totalWeight: this.coData.totalWeight || null,
}
if(this.coData.transType == 2){
coPackItem.etd = parseTime(this.coData.airTime, '{y}-{m}-{d} {h}:{i}:{s}');
this.coData.etd = parseTime(this.coData.airTime, '{y}-{m}-{d} {h}:{i}:{s}');
}else if(this.coData.transType == 4){
coPackItem.etd = parseTime(this.coData.shipTime, '{y}-{m}-{d} {h}:{i}:{s}');
this.coData.etd = parseTime(this.coData.shipTime, '{y}-{m}-{d} {h}:{i}:{s}');
}else{
coPackItem.etd = parseTime(this.coData.carTime, '{y}-{m}-{d} {h}:{i}:{s}');
this.coData.etd = parseTime(this.coData.carTime, '{y}-{m}-{d} {h}:{i}:{s}');
}
if(this.coPackType == "add"){// 新增
let resPack = await getTmsGroupBatchNo();
if(!resPack || resPack.code != 200){
this.$modal.msgError(resPack && resPack.msg || "未知错误");
return;
}
coPackItem.batchNo = resPack.data;
let response = await addEmisTmsSiteBatch(coPackItem);
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || '新增组批次失败')
return;
}
// })
for(let i = 0; i< this.emisCoPackDetail.length;i++){
let packDetail = {
batchNo:resPack.data,
billCode: this.emisCoPackDetail[i].billCode,
scanDate: this.emisCoPackDetail[i].scanDate,
scanStatus: this.emisCoPackDetail[i].scanStatus,
groupStatus: "1",//已组批次
scanMan: this.emisCoPackDetail[i].scanMan,
scanSite: this.emisCoPackDetail[i].scanSite,
createBy: this.$store.getters.empCode,
createTime: parseTime(new Date())
};
let response = await addEmisTmsSiteBatchDtl(packDetail);
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || '组批次明细新增失败')
return;
}
this.waitPackList=[];
}
// 新增配载数据 tableData
for(let lr = 0; lr < 3; lr++){
for(let ll = 0; ll < 6; ll++){
let batchLoadingData = {
batchNo: resPack.data,
posNo:lr+":"+ll+":1",
row: lr,
col: ll,
layer: 1,
posDesc:this.tableData[lr][ll],
remark:"",
tenantId:"",
}
let resLD = await addEmisTmsSiteBatchLoading(batchLoadingData);
if(!resLD || resLD.code != 200){
this.$modal.msgError(resLD && resLD.msg || '组批次配载明细新增失败')
return;
}
}
}
}else if(this.coPackType == "edit"){// 修改
//第一步:处理组批次信息的更新;
if(this.tempCoPackInfo.batchName != this.coData.batchName
|| this.tempCoPackInfo.transType != this.coData.transType
|| this.tempCoPackInfo.startSiteCode != this.coData.startSiteCode
|| this.tempCoPackInfo.nextSiteCode != this.coData.nextSiteCode
|| this.tempCoPackInfo.airBilllNo != this.coData.airBilllNo
|| this.tempCoPackInfo.etd != this.coData.etd
|| this.tempCoPackInfo.carNo != this.coData.carNo
|| this.tempCoPackInfo.destCountry != this.coData.destCountry
|| this.tempCoPackInfo.shipNo != this.coData.shipNo
// || this.tempCoPackInfo.shipTime != this.coData.shipTime
|| this.tempCoPackInfo.totalWaybillQty != this.coData.totalWaybillQty
|| this.tempCoPackInfo.totalParcelQty != this.coData.totalParcelQty
|| this.tempCoPackInfo.totalWeight != this.coData.totalWeight
|| this.tempCoPackInfo.totalVolume != this.coData.totalVolume
// || this.tempCoPackInfo.loadingFile != this.coData.loadingFile
){
this.tempCoPackInfo.batchName = this.coData.batchName;
this.tempCoPackInfo.transType = this.coData.transType;
this.tempCoPackInfo.startSiteCode = this.coData.startSiteCode;
this.tempCoPackInfo.startSiteName = this.coData.startSiteName || null;
this.tempCoPackInfo.nextSiteCode = this.coData.nextSiteCode;
this.tempCoPackInfo.nextSiteName = this.coData.nextSiteName;
this.tempCoPackInfo.airBilllNo = this.coData.airBilllNo;
this.tempCoPackInfo.etd = this.coData.etd;
this.tempCoPackInfo.carNo = this.coData.carNo;
this.tempCoPackInfo.destCountry = this.coData.destCountry;
this.tempCoPackInfo.shipNo = this.coData.shipNo;
// this.tempCoPackInfo.shipTime = this.coData.shipTime;
this.tempCoPackInfo.totalWaybillQty = this.coData.totalWaybillQty;
this.tempCoPackInfo.totalParcelQty = this.coData.totalParcelQty;
this.tempCoPackInfo.totalWeight = this.coData.totalWeight;
this.tempCoPackInfo.totalVolume = this.coData.totalVolume;
this.tempCoPackInfo.loadingFile = this.coData.loadingFile;
let res = await updateEmisTmsSiteBatch(this.tempCoPackInfo);
if(!res || res.code != 200){
this.$modal.msgError(res && res.msg || '未知错误')
return;
}
}
//第二步:处理运单列表的数据
//2.1:计算要删除的运单,提到“删除”按钮的操作逻辑
// let tempDelList = [];
//
// tempDelList = this.tempExistCoPackWayBillList.filter(item => {
// let ls = this.emisCoPackDetail.filter(cd => {
// return cd.billCode == item.billCode
// })
// if(ls.length > 0){
// return false;
// }else{
// return true;
// }
// })
// // tempDelList.forEach(item =>{
// for(let tdl = 0; tdl < tempDelList.length; tdl++){
// let item = tempDelList[tdl];
// let res = await delEmisTmsSiteBatchDtl(item.id);
// // delEmisTmsSiteBatchDtl(item.id).then(res => {
// if(!res || res.code != 200){
// this.$modal.msgError(res && res.msg || '未知错误')
// return;
// }
// // })
// }
// })
//2.2:计算要新增的运单
// let tempAddList=[];
// tempAddList = this.emisCoPackDetail.filter(item => {
// let ls = this.tempExistCoPackWayBillList.filter(cd => {
// return cd.billCode == item.billCode
// })
// if(ls.length > 0){
// return false;
// }else{
// return true;
// }
// })
// for(let tal = 0; tal < tempAddList.length; tal++){
// let item = tempAddList[tal];
// let packDetail = {
// batchNo:this.coData.batchNo,
// billCode: item.billCode,
// scanDate: item.scanDate,
// scanStatus: item.scanStatus,
// groupStatus: "1",//已组批次
// scanMan: item.scanMan,
// scanSite: item.scanSite,
// createBy: this.$store.getters.empCode,
// createTime: parseTime(new Date())
// };
// let response = await addEmisTmsSiteBatchDtl(packDetail);
// if(!response || response.code != 200){
// this.$modal.msgError(response && response.msg || '组批次明细新增失败')
// return;
// }
// }
// })
// 修改配载数据
for(let lr = 0; lr < 3; lr++){
for(let ll = 0; ll < 6; ll++){
if(this.tempCoPackInfo.tableData[lr][ll] != this.tableData[lr][ll]){
let batchLoadingData = {
id: this.tempCoPackInfo.tableDataId[lr][ll],
posDesc:this.tableData[lr][ll],
}
let resLD = await updateEmisTmsSiteBatchLoading(batchLoadingData);
if(!resLD || resLD.code != 200){
this.$modal.msgError(resLD && resLD.msg || '组批次配载明细新增失败')
return;
}
}
}
}
}
// this.openForm= false;
// this.titleForm = "";
this.$modal.msgSuccess('操作成功!');
this.$emit("on-changed");
},
handleCancelCo(){
// this.titleForm='';
// this.openForm=false;
this.coData={};
this.blUnpack="1";
this.emisCoPackDetail=[];
this.$emit("on-cancel");
},
handleWayBillSelectionChange(selection){
this.tempCoPackList = selection;
this.tempCoPackList.length > 0 ? this.addWayBillDisabled = false : this.addWayBillDisabled = true;
},
async submitFormBatch(){
if(this.formBatchBillList==null || this.formBatchBillList==''){
this.$modal.msgError("请输入单号");
return;
}
let bcList=this.formBatchBillList.trim().split(/[;\;\,\,\n]/)||[];
for(let i = 0; i < bcList.length; i++){
let billcode = bcList[i].trim();
if(this.emisCoPackDetail.filter(wb => wb.billCode == billcode).length == 0){
let billRes = await listEmisWaybill({billCode:billcode});
if(!billRes || billRes.code != 200){
this.$modal.msgError(billRes && billRes.msg)
return;
}else if(!billRes.rows || billRes.rows.length < 1){
this.$modal.msgError(('无此运单数据') + ": " + billcode)
return;
}
let item = billRes.rows[0];
this.emisCoPackDetail.push(item);
if(this.coPackType=="edit"){
let packDetail = {
batchNo: this.coData.batchNo,
billCode: item.billCode,
scanDate: item.scanDate,
scanStatus: item.scanStatus,
groupStatus: "1",//已组批次
scanMan: item.scanMan,
scanSite: item.scanSite,
createBy: this.$store.getters.empCode,
createTime: parseTime(new Date())
};
let response = await addEmisTmsSiteBatchDtl(packDetail);
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || '组批次明细新增失败')
return;
}
}
}
}
this.titleBatch="";
this.openBatch=false;
this.formBatchBillList = "";
this.wayBillData = {
pageNum: 1,
pageSize: 20,
params:{}
};
this.emisWayBillList=[];
this.tempCoPackList=[];
this.addWayBillDisabled = true;
this.wayBillotal=0;
this.computeTotal();
// 更新主表
if(this.coPackType=="edit"){
this.tempCoPackInfo.batchName = this.coData.batchName;
this.tempCoPackInfo.transType = this.coData.transType;
this.tempCoPackInfo.startSiteCode = this.coData.startSiteCode;
this.tempCoPackInfo.startSiteName = this.coData.startSiteName || null;
this.tempCoPackInfo.nextSiteCode = this.coData.nextSiteCode;
this.tempCoPackInfo.nextSiteName = this.coData.nextSiteName;
this.tempCoPackInfo.airBilllNo = this.coData.airBilllNo;
this.tempCoPackInfo.etd = this.coData.etd;
this.tempCoPackInfo.carNo = this.coData.carNo;
this.tempCoPackInfo.destCountry = this.coData.destCountry;
this.tempCoPackInfo.shipNo = this.coData.shipNo;
this.tempCoPackInfo.totalWaybillQty = this.coData.totalWaybillQty;
this.tempCoPackInfo.totalParcelQty = this.coData.totalParcelQty;
this.tempCoPackInfo.totalWeight = this.coData.totalWeight;
this.tempCoPackInfo.totalVolume = this.coData.totalVolume;
this.tempCoPackInfo.loadingFile = this.coData.loadingFile;
let res = await updateEmisTmsSiteBatch(this.tempCoPackInfo);
if(!res || res.code != 200){
this.$modal.msgError(res && res.msg || '未知错误')
return;
}
}
},
async handleCoAdd(){
this.tempCoPackList.forEach(async (item) => {
if(this.emisCoPackDetail.filter(wb => wb.billCode == item.billCode).length == 0){
this.emisCoPackDetail.push(item);
if(this.coPackType=="edit"){
let packDetail = {
batchNo: this.coData.batchNo,
billCode: item.billCode,
scanDate: item.scanDate,
scanStatus: item.scanStatus,
groupStatus: "1",//已组批次
scanMan: item.scanMan,
scanSite: item.scanSite,
createBy: this.$store.getters.empCode,
createTime: parseTime(new Date())
};
let response = await addEmisTmsSiteBatchDtl(packDetail);
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || '组批次明细新增失败')
return;
}
}
}
})
this.titleWayBill="";
this.openWayBillForm=false;
this.wayBillData = {
pageNum: 1,
pageSize: 20,
params:{}
};
this.emisWayBillList=[];
this.tempCoPackList=[];
this.addWayBillDisabled = true;
this.wayBillotal=0;
this.computeTotal();
// 更新主表
if(this.coPackType=="edit"){
this.tempCoPackInfo.batchName = this.coData.batchName;
this.tempCoPackInfo.transType = this.coData.transType;
this.tempCoPackInfo.startSiteCode = this.coData.startSiteCode;
this.tempCoPackInfo.startSiteName = this.coData.startSiteName || null;
this.tempCoPackInfo.nextSiteCode = this.coData.nextSiteCode;
this.tempCoPackInfo.nextSiteName = this.coData.nextSiteName;
this.tempCoPackInfo.airBilllNo = this.coData.airBilllNo;
this.tempCoPackInfo.etd = this.coData.etd;
this.tempCoPackInfo.carNo = this.coData.carNo;
this.tempCoPackInfo.destCountry = this.coData.destCountry;
this.tempCoPackInfo.shipNo = this.coData.shipNo;
this.tempCoPackInfo.totalWaybillQty = this.coData.totalWaybillQty;
this.tempCoPackInfo.totalParcelQty = this.coData.totalParcelQty;
this.tempCoPackInfo.totalWeight = this.coData.totalWeight;
this.tempCoPackInfo.totalVolume = this.coData.totalVolume;
this.tempCoPackInfo.loadingFile = this.coData.loadingFile;
let res = await updateEmisTmsSiteBatch(this.tempCoPackInfo);
if(!res || res.code != 200){
this.$modal.msgError(res && res.msg || '未知错误')
return;
}
}
// this.$emit("on-changed");
},
handleCloseWayBill(){
this.titleWayBill="";
this.openWayBillForm=false;
this.wayBillData = {
pageNum: 1,
pageSize: 20,
params:{}
};
this.emisWayBillList=[];
this.tempCoPackList=[];
this.addWayBillDisabled = true;
this.wayBillotal=0;
},
handleCoPackListDelete(){
if(!this.coData.batchName || !this.coData.destCountry || !this.coData.nextSiteCode || !this.coData.startSiteCode || !this.coData.transType
|| (this.coData.transType == "2" && (!this.coData.airBilllNo || !this.coData.airTime))
|| (this.coData.transType == "4" && (!this.coData.shipNo || !this.coData.shipTime))
|| ((this.coData.transType == "1" || this.coData.transType == "3" || this.coData.transType == "5") && (!this.coData.carNo || !this.coData.carTime))
){
this.$modal.msgError("请先选择必填项")
return;
}
if(this.coPackType == "edit"){
this.$confirm('确认删除该条数据吗?', '确认信息')
.then(async (isPass) => {
if (isPass) {
//计算要删除的运单, “删除”按钮的操作逻辑
// let tempDelList = [];
// 计算出选中的数据是已存在还是新增的;
let idsArrTemp=[];
for(let gti=0; gti < this.tempExistCoPackWayBillList.length;gti++){
if(this.coSelection.filter(item => {
return this.tempExistCoPackWayBillList[gti].billCode == item.billCode
}).length > 0){
// 已存在
let res = await delEmisTmsSiteBatchDtl(this.tempExistCoPackWayBillList[gti].id);
if(!res || res.code != 200){
this.$modal.msgError(res && res.msg || '未知错误')
return;
}
idsArrTemp.push(this.tempExistCoPackWayBillList[gti].id)
}
}
let newList =[];
this.emisCoPackDetail.forEach(item=>{
if(this.coSelection.filter(cs => cs.billCode == item.billCode) == 0){
newList.push(item);
}
});
this.emisCoPackDetail = newList;
let afterList=[];
for(let ai = 0; ai < this.tempExistCoPackWayBillList.length; ai++){
console.log(idsArrTemp)
console.log(this.tempExistCoPackWayBillList[ai])
if(idsArrTemp.indexOf(this.tempExistCoPackWayBillList[ai].id) == -1){
afterList.push(this.tempExistCoPackWayBillList[ai]);
}
}
this.tempExistCoPackWayBillList = afterList;//this.tempExistCoPackWayBillList.filter(item => {idsArrTemp.indexOf(item.id) == -1})
this.computeTotal();
// 更新主表
this.tempCoPackInfo.destCountry = this.coData.destCountry;
// this.tempCoPackInfo.sendStiteCode = this.coData.sendStiteCode;
// this.tempCoPackInfo.sendStiteName = this.coData.sendStiteName || null;
this.tempCoPackInfo.nextSiteCode = this.coData.nextSiteCode;
this.tempCoPackInfo.nextSiteName = this.coData.nextSiteName;
this.tempCoPackInfo.blUnpack = this.blUnpack;
this.tempCoPackInfo.totalWaybillQty = this.coData.totalWaybillQty;
this.tempCoPackInfo.totalParcelQty = this.coData.totalParcelQty;
this.tempCoPackInfo.totalWeight = this.coData.totalWeight;
this.tempCoPackInfo.totalVolume = this.coData.totalVolume;
let res = await updateEmisTmsSiteBatch(this.tempCoPackInfo);
if(!res || res.code != 200){
this.$modal.msgError(res && res.msg || '未知错误')
return;
}
this.$modal.msgSuccess('删除成功')
}
})
.catch()
}else{
let newList =[];
this.emisCoPackDetail.forEach(item=>{
if(this.coSelection.filter(cs => cs.billCode == item.billCode) == 0){
newList.push(item);
}
});
this.emisCoPackDetail = newList;
this.computeTotal();
}
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
// this.queryParams.pageSize = 20;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.selection = selection;
this.single = selection.length!==1
this.multiple = !selection.length
},
handleCoPackSelectionChange(selection){
// this.coSelection = selection.map(item => item.id)
this.coSelection = selection;
this.coSingle = selection.length!==1
this.coMultiple = !selection.length
},
computeTotal(){
let totalParcelQty=0;
let totalWeight=0;
let totalVolume=0;
this.emisCoPackDetail.forEach(item =>{
totalParcelQty +=item.parcelQty;
totalWeight +=item.billWeight;
totalVolume +=item.totalVolume;
item.destCountry = this.coData.destCountry;
// item.sendSiteCode = this.coData.sendSiteCode;
item.startSiteCode = this.coData.startSiteCode;
item.startSiteName = this.coData.startSiteName;
// item.nextSiteCode = this.coData.nextSiteCode;
item.nextSiteCode = this.coData.nextSiteCode;
item.nextSiteName = this.coData.nextSiteName;
item.blUnpack = this.blUnpack;
})
this.coData.totalWaybillQty=this.emisCoPackDetail.length;
this.coData.totalParcelQty=totalParcelQty;
this.coData.totalWeight=totalWeight;
this.coData.totalVolume=parseFloat(totalVolume.toFixed(5));
},
// 排序 查询字段是表格中字段名字 动态取值排序顺序
handleSortChange(column) {
this.queryParams.orderByColumn = column.prop;
this.queryParams.isAsc = column.order;
this.getList();
},
/** 新增按钮操作 */
handleAdd() {
},
async handleAdd_old() {
this.coPackType="add";
this.coData = {};
if(this.activeName=="first"){
let firstItemCountry = this.waitPackList.length > 0 ? this.waitPackList[0].receiveCountry : '';
// 将选中的“待组批次”的运单 置为 追加的运单号
for(let p = 0; p < this.waitPackList.length;p++){
if(this.waitPackList[p].receiveCountry != firstItemCountry){
this.$modal.msgError("存在了不同的目的国家!");
this.emisCoPackDetail=[];
return ;
}
this.emisCoPackDetail.push(this.waitPackList[p]);
}
}else if(this.activeName=="fourth"){
// let firstItemCountry = this.waitPackList.length > 0 ? this.waitPackList[0].receiveCountry : '';
// // 将选中的“待组批次”的运单 置为 追加的运单号
// for(let p = 0; p < this.waitPackList.length;p++){
// if(this.waitPackList[p].receiveCountry != firstItemCountry){
// this.$modal.msgError("存在了不同的目的国家!");
// this.emisCoPackDetail=[];
// return ;
// }
// this.emisCoPackDetail.push(this.waitPackList[p]);
// }
let res = await this.$refs.packListView.getPackBillList();
if(res.code == -1){
this.$modal.msgError(res.message);
return;
}
this.emisCoPackDetail = [...res.list];
}
this.tempExistCoPackWayBillList = [];// 清空临时保存的已有运单号
this.tempCoPackInfo={};
this.coData.createTime = parseTime(new Date());
this.coData.destCountry = null;
this.coData.destCountryName = null;
// this.coData.sendSiteCode = null;
this.coData.nextSiteCode = null;
this.coData.nextSiteName = null;
this.coData.nextStation = null;
// this.blUnpack = "1";
this.tableData = [
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
];
this.tableDataId=[
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
];
this.coData.startSiteCode = this.$store.getters.ownerSiteCode;
this.coData.startSiteName=this.$store.getters.ownerSiteName;
this.computeTotal();
this.currentId=null;
this.openForm= true;
this.titleForm = "新增组批次";
},
handleAddWayBill(){
if(!this.coData.batchName || !this.coData.destCountry || !this.coData.nextSiteCode || !this.coData.startSiteCode || !this.coData.transType
|| (this.coData.transType == "2" && (!this.coData.airBilllNo || !this.coData.airTime))
|| (this.coData.transType == "4" && (!this.coData.shipNo || !this.coData.shipTime))
|| ((this.coData.transType == "1" || this.coData.transType == "3" || this.coData.transType == "5") && (!this.coData.carNo || !this.coData.carTime))
){
this.$modal.msgError("请先选择必填项")
return;
}
// this.openWayBillForm= true;
// this.titleWayBill = "运单列表";
this.openBatch = true;
this.titleBatch = "批量输入运单号";
},
cancelBatch(){
this.openBatch=false;
this.titleBatch = "";
this.formBatchBillList = "";
},
handleShowMoreInput(){
this.moreInputVisible = !this.moreInputVisible;
},
/** 修改按钮操作 */
async handleUpdate() {
// this.coData={};
let id = this.ids[0]
this.coPackType="edit";
let response = await getEmisTmsSiteBatch(id);
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || "未知错误");
return;
}
let resData = response.data;
let time = {};
if(resData.transType == 2){
time.airTime = resData.etd;
}else if(resData.transType == 4){
time.shipTime = resData.etd;
}else{
time.carTime = resData.etd;
}
this.coData = {...resData, ...{batchDate:resData.createTime}, ...time};
// this.coData.batchNo = resData.batchNo;
// this.coData.destCountry = resData.destCountry;
// this.coData.batchDate = resData.createTime;
// this.coData.batchType = resData.batchType || null;
// this.coData.transType = resData.transType;
// this.coData.startSiteCode = resData.startSiteCode || null;
// this.coData.startSiteName = resData.startSiteName || null;
// this.coData.nextSiteCode = resData.nextSiteCode || null;
// this.coData.airBilllNo = resData.airBilllNo || null;
// this.coData.carNo = resData.carNo || "";
// this.coData.shipNo = resData.shipNo || null;
// this.coData.clearanceResStatus = resData.clearanceResStatus || null;
// this.coData.declareResStatus = resData.declareResStatus || null;
// this.coData.destCountry = resData.destCountry || null;
// this.coData.destCountryName = resData.destCountryName || null;
// this.coData.totalParcelQty = resData.totalParcelQty || null;
// this.coData.totalWaybillQty = resData.totalWaybillQty || null;
// this.coData.totalVolume = resData.totalVolume || null;
// this.coData.totalWeight = resData.totalWeight || null;
this.emisCoPackDetail=[];
let resList = await listEmisTmsSiteBatchDtl({batchNo: resData.batchNo});
if(!resList || resList.code != 200){
this.$modal.msgError(resList && resList.msg || "未知错误");
return;
}
this.tempExistCoPackWayBillList = resList.rows;//临时存储,用于运单号校验
this.tempCoPackInfo = resData;
for(let p = 0; p < resList.rows.length;p++){
this.emisCoPackDetail.push(resList.rows[p].waybillDetail);
}
this.coData.packStatus = this.tempCoPackInfo.packStatus;
this.coData.scanDate = this.tempCoPackInfo.scanDate;
let resLoadingList = await listEmisTmsSiteBatchLoading({batchNo: resData.batchNo});
if(!resLoadingList || resLoadingList.code != 200){
this.$modal.msgError(resLoadingList && resLoadingList.msg || "未知错误");
return;
}
this.tempCoPackInfo.tableData = [
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
];
this.tempCoPackInfo.tableDataId=[
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' },
{ 1: '', 2: '', 3: '', 4: '', 5: '', 6: '' }
];
for(let p = 0; p < resLoadingList.rows.length;p++){
this.tempCoPackInfo.tableDataId[resLoadingList.rows[p].row][resLoadingList.rows[p].col] = resLoadingList.rows[p].id;
this.tempCoPackInfo.tableData[resLoadingList.rows[p].row][resLoadingList.rows[p].col] = resLoadingList.rows[p].posDesc;
this.tableData[resLoadingList.rows[p].row][resLoadingList.rows[p].col] = resLoadingList.rows[p].posDesc;
// this.emisCoPackDetail.push(resLoadingList.rows[p].waybillDetail);
}
this.computeTotal();
this.currentId=null;
this.openForm= true;
this.titleForm = "修改组批次";
},
handleView(row) {
this.id=row.id;
this.titleView="查看";
this.openView=true;
// this.router.push({ path: '/emis/emisTmsPack/viewDetail', query: { id: row.id }})
},
handleFormChanged(){
this.openForm = false;
this.getList();
},
cancelForm(){
this.openForm = false;
},
/** 删除按钮操作 */
CoPack(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除').then(function() {
return delEmisTmsSiteBatch(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// this.download('emis/emisTmsPack/export', {
// ...this.queryParams
// }, `emisTmsPack_${new Date().getTime()}.xlsx`)
const loadingInstance = this.$loading({
text: '正在导出...'
})
var qParam = {...this.queryParams};
qParam.pageNum=1;
qParam.pageSize=5000;
listEmisTmsSiteBatch(this.addDateRange(qParam, this.dateTimeRange)).then(response => {
this.downloadLoading = false
if (response.code === 200) {
const curList = response.rows
import('@/vendor/Export2Excel').then(excel => {
const tHeader = ['id','组批次号','组批次名称','组批次时间','目的国家','目的国家名称','是否可拆','发出网点','下一网点','下一站','总件数','总运单数','总体积','总重量','组批次状态','扩展数据','操作员','ext1','ext2','ext3','ext4','备注','租户ID','删除标志(0代表存在','创建者','创建时间','更新者','更新时间','创建网点','更新网点',];
const filterVal = ['id','packNo','packName','packDate','destCountry','destCountryName','blUnpack','sendSiteCode','nextSiteCode','nextStation','totalParcelQty','totalWaybillQty','totalVolume','totalWeight','packStatus','extData','opMan','ext1','ext2','ext3','ext4','remark','tenantId','delFlag','createBy','createTime','updateBy','updateTime','createSite','updateSite',];
const data = this.formatJson(filterVal, curList, response.rows)
excel.export_json_to_excel({
header: tHeader,
data,
filename: 'TMS组批次',
autoWidth: true
})
loadingInstance.close()
})
}
});
},
formatJson(filterVal, jsonData, resData) {
let index = 0
return jsonData.map(v => filterVal.map(j => {
if (j === 'index') {
return ++index
}
if (j === 'status') {
var statusStr='xxx'
if(v[j] == 10){
statusStr='xxx'
}
return statusStr;
}
return v[j]
}))
},
/** 列索引函数 */
getIndex($index) {
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + $index + 1
},
/** 时间搜索响应函数 */
dateTimeChange(value){
this.dateTimeRange=value;
},
}
};
</script>
<style scoped>
.el-divider{
margin-top: 0px;
background: 0 0;
border-top: 1px solid #E6EBF5;
}
.el-divider__text {
color: #0955ee;
cursor: pointer;
}
.query-label {
.el-radio{
display: block;
line-height: 23px;
white-space: normal;
margin-right: 0;
}
}
.overflowhidden{
overflow: hidden;
}
.ellipsis {
width: 100px;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
white-space: nowrap;
}
</style>
<style lang="scss" scoped>
.feeItem{
border: 1px solid #dfe6ec;
margin-bottom:50px;
ul{
list-style: none;
padding: 0px;
margin: 0px;
width: 590px;
height: 32px;
line-height: 32px;
border: 1px solid #dfe6ec;
border-top: 0px;
font-size: 12px;
}
ul li{
display:block; width:33%; float:left;text-indent:2em
}
.th{
background:#FFF; font-weight:bold; border-top:1px
}
}
.statInfoValue{
color: red;
font-size: 13px;
font-weight: 500;
}
</style>