9292 </el-dialog >
9393</template >
9494<script setup lang="ts">
95- import { ref , reactive , watch } from ' vue'
95+ import { ref , reactive , watch , computed } from ' vue'
9696import { useRoute } from ' vue-router'
9797import type { FormInstance } from ' element-plus'
98- import documentApi from ' @/api/knowledge/document'
9998import { MsgSuccess } from ' @/utils/message'
10099import { hitHandlingMethod } from ' @/enums/document'
100+ import { loadSharedApi } from ' @/utils/dynamics-api/shared-api'
101101import { t } from ' @/locales'
102102const route = useRoute ()
103103const {
104- params : { id }
104+ params : { id },
105105} = route as any
106106
107107const props = defineProps ({
108- title: String
108+ title: String ,
109+ })
110+
111+ const apiType = computed (() => {
112+ if (route .path .includes (' shared' )) {
113+ return ' systemShare'
114+ } else if (route .path .includes (' resource-management' )) {
115+ return ' systemManage'
116+ } else {
117+ return ' workspace'
118+ }
109119})
110120
111121const emit = defineEmits ([' refresh' ])
@@ -116,7 +126,7 @@ const form = ref<any>({
116126 source_url: ' ' ,
117127 selector: ' ' ,
118128 hit_handling_method: ' optimization' ,
119- directly_return_similarity: 0.9
129+ directly_return_similarity: 0.9 ,
120130})
121131
122132// 文档设置
@@ -131,16 +141,16 @@ const rules = reactive({
131141 {
132142 required: true ,
133143 message: t (' views.document.form.source_url.requiredMessage' ),
134- trigger: ' blur'
135- }
144+ trigger: ' blur' ,
145+ },
136146 ],
137147 directly_return_similarity: [
138148 {
139149 required: true ,
140150 message: t (' views.document.form.similarity.requiredMessage' ),
141- trigger: ' blur'
142- }
143- ]
151+ trigger: ' blur' ,
152+ },
153+ ],
144154})
145155
146156const dialogVisible = ref <boolean >(false )
@@ -151,7 +161,7 @@ watch(dialogVisible, (bool) => {
151161 source_url: ' ' ,
152162 selector: ' ' ,
153163 hit_handling_method: ' optimization' ,
154- directly_return_similarity: 0.9
164+ directly_return_similarity: 0.9 ,
155165 }
156166 isImport .value = false
157167 documentType .value = ' '
@@ -167,7 +177,7 @@ const open = (row: any, list: Array<string>) => {
167177 form .value = {
168178 hit_handling_method: row .hit_handling_method ,
169179 directly_return_similarity: row .directly_return_similarity ,
170- ... row .meta
180+ ... row .meta ,
171181 }
172182 isImport .value = false
173183 } else if (list ) {
@@ -188,40 +198,46 @@ const submit = async (formEl: FormInstance | undefined) => {
188198 if (isImport .value ) {
189199 const obj = {
190200 source_url_list: form .value .source_url .split (' \n ' ),
191- selector: form .value .selector
201+ selector: form .value .selector ,
192202 }
193- documentApi .postWebDocument (id , obj , loading ).then (() => {
194- MsgSuccess (t (' views.document.tip.importMessage' ))
195- emit (' refresh' )
196- dialogVisible .value = false
197- })
203+ loadSharedApi ({ type: ' document' , systemType: apiType .value })
204+ .postWebDocument (id , obj , loading )
205+ .then (() => {
206+ MsgSuccess (t (' views.document.tip.importMessage' ))
207+ emit (' refresh' )
208+ dialogVisible .value = false
209+ })
198210 } else {
199211 if (documentId .value ) {
200212 const obj = {
201213 hit_handling_method: form .value .hit_handling_method ,
202214 directly_return_similarity: form .value .directly_return_similarity ,
203215 meta: {
204216 source_url: form .value .source_url ,
205- selector: form .value .selector
206- }
217+ selector: form .value .selector ,
218+ },
207219 }
208- documentApi .putDocument (id , documentId .value , obj , loading ).then (() => {
209- MsgSuccess (t (' common.settingSuccess' ))
210- emit (' refresh' )
211- dialogVisible .value = false
212- })
220+ loadSharedApi ({ type: ' document' , systemType: apiType .value })
221+ .putDocument (id , documentId .value , obj , loading )
222+ .then (() => {
223+ MsgSuccess (t (' common.settingSuccess' ))
224+ emit (' refresh' )
225+ dialogVisible .value = false
226+ })
213227 } else if (documentList .value .length > 0 ) {
214228 // 批量设置
215229 const obj = {
216230 hit_handling_method: form .value .hit_handling_method ,
217231 directly_return_similarity: form .value .directly_return_similarity ,
218- id_list: documentList .value
232+ id_list: documentList .value ,
219233 }
220- documentApi .putBatchEditHitHandling (id , obj , loading ).then (() => {
221- MsgSuccess (t (' common.settingSuccess' ))
222- emit (' refresh' )
223- dialogVisible .value = false
224- })
234+ loadSharedApi ({ type: ' document' , systemType: apiType .value })
235+ .putBatchEditHitHandling (id , obj , loading )
236+ .then (() => {
237+ MsgSuccess (t (' common.settingSuccess' ))
238+ emit (' refresh' )
239+ dialogVisible .value = false
240+ })
225241 }
226242 }
227243 }
0 commit comments