|
@@ -1440,24 +1440,37 @@ const checkForm = function () {
|
|
|
|
|
|
// 表单校验结果
|
|
|
let result = true
|
|
|
+ const promisePool: any[] = []
|
|
|
target.forEach((i: string) => {
|
|
|
const r: any = formRef.value[`${i}`]
|
|
|
if (typeof r.validate === 'function') {
|
|
|
r.clearValidate()
|
|
|
- r.validate((valid: boolean) => {
|
|
|
- if (!valid) {
|
|
|
- messageError('请检查表单必填项')
|
|
|
- result = false
|
|
|
- return
|
|
|
- }
|
|
|
+ const p = new Promise((resolve) => {
|
|
|
+ r.validate((valid: boolean) => {
|
|
|
+ if (!valid) {
|
|
|
+ messageError('请检查表单必填项')
|
|
|
+ resolve(false)
|
|
|
+ } else {
|
|
|
+ resolve(true)
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
+ promisePool.push(p)
|
|
|
} else {
|
|
|
result = false
|
|
|
}
|
|
|
})
|
|
|
- if (result) {
|
|
|
- createQuoteFunc()
|
|
|
+ if (!result) {
|
|
|
+ // 一般不会到这里
|
|
|
+ messageError('表单异常. 请刷新页面再试或者全屏截图联系管理员')
|
|
|
+ return
|
|
|
}
|
|
|
+ Promise.all(promisePool).then((res) => {
|
|
|
+ const valid = res.every((a) => a === true)
|
|
|
+ if (valid) {
|
|
|
+ createQuoteFunc()
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
const messageError = debounce(function (info) {
|
|
|
ElMessage.error(info)
|