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/addTableName.vue |   96 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 72 insertions(+), 24 deletions(-)

diff --git a/src/views/dmx/model/components/addTableName.vue b/src/views/dmx/model/components/addTableName.vue
index a6b5631..3b7b9a9 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"
@@ -20,12 +20,12 @@
       <a-form-item field="name" label="妯″瀷鍚嶇О">
         <a-input v-model="form.name" placeholder="璇疯緭鍏ユā鍨嬪悕绉�" />
       </a-form-item>
-      <a-form-item field="apiKey" label="API-Key">
+      <!-- <a-form-item field="apiKey" label="API-Key">
         <a-input v-model="form.apiKey" placeholder="API-Key" />
       </a-form-item>
       <a-form-item field="baseUrl" label="Base-Url">
         <a-input v-model="form.baseUrl" placeholder="Base-Url" />
-      </a-form-item>
+      </a-form-item> -->
       <a-form-item field="tags" label="妯″瀷鎻忚堪">
         <a-textarea
           v-model="form.tags"
@@ -39,6 +39,7 @@
           <Upload
             :action="uploadAction"
             :limit="1"
+            :url="form.urlS"
             @update:fileList="updateFileList"
             @success="handleSuccess"
           ></Upload>
@@ -57,11 +58,23 @@
 </template>
 
 <script lang="ts" setup>
-  import { onMounted, onBeforeMount, reactive, ref, computed } from 'vue';
-  import { addLlmFactory } from '@/api/model';
+  import {
+    onMounted,
+    onBeforeMount,
+    watchEffect,
+    reactive,
+    ref,
+    computed,
+  } from 'vue';
+  import { addLlmFactory, getLlmDetail, editLlmFactory } from '@/api/model';
   import { Message } from '@arco-design/web-vue';
+  import { userModelState } from '@/store';
+
+  const modelStore = userModelState();
 
   const addTabVisible = defineModel('tabShow');
+
+  const httpUrl = modelStore.hrefUrl;
   const loading = ref(false);
   const props = defineProps({
     task_id: {
@@ -71,6 +84,10 @@
     nameList: {
       type: Object,
       default: {},
+    },
+    title: {
+      type: String,
+      default: '娣诲姞妯″瀷',
     },
   });
   const editList = computed(() => props.nameList);
@@ -82,8 +99,9 @@
     api_base: '',
     tags: '',
     logo: '',
+    urlS: '',
   });
-  const formRef = ref(null);
+  const formRef = ref();
 
   const rules = {
     name: [
@@ -104,23 +122,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('娣诲姞澶辫触');
+            });
+        }
       }
     });
   };
@@ -136,13 +171,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) => {
@@ -154,6 +194,14 @@
     });
     formRef.value?.resetFields();
   };
+
+  watchEffect(() => {
+    if (props.nameList && props.title == '缂栬緫妯″瀷') {
+      form.name = props.nameList.llm_factory;
+      form.tags = props.nameList.tags;
+      form.urlS = props.nameList.logo;
+    }
+  });
 </script>
 
 <script lang="ts">

--
Gitblit v1.8.0