From 88b1281f51f590f88ae581d2a14b877da9439250 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期一, 12 八月 2024 14:55:37 +0800
Subject: [PATCH] fix: 只能体修改样式

---
 src/views/dmx/model/components/addPageModel.vue |  112 +++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 74 insertions(+), 38 deletions(-)

diff --git a/src/views/dmx/model/components/addPageModel.vue b/src/views/dmx/model/components/addPageModel.vue
index e0b0771..9a4aa7f 100644
--- a/src/views/dmx/model/components/addPageModel.vue
+++ b/src/views/dmx/model/components/addPageModel.vue
@@ -46,19 +46,19 @@
         <a-form-item field="api_base" label="鍩虹URL">
           <a-input v-model="form.api_base" placeholder="璇疯緭鍏ュ熀纭�URL" />
         </a-form-item>
-
-        <a-form-item
+        <!-- <a-form-item
           field="raptor"
           label="鏄惁鏀寔 Vision"
           v-if="form.model_type === 'chat'"
         >
           <a-switch v-model="form.raptor" />
-        </a-form-item>
+        </a-form-item> -->
         <a-form-item field="logo" label="妯″瀷鍥剧墖">
           <a-space direction="vertical" :style="{ width: '100%' }">
             <Upload
               :action="uploadAction"
               :limit="1"
+              :url="form.urlS"
               @update:fileList="updateFileList"
               @success="handleSuccess"
             ></Upload>
@@ -111,6 +111,7 @@
             <Upload
               :action="uploadAction"
               :limit="1"
+              :url="form.urlS"
               @update:fileList="updateFileList"
               @success="handleSuccess"
             ></Upload>
@@ -131,11 +132,14 @@
 </template>
 
 <script lang="ts" setup>
-  import { reactive, ref, computed, watch } from 'vue';
-  import { addLlm, getLlmDetail } from '@/api/model';
+  import { reactive, ref, computed, watch, watchEffect, onMounted } from 'vue';
+  import { addLlm, getLlmDetail, editLlm } from '@/api/model';
   import { Modal, Message } from '@arco-design/web-vue';
   import message from '@arco-design/web-vue/es/message';
   import { resolveUnref } from '@vueuse/core';
+  import { userModelState } from '@/store';
+
+  const modelStore = userModelState();
 
   const addPageModelVisible = defineModel('show');
   const loading = ref(false);
@@ -161,13 +165,6 @@
   const isType = computed(() => props.type);
   const editList = computed(() => props.editList);
 
-  watch(
-    () => editList.value.name,
-    (newValue) => {
-      getDetail();
-    }
-  );
-
   const form = reactive({
     size: 'medium',
     name: '',
@@ -181,15 +178,16 @@
     volc_sk: '',
     logo: '',
     radio: 'radio one',
+    urlS: '',
     slider: 5,
     score: 5,
     switch: false,
     multiSelect: ['section one'],
     treeSelect: '',
     raptor: false,
-    addFomList: [],
+    addFomList: <any[]>[],
   });
-  const form_ref = ref(null);
+  const form_ref = ref();
 
   const rules = {
     model_type: [
@@ -226,42 +224,70 @@
 
   const uploadAction = '/api/v1/llm/upload'; // 鏇挎崲涓轰綘鐨勪笂浼燗PI
   const fileList = ref([]);
-  const imageUrls = ref([]);
+  const imageUrls = ref<any[]>([]);
+  const uploadUrl = ref([]);
+  const httpUrl = modelStore.hrefUrl;
 
   const updateFileList = (newFileList) => {
     fileList.value = newFileList;
-    console.log(newFileList, 88);
   };
 
   const handleSuccess = (urls) => {
-    imageUrls.value = urls; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧�
+    uploadUrl.value = urls;
+
+    const urlsArr = urls.map((url) => {
+      return httpUrl + url;
+    });
+    imageUrls.value = urlsArr; // 鎷垮埌涓婁紶鐨勫浘鐗囧湴鍧�
   };
   const emit = defineEmits(['refresh-parent']);
   const handleSubmit = ({ values, errors }) => {
     const all_params = form.addFomList.map((item) => {
-      console.log(item, 8888);
       return item.name + ':' + item.value;
     });
     form_ref.value
       ?.validate()
       .then(async (res) => {
         if (!res) {
-          const data = await addLlm({
-            llm_factory: editList.value.llm_factory,
-            llm_name: form.llm_name,
-            model_type: form.model_type,
-            volc_ak: form.volc_ak,
-            volc_sk: form.volc_sk,
-            api_base: form.api_base,
-            raptor: form.raptor,
-            all_params: all_params,
-            logo: imageUrls.value[0],
-          });
-          if ((data as any).retmsg == 'success') {
-            message.success('娣诲姞鎴愬姛');
-            emit('refresh-parent');
+          if (props.title == '缂栬緫') {
+            console.log(imageUrls.value, 999);
+            const data = await editLlm({
+              llm_factory: editList.value.llm_factory,
+              llm_name: form.llm_name,
+              model_type: form.model_type,
+              volc_ak: form.volc_ak,
+              volc_sk: form.volc_sk,
+              api_base: form.api_base,
+              all_params: all_params,
+              logo: uploadUrl.value[0] || '',
+            });
+
+            if ((data as any).code == 200) {
+              message.success('娣诲姞鎴愬姛');
+              addPageModelVisible.value = false;
+              emit('refresh-parent');
+            } else {
+              message.error('娣诲姞澶辫触');
+            }
           } else {
-            message.error('娣诲姞澶辫触');
+            const data = await addLlm({
+              llm_factory: editList.value.llm_factory,
+              llm_name: form.llm_name,
+              model_type: form.model_type,
+              volc_ak: form.volc_ak,
+              volc_sk: form.volc_sk,
+              api_base: form.api_base,
+              all_params: all_params,
+              logo: uploadUrl.value[0] || '',
+            });
+
+            if ((data as any).code == 200) {
+              message.success('娣诲姞鎴愬姛');
+              addPageModelVisible.value = false;
+              emit('refresh-parent');
+            } else {
+              message.error('娣诲姞澶辫触');
+            }
           }
         }
       })
@@ -330,18 +356,28 @@
       editList.value.llm_factory,
       editList.value.name
     );
-    console.log(data.data, 8888);
+
     form.llm_name = data.data.llm_name;
     form.model_type = data.data.model_type;
     form.volc_ak = data.data.volc_ak;
     form.volc_sk = data.data.volc_sk;
     form.api_base = data.data.api_base;
     form.raptor = data.data.raptor;
-    form.addFomList = data.data.all_params.map((item) => {
-      return { name: item.split(':')[0], value: item.split(':')[1] };
-    });
-    imageUrls.value = data.data.logo;
+    form.urlS = data.data.logo;
+    if (JSON.parse(data.data.all_params).length > 0) {
+      form.addFomList = JSON.parse(data.data.all_params).map((item) => {
+        return { name: item.split(':')[0], value: item.split(':')[1] };
+      });
+    }
+
+    imageUrls.value.push(httpUrl + data.data.logo);
   };
+
+  watchEffect(() => {
+    if (props.editList.name) {
+      getDetail();
+    }
+  });
 </script>
 <style scoped lang="less">
   .addInput {

--
Gitblit v1.8.0