From 00d600d4c8445b6729007f50ed7038deb84a13f6 Mon Sep 17 00:00:00 2001 From: zhangxiao <898441624@qq.com> Date: 星期五, 09 八月 2024 20:36:46 +0800 Subject: [PATCH] fix: 修改上传问题 --- src/views/dmx/model/components/addTableName.vue | 89 ++++++++++++++++++++++++-------------------- 1 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/views/dmx/model/components/addTableName.vue b/src/views/dmx/model/components/addTableName.vue index 45ace16..8578ad7 100644 --- a/src/views/dmx/model/components/addTableName.vue +++ b/src/views/dmx/model/components/addTableName.vue @@ -2,7 +2,7 @@ <!-- 娣诲姞妯″瀷 --> <a-modal v-model:visible="addTabVisible" - title="娣诲姞妯″紡" + :title="title" @before-open="handleOpened" @cancel="handleCancel" :footer="false" @@ -66,10 +66,12 @@ ref, computed, } from 'vue'; - import { addLlmFactory, getLlmDetail } from '@/api/model'; + import { addLlmFactory, getLlmDetail, editLlmFactory } from '@/api/model'; import { Message } from '@arco-design/web-vue'; const addTabVisible = defineModel('tabShow'); + + const httpUrl = localStorage.getItem('httpUrl'); const loading = ref(false); const props = defineProps({ task_id: { @@ -79,6 +81,10 @@ nameList: { type: Object, default: {}, + }, + title: { + type: String, + default: '娣诲姞妯″瀷', }, }); const editList = computed(() => props.nameList); @@ -113,23 +119,40 @@ console.log(editList, 9999); formRef.value.validate().then(async (res) => { if (!res) { - await addLlmFactory({ - name: form.name, - tags: form.tags, - api_base: form.api_base, - // all_params: all_params, - logo: imageUrls.value[0], - }) - .then((resData) => { - if ((resData as any).code === 200) { - emit('refresh-parent'); - addTabVisible.value = false; - Message.success('娣诲姞鎴愬姛'); - } + if (props.title == '缂栬緫妯″瀷') { + await editLlmFactory({ + name: form.name, + tags: form.tags, + api_base: form.api_base, + // all_params: all_params, + logo: uploadUrl.value[0] || '', }) - .catch(() => { - Message.error('娣诲姞澶辫触'); - }); + .then((resData) => { + if ((resData as any).code === 200) { + emit('refresh-parent'); + addTabVisible.value = false; + } + }) + .catch(() => {}); + } else { + await addLlmFactory({ + name: form.name, + tags: form.tags, + api_base: form.api_base, + // all_params: all_params, + logo: uploadUrl.value[0], + }) + .then((resData) => { + if ((resData as any).code === 200) { + emit('refresh-parent'); + addTabVisible.value = false; + Message.success('娣诲姞鎴愬姛'); + } + }) + .catch(() => { + Message.error('娣诲姞澶辫触'); + }); + } } }); }; @@ -145,13 +168,18 @@ const uploadAction = '/api/v1/llm/upload'; // 鏇挎崲涓轰綘鐨勪笂浼燗PI const fileList = ref([]); const imageUrls = ref([]); + const uploadUrl = ref([]); const updateFileList = (newFileList) => { fileList.value = newFileList; }; const handleSuccess = (urls) => { - imageUrls.value = urls; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧� - console.log(urls, 77777); + uploadUrl.value = urls; + + const urlsArr = urls.map((url) => { + return httpUrl + url; + }); + imageUrls.value = urlsArr; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧� }; const handleOpened = (el) => { @@ -164,31 +192,12 @@ formRef.value?.resetFields(); }; - // onMounted(() => { - // if (editList.value) { - // getDetail(); - // } - // }); - - // const getDetail = async () => { - // const data = await getLlmDetail( - // editList.value.llm_factory, - // editList.value.tags - // ); - - // form.urlS = data.data.urlS; - // imageUrls.value = data.data.logo; - // }; - watchEffect(() => { - if (props.nameList) { - console.log(props.nameList); + if (props.nameList && props.title == '缂栬緫妯″瀷') { form.name = props.nameList.llm_factory; form.tags = props.nameList.tags; form.urlS = props.nameList.logo; } - - // getDetail(); }); </script> -- Gitblit v1.8.0