zhangxiao
2024-08-06 87929f7f9e7ba1c18c16ee58f7a689394f565995
fix: 图片回显
4个文件已修改
102 ■■■■■ 已修改文件
src/api/model.ts 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/upload/index.vue 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dmx/model/components/addTableName.vue 78 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/dmx/model/index.vue 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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);
}
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) => {
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>
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;