diff --git a/src/views/setting/entitySetting/EntitySettingForm.vue b/src/views/setting/entitySetting/EntitySettingForm.vue index 54c07f55..13b3cbf1 100644 --- a/src/views/setting/entitySetting/EntitySettingForm.vue +++ b/src/views/setting/entitySetting/EntitySettingForm.vue @@ -610,10 +610,7 @@ export default { const valid2 = await this.$refs.mappingForm.validate((valid) => { return valid }) - const valid3 = await this.$refs.relationForm.validate((valid) => { - return valid - }) - if (valid1 && valid2 && valid3) { + if (valid1 && valid2) { const formObj = this.$_.cloneDeep(this.editObj) formObj.schemaMappingData.data.forEach((item) => { const obj = {} @@ -624,7 +621,8 @@ export default { }) formObj.entities = JSON.stringify(formObj.schemaMappingData.data) formObj.relations = JSON.stringify(formObj.relationData.data) - if (formObj.schemaMappingData.data.length === 0 || formObj.relationData.data.length === 0) { + + if (formObj.schemaMappingData.data.length === 0) { this.activeNames = ['1', '2'] ElMessageBox.alert(this.$t('detection.create.informationFilled'), this.$t('overall.tip'), { confirmButtonText: 'OK', @@ -632,6 +630,33 @@ export default { }) return true } + + if (formObj.relationData.data.length === 1) { + const obj = formObj.relationData.data.find(d => !d.from_entity_index && !d.to_entity_index && !d.type) + if (!obj) { + const valid3 = await this.$refs.relationForm.validate((valid) => { + return valid + }) + if (!valid3) { + ElMessageBox.alert(this.$t('detection.create.informationFilled'), this.$t('overall.tip'), { + confirmButtonText: 'OK', + callback: () => {} + }) + return true + } + } + } else if (formObj.relationData.data.length > 1) { + const obj = formObj.relationData.data.find(d => !d.from_entity_index || !d.to_entity_index || !d.type) + if (obj) { + this.activeNames = ['1', '2'] + this.$refs.relationForm.validate(() => null) + ElMessageBox.alert(this.$t('detection.create.informationFilled'), this.$t('overall.tip'), { + confirmButtonText: 'OK', + callback: () => {} + }) + return true + } + } this.myLoading = true if (!this.ruleId) { // post调用是新增,put是编辑 @@ -684,12 +709,6 @@ export default { this.myLoading = false }) } - } else { - this.activeNames = ['1', '2'] - ElMessageBox.alert(this.$t('detection.create.informationFilled'), this.$t('overall.tip'), { - confirmButtonText: 'OK', - callback: () => {} - }) } }, /** 底部返回按钮 */