dongyukun
19 小时以前 4092339f2637a2d9b100050787699fb347416693
src/views/model/sche/model/ScheduleModelForm.vue
@@ -43,17 +43,13 @@
      </el-row>
      <el-divider content-position="left">模型信息</el-divider>
      <div style="width: 120px;text-align: right;margin-bottom: 8px">
        <el-popover placement="right" :width="300" trigger="click" ref="modelPopover"
                    @before-enter="model = undefined">
        <el-popover placement="right" :width="300" trigger="click" ref="modelPopover" @before-enter="model = undefined">
          <template #reference>
            <span style="color: #409eff;cursor: pointer">关联模型信息</span>
          </template>
          <template #default>
            <div style="display:flex;flex-direction: row;align-items: center;">
              <el-cascader style="width: 100%" v-model="model" placeholder="选择模型"
                           :teleported="false" @change="changeModel" :options="scheduleModelList" v-if="formData.invocation != '4'"/>
              <el-cascader style="width: 100%" v-model="model" placeholder="选择模型"
                           :teleported="false" @change="changeAiModel" :options="aiModelList" v-if="formData.invocation === '4'"/>
              <el-cascader style="width: 100%" v-model="model" placeholder="选择模型" :teleported="false" @change="changeModel" :options="scheduleModelList"/>
            </div>
          </template>
        </el-popover>
@@ -78,8 +74,7 @@
        </el-col>
        <el-col :span="12">
          <el-form-item label="参数数量" prop="portLength">
            <el-input-number v-model="formData.portLength" :min="0" controls-position="right"
                             :disabled="true"/>
            <el-input-number v-model="formData.portLength" :min="0" controls-position="right" :disabled="true" />
          </el-form-item>
        </el-col>
      </el-row>
@@ -128,8 +123,7 @@
          width="150"
          align="center">
          <template #default="scope">
            <el-select v-model="scope.row.modelparamtype" placeholder="请选择"
                       @change="changeModelparamtype(scope.row)">
            <el-select v-model="scope.row.modelparamtype" placeholder="请选择" @change="changeModelparamtype(scope.row)">
              <el-option
                v-for="dict in getStrDictOptions(DICT_TYPE.MODEL_PARAM_TYPE)"
                :key="dict.value"
@@ -170,8 +164,7 @@
          width="160"
          align="center">
          <template #default="scope">
            <el-input-number v-model="scope.row.datalength" :min="0" clearable
                             controls-position="right"
            <el-input-number v-model="scope.row.datalength" :min="0" clearable controls-position="right"
                             style="width:100%;hight:100%"/>
          </template>
        </el-table-column>
@@ -281,14 +274,12 @@
        </el-table-column>
        <el-table-column prop="resultPort" label="角标1" align="center" width="100">
          <template #default="scope">
            <el-input-number :min="0" clearable controls-position="right" size="small"
                             v-model="scope.row.resultPort" style="width:100%;height:100%"/>
            <el-input-number :min="0" clearable controls-position="right" size="small" v-model="scope.row.resultPort" style="width:100%;height:100%"/>
          </template>
        </el-table-column>
        <el-table-column prop="resultIndex" label="角标2" align="center" width="100">
          <template #default="scope">
            <el-input-number :min="0" clearable controls-position="right" size="small"
                             v-model="scope.row.resultIndex" style="width:100%;height:100%"/>
            <el-input-number :min="0" clearable controls-position="right" size="small" v-model="scope.row.resultIndex" style="width:100%;height:100%"/>
          </template>
        </el-table-column>
        <el-table-column prop="isWrite" label="是否下发" align="center" width="100">
@@ -313,7 +304,7 @@
            />
          </template>
        </el-table-column>
        <el-table-column prop="disturbancePointNo" label="无扰切换点位" align="center" min-width="200">
        <el-table-column prop="disturbancePointNo’" label="无扰切换点位" align="center" min-width="200">
          <template #default="scope">
            <el-select-v2
              v-model="scope.row.disturbancePointNo"
@@ -394,8 +385,6 @@
  const modelparamListMap = ref({})
  // 调度模型列表
  const scheduleModelList = ref([])
  const aiModelList = ref([])
  const aiModel = ref([])
  const model = ref()
  const modelPopover = ref()
@@ -446,8 +435,6 @@
    modelparamListMap.value = await ScheduleModelApi.getModelParamList(id)
    // 加载调度模型列表
    getScheduleModelList()
    // 加载ai模型列表
    getAiModelList()
  }
  defineExpose({open}) // 提供 open 方法,用于打开弹窗
@@ -538,24 +525,6 @@
    }
  }
  const getAiModelList = async () => {
    aiModel.value = await MpkApi.aiList(null)
    if (aiModel.value && aiModel.value.length > 0) {
      aiModelList.value = aiModel.value.map(e => {
        return {
          value: e.id,
          label: e.name,
          children: e.children.map(template => {
            return {
              value: template.id,
              label: template.questionName
            }
          })
        }
      })
    }
  };
  // 选择调度模型
  const changeModel = async () => {
    // 校验
@@ -563,14 +532,7 @@
      ElMessageBox.confirm(
        '是否更新输入参数?',
        '提示',
        {
          confirmButtonText: '是',
          cancelButtonText: '否',
          type: 'success',
          icon: markRaw(Refresh),
          closeOnClickModal: false,
          closeOnPressEscape: false
        }
        {confirmButtonText: '是', cancelButtonText: '否', type: 'success',icon: markRaw(Refresh),closeOnClickModal:false,closeOnPressEscape:false}
      ).then(() => {
        relevanceModel(true)
      }).catch(() => {
@@ -580,69 +542,6 @@
      message.error("请先选择模型")
    }
  }
  // 选择ai模型
  const changeAiModel = () => {
    if (!model.value && model.value.length > 0) return
    // 查找选中的模型组
    const modelGroup = aiModel.value.find(
      group => group.id === model.value[0]
    )
    // 查找选中的模板
    const template = modelGroup?.children.find(
      t => t.id === model.value[1]
    )
    if (!modelGroup || !template) return
    // 弹窗确认
    ElMessageBox.confirm(
      '是否更新输入参数?',
      '提示',
      {
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'success',
        icon: markRaw(Refresh),
        closeOnClickModal: false,
        closeOnPressEscape: false
      }
    ).then(() => {
      // 更新表单数据
      updateAiModelForm(modelGroup, template, true)
    }).catch(() => {
      updateAiModelForm(modelGroup, template, false)
    })
  }
  // 更新AI模型表单数据
  const updateAiModelForm = (modelGroup, template, updateParams) => {
    // 设置基本信息
    formData.value.modelName = modelGroup.name
    formData.value.methodName = template.questionName
    formData.value.portLength = template.dataLength
    // 设置参数列表转换
    formData.value.settingList = template.settingList.map(setting => {
      return {
        key: setting.settingKey,
        name: setting.settingName,
        value: setting.settingValue,
        valuetype: 'string'
      }
    })
      // 输入参数
      let paramList = []
      for (let i = 0; i < formData.value.portLength; i++) {
        paramList.push({
          modelparamportorder: i + 1 + '',
          modelparamorder: '1',
          modelparamtype: '',
          modelparamid: '',
          datalength: 0
        })
      }
      formData.value.paramList = paramList
    }
  function relevanceModel(refreshParam) {
    const modelInfo = model.value[0]
@@ -693,7 +592,6 @@
  function changeModelparamtype(row) {
    row.modelparamid = ''
  }
  const addRowOut = function () {
    if (formData.value.modelOut === undefined) {
      formData.value.modelOut = []