Skip to content

Commit 25debfb

Browse files
committed
fix: bug fix
1 parent afa56f3 commit 25debfb

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

frontend/src/views/system/workspace/index.vue

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ const init = () => {
9797
}
9898
})
9999
}
100+
101+
const duplicateName = async () => {
102+
const res = await workspaceList()
103+
const names = res.filter((ele: any) => ele.id !== workspaceForm.id).map((ele: any) => ele.name)
104+
if (names.includes(workspaceForm.name)) {
105+
ElMessage.error(t('embedded.duplicate_name'))
106+
return
107+
}
108+
109+
const req = workspaceForm.id ? workspaceUpdate : workspaceCreate
110+
req(workspaceForm).then(() => {
111+
ElMessage({
112+
type: 'success',
113+
message: t('common.save_success'),
114+
})
115+
init()
116+
fieldDialog.value = false
117+
})
118+
}
119+
100120
onMounted(() => {
101121
init()
102122
})
@@ -224,15 +244,7 @@ const closeField = () => {
224244
const saveField = () => {
225245
workspaceFormRef.value.validate((res: any) => {
226246
if (res) {
227-
const req = workspaceForm.id ? workspaceUpdate : workspaceCreate
228-
req(workspaceForm).then(() => {
229-
ElMessage({
230-
type: 'success',
231-
message: t('common.save_success'),
232-
})
233-
init()
234-
fieldDialog.value = false
235-
})
247+
duplicateName()
236248
}
237249
})
238250
}

0 commit comments

Comments
 (0)