liudong
2024-08-08 2f5fbb2144ca03477eb91ab36a990ea013065214
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>