// 表单校验
validate () {
return new Promise((resolve, reject) => {
if (this.subQuantityRadio === 2) {
this.subQuantityConfig = []
resolve('子广告位success+ 关闭状态')
} else {
// 子广告位开启状态
let count = 0
const subQuantityConfig = this.subQuantityConfig
// const self = this
subQuantityConfig.some((item, index) => {
console.log(index, 'test subspace index -==================')
if (item.subAdId === '') {
++count
return this.$message.warning('子广告位控量不能为空')
}
// 校验子广告位-广告源 + 竞价广告
const oValidator = async () => {
try {
const p1 = this.$refs.subAdBidding[index]
const p2 = this.$refs.subAdSource[index]
// 竞价
const res1 = await p1.validate()
if (res1) item.common.bidding = self.$refs.subAdBidding[index].bidding
// 广告源(串行设置)
const res2 = await p2.validate()
if (res2) item.common.whole = self.$refs.subAdSource[index].whole
} catch (err) {
++count
console.log(err, '===子广告位error=====')
}
}
oValidator()
})
if (count) return
if (this.isRepeat(subQuantityConfig)) {
++count
return this.$message.warning('子广告位控量配置不能重复')
}
setTimeout(res => {
count === 0 ? resolve('子广告位success + 开启状态') : reject(new Error('子广告位error'))
}, 500)
}
})
},