From 87929f7f9e7ba1c18c16ee58f7a689394f565995 Mon Sep 17 00:00:00 2001 From: zhangxiao <898441624@qq.com> Date: 星期二, 06 八月 2024 14:31:35 +0800 Subject: [PATCH] fix: 图片回显 --- src/api/model.ts | 6 +++ src/views/dmx/model/index.vue | 3 + src/components/upload/index.vue | 15 ++++++- src/views/dmx/model/components/addTableName.vue | 78 ++++++++++++++++++++------------------- 4 files changed, 62 insertions(+), 40 deletions(-) diff --git a/src/api/model.ts b/src/api/model.ts index a664cfc..6edf0be 100644 --- a/src/api/model.ts +++ b/src/api/model.ts @@ -71,3 +71,9 @@ export function deleteLlmFactory(name) { return axios.delete(`/api/v1/llm/delete_llm_factory/${name}`); } + +//缂栬緫妯″瀷 +export function editLlmFactory(params) { + return axios.put('/api/v1/llm/edit_llm_factory', params); +} + diff --git a/src/components/upload/index.vue b/src/components/upload/index.vue index 66900de..ffae588 100644 --- a/src/components/upload/index.vue +++ b/src/components/upload/index.vue @@ -10,7 +10,7 @@ </template> <script setup> - import { computed, ref, watch, watchEffect } from 'vue'; + import { computed, ref, onMounted, watch, watchEffect } from 'vue'; const props = defineProps({ limit: { type: Number, @@ -21,7 +21,7 @@ }); const emit = defineEmits(['update:fileList', 'success']); - + const urls = computed(() => props.url); const fileList = ref([]); watch( @@ -41,6 +41,17 @@ } ); + onMounted(() => { + if (urls.value) { + fileList.value = urls.value.split(',').map((item) => ({ + uid: item, + name: item, + status: 'done', + url: item, + })); + } + }); + // console.log(urls.value, 8988); const handleChange = (fileList) => { diff --git a/src/views/dmx/model/components/addTableName.vue b/src/views/dmx/model/components/addTableName.vue index 45ace16..0b5648c 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,7 +66,7 @@ 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'); @@ -79,6 +79,10 @@ nameList: { type: Object, default: {}, + }, + title: { + type: String, + default: '娣诲姞妯″瀷', }, }); const editList = computed(() => props.nameList); @@ -113,23 +117,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: imageUrls.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: imageUrls.value[0], + }) + .then((resData) => { + if ((resData as any).code === 200) { + emit('refresh-parent'); + addTabVisible.value = false; + Message.success('娣诲姞鎴愬姛'); + } + }) + .catch(() => { + Message.error('娣诲姞澶辫触'); + }); + } } }); }; @@ -164,31 +185,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> diff --git a/src/views/dmx/model/index.vue b/src/views/dmx/model/index.vue index 10d127a..0d2955a 100644 --- a/src/views/dmx/model/index.vue +++ b/src/views/dmx/model/index.vue @@ -155,6 +155,7 @@ <addTableName v-model:tabShow="tabShow" :nameList="editList" + :title="title" @refresh-parent="refreshParentMethod" v-if="tabShow" ></addTableName> @@ -216,6 +217,7 @@ const modelType = ref(1); const handleAdd = () => { tabShow.value = true; + title.value = '娣诲姞妯″瀷'; editList.value.llm_factory = tabKey.value; }; const editList = ref({ llm_factory: '' }); @@ -233,6 +235,7 @@ if (type == 1) { tabShow.value = true; editList.value = val; + title.value = '缂栬緫妯″瀷'; editList.value.llm_factory = tabKey.value; } else { modelType.value = 2; -- Gitblit v1.8.0