summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author刘洪洪 <[email protected]>2024-11-19 10:36:47 +0800
committer刘洪洪 <[email protected]>2024-11-19 10:36:47 +0800
commit27650f2c3779110e4a694e774c1a3b65b246322d (patch)
tree50483597c579f56aedf2c5c27097134010165086
parentd2b6eab486f787ceda26193336755b99f68e938d (diff)
fix: 1、添加创建source时名称重复的校验;2、source文件上传的id参数修改,去掉多余代码。
-rw-r--r--src/components/table/setting/SourcesTable.vue53
-rw-r--r--src/views/setting/sources/SourcesForm.vue23
2 files changed, 28 insertions, 48 deletions
diff --git a/src/components/table/setting/SourcesTable.vue b/src/components/table/setting/SourcesTable.vue
index 3609bc0d..bbc5c82b 100644
--- a/src/components/table/setting/SourcesTable.vue
+++ b/src/components/table/setting/SourcesTable.vue
@@ -101,7 +101,7 @@
<script>
import table from '@/mixins/table'
import { dateFormatByAppearance } from '@/utils/date-util'
-import { itemListHeight, storageKey, unitTypes, EN } from '@/utils/constants'
+import { storageKey, unitTypes, EN } from '@/utils/constants'
import _ from 'lodash'
import unitConvert from '@/utils/unit-convert'
import { ElMessageBox } from 'element-plus'
@@ -187,7 +187,7 @@ export default {
computed: {
uploadParams () {
return {
- id: this.sourceId
+ sourceId: this.sourceId
}
}
},
@@ -208,51 +208,10 @@ export default {
}
this.fileList = fileList.slice(-1)
},
- uploadSuccess (response) {
- if (response.code === 200) {
- this.uploaded = true
- // 上传成功后去掉upload和preview的错误提示
- this.uploadErrorTip = ''
- this.previewErrorTip = ''
- this.importedType = this.editObject.indicatorType
- const originalImportedData = _.cloneDeep(response.data.list)
- this.importedDataNoData = originalImportedData.length === 0
- if (originalImportedData.length > 0) {
- originalImportedData.forEach(data => {
- if (data.isValid === 1) {
- data.msg = this.$t('overall.success')
- } else if (data.isValid === 0) {
- if (data.errorAttribute === 'entityType') {
- data.msg = this.$t('validate.wrongType')
- } else if (data.errorAttribute === 'entityValue') {
- data.msg = this.$t('validate.wrongFormat')
- }
- }
- })
- }
- this.originalImportInfo = {
- total: originalImportedData.length,
- succeeded: originalImportedData.filter(d => d.isValid === 1).length,
- failed: originalImportedData.filter(d => d.isValid !== 1).length
- }
- this.isLoad = false
- originalImportedData.sort((a, b) => b.isValid - a.isValid)
- this.importedData = this.handleSpeticalTypeData(originalImportedData)
- this.addItemList = _.cloneDeep(this.importedData).filter(item => { return item.isValid === 1 })
- this.updateItemList = []
- this.deleteItemIds = this.oldItemIds
-
- this.handleShowImportedData()
- this.addEditFlag = false
- this.editTagErrorTip = ''
- this.editIndex = -1
- this.isPreviewChange = true
- this.stepHeights[2] = itemListHeight.hasData
- this.stepHeightConstant.third = itemListHeight.hasData
- } else {
- this.uploadLoading = false
- this.$message.error(this.$t('tip.uploadFailed', { msg: response.message }))
- }
+ uploadSuccess () {
+ this.uploaded = false
+ this.dialogVisible = false
+ this.$message.success(this.$t('tip.success'))
},
beforeUpload (file) {
return new Promise((resolve, reject) => {
diff --git a/src/views/setting/sources/SourcesForm.vue b/src/views/setting/sources/SourcesForm.vue
index 0cabd4af..e270d931 100644
--- a/src/views/setting/sources/SourcesForm.vue
+++ b/src/views/setting/sources/SourcesForm.vue
@@ -178,6 +178,20 @@ export default {
Loading
},
data () {
+ const nameDuplicateValidator = async (rule, value, callback) => {
+ let validate = true
+ if (!this.sourceObj.knowledgeId) {
+ const response = await this.getSourceList()
+ if (response.status === 200) {
+ const find = response.data.data.list.find(d => d.name === value)
+ if (find) {
+ validate = false
+ callback(new Error())
+ }
+ }
+ }
+ return validate
+ }
const nameValidator = (rule, value, callback) => {
// 校验value包含字母、数字和下划线,并且不是全数字、全下划线和连续下划线
const regex = /^(?=.*[a-zA-Z])(?=.*\d|^(?!\d+$))[a-zA-Z\d]+(?:_[a-zA-Z\d]+)*$/
@@ -204,7 +218,8 @@ export default {
return {
rules: {
name: [
- { required: true, message: this.$t('validate.required'), trigger: 'blur' }
+ { required: true, message: this.$t('validate.required'), trigger: 'blur' },
+ { validator: nameDuplicateValidator, message: this.$t('validate.duplicateRecord', { columns: `(${this.$t('config.roles.name')})` }), trigger: 'blur' }
],
dataFormat: [
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
@@ -460,6 +475,12 @@ export default {
onChangeFunction (index) {
this.sourceObj.lookupsData.data[index].output_type = ''
// this.$refs.lookupsForm.clearValidate('output_type')
+ },
+ async getSourceList () {
+ return await axios.get(api.setting.source.source, { params: { pageSize: 999 } }).catch(e => {
+ console.error(e)
+ this.$message.error(this.errorMsgHandler(e))
+ })
}
},
setup () {