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

表单验证

parent ad6de73f
......@@ -9,7 +9,7 @@ export default {
name: "channel-route",
components: {AirFreightRouteTemplate, PackagingType},
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.form.channelList = this.setChannelData(value)
})
......@@ -47,15 +47,15 @@ export default {
deletePackagingTypes() {
let a = []
this.form.channelList.forEach(item => {
item.packagingCreateReqVOList.forEach(i =>{
item.packagingCreateReqVOList.forEach(i => {
a.push(...i.packagingTypes)
})
})
return a
},
channelIdBlackList(){
channelIdBlackList() {
let arr = []
this.form.channelList.forEach(i =>{
this.form.channelList.forEach(i => {
arr.push(...i.channelIds)
})
return arr
......@@ -130,7 +130,7 @@ export default {
item.lineChannelPriceStepClearanceBackVOList = null;
})
})
if(arr.length === 0){
if (arr.length === 0) {
return [{
"channelIds": "",
"packagingCreateReqVOList": [
......@@ -180,6 +180,7 @@ export default {
return arr
},
submit() {
if(!this.validation()) return
createWarehouseLineChannelPackaging(this.getChannelDate(this.form)).then(r => {
this.$message.success('保存成功');
this.$router.back()
......@@ -190,8 +191,58 @@ export default {
this.form.channelList = this.setChannelData(value)
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
}
}
}
</script>
......@@ -205,7 +256,9 @@ export default {
</el-col>
<el-col :span="3">
<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
: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-col>
......@@ -238,7 +291,9 @@ export default {
<el-col :span="2">包装类型{{ indexx + 1 }}:</el-col>
<el-col :span="5">
<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
: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-col>
......
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