diff --git a/frontend/src/i18n/en.json b/frontend/src/i18n/en.json index 57fc3c3b..c869eb99 100644 --- a/frontend/src/i18n/en.json +++ b/frontend/src/i18n/en.json @@ -463,6 +463,7 @@ "duplicate_name": "Duplicate name", "duplicate_name_": "Duplicate name", "duplicate_account": "Duplicate account", + "repeating_parameters": "Repeating Parameters", "duplicate_email": "Duplicate email", "interface_credentials": "Interface credentials", "no_credentials_yet": "No credentials yet", diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index 8211dc67..5d3d7861 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -469,6 +469,7 @@ "duplicate_name_": "重复姓名", "duplicate_account": "重复账号", "duplicate_email": "重复邮箱", + "repeating_parameters": "重复参数", "interface_credentials": "接口凭证", "no_credentials_yet": "暂无凭证", "intelligent_customer_service": "SQLBot 智能客服", diff --git a/frontend/src/views/system/model/Model.vue b/frontend/src/views/system/model/Model.vue index 004c4df2..dc2dec0d 100644 --- a/frontend/src/views/system/model/Model.vue +++ b/frontend/src/views/system/model/Model.vue @@ -69,6 +69,35 @@ const defaultModelListWithSearch = computed(() => { }) }) +const duplicateName = async (item: any) => { + const res = await modelApi.queryAll() + const names = res.filter((ele: any) => ele.id !== item.id).map((ele: any) => ele.name) + if (names.includes(item.name)) { + ElMessage.error(t('embedded.duplicate_name')) + return + } + + if (!item.id) { + modelApi.add(item).then(() => { + beforeClose() + search() + ElMessage({ + type: 'success', + message: t('workspace.add_successfully'), + }) + }) + return + } + modelApi.edit(item).then(() => { + beforeClose() + search() + ElMessage({ + type: 'success', + message: t('common.save_success'), + }) + }) +} + const handleDefaultModelChange = (item: any) => { const current_default_node = modelList.value.find((ele: Model) => ele.default_model) if (current_default_node?.id === item.id) { @@ -185,25 +214,7 @@ const search = () => { search() const submit = (item: any) => { - if (!item.id) { - modelApi.add(item).then(() => { - beforeClose() - search() - ElMessage({ - type: 'success', - message: t('workspace.add_successfully'), - }) - }) - return - } - modelApi.edit(item).then(() => { - beforeClose() - search() - ElMessage({ - type: 'success', - message: t('common.save_success'), - }) - }) + duplicateName(item) } diff --git a/frontend/src/views/system/model/ModelForm.vue b/frontend/src/views/system/model/ModelForm.vue index 57f294ca..c9f0e8e2 100644 --- a/frontend/src/views/system/model/ModelForm.vue +++ b/frontend/src/views/system/model/ModelForm.vue @@ -116,9 +116,22 @@ const addParams = () => { paramsFormRef.value.submit() } -const submit = (item: any) => { +const duplicateName = async (item: any) => { + const arr = advancedSetting.value.filter((ele: any) => ele.id !== item.id) + const names = arr.map((ele: any) => ele.name) + const keys = arr.map((ele: any) => ele.key) + if (names.includes(item.name)) { + ElMessage.error(t('embedded.duplicate_name')) + return + } + + if (keys.includes(item.key)) { + ElMessage.error(t('embedded.repeating_parameters')) + return + } + if (isCreate.value) { - advancedSetting.value.push({ ...item }) + advancedSetting.value.push({ ...item, id: +new Date() }) beforeClose() return } @@ -132,6 +145,10 @@ const submit = (item: any) => { beforeClose() } +const submit = (item: any) => { + duplicateName(item) +} + const beforeClose = () => { paramsFormRef.value.close() paramsFormDrawer.value = false diff --git a/frontend/src/views/system/workspace/index.vue b/frontend/src/views/system/workspace/index.vue index fa744459..3f2a6fa1 100644 --- a/frontend/src/views/system/workspace/index.vue +++ b/frontend/src/views/system/workspace/index.vue @@ -205,6 +205,7 @@ const handleCheckAllChange = (val: any) => { } } + const handleToggleRowSelection = (check: boolean = true) => { let i = 0 const ids = multipleSelectionAll.value.map((ele: any) => ele.id)