From 36885d9fdc194ec984e257da0950478ebcb33288 Mon Sep 17 00:00:00 2001
From: dengzedong <dengzedong@email>
Date: 星期五, 20 十二月 2024 14:07:35 +0800
Subject: [PATCH] mergeItem添加pointId

---
 src/views/model/pre/item/MmPredictItemForm.vue |  180 +++++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 129 insertions(+), 51 deletions(-)

diff --git a/src/views/model/pre/item/MmPredictItemForm.vue b/src/views/model/pre/item/MmPredictItemForm.vue
index cb01f79..22e5776 100644
--- a/src/views/model/pre/item/MmPredictItemForm.vue
+++ b/src/views/model/pre/item/MmPredictItemForm.vue
@@ -1,5 +1,5 @@
 <template>
-  <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%">
+  <Dialog v-model="dialogVisible" :title="dialogTitle" width="60%">
     <el-form
       ref="formRef"
       v-loading="formLoading"
@@ -78,7 +78,7 @@
       <el-row>
         <el-col :span="12">
           <el-form-item label="管网" prop="dmModuleItem.moduleid">
-            <el-select v-model="dataForm.dmModuleItem.moduleid" placeholder="请选择">
+            <el-select v-model="dataForm.dmModuleItem.moduleid" placeholder="请选择" @change="clearExpressionList">
               <el-option
                 v-for="item in moduleList"
                 :key="item.id"
@@ -103,10 +103,26 @@
       </el-row>
       <el-row v-if="dataForm.itemtypename === 'MergeItem'">
         <el-col :span="12">
-          <el-form-item label="预测长度">
+          <el-form-item label="预测长度" prop="mmPredictItem.predictlength">
             <el-input
+              @change="clearExpressionList"
               v-model="dataForm.mmPredictItem.predictlength" placeholder="预测长度"
               maxlength="5"/>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="真实数据点">
+            <el-select
+              v-model="dataForm.pointId"
+              filterable
+              clearable
+              placeholder="请选择">
+              <el-option
+                v-for="item in pointList"
+                :key="item.id"
+                :label="item.pointName"
+                :value="item.id"/>
+            </el-select>
           </el-form-item>
         </el-col>
       </el-row>
@@ -135,9 +151,7 @@
               <Icon icon="ep:upload"/>
               上传模型
             </el-button>
-            <el-button
-              size="small" type="primary" @click="setReplaceModelOnly(true)"
-              v-if="formType.value === 'update'">
+            <el-button type="primary" plain @click="setReplaceModelOnly(true)">
               <Icon icon="ep:upload"/>
               更新模型
             </el-button>
@@ -146,7 +160,7 @@
       </el-row>
       <el-row v-if="dataForm.itemtypename === 'NormalItem'">
         <el-col :span="12">
-          <el-form-item label="关联项目">
+          <el-form-item label="关联项目" prop="mmPredictModel.mpkprojectid">
             <el-select v-model="dataForm.mmPredictModel.mpkprojectid" placeholder="请选择">
               <el-option
                 v-for="item in mpkProjectList"
@@ -201,7 +215,8 @@
       <el-divider content-position="left" v-if="dataForm.itemtypename === 'NormalItem'">模型输出
       </el-divider>
       <el-button
-        @click="addItemOutput(dataForm.mmItemOutputList)"
+        v-if="dataForm.itemtypename === 'NormalItem'"
+        @click="addItemOutput()"
         type="primary"
         size="small">
         添加
@@ -212,12 +227,12 @@
         border
         style="width: 100%; margin-top: 5px;">
         <el-table-column prop="outputorder" label="排序" align="center" width="80px"/>
-        <el-table-column label="结果" align="center" width="150px">
+        <el-table-column label="结果KEY" align="center" width="150px">
           <template #default="scope">
             <el-input v-model="scope.row.resultstr" placeholder="请输入"/>
           </template>
         </el-table-column>
-        <el-table-column label="结果数据类型" align="center" width="150px">
+        <el-table-column label="结果类型" align="center" width="150px">
           <template #default="scope">
             <el-select
               v-model="scope.row.resultType"
@@ -232,11 +247,16 @@
             </el-select>
           </template>
         </el-table-column>
-        <el-table-column label="索引" align="center" width="120px">
+        <el-table-column label="索引" align="center" width="100px">
           <template #default="scope">
             <el-input-number style="width:100%;hight:100%" :disabled="scope.row.resultType !== 2"
                              v-model="scope.row.resultIndex" :min="0" step-strictly
                              controls-position="right"/>
+          </template>
+        </el-table-column>
+        <el-table-column label="结果名称" align="center" width="150px">
+          <template #default="scope">
+            <el-input v-model="scope.row.resultName" placeholder="请输入"/>
           </template>
         </el-table-column>
         <el-table-column label="数据点" align="center">
@@ -244,6 +264,7 @@
             <el-select
               v-model="scope.row.pointid"
               filterable
+              clearable
               @change="(value) => changeOutputPoint(value,scope.row)"
               placeholder="请选择">
               <el-option
@@ -275,9 +296,10 @@
         <el-table-column prop="key" label="键" align="center" min-width="150"/>
         <el-table-column prop="name" label="名称" align="center" min-width="150"/>
         <el-table-column prop="valuetype" label="类型" align="center" min-width="150"/>
-        <el-table-column prop="" label="值" align="center" min-width="150">
+        <el-table-column prop="" label="值" align="center" min-width="200">
           <template #default="scope">
-            <el-input size="mini" v-model="scope.row.value" maxlength="256"
+            <el-input size="mini" v-model="scope.row.value" maxlength="1000"
+                      :disabled="scope.row.key === 'pyFile'"
                       style="width:100%;height:100%"/>
           </template>
         </el-table-column>
@@ -307,7 +329,26 @@
         </el-table-column>
         <el-table-column prop="" label="参数名称" align="center">
           <template #default="scope">
-            <el-select
+            <el-select v-if="scope.row.modelparamtype === 'NormalItem'"
+              v-model="scope.row.modelparamid"
+              placeholder="请选择"
+              filterable
+              @change="changeModelparam(scope.row)"
+              style="width: 100%">
+              <el-option-group
+                v-for="group in modelparamListMap['NormalItem']"
+                :key="group.value"
+                :label="group.label"
+              >
+                <el-option
+                  v-for="item in group.children"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                />
+              </el-option-group>
+            </el-select>
+            <el-select v-else
               v-model="scope.row.modelparamid"
               filterable
               @change="changeModelparam(scope.row)"
@@ -336,7 +377,7 @@
               添加
             </el-button>
             <el-button
-              @click="deleteRow(scope.$index, dataForm.mmModelParamList)"
+              @click="deleteRow(scope.$index, scope.row, dataForm.mmModelParamList)"
               type="text"
               size="mini">
               删除
@@ -353,18 +394,28 @@
         style="width: 100%; margin-top: 5px;">
         <el-table-column
           prop=""
-          label="预测项"
+          label="预测项(NormalItem)"
           align="center">
           <template #default="scope">
             <el-select
               v-model="scope.row.point"
+              placeholder="请选择"
               filterable
-              placeholder="请选择">
-              <el-option
-                v-for="(item, index) in predictItemList"
-                :key="index"
-                :label="item.itemname"
-                :value="item.itemno"/>
+              :no-data-text="'无数据(预测长度:' + dataForm.mmPredictItem.predictlength + ';管网:' + moduleList.find(e => e.id === dataForm.dmModuleItem.moduleid)?.modulename + ')'"
+              @change="changeNormalItemSelect"
+              style="width: 100%">
+              <el-option-group
+                v-for="group in modelparamListMap['NormalItem'].filter(e => e.predictlength == dataForm.mmPredictItem.predictlength && e.moduleid === dataForm.dmModuleItem.moduleid)"
+                :key="group.value"
+                :label="group.label"
+              >
+                <el-option
+                  v-for="item in group.children"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                />
+              </el-option-group>
             </el-select>
           </template>
         </el-table-column>
@@ -441,7 +492,6 @@
 const pointNoList = ref([])
 const pointList = ref([])
 const pointMap = ref({})
-const predictItemList = ref([])
 const modelparamListMap = ref({})
 const modelparamMap = ref({})
 const expressionList = ref([])
@@ -509,7 +559,8 @@
     num: undefined
   },
   mmModelArithSettingsList: [],
-  mmModelParamList: []
+  mmModelParamList: [],
+  pointId: undefined
 })
 const formRules = reactive({
   'mmPredictItem.itemname': [{required: true, message: '预测项名不能为空', trigger: 'blur'}],
@@ -527,6 +578,8 @@
   'mmPredictItem.status': [{required: true, message: '是否启用不能为空', trigger: 'blur'}],
   'dmModuleItem.moduleid': [{required: true, message: '管网不能为空', trigger: 'blur'}],
   'dmModuleItem.itemorder': [{required: true, message: '排序不能为空', trigger: 'blur'}],
+  'mmPredictItem.predictlength': [{required: true, message: '预测长度不能为空', trigger: 'blur'}],
+  'mmPredictModel.mpkprojectid': [{required: true, message: '关联项目不能为空', trigger: 'blur'}],
 
 })
 const formRef = ref() // 表单 Ref
@@ -542,7 +595,7 @@
   setDefaultFields()
 
   // 加载参数列表
-  modelparamListMap.value = await ScheduleModelApi.getModelParamList()
+  modelparamListMap.value = await ScheduleModelApi.getModelParamList(id)
 
   // 获取预测项类型列表
   itemTypeList.value = await MmItemType.getItemTypeList()
@@ -558,11 +611,6 @@
 
   // 获取mpk项目列表
   mpkProjectList.value = await ProjectApi.list()
-
-  // 获取normal列表
-  predictItemList.value = await MmPredictItem.getMmPredictItemList({
-    itemtypename: 'NormalItem'
-  })
 
   // 获取数据点列表
   pointNoList.value = await DaPoint.getPointList(queryParams)
@@ -594,21 +642,40 @@
   if (!formRef) return
   const valid = await formRef.value.validate()
   if (!valid) return
-
   //校验模型输出
-  if (dataForm.value.mmItemOutputList == undefined || dataForm.value.mmItemOutputList.length <= 0) {
-    message.error("模型输出不为空")
-    return
+  if (dataForm.value.itemtypename === 'NormalItem') {
+    if (dataForm.value.mmItemOutputList == undefined || dataForm.value.mmItemOutputList.length <= 0) {
+      message.error("模型输出不为空")
+      return
+    }
+
+    let flag = false
+    dataForm.value.mmItemOutputList.forEach(e => {
+      if (e.resultstr == undefined || e.resultstr === '' || e.resultType == undefined || e.resultType === '' || (e.resultType === 2 && (e.resultIndex == undefined || e.resultIndex === ''))) {
+        message.error("模型输出数据异常")
+        flag = true
+        return
+      }
+    })
+    if (flag) return
+  }
+  if (dataForm.value.itemtypename === 'MergeItem') {
+    if (expressionList.value == undefined || expressionList.value.length <= 1) {
+      message.error("表达式长度低于2")
+      return
+    }
+
+    let flag = false
+    expressionList.value.forEach((e,index) => {
+      if (e.point == undefined || e.point === '' || e.operator == undefined || (e.operator === '' && index != expressionList.value.length - 1)) {
+        message.error("表达式数据异常")
+        flag = true
+        return
+      }
+    })
+    if (flag) return
   }
 
-  let flag = false
-  dataForm.value.mmItemOutputList.forEach(e => {
-    if (e.resultstr == undefined || e.resultstr === '' || e.resultType == undefined || e.resultType === '' || e.pointid == undefined || e.pointid === '' || (e.resultType === 2 && (e.resultIndex == undefined || e.resultIndex === ''))) {
-      message.error("模型输出数据异常")
-      flag = true
-    }
-  })
-  if (flag) return
 
   // 提交请求
   formLoading.value = true
@@ -626,7 +693,7 @@
     }
     if (dataForm.value.mmModelArithSettingsList) {
       for (let item of dataForm.value.mmModelArithSettingsList) {
-        if (item.key === 'lenpredict') {
+        if (item.key === 'predictLength') {
           dataForm.value.mmPredictItem.predictlength = item.value
         }
       }
@@ -674,7 +741,7 @@
         let endIndex = (indexSub == -1 || (indexPlus < indexSub && indexPlus !== -1)) ? indexPlus : indexSub
         expressionList.value.push({
           point: expression.substring(0, endIndex),
-          operator: expression.substring(endIndex, 1)
+          operator: expression.substring(endIndex, endIndex + 1)
         })
         expression = expression.substring(endIndex + 1)
       } else {
@@ -714,7 +781,8 @@
     dataForm.value.mmPredictModel.modelparamstructure = ''
     if (response.data.loadFieldSetList && response.data.loadFieldSetList[0].propertyList) {
       response.data.loadFieldSetList[0].propertyList.forEach(function (value) {
-        if (value.key !== 'data1') {
+        //匹配  data数字
+        if (!/^data\d+$/.test(value.key)) {
           dataForm.value.mmModelArithSettingsList.push({
             key: value.key,
             name: value.name,
@@ -783,9 +851,9 @@
   rows.splice(index, 0, row)
 }
 
-function deleteRow(index: string, rows) {
-  if (!rows || rows.length === 1) {
-    message.error('不能全部删除!')
+function deleteRow(index, row, rows) {
+  if (!rows || rows.length === 1 || rows.filter(e => e.modelparamportorder === row.modelparamportorder).length === 1) {
+    message.error('不可删除!')
     return
   }
   rows.splice(index, 1)
@@ -798,9 +866,12 @@
   orderRow(rows)
 }
 
-function addItemOutput(list) {
-  list.push({})
-  orderItemOutput(list)
+function addItemOutput() {
+  if (!dataForm.value.mmItemOutputList) {
+    dataForm.value.mmItemOutputList = []
+  }
+  dataForm.value.mmItemOutputList.push({})
+  orderItemOutput(dataForm.value.mmItemOutputList)
 }
 
 function deleteItemOutput(index: string, rows) {
@@ -861,6 +932,13 @@
   fileList.value = []
 }
 
+const clearExpressionList = (value) => {
+  expressionList.value = [{
+    point: '',
+    operator: ''
+  }]
+}
+
 /** 重置表单 */
 const resetForm = () => {
   dataForm.value = {

--
Gitblit v1.9.3