|
|
|
@ -3648,226 +3648,229 @@ const handleSubmit = (formEl: FormInstance | undefined) => {
|
|
|
|
|
if (!formEl) return; |
|
|
|
|
formEl.validate(async valid => { |
|
|
|
|
if (!valid) return false; |
|
|
|
|
try { |
|
|
|
|
// 开启loading |
|
|
|
|
details.loadingObj.submitLoadingBtn = true; |
|
|
|
|
|
|
|
|
|
// 检测货物名称和件数是否正确填写 |
|
|
|
|
const _flag = details.goodsList.every(val => { |
|
|
|
|
if (!val.goodsName || !isNumber(val.num) || val.num === 0) return false; |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
// 开启loading |
|
|
|
|
details.loadingObj.submitLoadingBtn = true; |
|
|
|
|
|
|
|
|
|
if (!_flag) { |
|
|
|
|
return ElMessage({ |
|
|
|
|
type: 'warning', |
|
|
|
|
message: '请填写正确的货物名称和件数', |
|
|
|
|
const timer = setTimeout(async () => { |
|
|
|
|
try { |
|
|
|
|
// 检测货物名称和件数是否正确填写 |
|
|
|
|
const _flag = details.goodsList.every(val => { |
|
|
|
|
if (!val.goodsName || !isNumber(val.num) || val.num === 0) return false; |
|
|
|
|
return true; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// if (!(details.query.totalFreight > 0)) { |
|
|
|
|
// return ElMessage.warning('请输入大于零的运费'); |
|
|
|
|
// } |
|
|
|
|
if (totalCost.value === 0) return ElMessage.warning('合计费用不能等于0'); |
|
|
|
|
if (!_flag) { |
|
|
|
|
return ElMessage({ |
|
|
|
|
type: 'warning', |
|
|
|
|
message: '请填写正确的货物名称和件数', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const submitData = { |
|
|
|
|
...details.totalObj, |
|
|
|
|
...details.query, |
|
|
|
|
waybillDetailList: details.goodsList, |
|
|
|
|
advanceIds: info.value.advanceIds, |
|
|
|
|
huilaiPay: 1, |
|
|
|
|
addList: [], |
|
|
|
|
removeList: [], |
|
|
|
|
}; |
|
|
|
|
// if (!(details.query.totalFreight > 0)) { |
|
|
|
|
// return ElMessage.warning('请输入大于零的运费'); |
|
|
|
|
// } |
|
|
|
|
if (totalCost.value === 0) return ElMessage.warning('合计费用不能等于0'); |
|
|
|
|
|
|
|
|
|
const submitData = { |
|
|
|
|
...details.totalObj, |
|
|
|
|
...details.query, |
|
|
|
|
waybillDetailList: details.goodsList, |
|
|
|
|
advanceIds: info.value.advanceIds, |
|
|
|
|
huilaiPay: 1, |
|
|
|
|
addList: [], |
|
|
|
|
removeList: [], |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
submitData.customerTrain = details.query.trainNumber; |
|
|
|
|
submitData.customerTrain = details.query.trainNumber; |
|
|
|
|
|
|
|
|
|
const { destination, departure } = submitData; |
|
|
|
|
const { destination, departure } = submitData; |
|
|
|
|
|
|
|
|
|
if (destination.length === 1) { |
|
|
|
|
return ElMessage({ message: '请选择正确到站地址', type: 'warning' }); |
|
|
|
|
} |
|
|
|
|
if (departure.length === 1) { |
|
|
|
|
return ElMessage({ message: '请选择正确发站地址', type: 'warning' }); |
|
|
|
|
} |
|
|
|
|
if (destination.length === 1) { |
|
|
|
|
return ElMessage({ message: '请选择正确到站地址', type: 'warning' }); |
|
|
|
|
} |
|
|
|
|
if (departure.length === 1) { |
|
|
|
|
return ElMessage({ message: '请选择正确发站地址', type: 'warning' }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 筛选到站 |
|
|
|
|
const _findeLocation = details.regionOptione |
|
|
|
|
.find(val => val.value === destination[0]) |
|
|
|
|
.children.find(val => val.value === destination[1]); |
|
|
|
|
// 筛选到站 |
|
|
|
|
const _findeLocation = details.regionOptione |
|
|
|
|
.find(val => val.value === destination[0]) |
|
|
|
|
.children.find(val => val.value === destination[1]); |
|
|
|
|
|
|
|
|
|
let _item: any = {}; |
|
|
|
|
if (destination.length === 2) { |
|
|
|
|
_item = _findeLocation; |
|
|
|
|
} else { |
|
|
|
|
_item = _findeLocation.children.find(val => val.value === destination[2]); |
|
|
|
|
} |
|
|
|
|
submitData.destination = _item.label; |
|
|
|
|
submitData.destinationCode = _item.value; |
|
|
|
|
let _item: any = {}; |
|
|
|
|
if (destination.length === 2) { |
|
|
|
|
_item = _findeLocation; |
|
|
|
|
} else { |
|
|
|
|
_item = _findeLocation.children.find(val => val.value === destination[2]); |
|
|
|
|
} |
|
|
|
|
submitData.destination = _item.label; |
|
|
|
|
submitData.destinationCode = _item.value; |
|
|
|
|
|
|
|
|
|
// 筛选发站 |
|
|
|
|
const _findeDeparture = details.regionOptione |
|
|
|
|
.find(val => val.value === departure[0]) |
|
|
|
|
.children.find(val => val.value === departure[1]); |
|
|
|
|
// 筛选发站 |
|
|
|
|
const _findeDeparture = details.regionOptione |
|
|
|
|
.find(val => val.value === departure[0]) |
|
|
|
|
.children.find(val => val.value === departure[1]); |
|
|
|
|
|
|
|
|
|
let _itemDeparture: any = {}; |
|
|
|
|
if (departure.length === 2) { |
|
|
|
|
_itemDeparture = _findeDeparture; |
|
|
|
|
} else { |
|
|
|
|
_itemDeparture = _findeDeparture.children.find(val => val.value === departure[2]); |
|
|
|
|
} |
|
|
|
|
let _itemDeparture: any = {}; |
|
|
|
|
if (departure.length === 2) { |
|
|
|
|
_itemDeparture = _findeDeparture; |
|
|
|
|
} else { |
|
|
|
|
_itemDeparture = _findeDeparture.children.find(val => val.value === departure[2]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
submitData.departure = _itemDeparture.label; |
|
|
|
|
submitData.departureCode = _itemDeparture.value; |
|
|
|
|
submitData.departure = _itemDeparture.label; |
|
|
|
|
submitData.departureCode = _itemDeparture.value; |
|
|
|
|
|
|
|
|
|
console.log('submitData :>> ', submitData); |
|
|
|
|
console.log('submitData :>> ', submitData); |
|
|
|
|
|
|
|
|
|
// let numFlag = false; |
|
|
|
|
// let numFlag = false; |
|
|
|
|
|
|
|
|
|
// for (const iterator of details.goodsList) { |
|
|
|
|
// if (iterator.subtotalFreight <= 0 || !iterator.subtotalFreight) { |
|
|
|
|
// numFlag = true; |
|
|
|
|
// break; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
// for (const iterator of details.goodsList) { |
|
|
|
|
// if (iterator.subtotalFreight <= 0 || !iterator.subtotalFreight) { |
|
|
|
|
// numFlag = true; |
|
|
|
|
// break; |
|
|
|
|
// } |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
// if (numFlag) return ElMessage.warning('小计费用存在异常'); |
|
|
|
|
// if (numFlag) return ElMessage.warning('小计费用存在异常'); |
|
|
|
|
|
|
|
|
|
const _content = handleDetectionPayWay(); |
|
|
|
|
if (_content) { |
|
|
|
|
return ElMessage.warning(_content); |
|
|
|
|
} |
|
|
|
|
submitData.goodsName = submitData.waybillDetailList.map(val => val.goodsName).join(','); |
|
|
|
|
const _content = handleDetectionPayWay(); |
|
|
|
|
if (_content) { |
|
|
|
|
return ElMessage.warning(_content); |
|
|
|
|
} |
|
|
|
|
submitData.goodsName = submitData.waybillDetailList.map(val => val.goodsName).join(','); |
|
|
|
|
|
|
|
|
|
let res: any = {}; |
|
|
|
|
// 新增提交 |
|
|
|
|
if (details.pageInfo.type !== 'edit') { |
|
|
|
|
submitData.addList = deepClone(details.goodsList); |
|
|
|
|
submitData.removeList = []; |
|
|
|
|
let res: any = {}; |
|
|
|
|
// 新增提交 |
|
|
|
|
if (details.pageInfo.type !== 'edit') { |
|
|
|
|
submitData.addList = deepClone(details.goodsList); |
|
|
|
|
submitData.removeList = []; |
|
|
|
|
|
|
|
|
|
delete submitData.goodsList; |
|
|
|
|
delete submitData.goodsList; |
|
|
|
|
|
|
|
|
|
submitData.waybillType = 1; |
|
|
|
|
if (getObjType(submitData.receipt) === 'array') |
|
|
|
|
submitData.receipt = submitData.receipt.join(','); |
|
|
|
|
submitData.waybillType = 1; |
|
|
|
|
if (getObjType(submitData.receipt) === 'array') |
|
|
|
|
submitData.receipt = submitData.receipt.join(','); |
|
|
|
|
|
|
|
|
|
submitData.updateAdvanceDetailList = []; |
|
|
|
|
submitData.updateAdvanceDetailList = []; |
|
|
|
|
|
|
|
|
|
for (let i = 0; i < details.package.data.length; i++) { |
|
|
|
|
const value = details.package.data[i]; |
|
|
|
|
|
|
|
|
|
const _obj = { |
|
|
|
|
...value, |
|
|
|
|
id: value.advanceDetailId, |
|
|
|
|
incomeCategoryId: value.confirmIncomeCategoryId, |
|
|
|
|
incomeCategoryName: value.confirmIncomeCategoryName, |
|
|
|
|
costCategoryId: value.confirmCostCategoryId, |
|
|
|
|
costCategoryName: value.confirmCostCategoryName, |
|
|
|
|
}; |
|
|
|
|
for (let i = 0; i < details.package.data.length; i++) { |
|
|
|
|
const value = details.package.data[i]; |
|
|
|
|
|
|
|
|
|
submitData.updateAdvanceDetailList.push(_obj); |
|
|
|
|
} |
|
|
|
|
console.log('submitData :>> ', submitData); |
|
|
|
|
handleComputedPlanPrice(submitData); |
|
|
|
|
const _obj = { |
|
|
|
|
...value, |
|
|
|
|
id: value.advanceDetailId, |
|
|
|
|
incomeCategoryId: value.confirmIncomeCategoryId, |
|
|
|
|
incomeCategoryName: value.confirmIncomeCategoryName, |
|
|
|
|
costCategoryId: value.confirmCostCategoryId, |
|
|
|
|
costCategoryName: value.confirmCostCategoryName, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 有数据开单 |
|
|
|
|
submitData.updateAdvanceDetailList.push(_obj); |
|
|
|
|
} |
|
|
|
|
console.log('submitData :>> ', submitData); |
|
|
|
|
handleComputedPlanPrice(submitData); |
|
|
|
|
|
|
|
|
|
if (details.submitType === 'haveData') res = await postOpenOrderOpenWaybill(submitData); |
|
|
|
|
else { |
|
|
|
|
submitData.waybillType = 2; |
|
|
|
|
// 有数据开单 |
|
|
|
|
|
|
|
|
|
res = await postOpenOrderOpenZeroWaybill(submitData); |
|
|
|
|
} |
|
|
|
|
const { code, data, msg } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
if (msg) ElMessage.success(msg); |
|
|
|
|
if (details.submitType === 'haveData') res = await postOpenOrderOpenWaybill(submitData); |
|
|
|
|
else { |
|
|
|
|
submitData.waybillType = 2; |
|
|
|
|
|
|
|
|
|
details.waybillId = getObjType(data) === 'object' ? data.waybillId || '' : ''; |
|
|
|
|
res = await postOpenOrderOpenZeroWaybill(submitData); |
|
|
|
|
} |
|
|
|
|
const { code, data, msg } = res.data; |
|
|
|
|
if (code !== 200) return; |
|
|
|
|
if (msg) ElMessage.success(msg); |
|
|
|
|
|
|
|
|
|
// 开启提示框, 是否继续开单 |
|
|
|
|
if (details.pageInfo.type === 'add') details.popUpShow.titleVisited = true; |
|
|
|
|
} else { |
|
|
|
|
submitData.waybillId = details.pageInfo.id; |
|
|
|
|
details.waybillId = getObjType(data) === 'object' ? data.waybillId || '' : ''; |
|
|
|
|
|
|
|
|
|
// 开启提示框, 是否继续开单 |
|
|
|
|
if (details.pageInfo.type === 'add') details.popUpShow.titleVisited = true; |
|
|
|
|
} else { |
|
|
|
|
submitData.waybillId = details.pageInfo.id; |
|
|
|
|
|
|
|
|
|
const oldGoodsList = [...details.deepCloneGoodsList]; |
|
|
|
|
const oldGoodsList = [...details.deepCloneGoodsList]; |
|
|
|
|
|
|
|
|
|
for (let iterator of details.goodsList) { |
|
|
|
|
// 查看每一项是否存在Id updateType: 1新增; 2修改 |
|
|
|
|
if (iterator.id) { |
|
|
|
|
// 存在则证明为老数据 |
|
|
|
|
for (let iterator of details.goodsList) { |
|
|
|
|
// 查看每一项是否存在Id updateType: 1新增; 2修改 |
|
|
|
|
if (iterator.id) { |
|
|
|
|
// 存在则证明为老数据 |
|
|
|
|
|
|
|
|
|
// 根据存在的数据, 筛选被删除的数据 |
|
|
|
|
const _item = oldGoodsList.splice( |
|
|
|
|
oldGoodsList.findIndex(val => val.id === iterator.id), |
|
|
|
|
1 |
|
|
|
|
); |
|
|
|
|
// 根据存在的数据, 筛选被删除的数据 |
|
|
|
|
const _item = oldGoodsList.splice( |
|
|
|
|
oldGoodsList.findIndex(val => val.id === iterator.id), |
|
|
|
|
1 |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 检测是否被修改 |
|
|
|
|
let _flag = false; |
|
|
|
|
// 检测是否被修改 |
|
|
|
|
let _flag = false; |
|
|
|
|
|
|
|
|
|
for (const key in iterator) { |
|
|
|
|
_flag = iterator[key] !== _item[key]; |
|
|
|
|
// 检测到不一致则退出循环 |
|
|
|
|
if (_flag) break; |
|
|
|
|
} |
|
|
|
|
for (const key in iterator) { |
|
|
|
|
_flag = iterator[key] !== _item[key]; |
|
|
|
|
// 检测到不一致则退出循环 |
|
|
|
|
if (_flag) break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (_flag) submitData.addList.push({ ...iterator, updateType: 2 }); |
|
|
|
|
} else { |
|
|
|
|
submitData.addList.push({ ...iterator, updateType: 1 }); |
|
|
|
|
if (_flag) submitData.addList.push({ ...iterator, updateType: 2 }); |
|
|
|
|
} else { |
|
|
|
|
submitData.addList.push({ ...iterator, updateType: 1 }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
submitData.removeList = oldGoodsList; |
|
|
|
|
submitData.removeList = oldGoodsList; |
|
|
|
|
|
|
|
|
|
delete submitData.goodsList; |
|
|
|
|
delete submitData.goodsList; |
|
|
|
|
|
|
|
|
|
submitData.waybillType = 1; |
|
|
|
|
if (getObjType(submitData.receipt) === 'array') |
|
|
|
|
submitData.receipt = submitData.receipt.join(','); |
|
|
|
|
submitData.waybillType = 1; |
|
|
|
|
if (getObjType(submitData.receipt) === 'array') |
|
|
|
|
submitData.receipt = submitData.receipt.join(','); |
|
|
|
|
|
|
|
|
|
submitData.updateAdvanceDetailList = []; |
|
|
|
|
submitData.updateAdvanceDetailList = []; |
|
|
|
|
|
|
|
|
|
for (let i = 0; i < details.package.data.length; i++) { |
|
|
|
|
const value = details.package.data[i]; |
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
|
value.cloneCostCategoryId === value.confirmCostCategoryId && |
|
|
|
|
value.cloneIncomeCategoryId === value.confirmIncomeCategoryId |
|
|
|
|
) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
const _obj = { |
|
|
|
|
id: value.advanceDetailId, |
|
|
|
|
incomeCategoryId: value.confirmIncomeCategoryId, |
|
|
|
|
incomeCategoryName: value.confirmIncomeCategoryName, |
|
|
|
|
costCategoryId: value.confirmCostCategoryId, |
|
|
|
|
costCategoryName: value.confirmCostCategoryName, |
|
|
|
|
}; |
|
|
|
|
for (let i = 0; i < details.package.data.length; i++) { |
|
|
|
|
const value = details.package.data[i]; |
|
|
|
|
|
|
|
|
|
submitData.updateAdvanceDetailList.push(_obj); |
|
|
|
|
} |
|
|
|
|
handleComputedPlanPrice(submitData); |
|
|
|
|
if ( |
|
|
|
|
value.cloneCostCategoryId === value.confirmCostCategoryId && |
|
|
|
|
value.cloneIncomeCategoryId === value.confirmIncomeCategoryId |
|
|
|
|
) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
// 记录提交参数 |
|
|
|
|
details.submitData = submitData; |
|
|
|
|
const response = await postUpdateWaybillVerify(submitData); |
|
|
|
|
if (response.data.code !== 200) return; |
|
|
|
|
const _obj = { |
|
|
|
|
id: value.advanceDetailId, |
|
|
|
|
incomeCategoryId: value.confirmIncomeCategoryId, |
|
|
|
|
incomeCategoryName: value.confirmIncomeCategoryName, |
|
|
|
|
costCategoryId: value.confirmCostCategoryId, |
|
|
|
|
costCategoryName: value.confirmCostCategoryName, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (!response.data.data || response.data.data.length === 0) |
|
|
|
|
return ElMessage.warning('没有更改的数据'); |
|
|
|
|
submitData.updateAdvanceDetailList.push(_obj); |
|
|
|
|
} |
|
|
|
|
handleComputedPlanPrice(submitData); |
|
|
|
|
|
|
|
|
|
details.changeData = response.data.data; |
|
|
|
|
details.popUpShow.causeVisited = true; |
|
|
|
|
await nextTick(); |
|
|
|
|
// 记录提交参数 |
|
|
|
|
details.submitData = submitData; |
|
|
|
|
const response = await postUpdateWaybillVerify(submitData); |
|
|
|
|
if (response.data.code !== 200) return; |
|
|
|
|
|
|
|
|
|
setNodeHeight(tableNode.value.$el, '40vh'); |
|
|
|
|
if (!response.data.data || response.data.data.length === 0) |
|
|
|
|
return ElMessage.warning('没有更改的数据'); |
|
|
|
|
|
|
|
|
|
details.changeData = response.data.data; |
|
|
|
|
details.popUpShow.causeVisited = true; |
|
|
|
|
await nextTick(); |
|
|
|
|
|
|
|
|
|
setNodeHeight(tableNode.value.$el, '40vh'); |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.log('error :>> ', error); |
|
|
|
|
} finally { |
|
|
|
|
clearTimeout(timer); |
|
|
|
|
$store.commit('EDIT_REFRESHITEM', { title: 'TemporaryStorageList', status: true }); |
|
|
|
|
details.loadingObj.submitLoadingBtn = false; |
|
|
|
|
} |
|
|
|
|
} catch (error) { |
|
|
|
|
console.log('error :>> ', error); |
|
|
|
|
} finally { |
|
|
|
|
$store.commit('EDIT_REFRESHITEM', { title: 'TemporaryStorageList', status: true }); |
|
|
|
|
details.loadingObj.submitLoadingBtn = false; |
|
|
|
|
} |
|
|
|
|
}, 500); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|