Commit 390a19f6 authored by 邓春圆's avatar 邓春圆

表单验证 重构,修复bug

parent d3a32c24
......@@ -30,12 +30,6 @@ export default {
]
}],
},
form1: {
bubbleWeightRatio: 100,
channelCostCreateReqVO: {},
channelPackagingList: [],
},
channelList: [],
dialogVisible: false,
}
......@@ -82,7 +76,7 @@ export default {
this.$set(this.form.channelList[index], 'packagingCreateReqVOList', arr);
},
newChannelsAdd(index) {
this.form.channelList.splice(index, 0, {
this.form.channelList.splice(index + 1, 0, {
"channelIds": "",
"packagingCreateReqVOList": [
{
......@@ -101,13 +95,8 @@ export default {
arr[index].packagingCreateReqVOList.splice(indexx, 1);
this.form.channelList = arr;
},
getRouteDetails(id, callback = () => {
}) {
getAirLineChannelPackagingList(id).then(
(r) => {
callback(r.data)
}
)
getRouteDetails(id, callback = () => {}){
getAirLineChannelPackagingList(id).then((r) => {callback(r.data)})
},
setChannelData(list = []) {
let arr = []
......@@ -180,7 +169,7 @@ export default {
return arr
},
submit() {
if(!this.validation()) return
if (!this.validation()) return
createWarehouseLineChannelPackaging(this.getChannelDate(this.form)).then(r => {
this.$message.success('保存成功');
this.$router.back()
......@@ -194,53 +183,51 @@ export default {
},
validation() {
let flag = true
try {
this.form.channelList.forEach((item, index) => {
if (!item.channelIds.length) {
this.$message.warning(`渠道${index + 1}没有选择航道`)
flag = false
return
throw `渠道${index + 1}没有选择航道`;
}
item.packagingCreateReqVOList.forEach((itemm, indexx) => {
console.log(itemm.packagingTypes);
if (!itemm.packagingTypes.length) {
this.$message.warning(`渠道${index + 1}-包装类型${indexx + 1},没有选择包装类型。`)
flag = false
return
throw `渠道${index + 1}-包装类型${indexx + 1},没有选择包装类型。`;
}
if (!(itemm.airWeightLimit >= 0)) {
this.$message.warning(`渠道${index + 1}-包装类型${indexx + 1},没有输入空运订单重量上限。`)
flag = false
return
throw `渠道${index + 1}-包装类型${indexx + 1},没有输入空运订单重量上限。`;
}
let check = (indexxx) => {
this.$message.warning(`渠道${index + 1}-包装类型${indexx + 1}- 第${indexxx + 1}价格输入有问题。`)
flag = false
return `渠道${index + 1}-包装类型${indexx + 1}- 第${indexxx + 1}价格输入有问题。`
}
itemm.priceStepClearanceCreateReqVOList.forEach((itemmm, indexxx) => {
if (!itemmm.clearancePrice || itemmm.clearancePrice === '') {
check(indexxx)
return
throw check(indexxx);
}
if (!itemmm.clearancePriceUnit || itemmm.clearancePriceUnit === '') {
check(indexxx)
throw check(indexxx);
}
if (!itemmm.clearanceVolumeUnit || itemmm.clearanceVolumeUnit === '') {
throw check(indexxx);
}
if (isNaN(itemmm.endNum) || itemmm.endNum === '') {
check(indexxx)
throw check(indexxx);
}
if (isNaN(itemmm.startNum) || itemmm.startNum === '') {
check(indexxx)
throw check(indexxx);
}
if (!itemmm.weightUnit || itemmm.weightUnit === '') {
check(indexxx)
throw check(indexxx);
}
})
})
})
}catch (e) {
flag = false
console.log(e.Error,'eee')
this.$message.warning(e);
}
return flag
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment