From bb203eb72ee4604be8c9272cc583ecb9e393aeb8 Mon Sep 17 00:00:00 2001
From: houzhongjian <houzhongyi@126.com>
Date: 星期三, 04 十二月 2024 11:55:21 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/model/pre/item/index.vue                 |    1 
 src/api/model/sche/scheme/index.ts                 |    1 
 src/views/model/sche/scheme/ScheduleSchemeForm.vue |  264 ++++++++++++++++-------------
 src/views/model/mpk/menu/index.vue                 |    1 
 src/views/model/pre/item/MmPredictItemForm.vue     |  125 ++++++++++---
 src/views/model/pre/type/index.vue                 |    1 
 src/views/model/pre/dm/index.vue                   |    1 
 src/views/model/mpk/pack/index.vue                 |    1 
 src/views/model/mpk/file/MpkForm.vue               |    3 
 src/api/model/sche/model/index.ts                  |   41 +++
 src/views/model/mpk/file/index.vue                 |    1 
 src/views/data/point/DaPointForm.vue               |   53 +++++
 src/views/model/mpk/icon/index.vue                 |    1 
 13 files changed, 331 insertions(+), 163 deletions(-)

diff --git a/src/api/model/sche/model/index.ts b/src/api/model/sche/model/index.ts
index 8863d31..9fb78ba 100644
--- a/src/api/model/sche/model/index.ts
+++ b/src/api/model/sche/model/index.ts
@@ -70,7 +70,7 @@
 }
 
 // 查询模型参数列表
-export const getModelParamList = async () => {
+export const getModelParamList = async (id) => {
 
   const dataPointList = ref([] as DataPointApi.DaPointVO)
   dataPointList.value = await DataPointApi.getPointList({})
@@ -91,13 +91,21 @@
     status: CommonEnabled.ENABLE,
     itemtypename: 'NormalItem'
   })
-  const itemList = []
+  const normalItemList = []
   if (predictItemList.value) {
-    predictItemList.value.forEach(item => {
-      itemList.push(
+    // 过滤掉本身
+    predictItemList.value.filter(e => e.id !== id).forEach(item => {
+      normalItemList.push(
         {
-          id: item.id,
-          name:  item.itemname
+          value: item.id,
+          label:  item.itemname,
+          predictlength: item.predictlength,
+          children: item.outPuts?.map(e => {
+            return {
+              value: e.id,
+              label: e.resultName
+            }
+          })
         }
       )
     })
@@ -118,9 +126,28 @@
     })
   }
 
+
+  predictItemList.value = await PredictItemApi.getMmPredictItemList({
+    status: CommonEnabled.ENABLE,
+    itemtypename: 'MergeItem'
+  })
+  const mergeItemList = []
+  if (predictItemList.value) {
+    // 过滤掉本身
+    predictItemList.value.filter(e => e.id !== id).forEach(item => {
+      mergeItemList.push(
+          {
+            id: item.id,
+            name: item.itemname
+          }
+      )
+    })
+  }
+
   return {
     'DATAPOINT':pointList,
-    'PREDICTITEM': itemList,
+    'NormalItem': normalItemList,
+    'MergeItem': mergeItemList,
     'PLAN': planList,
   }
 }
diff --git a/src/api/model/sche/scheme/index.ts b/src/api/model/sche/scheme/index.ts
index 3d3971f..0bcafb3 100644
--- a/src/api/model/sche/scheme/index.ts
+++ b/src/api/model/sche/scheme/index.ts
@@ -13,6 +13,7 @@
   scheduleTime: string
   remark: string
   status: number
+  mpkprojectid: string
 }
 
 export interface ScheduleSchemePageReqVO extends PageParam {
diff --git a/src/views/data/point/DaPointForm.vue b/src/views/data/point/DaPointForm.vue
index 0279054..12536e0 100644
--- a/src/views/data/point/DaPointForm.vue
+++ b/src/views/data/point/DaPointForm.vue
@@ -283,6 +283,38 @@
           </el-form-item>
         </el-col>
       </el-row>
+      <!--累计点-->
+      <el-row :gutter="20" v-if="formData.pointType === 'CUMULATE'">
+        <el-col :span="24">
+          <el-form-item label="瞬时测点" prop="cumulatePoint.momentPoint">
+            <el-select
+              v-model="formData.cumulatePoint.momentPoint"
+              filterable
+              placeholder="请选择">
+              <el-option
+                v-for="(item, index) in pointList"
+                :key="index"
+                :label="item.pointName"
+                :value="item.pointNo"/>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="累计长度" prop="cumulatePoint.length">
+            <el-input-number v-model="formData.cumulatePoint.length" style="width: 100%"
+                             :min="1" :max="3000"
+                             :controls="false"/>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="除数" prop="cumulatePoint.divisor">
+            <el-input-number v-model="formData.cumulatePoint.divisor" style="width: 100%"
+                             :min="1" :max="3000"
+                             :controls="false"/>
+          </el-form-item>
+        </el-col>
+
+      </el-row>
     </el-form>
     <template #footer>
       <el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
@@ -343,6 +375,13 @@
     tagNo: '',
     dimension: '',
     valueType: '',
+  },
+  cumulatePoint: {
+    id: '',
+    pointId: '',
+    momentPoint: '',
+    length: '',
+    divisor: ''
   }
 })
 const formRules = reactive({
@@ -350,8 +389,11 @@
   pointType: [{required: true, message: '测点类型不能为空', trigger: 'blur'}],
   dataType: [{required: true, message: '数据类型不能为空', trigger: 'blur'}],
   minfreqid: [{required: true, message: '采集频率不能为空', trigger: 'blur'}],
-  "measurePoint.valueType": [{required: true, message: '采集频率不能为空', trigger: 'blur'}],
-  "measurePoint.dimension": [{required: true, message: '采集频率不能为空', trigger: 'blur'}],
+  "measurePoint.valueType": [{required: true, message: '值类型不能为空', trigger: 'blur'}],
+  "measurePoint.dimension": [{required: true, message: '平滑尺度不能为空', trigger: 'blur'}],
+  "cumulatePoint.momentPoint": [{required: true, message: '累计测点不能为空', trigger: 'blur'}],
+  "cumulatePoint.length": [{required: true, message: '累计长度不能为空', trigger: 'blur'}],
+  "cumulatePoint.divisor": [{required: true, message: '除数不能为空', trigger: 'blur'}],
 })
 const formRef = ref() // 表单 Ref
 
@@ -465,6 +507,13 @@
       tagNo: '',
       dimension: '1',
       valueType: 'SIMULATE',
+    },
+    cumulatePoint: {
+      id: '',
+      pointId: '',
+      momentPoint: '',
+      length: 60,
+      divisor: 60
     }
   }
   formRef.value?.resetFields()
diff --git a/src/views/model/mpk/file/MpkForm.vue b/src/views/model/mpk/file/MpkForm.vue
index 22d5efc..8dfbae9 100644
--- a/src/views/model/mpk/file/MpkForm.vue
+++ b/src/views/model/mpk/file/MpkForm.vue
@@ -333,6 +333,9 @@
     menuAndGroup: [
       {required: true, message: '所属目录不能为空', trigger: 'blur'}
     ],
+    icon: [
+      {required: true, message: 'icon不能为空', trigger: 'blur'}
+    ],
   })
 
   const formRef = ref() // 表单 Ref
diff --git a/src/views/model/mpk/file/index.vue b/src/views/model/mpk/file/index.vue
index 8e98f7f..666a1f4 100644
--- a/src/views/model/mpk/file/index.vue
+++ b/src/views/model/mpk/file/index.vue
@@ -22,6 +22,7 @@
           ref="queryFormRef"
           :inline="true"
           label-width="68px"
+          @submit.prevent
         >
           <el-form-item label="模型名称" prop="pyName">
             <el-input
diff --git a/src/views/model/mpk/icon/index.vue b/src/views/model/mpk/icon/index.vue
index 2f97330..e9c3654 100644
--- a/src/views/model/mpk/icon/index.vue
+++ b/src/views/model/mpk/icon/index.vue
@@ -7,6 +7,7 @@
       ref="queryFormRef"
       :inline="true"
       label-width="68px"
+      @submit.prevent
     >
       <el-form-item label="模型名称" prop="iconName">
         <el-input
diff --git a/src/views/model/mpk/menu/index.vue b/src/views/model/mpk/menu/index.vue
index 0578c7e..6ba4c18 100644
--- a/src/views/model/mpk/menu/index.vue
+++ b/src/views/model/mpk/menu/index.vue
@@ -7,6 +7,7 @@
       ref="queryFormRef"
       :inline="true"
       label-width="68px"
+      @submit.prevent
     >
       <el-form-item label="菜单名称" prop="name">
         <el-input
diff --git a/src/views/model/mpk/pack/index.vue b/src/views/model/mpk/pack/index.vue
index f3e4a4c..da368c7 100644
--- a/src/views/model/mpk/pack/index.vue
+++ b/src/views/model/mpk/pack/index.vue
@@ -7,6 +7,7 @@
       ref="queryFormRef"
       :inline="true"
       label-width="68px"
+      @submit.prevent
     >
       <el-form-item label="名称" prop="packName">
         <el-input
diff --git a/src/views/model/pre/dm/index.vue b/src/views/model/pre/dm/index.vue
index 77ebac9..27df07a 100644
--- a/src/views/model/pre/dm/index.vue
+++ b/src/views/model/pre/dm/index.vue
@@ -7,6 +7,7 @@
       ref="queryFormRef"
       :inline="true"
       label-width="68px"
+      @submit.prevent
     >
       <el-form-item label="名称" prop="modulename">
         <el-input
diff --git a/src/views/model/pre/item/MmPredictItemForm.vue b/src/views/model/pre/item/MmPredictItemForm.vue
index 28e5345..c7d32b1 100644
--- a/src/views/model/pre/item/MmPredictItemForm.vue
+++ b/src/views/model/pre/item/MmPredictItemForm.vue
@@ -103,8 +103,9 @@
       </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="changePredictLength"
               v-model="dataForm.mmPredictItem.predictlength" placeholder="预测长度"
               maxlength="5"/>
           </el-form-item>
@@ -201,7 +202,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">
         添加
@@ -283,6 +285,7 @@
         <el-table-column prop="" label="值" align="center" min-width="200">
           <template #default="scope">
             <el-input size="mini" v-model="scope.row.value" maxlength="256"
+                      :disabled="scope.row.key === 'pyFile'"
                       style="width:100%;height:100%"/>
           </template>
         </el-table-column>
@@ -312,7 +315,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)"
@@ -358,18 +380,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="'无数据(predictlength:' + dataForm.mmPredictItem.predictlength + ')'"
+              @change="changeNormalItemSelect"
+              style="width: 100%">
+              <el-option-group
+                v-for="group in modelparamListMap['NormalItem'].filter(e => e.predictlength == dataForm.mmPredictItem.predictlength)"
+                :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>
@@ -446,7 +478,6 @@
 const pointNoList = ref([])
 const pointList = ref([])
 const pointMap = ref({})
-const predictItemList = ref([])
 const modelparamListMap = ref({})
 const modelparamMap = ref({})
 const expressionList = ref([])
@@ -532,6 +563,7 @@
   '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'}],
 
 })
 const formRef = ref() // 表单 Ref
@@ -547,7 +579,7 @@
   setDefaultFields()
 
   // 加载参数列表
-  modelparamListMap.value = await ScheduleModelApi.getModelParamList()
+  modelparamListMap.value = await ScheduleModelApi.getModelParamList(id)
 
   // 获取预测项类型列表
   itemTypeList.value = await MmItemType.getItemTypeList()
@@ -563,11 +595,6 @@
 
   // 获取mpk项目列表
   mpkProjectList.value = await ProjectApi.list()
-
-  // 获取normal列表
-  predictItemList.value = await MmPredictItem.getMmPredictItemList({
-    itemtypename: 'NormalItem'
-  })
 
   // 获取数据点列表
   pointNoList.value = await DaPoint.getPointList(queryParams)
@@ -599,21 +626,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.pointid == undefined || e.pointid === '' || (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
@@ -679,7 +725,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 {
@@ -719,7 +765,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,
@@ -803,9 +850,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) {
@@ -866,6 +916,13 @@
   fileList.value = []
 }
 
+const changePredictLength = (value) => {
+  expressionList.value = [{
+    point: '',
+    operator: ''
+  }]
+}
+
 /** 重置表单 */
 const resetForm = () => {
   dataForm.value = {
diff --git a/src/views/model/pre/item/index.vue b/src/views/model/pre/item/index.vue
index 2158644..185ec8b 100644
--- a/src/views/model/pre/item/index.vue
+++ b/src/views/model/pre/item/index.vue
@@ -7,6 +7,7 @@
       ref="queryFormRef"
       :inline="true"
       label-width="68px"
+      @submit.prevent
     >
       <el-form-item label="编号" prop="itemno">
         <el-input
diff --git a/src/views/model/pre/type/index.vue b/src/views/model/pre/type/index.vue
index 601d7c1..bc1eab1 100644
--- a/src/views/model/pre/type/index.vue
+++ b/src/views/model/pre/type/index.vue
@@ -7,6 +7,7 @@
       ref="queryFormRef"
       :inline="true"
       label-width="68px"
+      @submit.prevent
     >
       <el-form-item label="名称" prop="itemtypename">
         <el-input
diff --git a/src/views/model/sche/scheme/ScheduleSchemeForm.vue b/src/views/model/sche/scheme/ScheduleSchemeForm.vue
index f7c0b44..1fcdc8c 100644
--- a/src/views/model/sche/scheme/ScheduleSchemeForm.vue
+++ b/src/views/model/sche/scheme/ScheduleSchemeForm.vue
@@ -10,12 +10,12 @@
       <el-row>
         <el-col :span="12">
           <el-form-item label="方案编号" prop="code">
-            <el-input v-model="formData.code" placeholder="请输入方案编号" />
+            <el-input v-model="formData.code" placeholder="请输入方案编号"/>
           </el-form-item>
         </el-col>
         <el-col :span="12">
           <el-form-item label="方案名称" prop="name">
-            <el-input v-model="formData.name" placeholder="请输入方案名称" />
+            <el-input v-model="formData.name" placeholder="请输入方案名称"/>
           </el-form-item>
         </el-col>
       </el-row>
@@ -24,7 +24,7 @@
           <el-form-item label="触发方式" prop="triggerMethod">
             <el-select v-model="formData.triggerMethod" placeholder="请选择">
               <el-option
-                v-for="dict in getIntDictOptions(DICT_TYPE.SCHE_TRIGGER_METHOD)"
+                v-for="dict in getDictOptions(DICT_TYPE.SCHE_TRIGGER_METHOD)"
                 :key="dict.value"
                 :label="dict.label"
                 :value="dict.value"
@@ -34,26 +34,26 @@
         </el-col>
         <el-col :span="12">
           <el-form-item label="触发条件" prop="triggerCondition">
-            <el-input v-model="formData.triggerCondition" placeholder="请输入触发条件" />
+            <el-input v-model="formData.triggerCondition" placeholder="请输入触发条件"/>
           </el-form-item>
         </el-col>
       </el-row>
       <el-row>
         <el-col :span="12">
           <el-form-item label="调整对象" prop="scheduleObj">
-            <el-input v-model="formData.scheduleObj" placeholder="请输入调整对象" />
+            <el-input v-model="formData.scheduleObj" placeholder="请输入调整对象"/>
           </el-form-item>
         </el-col>
         <el-col :span="12">
           <el-form-item label="调整类型" prop="scheduleType">
-            <el-input v-model="formData.scheduleType" placeholder="请输入调整类型" />
+            <el-input v-model="formData.scheduleType" placeholder="请输入调整类型"/>
           </el-form-item>
         </el-col>
       </el-row>
       <el-row>
         <el-col :span="12">
           <el-form-item label="调整策略" prop="scheduleStrategy">
-            <el-input v-model="formData.scheduleStrategy" placeholder="请输入调整策略 " />
+            <el-input v-model="formData.scheduleStrategy" placeholder="请输入调整策略 "/>
           </el-form-item>
         </el-col>
         <el-col :span="12">
@@ -71,9 +71,23 @@
         </el-col>
       </el-row>
       <el-row>
+        <el-col :span="12">
+          <el-form-item label="关联项目">
+            <el-select v-model="formData.mpkprojectid" placeholder="请选择">
+              <el-option
+                v-for="item in mpkProjectList"
+                :key="item.id"
+                :label="item.projectName"
+                :value="item.id"/>
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
         <el-col :span="24">
           <el-form-item label="备注" prop="remark">
-            <el-input v-model="formData.remark" placeholder="请输入备注"  type="textarea" maxlength="100"
+            <el-input v-model="formData.remark" placeholder="请输入备注" type="textarea"
+                      maxlength="100"
                       show-word-limit/>
           </el-form-item>
         </el-col>
@@ -86,20 +100,126 @@
   </Dialog>
 </template>
 <script lang="ts" setup>
-  import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
-  import * as ScheduleSchemeApi from '@/api/model/sche/scheme'
-  import { CommonStatusEnum } from '@/utils/constants'
-  import * as ScheduleModelApi from "@/api/model/sche/model";
+import {DICT_TYPE, getDictOptions} from '@/utils/dict'
+import * as ScheduleSchemeApi from '@/api/model/sche/scheme'
+import {CommonStatusEnum} from '@/utils/constants'
+import * as ScheduleModelApi from "@/api/model/sche/model";
+import * as ProjectApi from '@/api/model/mpk/project'
 
-  defineOptions({ name: 'ScheduleSchemeForm' })
+defineOptions({name: 'ScheduleSchemeForm'})
 
-  const { t } = useI18n() // 国际化
-  const message = useMessage() // 消息弹窗
-  const dialogVisible = ref(false) // 弹窗的是否展示
-  const dialogTitle = ref('') // 弹窗的标题
-  const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
-  const formType = ref('') // 表单的类型:create - 新增;update - 修改
-  const formData = ref({
+const {t} = useI18n() // 国际化
+const message = useMessage() // 消息弹窗
+const dialogVisible = ref(false) // 弹窗的是否展示
+const dialogTitle = ref('') // 弹窗的标题
+const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
+const formType = ref('') // 表单的类型:create - 新增;update - 修改
+const formData = ref({
+  id: undefined,
+  code: undefined,
+  name: undefined,
+  triggerMethod: undefined,
+  triggerCondition: undefined,
+  scheduleObj: undefined,
+  scheduleType: undefined,
+  scheduleStrategy: undefined,
+  modelId: undefined,
+  scheduleTime: undefined,
+  remark: undefined,
+  status: 0,
+  mpkprojectid: undefined,
+})
+const formRules = reactive({
+  code: [{required: true, message: '编号不能为空', trigger: 'blur'}],
+  name: [{required: true, message: '名称不能为空', trigger: 'blur'}],
+  triggerMethod: [{required: true, message: '触发方式不能为空', trigger: 'blur'}],
+  triggerCondition: [{required: true, message: '触发条件不能为空', trigger: 'blur'}],
+  modelId: [{required: true, message: '调度模型不能为空', trigger: 'blur'}],
+  triggerCondition: [{required: true, message: '触发条件不能为空', trigger: 'blur'}],
+})
+const formRef = ref() // 表单 Ref
+const scheduleModelList = ref([] as ScheduleModelApi.ScheduleModelVO[])
+const mpkProjectList = ref([])
+const addRow = function (index, rows) {
+  let row = JSON.parse(JSON.stringify(rows[index]))
+  rows.splice(index, 0, row)
+  this.orderRow(rows)
+}
+
+const deleteRow = function (index, rows) {
+  if (!rows || rows.length === 1) {
+    message.error('不能全部删除!')
+    return
+  }
+  rows.splice(index, 1)
+  this.orderRow(rows)
+}
+
+const orderRow = function (rows) {
+  let modelparamorder = 0
+  let modelparamportorder = 0
+  rows.forEach(function (value) {
+    if (value.modelparamportorder !== modelparamportorder) {
+      modelparamportorder = value.modelparamportorder
+      modelparamorder = 1
+    }
+    value.modelparamorder = modelparamorder
+    modelparamorder++
+  })
+}
+
+/** 打开弹窗 */
+const open = async (type: string, id?: number) => {
+  dialogVisible.value = true
+  dialogTitle.value = t('action.' + type)
+  formType.value = type
+  resetForm()
+  // 修改时,设置数据
+  if (id) {
+    formLoading.value = true
+    try {
+      formData.value = await ScheduleSchemeApi.getScheduleScheme(id)
+    } finally {
+      formLoading.value = false
+    }
+  }
+  // 加载调度模型列表
+  scheduleModelList.value = await ScheduleModelApi.getScheduleModelList()
+
+  // 获取mpk项目列表
+  mpkProjectList.value = await ProjectApi.list()
+}
+defineExpose({open}) // 提供 open 方法,用于打开弹窗
+
+/** 提交表单 */
+const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
+const submitForm = async () => {
+  // 校验表单
+  if (!formRef) return
+  const valid = await formRef.value.validate()
+  if (!valid) return
+  // 提交请求
+  formLoading.value = true
+  try {
+    const data = formData.value as unknown as ScheduleSchemeApi.ScheduleSchemeVO
+    if (formType.value === 'create') {
+      await ScheduleSchemeApi.createScheduleScheme(data)
+      message.success(t('common.createSuccess'))
+    } else {
+      await ScheduleSchemeApi.updateScheduleScheme(data)
+      message.success(t('common.updateSuccess'))
+    }
+    dialogVisible.value = false
+    // 发送操作成功的事件
+    emit('success')
+  } finally {
+    formLoading.value = false
+  }
+}
+
+/** 重置表单 */
+const resetForm = () => {
+  formData.value = {
     id: undefined,
     code: undefined,
     name: undefined,
@@ -111,105 +231,9 @@
     modelId: undefined,
     scheduleTime: undefined,
     remark: undefined,
-    status: 0
-  })
-  const formRules = reactive({
-    code: [{ required: true, message: '编号不能为空', trigger: 'blur' }],
-    name: [{ required: true, message: '名称不能为空', trigger: 'blur' }]
-  })
-  const formRef = ref() // 表单 Ref
-  const scheduleModelList = ref([] as ScheduleModelApi.ScheduleModelVO[])
-
-  const addRow = function (index, rows) {
-    let row = JSON.parse(JSON.stringify(rows[index]))
-    rows.splice(index, 0, row)
-    this.orderRow(rows)
+    status: CommonStatusEnum.ENABLE,
+    mpkprojectid: undefined
   }
-
-  const deleteRow = function (index, rows) {
-    if (!rows || rows.length === 1) {
-      message.error('不能全部删除!')
-      return
-    }
-    rows.splice(index, 1)
-    this.orderRow(rows)
-  }
-
-  const orderRow = function (rows) {
-    let modelparamorder = 0
-    let modelparamportorder = 0
-    rows.forEach(function (value) {
-      if (value.modelparamportorder !== modelparamportorder) {
-        modelparamportorder = value.modelparamportorder
-        modelparamorder = 1
-      }
-      value.modelparamorder = modelparamorder
-      modelparamorder++
-    })
-  }
-
-  /** 打开弹窗 */
-  const open = async (type: string, id?: number) => {
-    dialogVisible.value = true
-    dialogTitle.value = t('action.' + type)
-    formType.value = type
-    resetForm()
-    // 修改时,设置数据
-    if (id) {
-      formLoading.value = true
-      try {
-        formData.value = await ScheduleSchemeApi.getScheduleScheme(id)
-      } finally {
-        formLoading.value = false
-      }
-    }
-    // 加载调度模型列表
-    scheduleModelList.value = await ScheduleModelApi.getScheduleModelList()
-  }
-  defineExpose({ open }) // 提供 open 方法,用于打开弹窗
-
-  /** 提交表单 */
-  const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
-  const submitForm = async () => {
-    // 校验表单
-    if (!formRef) return
-    const valid = await formRef.value.validate()
-    if (!valid) return
-    // 提交请求
-    formLoading.value = true
-    try {
-      const data = formData.value as unknown as ScheduleSchemeApi.ScheduleSchemeVO
-      if (formType.value === 'create') {
-        await ScheduleSchemeApi.createScheduleScheme(data)
-        message.success(t('common.createSuccess'))
-      } else {
-        await ScheduleSchemeApi.updateScheduleScheme(data)
-        message.success(t('common.updateSuccess'))
-      }
-      dialogVisible.value = false
-      // 发送操作成功的事件
-      emit('success')
-    } finally {
-      formLoading.value = false
-    }
-  }
-
-  /** 重置表单 */
-  const resetForm = () => {
-    formData.value = {
-      id: undefined,
-      code: undefined,
-      name: undefined,
-      triggerMethod: undefined,
-      triggerCondition: undefined,
-      scheduleObj: undefined,
-      scheduleType: undefined,
-      scheduleStrategy: undefined,
-      modelId: undefined,
-      scheduleTime: undefined,
-      remark: undefined,
-      status: CommonStatusEnum.ENABLE
-    }
-    formRef.value?.resetFields()
-  }
+  formRef.value?.resetFields()
+}
 </script>

--
Gitblit v1.9.3