CN-906 fix: 修复一系列问题
This commit is contained in:
@@ -55,23 +55,7 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
tableDataSort (item) {
|
tableDataSort (item) {
|
||||||
/*let orderBy = ''
|
const orderBy = (item.order === 'descending' ? '-' : '') + (item.prop ? (chartTableOrderOptionsMapping[item.prop] || item.prop) : '')
|
||||||
if (item.order === 'ascending') {
|
|
||||||
if (item.prop === 'lastTime') {
|
|
||||||
orderBy = chartTableOrderOptionsMapping[item.prop]
|
|
||||||
} else {
|
|
||||||
orderBy = item.prop
|
|
||||||
}
|
|
||||||
orderBy = chartTableOrderOptionsMapping[item.prop] || item.prop
|
|
||||||
}
|
|
||||||
if (item.order === 'descending') {
|
|
||||||
if (item.prop === 'lastTime') {
|
|
||||||
orderBy = '-' + chartTableOrderOptionsMapping[item.prop]
|
|
||||||
} else {
|
|
||||||
orderBy = '-' + item.prop
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
const orderBy = (item.order === 'descending' ? '-' : '') + (chartTableOrderOptionsMapping[item.prop] || item.prop)
|
|
||||||
this.$emit('orderBy', orderBy)
|
this.$emit('orderBy', orderBy)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import cnDataList from '@/components/table/CnDataList'
|
|||||||
import dataListMixin from '@/mixins/data-list'
|
import dataListMixin from '@/mixins/data-list'
|
||||||
import KnowledgeBaseTable from '@/components/table/setting/KnowledgeBaseTable'
|
import KnowledgeBaseTable from '@/components/table/setting/KnowledgeBaseTable'
|
||||||
import { api } from '@/utils/api'
|
import { api } from '@/utils/api'
|
||||||
import { del, get } from '@/utils/http'
|
import axios from 'axios'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'knowledgeBase',
|
name: 'knowledgeBase',
|
||||||
@@ -59,10 +59,9 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
edit (u) {
|
edit (u) {
|
||||||
get(`${this.url}`, { ids: u.id }).then(response => {
|
axios.get(`${this.url}`, { params: { ids: u.id } }).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.data.code === 200) {
|
||||||
this.object = response.data.list[0]
|
this.object = response.data.data.list[0]
|
||||||
this.rightBox.show = true
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -73,13 +72,13 @@ export default {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.tools.loading = true
|
this.tools.loading = true
|
||||||
del(this.url + '?ids=' + row.id).then(response => {
|
axios.delete(this.url + '?ids=' + row.id).then(response => {
|
||||||
if (response.code === 200) {
|
if (response.data.code === 200) {
|
||||||
this.delFlag = true
|
this.delFlag = true
|
||||||
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
||||||
this.getTableData()
|
this.getTableData()
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(response.msg)
|
this.$message.error(response.data.message)
|
||||||
}
|
}
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.tools.loading = false
|
this.tools.loading = false
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('overall.remark')" prop="remark">
|
<el-form-item :label="$t('overall.remark')" prop="remark">
|
||||||
<el-input maxlength="256" show-word-limit :rows="4" size='mini' type="textarea" v-model="editObject.remark" id="role-box-input-remark"/>
|
<el-input maxlength="255" show-word-limit :rows="4" size='mini' type="textarea" v-model="editObject.remark" id="role-box-input-remark"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
@@ -44,9 +44,10 @@
|
|||||||
:on-remove="onRemove"
|
:on-remove="onRemove"
|
||||||
:before-upload="beforeUpload"
|
:before-upload="beforeUpload"
|
||||||
:on-progress="onUpload"
|
:on-progress="onUpload"
|
||||||
|
:on-error="uploadError"
|
||||||
:class="uploadErrorTip ? 'el-upload--error' : ''"
|
:class="uploadErrorTip ? 'el-upload--error' : ''"
|
||||||
drag
|
drag
|
||||||
accept=".csv"
|
:accept="fileTypeLimit"
|
||||||
ref="upload"
|
ref="upload"
|
||||||
>
|
>
|
||||||
<i class="el-icon-upload"></i>
|
<i class="el-icon-upload"></i>
|
||||||
@@ -126,7 +127,6 @@ import { useRoute } from 'vue-router'
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { knowledgeBaseType, storageKey, unitTypes } from '@/utils/constants'
|
import { knowledgeBaseType, storageKey, unitTypes } from '@/utils/constants'
|
||||||
import i18n from '@/i18n'
|
|
||||||
import Pagination from '@/components/common/Pagination'
|
import Pagination from '@/components/common/Pagination'
|
||||||
import ChartNoData from '@/views/charts/charts/ChartNoData'
|
import ChartNoData from '@/views/charts/charts/ChartNoData'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
@@ -140,11 +140,65 @@ export default {
|
|||||||
ChartNoData,
|
ChartNoData,
|
||||||
Loading
|
Loading
|
||||||
},
|
},
|
||||||
|
data () {
|
||||||
|
const nameValidator = (rule, value, callback) => {
|
||||||
|
let validate = true
|
||||||
|
// /^[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEFA-Za-z0-9\-\_]*$/
|
||||||
|
const reg = /^[\u4e00-\u9fa5A-Za-z0-9\-\_]*$/
|
||||||
|
validate = reg.test(value)
|
||||||
|
return validate
|
||||||
|
}
|
||||||
|
const nameAndTypeValidator = async (rule, value, callback) => {
|
||||||
|
this.$refs.form.clearValidate('tagType')
|
||||||
|
let validate = true
|
||||||
|
const response = await this.getKnowledgeBaseList()
|
||||||
|
if (response.data.code === 200) {
|
||||||
|
const find = response.data.data.list.find(d => d.tagName === value && d.tagType === this.editObject.tagType)
|
||||||
|
if (find) {
|
||||||
|
validate = false
|
||||||
|
callback(new Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validate
|
||||||
|
}
|
||||||
|
const typeAndNameValidator = async (rule, value, callback) => {
|
||||||
|
this.$refs.form.clearValidate('tagName')
|
||||||
|
let validate = true
|
||||||
|
const response = await this.getKnowledgeBaseList()
|
||||||
|
if (response.data.code === 200) {
|
||||||
|
const find = response.data.data.list.find(d => d.tagName === this.editObject.tagName && d.tagType === value)
|
||||||
|
if (find) {
|
||||||
|
validate = false
|
||||||
|
callback(new Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return validate
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
rules: {
|
||||||
|
tagName: [
|
||||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
|
||||||
|
{ validator: nameValidator, message: this.$t('validate.onlyAllowNumberLetterChinese-_'), trigger: 'blur' },
|
||||||
|
{ validator: nameAndTypeValidator, message: this.$t('validate.duplicateRecord', { columns: '(' + this.$t('config.roles.name') + '+' + this.$t('overall.type') + ')' }), trigger: 'blur' }
|
||||||
|
],
|
||||||
|
tagType: [
|
||||||
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' },
|
||||||
|
{ validator: typeAndNameValidator, message: this.$t('validate.duplicateRecord', { columns: '(' + this.$t('config.roles.name') + '+' + this.$t('overall.type') + ')' }), trigger: 'change' }
|
||||||
|
],
|
||||||
|
remark: [
|
||||||
|
{ validator: nameValidator, message: this.$t('validate.onlyAllowNumberLetterChinese-_'), trigger: 'blur' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fileChange (files, fileList) {
|
fileChange (files, fileList) {
|
||||||
console.info(111)
|
|
||||||
this.fileList = fileList.slice(-1)
|
this.fileList = fileList.slice(-1)
|
||||||
},
|
},
|
||||||
|
uploadError () {
|
||||||
|
this.uploadLoading = false
|
||||||
|
this.$message.error(this.$t('tip.uploadFailed', { msg: 'error' }))
|
||||||
|
},
|
||||||
uploadSuccess (response) {
|
uploadSuccess (response) {
|
||||||
this.uploaded = response.code === 200
|
this.uploaded = response.code === 200
|
||||||
if (response.code === 200) {
|
if (response.code === 200) {
|
||||||
@@ -169,7 +223,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onRemove (files, fileList) {
|
onRemove (files, fileList) {
|
||||||
console.info(222)
|
|
||||||
this.uploaded = false
|
this.uploaded = false
|
||||||
this.typeSelectDisable = false
|
this.typeSelectDisable = false
|
||||||
this.importedData = []
|
this.importedData = []
|
||||||
@@ -181,6 +234,12 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeUpload (file) {
|
beforeUpload (file) {
|
||||||
|
// 判断后缀,仅支持.csv
|
||||||
|
if (!_.endsWith(file.name, '.csv')) {
|
||||||
|
this.$message.error(this.$t('validate.fileTypeLimit', { types: this.fileTypeLimit }))
|
||||||
|
this.fileList = []
|
||||||
|
return false
|
||||||
|
}
|
||||||
// 判断文件大小
|
// 判断文件大小
|
||||||
if (file.size > this.uploadFileSizeLimit) {
|
if (file.size > this.uploadFileSizeLimit) {
|
||||||
this.$message.error(this.$t('validate.fileSizeLimit', { size: unitConvert(this.uploadFileSizeLimit, unitTypes.byte).join('') }))
|
this.$message.error(this.$t('validate.fileSizeLimit', { size: unitConvert(this.uploadFileSizeLimit, unitTypes.byte).join('') }))
|
||||||
@@ -211,7 +270,6 @@ export default {
|
|||||||
this.importedPageObj.pageNo++
|
this.importedPageObj.pageNo++
|
||||||
},
|
},
|
||||||
removeImportedData (index) {
|
removeImportedData (index) {
|
||||||
/* const toRemoveIndex = this.importedData.findIndex(d => d.tagName === data.tagName && d.tagItem === data.tagItem) */
|
|
||||||
const toRemoveIndex = (this.importedPageObj.pageNo - 1) * this.importedPageObj.pageSize + index
|
const toRemoveIndex = (this.importedPageObj.pageNo - 1) * this.importedPageObj.pageSize + index
|
||||||
this.importedData.splice(toRemoveIndex, 1)
|
this.importedData.splice(toRemoveIndex, 1)
|
||||||
this.handleShowImportedData()
|
this.handleShowImportedData()
|
||||||
@@ -219,6 +277,7 @@ export default {
|
|||||||
if (this.showImportedData.length === 0) {
|
if (this.showImportedData.length === 0) {
|
||||||
if (this.importedData.length > 0) {
|
if (this.importedData.length > 0) {
|
||||||
this.importedPageObj.pageNo--
|
this.importedPageObj.pageNo--
|
||||||
|
this.importedPageObj.total = this.importedData.length
|
||||||
this.handleShowImportedData()
|
this.handleShowImportedData()
|
||||||
} else {
|
} else {
|
||||||
this.importedDataNoData = true
|
this.importedDataNoData = true
|
||||||
@@ -298,6 +357,9 @@ export default {
|
|||||||
},
|
},
|
||||||
hasErrorImportedData () {
|
hasErrorImportedData () {
|
||||||
return this.importedData.filter(d => d.status !== 1).length > 0
|
return this.importedData.filter(d => d.status !== 1).length > 0
|
||||||
|
},
|
||||||
|
async getKnowledgeBaseList () {
|
||||||
|
return await axios.get(this.url, { params: { pageSize: 999 } })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -346,6 +408,7 @@ export default {
|
|||||||
setup () {
|
setup () {
|
||||||
const { query } = useRoute()
|
const { query } = useRoute()
|
||||||
const knowledgeBaseId = ref(query.id || '')
|
const knowledgeBaseId = ref(query.id || '')
|
||||||
|
const url = api.knowledgeBase
|
||||||
// 空白对象
|
// 空白对象
|
||||||
const blankObject = {
|
const blankObject = {
|
||||||
tagName: '',
|
tagName: '',
|
||||||
@@ -367,26 +430,6 @@ export default {
|
|||||||
second: 284
|
second: 284
|
||||||
}
|
}
|
||||||
const stepHeights = ref([stepHeightConstant.first, stepHeightConstant.second, stepHeightConstant.collapse])
|
const stepHeights = ref([stepHeightConstant.first, stepHeightConstant.second, stepHeightConstant.collapse])
|
||||||
// 表单校验规则
|
|
||||||
const nameValidator = (rule, value, callback) => {
|
|
||||||
let validate = true
|
|
||||||
// /^[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEFA-Za-z0-9\-\_]*$/
|
|
||||||
const reg = /^[\u4e00-\u9fa5A-Za-z0-9\-\_]*$/
|
|
||||||
validate = reg.test(value)
|
|
||||||
return validate
|
|
||||||
}
|
|
||||||
const rules = {
|
|
||||||
tagName: [
|
|
||||||
{ required: true, message: i18n.global.t('validate.required'), trigger: 'blur' },
|
|
||||||
{ validator: nameValidator, message: i18n.global.t('validate.onlyAllowNumberLetterChinese-_'), trigger: 'blur' }
|
|
||||||
],
|
|
||||||
tagType: [
|
|
||||||
{ required: true, message: i18n.global.t('validate.required'), trigger: 'change' }
|
|
||||||
],
|
|
||||||
remark: [
|
|
||||||
{ validator: nameValidator, message: i18n.global.t('validate.onlyAllowNumberLetterChinese-_'), trigger: 'blur' }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
// 所有导入的数据
|
// 所有导入的数据
|
||||||
const importedData = ref([])
|
const importedData = ref([])
|
||||||
// 导入数据的原始数量信息
|
// 导入数据的原始数量信息
|
||||||
@@ -416,7 +459,6 @@ export default {
|
|||||||
stepHeightConstant,
|
stepHeightConstant,
|
||||||
stepHeights,
|
stepHeights,
|
||||||
knowledgeBaseType,
|
knowledgeBaseType,
|
||||||
rules,
|
|
||||||
importedData,
|
importedData,
|
||||||
showImportedData,
|
showImportedData,
|
||||||
importedPageObj,
|
importedPageObj,
|
||||||
@@ -428,13 +470,14 @@ export default {
|
|||||||
},
|
},
|
||||||
uploaded: ref(false),
|
uploaded: ref(false),
|
||||||
importedDataNoData: ref(false),
|
importedDataNoData: ref(false),
|
||||||
url: api.knowledgeBase,
|
url,
|
||||||
originalImportInfo,
|
originalImportInfo,
|
||||||
uploadErrorTip,
|
uploadErrorTip,
|
||||||
previewErrorTip,
|
previewErrorTip,
|
||||||
typeSelectDisable: ref(false),
|
typeSelectDisable: ref(false),
|
||||||
uploadFileSizeLimit: 100 * 1024 * 1024,
|
uploadFileSizeLimit: 100 * 1024 * 1024,
|
||||||
uploadLoading: ref(false)
|
uploadLoading: ref(false),
|
||||||
|
fileTypeLimit: '.csv'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user