File tree Expand file tree Collapse file tree 5 files changed +52
-21
lines changed
Expand file tree Collapse file tree 5 files changed +52
-21
lines changed Original file line number Diff line number Diff line change 463463 "duplicate_name" : " Duplicate name" ,
464464 "duplicate_name_" : " Duplicate name" ,
465465 "duplicate_account" : " Duplicate account" ,
466+ "repeating_parameters" : " Repeating Parameters" ,
466467 "duplicate_email" : " Duplicate email" ,
467468 "interface_credentials" : " Interface credentials" ,
468469 "no_credentials_yet" : " No credentials yet" ,
Original file line number Diff line number Diff line change 469469 "duplicate_name_" : " 重复姓名" ,
470470 "duplicate_account" : " 重复账号" ,
471471 "duplicate_email" : " 重复邮箱" ,
472+ "repeating_parameters" : " 重复参数" ,
472473 "interface_credentials" : " 接口凭证" ,
473474 "no_credentials_yet" : " 暂无凭证" ,
474475 "intelligent_customer_service" : " SQLBot 智能客服" ,
Original file line number Diff line number Diff line change @@ -69,6 +69,35 @@ const defaultModelListWithSearch = computed(() => {
6969 })
7070})
7171
72+ const duplicateName = async (item : any ) => {
73+ const res = await modelApi .queryAll ()
74+ const names = res .filter ((ele : any ) => ele .id !== item .id ).map ((ele : any ) => ele .name )
75+ if (names .includes (item .name )) {
76+ ElMessage .error (t (' embedded.duplicate_name' ))
77+ return
78+ }
79+
80+ if (! item .id ) {
81+ modelApi .add (item ).then (() => {
82+ beforeClose ()
83+ search ()
84+ ElMessage ({
85+ type: ' success' ,
86+ message: t (' workspace.add_successfully' ),
87+ })
88+ })
89+ return
90+ }
91+ modelApi .edit (item ).then (() => {
92+ beforeClose ()
93+ search ()
94+ ElMessage ({
95+ type: ' success' ,
96+ message: t (' common.save_success' ),
97+ })
98+ })
99+ }
100+
72101const handleDefaultModelChange = (item : any ) => {
73102 const current_default_node = modelList .value .find ((ele : Model ) => ele .default_model )
74103 if (current_default_node ?.id === item .id ) {
@@ -185,25 +214,7 @@ const search = () => {
185214search ()
186215
187216const submit = (item : any ) => {
188- if (! item .id ) {
189- modelApi .add (item ).then (() => {
190- beforeClose ()
191- search ()
192- ElMessage ({
193- type: ' success' ,
194- message: t (' workspace.add_successfully' ),
195- })
196- })
197- return
198- }
199- modelApi .edit (item ).then (() => {
200- beforeClose ()
201- search ()
202- ElMessage ({
203- type: ' success' ,
204- message: t (' common.save_success' ),
205- })
206- })
217+ duplicateName (item )
207218}
208219 </script >
209220
Original file line number Diff line number Diff line change @@ -116,9 +116,22 @@ const addParams = () => {
116116 paramsFormRef .value .submit ()
117117}
118118
119- const submit = (item : any ) => {
119+ const duplicateName = async (item : any ) => {
120+ const arr = advancedSetting .value .filter ((ele : any ) => ele .id !== item .id )
121+ const names = arr .map ((ele : any ) => ele .name )
122+ const keys = arr .map ((ele : any ) => ele .key )
123+ if (names .includes (item .name )) {
124+ ElMessage .error (t (' embedded.duplicate_name' ))
125+ return
126+ }
127+
128+ if (keys .includes (item .key )) {
129+ ElMessage .error (t (' embedded.repeating_parameters' ))
130+ return
131+ }
132+
120133 if (isCreate .value ) {
121- advancedSetting .value .push ({ ... item })
134+ advancedSetting .value .push ({ ... item , id: + new Date () })
122135 beforeClose ()
123136 return
124137 }
@@ -132,6 +145,10 @@ const submit = (item: any) => {
132145 beforeClose ()
133146}
134147
148+ const submit = (item : any ) => {
149+ duplicateName (item )
150+ }
151+
135152const beforeClose = () => {
136153 paramsFormRef .value .close ()
137154 paramsFormDrawer .value = false
Original file line number Diff line number Diff line change @@ -205,6 +205,7 @@ const handleCheckAllChange = (val: any) => {
205205 }
206206}
207207
208+
208209const handleToggleRowSelection = (check : boolean = true ) => {
209210 let i = 0
210211 const ids = multipleSelectionAll .value .map ((ele : any ) => ele .id )
You can’t perform that action at this time.
0 commit comments