CN-965 知识库Preview:1.一条一条删除数据,直到删除完毕,列表未显示nodata;2.列表没有数据时,不弹出对话框;3.删除最后一条记录时报错;4.导入数据中,此时点击报错按钮,报错;
This commit is contained in:
@@ -431,8 +431,7 @@ export default {
|
|||||||
if (this.fileList.length > 0 && this.fileList[0].status === 'success') {
|
if (this.fileList.length > 0 && this.fileList[0].status === 'success') {
|
||||||
this.fileListBack = this.fileList[0]
|
this.fileListBack = this.fileList[0]
|
||||||
}
|
}
|
||||||
const file = fileList.slice(-1)
|
this.fileList = fileList.slice(-1)
|
||||||
this.fileList = file
|
|
||||||
},
|
},
|
||||||
uploadError () {
|
uploadError () {
|
||||||
this.uploadLoading = false
|
this.uploadLoading = false
|
||||||
@@ -481,6 +480,7 @@ export default {
|
|||||||
this.editTagErrorTip = ''
|
this.editTagErrorTip = ''
|
||||||
this.editIndex = -1
|
this.editIndex = -1
|
||||||
this.isPreviewChange = true
|
this.isPreviewChange = true
|
||||||
|
this.importedDataNoData = true
|
||||||
}
|
}
|
||||||
if (this.fileListBack !== undefined && this.fileListBack.status === 'success' &&
|
if (this.fileListBack !== undefined && this.fileListBack.status === 'success' &&
|
||||||
this.importedData.length > 0) {
|
this.importedData.length > 0) {
|
||||||
@@ -491,20 +491,26 @@ export default {
|
|||||||
if (!this.isShowUploadTips) {
|
if (!this.isShowUploadTips) {
|
||||||
this.isShowUploadTips = true
|
this.isShowUploadTips = true
|
||||||
const self = this
|
const self = this
|
||||||
this.$confirm(this.$t('tip.uploadFile'), {
|
if (this.importedData.length > 0) {
|
||||||
confirmButtonText: this.$t('tip.confirm'),
|
this.$confirm(this.$t('tip.uploadFile'), {
|
||||||
cancelButtonText: this.$t('overall.cancel'),
|
confirmButtonText: this.$t('tip.confirm'),
|
||||||
message: this.$t('tip.uploadFileTips'),
|
cancelButtonText: this.$t('overall.cancel'),
|
||||||
title: this.$t('tip.uploadFile'),
|
message: this.$t('tip.uploadFileTips'),
|
||||||
type: 'warning',
|
title: this.$t('tip.uploadFile'),
|
||||||
iconClass: 'width:0px;height:0px;',
|
type: 'warning',
|
||||||
customClass: 'del-model'
|
iconClass: 'width:0px;height:0px;',
|
||||||
}).then(() => {
|
customClass: 'del-model'
|
||||||
|
}).then(() => {
|
||||||
|
this.isClick = true
|
||||||
|
self.$refs.upload.$refs.uploadRef.handleClick()
|
||||||
|
}).catch(e => {}).finally(() => {
|
||||||
|
this.isShowUploadTips = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
this.isClick = true
|
this.isClick = true
|
||||||
self.$refs.upload.$refs.uploadRef.handleClick()
|
|
||||||
}).catch(e => {}).finally(() => {
|
|
||||||
this.isShowUploadTips = false
|
this.isShowUploadTips = false
|
||||||
})
|
self.$refs.upload.$refs.uploadRef.handleClick()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
promiseState (p) {
|
promiseState (p) {
|
||||||
@@ -525,19 +531,23 @@ export default {
|
|||||||
reject(new Error(this.$t('validate.fileSizeLimit', { size: unitConvert(this.uploadFileSizeLimit, unitTypes.byte).join('') })))
|
reject(new Error(this.$t('validate.fileSizeLimit', { size: unitConvert(this.uploadFileSizeLimit, unitTypes.byte).join('') })))
|
||||||
} else {
|
} else {
|
||||||
if (!this.isClick) {
|
if (!this.isClick) {
|
||||||
this.$confirm(this.$t('tip.uploadFile'), {
|
if (this.importedData.length > 0) {
|
||||||
confirmButtonText: this.$t('tip.confirm'),
|
this.$confirm(this.$t('tip.uploadFile'), {
|
||||||
cancelButtonText: this.$t('overall.cancel'),
|
confirmButtonText: this.$t('tip.confirm'),
|
||||||
message: this.$t('tip.uploadFileTips'),
|
cancelButtonText: this.$t('overall.cancel'),
|
||||||
title: this.$t('tip.uploadFile'),
|
message: this.$t('tip.uploadFileTips'),
|
||||||
type: 'warning',
|
title: this.$t('tip.uploadFile'),
|
||||||
iconClass: 'width:0px;height:0px;',
|
type: 'warning',
|
||||||
customClass: 'del-model'
|
iconClass: 'width:0px;height:0px;',
|
||||||
}).then(() => {
|
customClass: 'del-model'
|
||||||
|
}).then(() => {
|
||||||
|
resolve()
|
||||||
|
}).catch(e => {
|
||||||
|
reject(e)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(e => {
|
}
|
||||||
reject(e)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
@@ -575,7 +585,7 @@ export default {
|
|||||||
// 删除内容为空的新增记录
|
// 删除内容为空的新增记录
|
||||||
const lastIndex = this.importedData.length - 1
|
const lastIndex = this.importedData.length - 1
|
||||||
const lastData = this.importedData[lastIndex]
|
const lastData = this.importedData[lastIndex]
|
||||||
if (lastData.tagItem === '' && lastData.tagValue === '') {
|
if (lastData !== undefined && lastData.tagItem === '' && lastData.tagValue === '') {
|
||||||
this.importedData.pop()
|
this.importedData.pop()
|
||||||
}
|
}
|
||||||
this.importedPageObj.total = this.importedData.length
|
this.importedPageObj.total = this.importedData.length
|
||||||
@@ -639,88 +649,96 @@ export default {
|
|||||||
this.previewErrorTip = ''
|
this.previewErrorTip = ''
|
||||||
}
|
}
|
||||||
if (valid) {
|
if (valid) {
|
||||||
this.$refs.editForm.validate((validImportData) => {
|
if (this.$refs.editForm) {
|
||||||
if (validImportData) {
|
this.$refs.editForm.validate((validImportData) => {
|
||||||
// 校验通过后组织数据、请求接口
|
if (validImportData) {
|
||||||
if (valid && !this.uploadErrorTip && !this.previewErrorTip) {
|
// 校验通过后组织数据、请求接口
|
||||||
const postData = {
|
if (valid && !this.uploadErrorTip && !this.previewErrorTip) {
|
||||||
tagName: this.editObject.tagName,
|
if (this.importedData.length === 1 && this.importedData[0].tagItem === '') {
|
||||||
tagType: this.editObject.tagType,
|
// this.blockOperation.save = false
|
||||||
data: []
|
|
||||||
}
|
|
||||||
// 避免点击新增后,并没有保存新增项就点击了save,此时删除新增的空白项
|
|
||||||
if (this.importedData[this.importedData.length - 1].tagItem === '') {
|
|
||||||
this.importedData.pop()
|
|
||||||
}
|
|
||||||
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()
|
const postData = {
|
||||||
set.add(d.tagItem)
|
tagName: this.editObject.tagName,
|
||||||
postData.data.push({
|
tagType: this.editObject.tagType,
|
||||||
tagValue: d.tagValue,
|
data: []
|
||||||
itemList: set
|
}
|
||||||
|
// 避免点击新增后,并没有保存新增项就点击了save,此时删除新增的空白项
|
||||||
|
if (this.importedData[this.importedData.length - 1].tagItem === '') {
|
||||||
|
this.importedData.pop()
|
||||||
|
}
|
||||||
|
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]
|
||||||
|
d.itemList = Array.from(d.itemList)
|
||||||
|
})
|
||||||
|
postData.remark = this.editObject.remark
|
||||||
|
if (!this.editObject.id) {
|
||||||
|
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.errorMsgHandler(response)
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
console.error(e)
|
||||||
|
this.errorMsgHandler(e)
|
||||||
|
}).finally(() => {
|
||||||
|
this.blockOperation.save = false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
postData.id = this.editObject.id
|
||||||
|
axios.put(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.errorMsgHandler(response)
|
||||||
|
}
|
||||||
|
}).catch(e => {
|
||||||
|
console.error(e)
|
||||||
|
this.errorMsgHandler(e)
|
||||||
|
}).finally(() => {
|
||||||
|
this.blockOperation.save = false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
postData.data.forEach(d => {
|
|
||||||
// d.itemList = [...d.itemList]
|
|
||||||
d.itemList = Array.from(d.itemList)
|
|
||||||
})
|
|
||||||
postData.remark = this.editObject.remark
|
|
||||||
if (!this.editObject.id) {
|
|
||||||
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.errorMsgHandler(response)
|
|
||||||
}
|
|
||||||
}).catch(e => {
|
|
||||||
console.error(e)
|
|
||||||
this.errorMsgHandler(e)
|
|
||||||
}).finally(() => {
|
|
||||||
this.blockOperation.save = false
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
postData.id = this.editObject.id
|
this.blockOperation.save = false
|
||||||
axios.put(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.errorMsgHandler(response)
|
|
||||||
}
|
|
||||||
}).catch(e => {
|
|
||||||
console.error(e)
|
|
||||||
this.errorMsgHandler(e)
|
|
||||||
}).finally(() => {
|
|
||||||
this.blockOperation.save = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.blockOperation.save = false
|
this.blockOperation.save = false
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
this.blockOperation.save = false
|
} else {
|
||||||
}
|
this.blockOperation.save = false
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
this.blockOperation.save = false
|
this.blockOperation.save = false
|
||||||
}
|
}
|
||||||
@@ -806,11 +824,13 @@ export default {
|
|||||||
if (total > 0 && total < 10) {
|
if (total > 0 && total < 10) {
|
||||||
this.importedData.push({ tagItem: '', tagValue: '', status: 1 })
|
this.importedData.push({ tagItem: '', tagValue: '', status: 1 })
|
||||||
this.showImportedData.push({ tagItem: '', tagValue: '', status: 1 })
|
this.showImportedData.push({ tagItem: '', tagValue: '', status: 1 })
|
||||||
|
this.importedDataNoData = false
|
||||||
} else {
|
} else {
|
||||||
const lastPageSize = Math.ceil((total + 1) / 10)
|
const lastPageSize = Math.ceil((total + 1) / 10)
|
||||||
this.pageNo(lastPageSize)
|
this.pageNo(lastPageSize)
|
||||||
this.importedData.push({ tagItem: '', tagValue: '', status: 1 })
|
this.importedData.push({ tagItem: '', tagValue: '', status: 1 })
|
||||||
this.showImportedData.push({ tagItem: '', tagValue: '', status: 1 })
|
this.showImportedData.push({ tagItem: '', tagValue: '', status: 1 })
|
||||||
|
this.importedDataNoData = false
|
||||||
}
|
}
|
||||||
this.importedPageObj.total = this.importedData.length
|
this.importedPageObj.total = this.importedData.length
|
||||||
this.timer = setTimeout(() => {
|
this.timer = setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user