Commit d3a32c24 authored by 邓春圆's avatar 邓春圆

表单验证

parent ad6de73f
...@@ -9,7 +9,7 @@ export default { ...@@ -9,7 +9,7 @@ export default {
name: "channel-route", name: "channel-route",
components: {AirFreightRouteTemplate, PackagingType}, components: {AirFreightRouteTemplate, PackagingType},
mounted() { mounted() {
getChannelList({lineId:this.lineId}).then((res) => (this.channelList = res.data)); getChannelList({lineId: this.lineId}).then((res) => (this.channelList = res.data));
this.getRouteDetails(this.lineId, (value) => { this.getRouteDetails(this.lineId, (value) => {
this.form.channelList = this.setChannelData(value) this.form.channelList = this.setChannelData(value)
}) })
...@@ -47,16 +47,16 @@ export default { ...@@ -47,16 +47,16 @@ export default {
deletePackagingTypes() { deletePackagingTypes() {
let a = [] let a = []
this.form.channelList.forEach(item => { this.form.channelList.forEach(item => {
item.packagingCreateReqVOList.forEach(i =>{ item.packagingCreateReqVOList.forEach(i => {
a.push(...i.packagingTypes) a.push(...i.packagingTypes)
}) })
}) })
return a return a
}, },
channelIdBlackList(){ channelIdBlackList() {
let arr = [] let arr = []
this.form.channelList.forEach(i =>{ this.form.channelList.forEach(i => {
arr.push(...i.channelIds) arr.push(...i.channelIds)
}) })
return arr return arr
}, },
...@@ -130,8 +130,8 @@ export default { ...@@ -130,8 +130,8 @@ export default {
item.lineChannelPriceStepClearanceBackVOList = null; item.lineChannelPriceStepClearanceBackVOList = null;
}) })
}) })
if(arr.length === 0){ if (arr.length === 0) {
return [{ return [{
"channelIds": "", "channelIds": "",
"packagingCreateReqVOList": [ "packagingCreateReqVOList": [
{ {
...@@ -180,6 +180,7 @@ export default { ...@@ -180,6 +180,7 @@ export default {
return arr return arr
}, },
submit() { submit() {
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()
...@@ -190,7 +191,57 @@ export default { ...@@ -190,7 +191,57 @@ export default {
this.form.channelList = this.setChannelData(value) this.form.channelList = this.setChannelData(value)
this.$message.success('复制成功。') this.$message.success('复制成功。')
}) })
},
validation() {
let flag = true
this.form.channelList.forEach((item, index) => {
if (!item.channelIds.length) {
this.$message.warning(`渠道${index + 1}没有选择航道`)
flag = false
return
}
item.packagingCreateReqVOList.forEach((itemm, indexx) => {
console.log(itemm.packagingTypes);
if (!itemm.packagingTypes.length) {
this.$message.warning(`渠道${index + 1}-包装类型${indexx + 1},没有选择包装类型。`)
flag = false
return
}
if (!(itemm.airWeightLimit >= 0)) {
this.$message.warning(`渠道${index + 1}-包装类型${indexx + 1},没有输入空运订单重量上限。`)
flag = false
return
}
let check = (indexxx) => {
this.$message.warning(`渠道${index + 1}-包装类型${indexx + 1}- 第${indexxx + 1}价格输入有问题。`)
flag = false
}
itemm.priceStepClearanceCreateReqVOList.forEach((itemmm, indexxx) => {
if (!itemmm.clearancePrice || itemmm.clearancePrice === '') {
check(indexxx)
return
}
if (!itemmm.clearancePriceUnit || itemmm.clearancePriceUnit === '') {
check(indexxx)
}
if (!itemmm.clearanceVolumeUnit || itemmm.clearanceVolumeUnit === '') {
}
if (isNaN(itemmm.endNum) || itemmm.endNum === '') {
check(indexxx)
}
if (isNaN(itemmm.startNum) || itemmm.startNum === '') {
check(indexxx)
}
if (!itemmm.weightUnit || itemmm.weightUnit === '') {
check(indexxx)
}
})
})
})
return flag
} }
} }
} }
...@@ -205,8 +256,10 @@ export default { ...@@ -205,8 +256,10 @@ export default {
</el-col> </el-col>
<el-col :span="3"> <el-col :span="3">
<el-select multiple v-model="itemOuter.channelIds"> <el-select multiple v-model="itemOuter.channelIds">
<el-option :disabled="channelIdBlackList.includes(item.channelId.toString()) && (!itemOuter.channelIds.includes(item.channelId.toString()))" v-for="item in channelList" :value="item.channelId.toString()" :key="item.channelId" <el-option
:label="$l(item, 'name')"></el-option> :disabled="channelIdBlackList.includes(item.channelId.toString()) && (!itemOuter.channelIds.includes(item.channelId.toString()))"
v-for="item in channelList" :value="item.channelId.toString()" :key="item.channelId"
:label="$l(item, 'name')"></el-option>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2">
...@@ -238,8 +291,10 @@ export default { ...@@ -238,8 +291,10 @@ export default {
<el-col :span="2">包装类型{{ indexx + 1 }}:</el-col> <el-col :span="2">包装类型{{ indexx + 1 }}:</el-col>
<el-col :span="5"> <el-col :span="5">
<el-select multiple v-model="itemm.packagingTypes"> <el-select multiple v-model="itemm.packagingTypes">
<el-option :disabled="deletePackagingTypes.includes(item.value) && (!itemm.packagingTypes.includes(item.value))" v-for="item in getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE)" :value="item.value" :key="item.value" <el-option
:label="$l(item, 'label')"></el-option> :disabled="deletePackagingTypes.includes(item.value) && (!itemm.packagingTypes.includes(item.value))"
v-for="item in getDictDatas(DICT_TYPE.ECW_PACKAGING_TYPE)" :value="item.value" :key="item.value"
:label="$l(item, 'label')"></el-option>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
......
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