fix: 修复知识库增加重复校验后无法保存的问题
This commit is contained in:
@@ -304,65 +304,66 @@ export default {
|
|||||||
if (this.blockOperation.save) { return }
|
if (this.blockOperation.save) { return }
|
||||||
this.blockOperation.save = true
|
this.blockOperation.save = true
|
||||||
// 校验form + upload + preview
|
// 校验form + upload + preview
|
||||||
let formValid
|
|
||||||
this.$refs.form.validate(valid => {
|
this.$refs.form.validate(valid => {
|
||||||
formValid = valid
|
if (valid) {
|
||||||
})
|
if (!this.uploaded) {
|
||||||
|
this.uploadErrorTip = this.$t('validate.required')
|
||||||
if (!this.uploaded) {
|
|
||||||
this.uploadErrorTip = this.$t('validate.required')
|
|
||||||
} else {
|
|
||||||
this.uploadErrorTip = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.importedData.length === 0) {
|
|
||||||
this.previewErrorTip = this.$t('validate.required')
|
|
||||||
} else if (this.hasErrorImportedData()) {
|
|
||||||
this.previewErrorTip = this.$t('validate.pleaseCheckForErrorItem')
|
|
||||||
} else {
|
|
||||||
this.previewErrorTip = ''
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验通过后组织数据、请求接口
|
|
||||||
if (formValid && !this.uploadErrorTip && !this.previewErrorTip) {
|
|
||||||
const postData = {
|
|
||||||
tagName: this.editObject.tagName,
|
|
||||||
tagType: this.editObject.tagType,
|
|
||||||
data: []
|
|
||||||
}
|
|
||||||
this.importedData.forEach(d => {
|
|
||||||
const findData = postData.data.find(d2 => d2.tagValue === d.tagValue)
|
|
||||||
if (findData) {
|
|
||||||
findData.itemList.add(d.tagItem)
|
|
||||||
} else {
|
} else {
|
||||||
const set = new Set()
|
this.uploadErrorTip = ''
|
||||||
set.add(d.tagItem)
|
|
||||||
postData.data.push({
|
|
||||||
tagValue: d.tagValue,
|
|
||||||
itemList: set
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
postData.data.forEach(d => {
|
if (this.importedData.length === 0) {
|
||||||
d.itemList = [...d.itemList]
|
this.previewErrorTip = this.$t('validate.required')
|
||||||
})
|
} else if (this.hasErrorImportedData()) {
|
||||||
postData.remark = this.editObject.remark
|
this.previewErrorTip = this.$t('validate.pleaseCheckForErrorItem')
|
||||||
axios.post(this.url, postData).then(response => {
|
} else {
|
||||||
if (response.data.code === 200) {
|
this.previewErrorTip = ''
|
||||||
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
}
|
||||||
this.$router.push({
|
|
||||||
path: '/knowledgeBase',
|
// 校验通过后组织数据、请求接口
|
||||||
t: +new Date()
|
if (valid && !this.uploadErrorTip && !this.previewErrorTip) {
|
||||||
|
const postData = {
|
||||||
|
tagName: this.editObject.tagName,
|
||||||
|
tagType: this.editObject.tagType,
|
||||||
|
data: []
|
||||||
|
}
|
||||||
|
this.importedData.forEach(d => {
|
||||||
|
const findData = postData.data.find(d2 => d2.tagValue === d.tagValue)
|
||||||
|
if (findData) {
|
||||||
|
findData.itemList.add(d.tagItem)
|
||||||
|
} else {
|
||||||
|
const set = new Set()
|
||||||
|
set.add(d.tagItem)
|
||||||
|
postData.data.push({
|
||||||
|
tagValue: d.tagValue,
|
||||||
|
itemList: set
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
postData.data.forEach(d => {
|
||||||
|
d.itemList = [...d.itemList]
|
||||||
|
})
|
||||||
|
postData.remark = this.editObject.remark
|
||||||
|
axios.post(this.url, postData).then(response => {
|
||||||
|
if (response.data.code === 200) {
|
||||||
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') })
|
||||||
|
this.$router.push({
|
||||||
|
path: '/knowledgeBase',
|
||||||
|
t: +new Date()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.$message.error(response.data.message)
|
||||||
|
}
|
||||||
|
}).finally(() => {
|
||||||
|
this.blockOperation.save = false
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.data.message)
|
this.blockOperation.save = false
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
} else {
|
||||||
this.blockOperation.save = false
|
this.blockOperation.save = false
|
||||||
})
|
}
|
||||||
} else {
|
})
|
||||||
this.blockOperation.save = false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
hasErrorImportedData () {
|
hasErrorImportedData () {
|
||||||
return this.importedData.filter(d => d.status !== 1).length > 0
|
return this.importedData.filter(d => d.status !== 1).length > 0
|
||||||
|
|||||||
Reference in New Issue
Block a user