emis-frontend/src/views/emis/emisTmsPack/WaitPackList.vue
2024-07-31 12:01:45 +08:00

1154 lines
43 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<XdPageContainer>
<!-- <SearchForm :model="queryParams" ref="queryForm" size="small" :maxShow="3" label-width="68px" v-show="showSearch" @search="handleQuery" @reset="resetQuery"> -->
<el-form slot="pageHeader" ref="form" size="mini" :model="queryParams" label-width="80px">
<el-row :gutter="0" style="display: flex;flex-wrap: wrap;">
<el-col :span="8">
<el-form-item label="运单号" prop="queryOrderType">
<XdTextareaInput
v-model="queryParams.billCode"
:placeholder="$t('多个流水号逗号或换行隔开')"
clearable
:rows="2"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发货时间" prop="dateTimeRange">
<elDateAdvPicker clearable v-model="dateTimeRange" @dateTimeChange="onDateSelect" ></elDateAdvPicker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item :label="$t('寄件网点')" prop="sendSiteCode">
<EmisSiteSimplePicker v-model="queryParams.sendSiteCode" :placeholder="$t('寄件网点')" isInitiated="true" ></EmisSiteSimplePicker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="目的国家" prop="receiveCountry">
<CountryPicker v-model="queryParams.receiveCountry" :placeholder="$t('目的国家')" ></CountryPicker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="所属线路" prop="lineCode">
<TransLinePicker v-model="queryParams.lineCode" :countryCode="queryParams.receiveCountry"></TransLinePicker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="产品类型" prop="productType">
<TransProductPicker placeholder="全部" v-model="queryParams.productType" :transLineCode="queryParams.lineCode" ></TransProductPicker>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="问题件方式" prop="pickupMethod">
<el-select clearable="" v-model="queryParams.problemQueryType" placeholder="请选择">
<el-option label="只查问题件类型" :value="1"></el-option>
<el-option label="剔除问题件类型" :value="2"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="问题件类型" prop="problemType">
<ProblemTypePicker v-model="queryParams.problemType" ></ProblemTypePicker>
</el-form-item>
</el-col>
</el-row>
<!-- </SearchForm> -->
</el-form>
<!-- slot="pageContent"
slot-scope="slotProps"
:height="(slotProps.contentHeight)+'px'" -->
<XdTable
v-loading="loadingWait"
border
storageName="emisTmsWaitPackList_main_240702"
size="mini"
:data="emisTmsWaitPackList"
:showSearch.sync="showSearch"
:queryParams="queryWaitParams"
:total="waitTotal"
:showRightButton="true"
:showOperateButton="true"
@queryTable="handleQueryWait"
@selection-change="handleWaitSelectionChange"
@sort-change="handleSortChange"
>
<div slot="toolbar" >
<el-button style="margin-right: 5px;"
type="primary"
plain
size="mini"
v-hasPermi="['emis:emisTmsPack:query']"
@click="getQuery"
>查询</el-button>
<!-- <el-button style="margin-right: 5px;"
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['emis:emisTmsPack:add']"
>去组包</el-button> -->
<!-- <el-button style="margin-right: 5px;"
type="danger"
plain
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['emis:emisTmsPack:remove']"
>查看</el-button> -->
<!-- <el-button style="margin-right: 5px;"
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDeleteCoPack"
v-hasPermi="['emis:emisTmsPack:remove']"
>删除</el-button> -->
</div>
<el-table-column type="selection" width="55" align="center" />
<el-table-column :label="$t('运单号')" align="center" prop="billCode" min-width="170" />
<!-- <el-table-column :label="$t('订单号')" align="center" prop="orderSn" min-width="170" /> -->
<!-- <el-table-column :label="$t('进仓单号')" align="center" prop="intoWarehouseCode" min-width="100" /> -->
<!-- <el-table-column :label="$t('运单状态')" align="center" prop="waybillStatus" min-width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.emis_waybill_status" :value="scope.row.waybillStatus"/>
</template>
</el-table-column> -->
<el-table-column :label="$t('当前网点')" align="center" prop="currentSiteName" min-width="100" />
<el-table-column :label="$t('下一网点')" align="center" prop="nextSiteName" min-width="100" />
<el-table-column :label="$t('寄件国家')" align="center" prop="sendCountryName" min-width="100">
<template slot-scope="scope">
<span class="ellipsis">{{ scope.row.sendCountryName }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('目的国家')" align="center" prop="receiveCountryName" min-width="100">
<template slot-scope="scope">
<span class="ellipsis">{{ scope.row.receiveCountryName }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('线路')" align="center" prop="transLineTypeName" min-width="100" />
<el-table-column :label="$t('产品类型')" align="center" prop="productTypeName" min-width="100" />
<el-table-column :label="$t('预计到达时间')" align="center" prop="estimateDate" min-width="170">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.estimateDate, '{y}-{m}-{d}') }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('件数')" align="center" prop="parcelQty" min-width="100" />
<el-table-column :label="$t('实际重量')" align="center" prop="billWeight" min-width="100" />
<!-- <el-table-column :label="$t('总重量')" align="center" prop="totalWeight" min-width="100" /> -->
<el-table-column :label="$t('总体积')" align="center" prop="totalVolume" min-width="100" />
<el-table-column :label="$t('体积重量')" align="center" prop="volumeWeight" min-width="100" />
<el-table-column :label="$t('结算重量')" align="center" prop="settlementWeight" min-width="100" />
<el-table-column :label="$t('收件人')" align="center" prop="receiveName" min-width="150" />
<el-table-column :label="$t('收件公司')" align="center" prop="receiveCompany" min-width="100">
<template slot-scope="scope">
<span class="ellipsis">{{ scope.row.receiveCompany }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('取件员')" align="center" prop="takePieceEmployeeName" min-width="150" />
<el-table-column :label="$t('取件方式')" align="center" prop="pickupMethod" min-width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.emis_qujian_fangshi" :value="scope.row.pickupMethod"/>
</template>
</el-table-column>
<el-table-column :label="$t('付款方式')" align="center" prop="paymentType" min-width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.emis_payment_type" :value="scope.row.paymentType"/>
</template>
</el-table-column>
<el-table-column :label="$t('运费')" align="center" prop="freight" min-width="100" />
<el-table-column :label="$t('寄件人')" align="center" prop="sendName" min-width="150" />
<el-table-column :label="$t('寄件公司')" align="center" prop="sendCompany" min-width="100">
<template slot-scope="scope">
<span class="ellipsis">{{ scope.row.sendCompany }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('备注')" align="center" prop="remark" min-width="100">
<template slot-scope="scope">
<span class="ellipsis">{{ scope.row.remark }}</span>
</template>
</el-table-column>
</XdTable>
</div>
</XdPageContainer>
</template>
<script>
import { listEmisTmsPack, getPackNo, getEmisTmsPack, delEmisTmsPack, addEmisTmsPack, updateEmisTmsPack } from "@/api/emis/emisTmsPack";
import { listEmisWaybill } from "@/api/emis/emisWaybill";
import { listEmisTmsPackDtl, delEmisTmsPackDtl, addEmisTmsPackDtl } from "@/api/emis/emisTmsPackDtl";
// import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
import emisTmsPackForm from '@/views/emis/emisTmsPack/emisTmsPackForm';
import elDateAdvPicker from '@/components/DatePickerAdv/elDateAdvPicker';
import CountryPicker from '@/views/emis/EmisBaseTools/CountryPicker.vue';
import EmisSiteSimplePicker from '@/views/emis/EmisBaseTools/EmisSiteSimplePicker.vue';
import EmisGetNextSitePicker from '@/views/emis/EmisBaseTools/EmisGetNextSitePicker.vue';
import TransProductPicker from '@/views/emis/EmisBaseTools/TransProductPicker.vue';
import TransLinePicker from '@/views/emis/EmisBaseTools/TransLinePicker.vue';
import ProblemTypePicker from '@/views/emis/EmisBaseTools/ProblemTypePicker.vue';
import PackListView from '@/views/emis/emisTmsSiteBatch/packListView';
import { parseTime, dateToStr } from "@/utils/custom";
import { formatSearchStr } from '@/utils/index'
import {timeDiffTime,timeFormat} from '@/utils/dateUtils'
export default {
name: "PackageManagement",
components: { ProblemTypePicker, EmisGetNextSitePicker, CountryPicker, EmisSiteSimplePicker, elDateAdvPicker, emisTmsPackForm, TransLinePicker, TransProductPicker, PackListView},
dicts: ['emis_pack_status', 'emis_qujian_fangshi', 'emis_payment_type', 'emis_waybill_status'],
data() {
return {
// 遮罩层
loading: false,
loading2: false,
loadingWait: false,
loadingDone: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
coSingle: true,
coMultiple: true,
packDisabled:false,//是否禁用可拆分包的按钮
addWayBillDisabled: true,
// packDisabled: true,
activeName:'first',
// 显示搜索条件
showSearch: true,
// 创建时间搜索
dateTimeRange:[],
// 总条数
total: 0,
// TMS合包表格数据
emisTmsPackList: [],
// 待合包列表
emisTmsWaitPackList:[],
waitTotal:0,
// 已合包列表
emisTmsDonePackList:[],
doneTotal:0,
waitPackList:[],//选择未组包的运单先保存起来,在后续新增合包的弹框中使用
// 新增/修改弹窗数据
coData: {
blUnpack:"1"
},
// 新增/修改包详情数据
emisCoPackDetail:[],
blUnpack:"1",
// 追加的运单查询数据
wayBillData: {
pageNum: 1,
pageSize: 20,
params:{
queryOrderType:'1',
dataTimeType:'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: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
packNo: null,
packName: null,
packDate: null,
destCountry: null,
destCountryName: null,
blUnpack: null,
sendStiteCode: null,
totalParcelQty: null,
totalWaybillQty: null,
totalVolume: null,
totalWeight: null,
packStatus: null,
opMan: null,
remark: null,
delFlag: null,
params:{
queryOrderType: '1',
},
packNo:'',
billCode: ''
},
queryCoParams: {
params:{}
},
// 查询参数
queryWaitParams: {
pageNum: 1,
pageSize: 20,
packNo: null,
beginCreateTime: null,
endCreateTime: null,
params:{}
},
// 查询参数
queryDoneParams: {
pageNum: 1,
pageSize: 20,
packNo: null,
params:{}
},
};
},
created() {
},
mounted() {
const end = new Date()
const start = new Date()
start.setHours(0,0,0,0)
end.setHours(23,59,59,0)
this.dateTimeRange=[timeFormat(start), timeFormat(end)]
this.activeName="first";
this.getQuery();
},
methods: {
getQuery(){
// this.packDisabled = true;
switch(this.activeName){
case 'first':
this.waitPackList=[];
this.handleQueryWait();
break;
case 'second':
this.waitPackList=[];
this.handleQueryDone();
break;
case 'third':
this.waitPackList=[];
// this.getList();
this.queryParams.dateTimeRange = this.dateTimeRange;
this.$refs.packListView.getList();
break;
default:
break;
}
},
expandChange(row, expandedRows){
if(expandedRows.length==0){// 没有扩展的行
this.currentExpandedRow = null;
return;
}
if(this.currentExpandedRow && expandedRows.length == 1 && expandedRows[0].packNo == this.currentExpandedRow.packNo){// 已经查询过了
return;
}
this.loading = true;
this.currentExpandedRow = row;
this.emisTmsDonePackList=[];
listEmisTmsPackDtl({packNo: row.packNo}).then(resList => {
// if(!resList || resList.code != 200){
// this.$message.error(resList && resList.msg || "未知错误");
// return;
// }
// for(let p = 0; p < resList.rows.length;p++){
// this.emisTmsDonePackList.push(resList.rows[p].waybillDetail);
// }
this.emisTmsDonePackList=resList.rows;
this.doneTotal = resList.total;
this.loading = false;
});
if(expandedRows.length > 1){
for(let i = 0; i < expandedRows.length; i++){
if(row.packNo != expandedRows[i].packNo){
this.$refs.table.$refs.table.$refs.elTable.toggleRowExpansion(expandedRows[i], false);
}
}
}
},
donothing(){
},
/** 查询TMS合包列表 */
getList() {
this.loading = true;
this.single = true;
this.multiple = true;
// this.queryParams.params = {};
// if(this.queryParams.packNo){
// let qBillCode=formatSearchStr(this.queryParams.packNo);
// 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 == "1"){
// this.queryParams.packNo=newBillCodeStr;
// this.queryParams.billCode=null;
// }else{
// // 处理子单号
// this.queryParams.billCode=newBillCodeStr;
// this.queryParams.packNo=null;
// }
// }
this.emisTmsPackList = [];
if (null != this.dateTimeRange && '' != this.dateTimeRange) {
this.queryParams.params["beginSendDate"] = dateToStr(new Date(this.dateTimeRange[0]));
this.queryParams.params["endSendDate"] = dateToStr(new Date(this.dateTimeRange[1]));
}
this.queryParams.packStatus='1';
this.queryParams.destCountry = this.queryParams.receiveCountry;
listEmisTmsPack(this.queryParams).then(response => {
this.emisTmsPackList = response.rows;
this.total = response.total;
this.loading = false;
});
},
handleQueryWait(){
this.single = true;
this.multiple = true;
this.queryWaitParams = {...this.queryParams};
if(null != this.dateTimeRange && '' != this.dateTimeRange){
this.queryWaitParams.params.beginSendDate = dateToStr(new Date(this.dateTimeRange[0]));
this.queryWaitParams.params.endSendDate = dateToStr(new Date(this.dateTimeRange[1]));
}
// this.queryWaitParams.packNo = this.queryParams.packNo;
let qBillCode=formatSearchStr(this.queryParams.packNo);
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 == "1"){
this.queryWaitParams.packNo=newBillCodeStr;
this.queryWaitParams.billCode=null;
}else{
// 处理子单号
this.queryWaitParams.billCode=newBillCodeStr;
this.queryWaitParams.packNo=null;
}
this.loadingWait = true;
this.queryWaitParams.params.isNeedPack = 1;
listEmisWaybill(this.queryWaitParams).then(response => {
this.loadingWait = false;
if(response.code != 200){
this.$message.error(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;
this.queryDoneParams = {...this.queryParams};
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;
let qBillCode=formatSearchStr(this.queryParams.packNo);
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 == "1"){
this.queryDoneParams.packNo=newBillCodeStr;
this.queryDoneParams.billCode=null;
}else{
// 处理子单号
this.queryDoneParams.billCode=newBillCodeStr;
this.queryDoneParams.packNo=null;
}
let resList = await listEmisTmsPackDtl(this.queryDoneParams);
this.loadingDone = false;
if(!resList || resList.code != 200){
this.$message.error(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.isNeedPack = 1;
listEmisWaybill(this.wayBillData).then(response => {
this.loading2 = false;
if(response.code != 200){
this.$message.error(response.msg);
return;
}
this.emisWayBillList = response.rows;
// this.emisCoPackDetail = response.rows;
console.log(this)
this.wayBillotal = response.total;
})
},
onDateSelect(value){
console.log("date picker---->", value)
this.dateTimeRange=value;
},
onWayBillDateSelect(value){
console.log("date picker---->", value)
this.wayBillData.dateTimeRange=value;
},
async handleAddCoPack(){
// if(!this.coData.destCountry || !this.coData.sendStiteCode || !this.coData.nextSiteCode || !this.blUnpack){
if(!this.coData.sendStiteCode || !this.coData.nextSiteCode || !this.blUnpack){
this.$modal.msgError("请先选择必填项")
return;
}
if(this.emisCoPackDetail.length == 0){
this.$modal.msgError("请先选择至少一条运单信息")
return;
}
let coPackItem={
packNo: this.coData.packNo,
packName: this.coData.packName || '',
packDate: this.coData.createTime,
destCountry: this.coData.destCountry,
nextSiteCode: this.coData.nextSiteCode,
// destCountryName: this.coData.,
blUnpack: this.coData.blUnpack,
sendStiteCode: this.coData.sendStiteCode,
sendSiteName: this.coData.sendSiteName,
totalParcelQty: this.coData.totalParcelQty,
totalWaybillQty: this.coData.totalWaybillQty,
totalVolume: this.coData.totalVolume,
totalWeight: this.coData.totalWeight,
// packStatus: this.coData.,
opMan: this.$store.getters.empCode
}
if(this.coPackType == "add"){// 新增
if(this.emisCoPackDetail.length<2){
this.$message.error("合包总件数少于2件");
return;
}
let resPack = await getPackNo();
if(!resPack || resPack.code != 200){
this.$message.error(resPack && resPack.msg || "未知错误");
return;
}
// this.coData.packNo = resPack.data;
coPackItem.packNo = resPack.data;
let response = await addEmisTmsPack(coPackItem);
// addEmisTmsPack(coPackItem).then(response => {
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || '新增合包失败')
return;
}
// })
for(let i = 0; i< this.emisCoPackDetail.length;i++){
let packDetail = {
packNo:resPack.data,
billCode: this.emisCoPackDetail[i].billCode,
scanDate: this.emisCoPackDetail[i].scanDate,
scanStatus: this.emisCoPackDetail[i].scanStatus,
packStatus: "1",//已合包
scanMan: this.emisCoPackDetail[i].scanMan,
createBy: this.$store.getters.empCode,
createTime: parseTime(new Date())
};
let response = await addEmisTmsPackDtl(packDetail);
// addEmisTmsPackDtl(packDetail).then(response => {
if(!response || response.code != 200){
this.$modal.msgError(response && response.msg || '合包明细新增失败')
return;
}
this.waitPackList=[];
// })
}
}else if(this.coPackType == "edit"){// 修改
//第一步:处理合包信息的更新;
if(this.tempCoPackInfo.destCountry != this.coData.destCountry
|| this.tempCoPackInfo.sendStiteCode != this.coData.sendStiteCode
|| this.tempCoPackInfo.nextSiteCode != this.coData.nextSiteCode
|| 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
){
this.tempCoPackInfo.destCountry = this.coData.destCountry;
this.tempCoPackInfo.sendStiteCode = this.coData.sendStiteCode;
this.tempCoPackInfo.nextSiteCode = this.coData.nextSiteCode;
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 updateEmisTmsPack(this.tempCoPackInfo);
// updateEmisTmsPack(this.tempCoPackInfo).then(res => {
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 delEmisTmsPackDtl(item.id);
// // delEmisTmsPackDtl(item.id).then(res => {
// if(!res || res.code != 200){
// this.$modal.msgError(res && res.msg || '未知错误')
// return;
// }
// // })
// }
// })
}
this.openForm= false;
this.titleForm = "";
this.$modal.msgSuccess('操作成功!');
this.getQuery();
},
async handleDeleteCoPack(){
let that =this;
for(let i = 0; i< this.ids.length;i++){
let res = await delEmisTmsPack(this.ids[i]);
if(!res || res.code != 200){
that.$modal.msgError(res && res.msg || '合包删除失败')
that.getList();
return;
}
}
this.$modal.msgSuccess('操作成功');
this.getList();
},
handleCancelCo(){
this.titleForm='';
this.openForm=false;
this.coData={};
this.blUnpack="1";
this.emisCoPackDetail=[];
this.getQuery();
},
handleWayBillSelectionChange(selection){
this.tempCoPackList = selection;
this.tempCoPackList.length > 0 ? this.addWayBillDisabled = false : this.addWayBillDisabled = true;
},
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 = {
packNo:this.coData.packNo,
billCode: item.billCode,
scanDate: item.scanDate,
scanStatus: item.scanStatus,
packStatus: null,
scanMan: item.scanMan,
createBy: this.$store.getters.empCode,
createTime: parseTime(new Date())
};
let response = await addEmisTmsPackDtl(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.destCountry = this.coData.destCountry;
this.tempCoPackInfo.sendStiteCode = this.coData.sendStiteCode;
this.tempCoPackInfo.nextSiteCode = this.coData.nextSiteCode;
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 updateEmisTmsPack(this.tempCoPackInfo);
if(!res || res.code != 200){
this.$modal.msgError(res && res.msg || '未知错误')
return;
}
this.$modal.msgSuccess('追加成功')
}
},
handleCloseWayBill(){
this.titleWayBill="";
this.openWayBillForm=false;
this.wayBillData = {
pageNum: 1,
pageSize: 20,
params:{}
};
this.emisWayBillList=[];
this.tempCoPackList=[];
this.addWayBillDisabled = true;
this.wayBillotal=0;
},
async handleCoPackListDelete(){
// if(!this.coData.destCountry || !this.coData.sendStiteCode || !this.coData.nextSiteCode || !this.blUnpack){
if(!this.coData.sendStiteCode || !this.coData.nextSiteCode || !this.blUnpack){
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 delEmisTmsPackDtl(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++){
debugger
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.nextSiteCode = this.coData.nextSiteCode;
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 updateEmisTmsPack(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;
let firstItem = this.emisCoPackDetail.length > 0 ? this.emisCoPackDetail[0] : null;
let blUnpack = true;
this.emisCoPackDetail.forEach(item =>{
totalParcelQty +=item.parcelQty;
totalWeight +=item.billWeight;
totalVolume +=item.totalVolume;
item.destCountry = this.coData.destCountry;
item.sendStiteCode = this.coData.sendStiteCode;
item.nextSiteCode = this.coData.nextSiteCode;
item.blUnpack = this.blUnpack;
if(firstItem.receiveCountry != item.receiveCountry){
blUnpack = false;
}
})
if(!blUnpack){
this.packDisabled = true;
this.blUnpack = "1";
}else{
this.packDisabled = false;
}
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();
},
/** 新增按钮操作 */
async handleAdd() {
this.coPackType="add";
this.coData = {};
if(this.activeName=="first"){
// 将选中的“待合包”的运单 置为 追加的运单号
for(let p = 0; p < this.waitPackList.length;p++){
this.emisCoPackDetail.push(this.waitPackList[p]);
}
}
this.tempExistCoPackWayBillList = [];// 清空临时保存的已有运单号
this.tempCoPackInfo={};
this.coData.createTime = parseTime(new Date());
this.coData.destCountry = null;
this.coData.destCountryName = null;
// this.coData.sendStiteCode = null;
this.coData.nextSiteCode = null;
this.coData.nextStation = null;
this.blUnpack = "1";
this.coData.sendStiteCode = this.$store.getters.ownerSiteCode;
this.coData.sendSiteName=this.$store.getters.ownerSiteName;
this.computeTotal();
this.currentId=null;
this.openForm= true;
this.titleForm = "新增合包";
},
handleAddWayBill(){
// if(!this.coData.destCountry || !this.coData.sendStiteCode || !this.coData.nextSiteCode || !this.blUnpack){
if(!this.coData.sendStiteCode || !this.coData.nextSiteCode || !this.blUnpack){
this.$modal.msgError("请先选择必填项")
return;
}
this.openWayBillForm= true;
this.titleWayBill = "运单列表";
},
handleShowMoreInput(){
this.moreInputVisible = !this.moreInputVisible;
},
/** 修改按钮操作 */
async handleUpdate() {
let id = this.ids[0]
this.coPackType="edit";
let response = await getEmisTmsPack(id);
if(!response || response.code != 200){
this.$message.error(response && response.msg || "未知错误");
return;
}
let resData = response.data;
this.coData.packNo = resData.packNo;
this.coData.createTime = resData.createTime;
this.coData.destCountry = resData.destCountry;
// this.coData.destCountryName = null;
this.coData.sendStiteCode = resData.sendStiteCode;
this.coData.sendSiteName = resData.sendSiteName;
this.coData.nextSiteCode = resData.nextSiteCode;
// this.coData.nextStation = null;
this.blUnpack = resData.blUnpack;
this.emisCoPackDetail=[];
let resList = await listEmisTmsPackDtl({packNo: resData.packNo});
if(!resList || resList.code != 200){
this.$message.error(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;
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 delEmisTmsPack(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;
listEmisTmsPack(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','sendStiteCode','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>