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

表单验证 重构,修复bug

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