dengzedong
2024-10-10 b45bad33154fb97b76e6c54a86609d446f02ad21
src/views/model/mpk/file/MpkForm.vue
@@ -13,8 +13,23 @@
      >
        <el-divider content-position="left">模型信息</el-divider>
        <el-row :gutter="8">
          <el-col :span="20">
            <el-form-item label="模型名称" prop="pyName">
          <el-col :span="12">
            <el-form-item label="模型类型" prop="pyType">
              <el-radio-group v-model="formData.pyType" @change="pyTypeChange">
                <el-radio-button
                  v-for="dict in getDictOptions(DICT_TYPE.MODEL_TYPE)"
                  :key="dict.label"
                  :label="dict.value"
                >
                  {{ dict.label }}
                </el-radio-button>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="8">
          <el-col :span="8">
            <el-form-item label="模型文件" prop="pyName">
              <el-input disabled v-model="formData.pyName" placeholder=""/>
            </el-form-item>
          </el-col>
@@ -32,35 +47,22 @@
              :on-success="submitFormSuccess"
              accept=".pyd"
            >
              <el-button type="primary">
                <Icon icon="ep:upload"/>
                模型上传
              </el-button>
              <el-tooltip content="上传.pyd算法文件" placement="top" effect="light">
                <el-button type="primary">
                  <Icon icon="ep:upload"/>
                  模型上传
                </el-button>
              </el-tooltip>
            </el-upload>
          </el-col>
        </el-row>
        <el-row :gutter="8">
          <el-col :span="12">
            <el-form-item label="模型中文名称" prop="pyChineseName">
            <el-form-item label="模型名称" prop="pyChineseName">
              <el-input v-model="formData.pyChineseName" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="模型类型" prop="pyType">
              <el-select
                v-model="formData.pyType"
                placeholder="请选择"
                @change="pyTypeChange"
              >
                <el-option
                  v-for="dict in getDictOptions(DICT_TYPE.MODEL_TYPE)"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="8">
          <el-col :span="12">
@@ -76,20 +78,36 @@
        </el-row>
        <el-row :gutter="8">
          <el-col :span="12">
            <el-form-item label="所属菜单" prop="menuName">
              <el-input v-model="formData.menuName" placeholder=""/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="所属组" prop="groupName">
              <el-input v-model="formData.groupName" placeholder=""/>
            <el-form-item label="所属目录" prop="menuAndGroup">
              <el-cascader
                style="width: 100%;"
                v-model="formData.menuAndGroup"
                :options="treeData"
                @change="handleChange"
              />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="8">
          <el-col :span="12">
            <el-form-item label="icon" prop="icon">
              <el-input v-model="formData.icon" placeholder=""/>
            <el-form-item label="图标" prop="icon">
              <el-select v-model="formData.icon" clearable filterable placeholder="请选择图标">
                <el-option
                  v-for="item in iconList"
                  :key="item.iconName"
                  :label="item.iconName"
                  :value="item.iconName"
                >
                  <span style="float: left">{{ item.iconName}}</span>
                  <span
                      style="
                      float: right;
                      color: var(--el-text-color-secondary);
                      font-size: 13px;">
                    <img :src="'/SimtreeUnitImage/' + item.iconName" style="height: 24px;" :alt=" item.iconDesc" />
                  </span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
@@ -174,27 +192,12 @@
                  <el-table-column align="center" label="参数类型" prop="valueType"/>
                  <el-table-column align="center" label="最大值" prop="max"/>
                  <el-table-column align="center" label="最小值" prop="min"/>
                  <!--                <el-table-column align="center" label="选项" width="50">-->
                  <!--                  <template #default="props">-->
                  <!--                    <div v-if="props.row.type === 'select'">-->
                  <!--                      <el-popover placement="left" :width="400">-->
                  <!--                        <template #reference>-->
                  <!--                          <Icon icon="ep:more" />-->
                  <!--                        </template>-->
                  <!--                        <el-table width="50%" :data="props.row.settingSelects" border size="small">-->
                  <!--                          <el-table-column align="center" label="key" prop="selectKey"/>-->
                  <!--                          <el-table-column align="center" label="name" prop="name"/>-->
                  <!--                        </el-table>-->
                  <!--                      </el-popover>-->
                  <!--                    </div>-->
                  <!--                  </template>-->
                  <!--                </el-table-column>-->
                  <el-table-column label="操作" fixed="right" header-align="center" align="center" width="100">
                    <template #default="scope">
                      <el-button
                        @click="updateSetting(scope.row)"
                        key="danger"
                        type="danger"
                        type="primary"
                        link
                      >修改
                      </el-button>
@@ -234,8 +237,10 @@
  <SettingForm ref="settingFormRef"/>
</template>
<script lang="ts" setup>
  import {DICT_TYPE, getDictOptions} from '@/utils/dict'
  import * as MpkApi from '@/api/mpk/mpk'
  import {DICT_TYPE, getDictOptions, getIntDictOptions} from '@/utils/dict'
  import * as MpkApi from '@/api/model/mpk/mpk'
  import * as MpkIconApi from '@/api/model/mpk/icon'
  import * as MpkMenuApi from '@/api/model/mpk/menu'
  import {FormRules} from 'element-plus'
  import {getAccessToken, getTenantId} from "@/utils/auth";
  import SettingForm from './SettingForm.vue'
@@ -249,7 +254,10 @@
  const route = useRoute() // 路由
  const router = useRouter();
  /** settingForm弹窗 */
  const treeData = ref([])
  const iconList = ref([] as MpkIconApi.MpkIconVO)
/** settingForm弹窗 */
  const settingFormRef = ref()
  // 添加setting
  const addSetting = (methodSettings) => {
@@ -259,6 +267,10 @@
  // 修改setting
  const updateSetting = (info) => {
    settingFormRef.value.open(info)
  }
  // 删除setting
  const deleteSetting = (methodSettings,index) => {
    methodSettings.splice(index, 1);
  }
  const methodExpandedRowKeys = ref([])
@@ -271,7 +283,7 @@
    pyChineseName: undefined,
    pyName: undefined,
    pkgName: undefined,
    pyType: undefined,
    pyType: 'predict',
    className: undefined,
    pyModule: undefined,
    icon: undefined,
@@ -280,6 +292,7 @@
    remark: undefined,
    modelMethods: [],
    filePath: undefined,
    menuAndGroup: [],
  })
  const formRules = reactive<FormRules>({
@@ -301,7 +314,7 @@
    pyModule: [
      {required: true, message: '模型路径不能为空', trigger: 'blur'}
    ],
    menuName: [
    menuAndGroup: [
      {required: true, message: '所属目录不能为空', trigger: 'blur'}
    ],
  })
@@ -349,7 +362,7 @@
      pyName: undefined,
      pyChineseName: undefined,
      pkgName: undefined,
      pyType: undefined,
      pyType: 'predict',
      className: undefined,
      pyModule: undefined,
      icon: undefined,
@@ -360,6 +373,10 @@
      filePath: undefined
    }
    formRef.value?.resetFields()
  }
  const handleChange = function () {
  }
  const addRow = function () {
@@ -412,6 +429,7 @@
    title.value = t('action.' + type)
    formType.value = type
    resetForm()
    pyTypeChange()
    // 修改时,设置数据
    if (id) {
      formLoading.value = true
@@ -421,6 +439,12 @@
        formLoading.value = false
      }
    }
    // 加载图标列表
    iconList.value = await MpkIconApi.getList()
    // 加载菜单,分组
    treeData.value = await MpkMenuApi.getTree()
  })
  const pyTypeChange = () => {
@@ -431,7 +455,7 @@
          methodName: 'train',
          dataLength: 1,
          model: 0,
          resultKey: undefined,
          resultKey: 'result',
          methodSettings: []
        },
        {