Quellcode durchsuchen

两种训练任务增删改查功能联调

zy vor 2 Wochen
Ursprung
Commit
70ff346f8f

+ 17 - 2
xvji-ui/src/api/xvji/predict.js

@@ -1,6 +1,6 @@
 import request from '@/utils/request'
 
-// 新增训练任务
+// 新增任务
 export function addTask(data) {
   return request({
     url: '/task/predict/addTask',
@@ -8,7 +8,15 @@ export function addTask(data) {
     data: data
   })
 }
-// 查询训练任务
+// 更新训练任务
+export function updateTask(data) {
+  return request({
+    url: '/task/predict/updateTask',
+    method: 'post',
+    data: data
+  })
+}
+// 查询任务
 export function queryTasks(data) {
   return request({
     url: '/task/predict/queryTasks',
@@ -16,3 +24,10 @@ export function queryTasks(data) {
     params:data
   })
 }
+// 删除任务
+export function deleteId(id) {
+  return request({
+    url: '/task/predict/' + id,
+    method: 'delete'
+  })
+}

+ 15 - 0
xvji-ui/src/api/xvji/training.js

@@ -8,6 +8,14 @@ export function addTask(data) {
     data: data
   })
 }
+// 更新训练任务
+export function updateTask(data) {
+  return request({
+    url: '/task/train/updateTask',
+    method: 'post',
+    data: data
+  })
+}
 // 查询训练任务
 export function queryTasks(data) {
   return request({
@@ -16,3 +24,10 @@ export function queryTasks(data) {
     params:data
   })
 }
+// 删除任务
+export function deleteId(id) {
+  return request({
+    url: '/task/train/' + id,
+    method: 'delete'
+  })
+}

+ 1 - 1
xvji-ui/src/views/tasks/predict/dataCleanForm.vue

@@ -176,7 +176,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
-          console.log('error submit!!');
+          this.$message.warning(this.dataCleaning.componentType+'模块校验未通过')
           return false;
         }
       });

+ 142 - 64
xvji-ui/src/views/tasks/predict/index.vue

@@ -17,12 +17,12 @@
         :data="tableData"
         border
         style="width: 100%">
-        <el-table-column align="center" prop="ttaskId" label="任务id"></el-table-column>
-        <el-table-column align="center" prop="ttaskName" label="名称"></el-table-column>
-        <el-table-column align="center" prop="ttaskStatus" label="状态"></el-table-column>
-        <el-table-column align="center" prop="tcreateTime" label="创建时间"></el-table-column>
-        <el-table-column align="center" prop="tcronExpression" label="定时任务"></el-table-column>
-        <el-table-column align="center" prop="trunInfo" label="运行信息" width="100">
+        <el-table-column align="center" prop="ptaskId" label="任务id"></el-table-column>
+        <el-table-column align="center" prop="ptaskName" label="名称"></el-table-column>
+        <el-table-column align="center" prop="ptaskStatus" label="状态"></el-table-column>
+        <el-table-column align="center" prop="pcreateTime" label="创建时间"></el-table-column>
+        <el-table-column align="center" prop="pcronExpression" label="定时任务"></el-table-column>
+        <el-table-column align="center" prop="prunInfo" label="运行信息" width="100">
           <template slot-scope="{row}">
             <el-button @click="viewInfo(row)" type="text" size="small">查看</el-button>
           </template>
@@ -33,7 +33,7 @@
         >
           <template slot-scope="{row}">
             <el-button @click="handleClick(row)" type="primary" plain size="mini">编辑</el-button>
-            <el-button type="danger" plain size="mini">删除</el-button>
+            <el-button @click="handleDeleteClick(row)" type="danger" plain size="mini">删除</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -54,13 +54,13 @@
         <el-form ref="ruleForm" :rules="rules" :model="formData" class="demo-form-inline" label-width="130px">
           <el-row :gutter="20">
             <el-col :span="12">
-              <el-form-item label="任务名称" prop="tTaskName" label-width="100px">
-                <el-input v-model="formData.tTaskName"></el-input>
+              <el-form-item label="任务名称" prop="pTaskName" label-width="100px">
+                <el-input v-model="formData.pTaskName"></el-input>
               </el-form-item>
             </el-col>
             <el-col :span="12">
-              <el-form-item label="定时任务" prop="tCronExpression" label-width="100px">
-                <el-input v-model="formData.tCronExpression"></el-input>
+              <el-form-item label="定时任务" prop="pCronExpression" label-width="100px">
+                <el-input v-model="formData.pCronExpression"></el-input>
               </el-form-item>
             </el-col>
           </el-row>
@@ -68,21 +68,24 @@
 
         </el-form>
         <div class="mode-table">
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0"></span>
-            <span class="pa-0 td td1 font-bold">是否开启</span>
-            <span class="pa-0 td2 font-bold">参数</span>
+          <div class="mode-table-thead">
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0"></span>
+              <span class="pa-0 td td1 font-bold">是否开启</span>
+              <span class="pa-0 td2 font-bold">参数</span>
+            </div>
           </div>
-          <!--    数据获取        -->
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0">数据获取</span>
-            <span class="pa-0 td td1">
+          <div class="mode-table-body">
+            <!--    数据获取        -->
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0">数据获取</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.dataAcquisition.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                    <el-form ref="ruleForm" :rules="dataAcquisitionRules" :model="formData.dataAcquisition.params"
                             class="demo-form-inline"
@@ -110,26 +113,26 @@
                    </el-form>
                 </div>
               </span>
-          </div>
-          <!--    数据处理        -->
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0">数据处理</span>
-            <span class="pa-0 td td1">
+            </div>
+            <!--    数据处理        -->
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0">数据处理</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.dataCleaning.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <data-clean-form ref="dataCleaning" :form-data="formData.dataCleaning"
                                    @child-event="getDataCleaning"></data-clean-form>
                 </div>
               </span>
-          </div>
+            </div>
 
-          <!--    模型        -->
-          <div class="flex model-table-tr">
+            <!--    模型        -->
+            <div class="flex model-table-tr">
             <span class="pa-0 td td0">
               <el-select v-model="formData.model.componentType" placeholder="请选择" size="small"
                          style="width: 100%">
@@ -141,34 +144,36 @@
                 </el-option>
               </el-select>
             </span>
-            <span class="pa-0 td td1">
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.model.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false" disabled>关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <model-form ref="model" :form-data="formData.model" @child-event="getModel"></model-form>
                 </div>
               </span>
-          </div>
+            </div>
 
-          <!--    后处理        -->
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0">后处理</span>
-            <span class="pa-0 td td1">
+            <!--    后处理        -->
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0">后处理</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.processing.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <processing-form ref="processing" :form-data="formData.processing"
                                    @child-event="getProcessing"></processing-form>
                 </div>
               </span>
+            </div>
+
           </div>
 
 
@@ -197,7 +202,7 @@
 import dataCleanForm from './dataCleanForm.vue'
 import modelForm from './modelForm.vue'
 import processingForm from './processingForm.vue'
-import {addTask, queryTasks} from "@/api/xvji/training";
+import {addTask, deleteId, queryTasks,updateTask} from "@/api/xvji/predict";
 
 export default {
   components: {modelForm, dataCleanForm, processingForm},
@@ -227,13 +232,9 @@ export default {
       dialogInfoVisible: false,
       info: '',
       rules: {
-        tTaskName: [
+        pTaskName: [
           {required: true, message: '请填写任务名称', trigger: 'blur'}
-        ],
-        name:  [
-          {required: true, message: '请填写任务名称', trigger: 'blur'}
-        ],
-
+        ]
       },
       dataAcquisitionRules: {
         query_sql: [
@@ -259,7 +260,8 @@ export default {
         {label: 'Holtwinters模型', value: 'Holtwinters模型'},
         {label: 'LSTM', value: 'LSTM'},
         {label: '机器学习模型', value: '机器学习模型'}
-      ]
+      ],
+      modelOption:['光伏物理模型', '风电物理模型','Holtwinters模型','LSTM','机器学习模型',],
     }
   },
   mounted() {
@@ -271,7 +273,7 @@ export default {
       this.loading = true
       queryTasks(this.queryParams).then(res=>{
         this.tableData = res.data.list
-        console.log(this.tableData[0])
+        // console.log(this.tableData[0])
         this.total = res.data.total
         this.loading = false
       }).catch(err=>{
@@ -280,13 +282,11 @@ export default {
     },
     // 新增
     addTask() {
-
       this.isEdit = false
       this.dialogVisible = true
       this.formData = {
-        tTaskId: '',
-        tTaskName: '',
-        tCronExpression: '',
+        pTaskName: '',
+        pCronExpression: '',
         dataAcquisition: {componentType:  '数据获取', isEnable: true, params: {}},
         dataCleaning: {componentType:  '数据处理', isEnable: true, params: {}},
         model: {componentType:  '光伏物理模型', isEnable: true, params: {}},
@@ -297,17 +297,17 @@ export default {
       })
     },
     // 编辑
-    handleClick() {
+    handleClick(row) {
       this.isEdit = true
       this.formData = {
-        tTaskId:row.ttaskId,
-        tTaskName: row.ttaskName,
-        tTaskStatus: row.ttaskStatus,
-        tComponentIds:row.tcomponentIds,
-        tCreateTime:row.tcreateTime,
-        tCronExpression:row.tcronExpression,
-        tQuartzTask:row.tquartzTask,
-        tRunInfo:row.trunInfo,
+        pTaskId:row.ptaskId,
+        pTaskName: row.ptaskName,
+        pTaskStatus: row.ptaskStatus,
+        pComponentIds:row.pcomponentIds,
+        pCreateTime:row.pcreateTime,
+        pCronExpression:row.pcronExpression,
+        pQuartzTask:row.pquartzTask,
+        pRunInfo:row.prunInfo,
         dataAcquisition: row.components.find(w=>w.componentType.includes('数据获取'))|| {componentType: '数据获取', isEnable: true, params:{}},
         dataCleaning: row.components.find(w=>w.componentType ==='数据处理')|| {componentType: '数据处理', isEnable: true, params:{}},
         model: row.components.find(w=>this.modelOption.includes(w.componentType))|| {componentType: '光伏物理模型', isEnable: true, params:{}},
@@ -333,6 +333,34 @@ export default {
           }
           if(!this.isEdit){
             addTask(this.formData).then(res=>{
+              if(res.code === 200){
+                this.$message({
+                  type: 'success',
+                  message: res.msg
+                });
+              }else{
+                this.$message({
+                  type: 'danger',
+                  message: res.msg
+                });
+              }
+              this.getList()
+              this.dialogVisible = false
+            })
+          }else{
+            updateTask(this.formData).then(res=>{
+              if(res.code === 200){
+                this.$message({
+                  type: 'success',
+                  message: res.msg
+                });
+              }else{
+                this.$message({
+                  type: 'danger',
+                  message: res.msg
+                });
+              }
+              this.getList()
               this.dialogVisible = false
             })
           }
@@ -361,9 +389,9 @@ export default {
     handleClose() {
       this.$refs.ruleForm.resetFields()
       this.formData = {
-        tTaskId: '',
-        tTaskName: '',
-        tCronExpression: '',
+        pTaskId: '',
+        pTaskName: '',
+        pCronExpression: '',
         dataAcquisition: {componentType:  '数据获取', isEnable: true, params: {}},
         dataCleaning: {componentType:  '数据处理', isEnable: true, params: {}},
         model: {componentType:  '光伏物理模型', isEnable: true, params: {}},
@@ -376,7 +404,36 @@ export default {
     viewInfo(row) {
       this.info = row.tRunInfo
       this.dialogInfoVisible = true
-    }
+    },
+    //删除
+    handleDeleteClick(row){
+      this.$confirm('此操作将永久删除'+row.ptaskName+'任务, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        deleteId(row.ptaskId).then(res=>{
+          if(res.code === 200){
+            this.$message({
+              type: 'success',
+              message: res.msg
+            });
+          }else{
+            this.$message({
+              type: 'danger',
+              message: res.msg
+            });
+          }
+          this.getList()
+        })
+
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
+        });
+      });
+    },
   }
 }
 </script>
@@ -402,7 +459,28 @@ export default {
 .td2 {
   width: calc(100% - 350px);
 }
-
+.mode-table{
+  max-height: 63vh;
+  overflow-y: auto;
+  position: relative;
+  border-collapse: separate;
+}
+.mode-table-thead {
+  position: sticky;
+  top: 0;
+  z-index: 1000000;
+  background-color: white;
+}
+.mode-table.mode-table-body .model-table-tr {
+  &:last-child{
+    border-bottom: 1px solid #ebeef5;
+  }
+}
+.mode-table .mode-table-body .model-table-tr{
+  &:first-child{
+    border-top: none;
+  }
+}
 .mode-table .model-table-tr:last-child {
   border-bottom: 1px solid #ebeef5;
 }

+ 40 - 25
xvji-ui/src/views/tasks/predict/modelForm.vue

@@ -61,8 +61,9 @@
                   :autosize="{ minRows: 1 }"></el-input>
       </el-form-item>
 
-      <el-form-item label="是否配置生产" prop="forecast_file" v-if="modelType !== 3" @change="forecastFileChange">
-        <el-select v-model="form['forecast_file']" clearable placeholder="请选择" size="small" style="width: 100%">
+      <el-form-item label="是否配置生产" prop="forecast_file" v-if="modelType !== 3">
+        <el-select v-model="form['forecast_file']" clearable placeholder="请选择" size="small" style="width: 100%"
+                   @change="forecastFileChange">
           <el-option
             v-for="item in forecastFileType" :disabled="!model.isEnable"
             :key="item.value"
@@ -72,7 +73,8 @@
         </el-select>
       </el-form-item>
       <el-form-item label="测试or生产" prop="algorithm_test" v-if="modelType ===3">
-        <el-select v-model="form['algorithm_test']" clearable placeholder="请选择" size="small" style="width: 100%" @change="columnChange">
+        <el-select v-model="form['algorithm_test']" clearable placeholder="请选择" size="small" style="width: 100%"
+                   @change="columnChange">
           <el-option
             v-for="item in algorithmTestType" :disabled="!model.isEnable"
             :key="item.value"
@@ -102,7 +104,7 @@
         </el-select>
       </el-form-item>
       <div v-if="modelType !== 3">
-        <el-form-item label="测试第N天" >
+        <el-form-item label="测试第N天">
           <el-input v-model="form['howLongAgo']" size="mini"
                     :disabled="!model.isEnable || form['forecast_file'] !=='0' " type="textarea"
                     :autosize="{ minRows: 1 }"></el-input>
@@ -113,8 +115,8 @@
                     :autosize="{ minRows: 1 }"></el-input>
         </el-form-item>
       </div>
-     <div v-else>
-        <el-form-item label="测试第N天" >
+      <div v-else>
+        <el-form-item label="测试第N天">
           <el-input v-model="form['howLongAgo']" size="mini"
                     :disabled="!model.isEnable || columnDisabled" type="textarea"
                     :autosize="{ minRows: 1 }"></el-input>
@@ -153,7 +155,6 @@
       </el-form-item>
 
 
-
       <el-form-item label="周期" prop="seasonal_periods" v-if="modelType === 2">
         <el-input v-model="form['seasonal_periods']" size="mini"
                   :disabled="!model.isEnable" type="textarea"
@@ -197,16 +198,16 @@ export default {
         this.model = newVal
         this.modelType = this.modelName.find(w => w.label === newVal.componentType).value
         this.rules = {}
-        if(this.modelType === 0){
-          this.rules = { ...this.commonRules, ...this.solarRules }
-        }else if(this.modelType === 1){
-          this.rules = { ...this.commonRules, ...this.windRules }
-        }else if(this.modelType === 2){
-          this.rules = { ...this.commonRules, ...this.HoltwintersRules }
-        }else if(this.modelType === 3){
-          this.rules = { ...this.commonRules, ...this.LSTMRules }
-        }else if(this.modelType === 4){
-          this.rules = { ...this.commonRules, ...this.machineRules }
+        if (this.modelType === 0) {
+          this.rules = {...this.commonRules, ...this.solarRules}
+        } else if (this.modelType === 1) {
+          this.rules = {...this.commonRules, ...this.windRules}
+        } else if (this.modelType === 2) {
+          this.rules = {...this.commonRules, ...this.HoltwintersRules}
+        } else if (this.modelType === 3) {
+          this.rules = {...this.commonRules, ...this.LSTMRules}
+        } else if (this.modelType === 4) {
+          this.rules = {...this.commonRules, ...this.machineRules}
         }
         this.form = newVal.params
 
@@ -330,7 +331,7 @@ export default {
   },
   methods: {
     saveTask() {
-      if(this.form['forecast_file'] === '0'){
+      if (this.form['forecast_file'] === '0') {
         this.$refs.modelForm.clearValidate('target')
         this.$refs.modelForm.clearValidate('model_name')
       }
@@ -341,6 +342,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
+          this.$message.warning(this.model.componentType + '模块校验未通过')
           console.log('error submit!!');
           return false;
         }
@@ -348,12 +350,25 @@ export default {
 
       // this.dialogVisible = false
     },
-    forecastFileChange(){
-      if(this.form['forecast_file'] === '0'){
+    forecastFileChange() {
+      if (this.form['forecast_file'] === '0') {
         this.form['howLongAgo'] = '1'
-        this.$refs.modelForm.clearValidate('target')
-        this.$refs.modelForm.clearValidate('model_name')
-      }else{
+        delete this.rules.target;
+        delete this.rules.model_name;
+        this.rules = Object.assign({
+          target: [
+            {required: true, message: '请填写目标列', trigger: 'blur'}
+          ],
+          model_name: [
+            {required: true, message: '请填写模型名称', trigger: 'blur'}
+          ],
+        }, this.rules)
+        this.$nextTick(() => {
+          this.$refs.modelForm.clearValidate()
+        });
+      } else {
+        delete this.rules.target;
+        delete this.rules.model_name;
         this.form['howLongAgo'] = ''
       }
     },
@@ -361,10 +376,10 @@ export default {
       if (this.form['algorithm_test'] === '1') {
         this.columnDisabled = false
       } else {
-        if(this.modelType === 1){
+        if (this.modelType === 1) {
           this.$refs.modelForm.clearValidate('target')
           this.$refs.modelForm.clearValidate('model_name')
-        }else{
+        } else {
           this.$refs.modelForm.clearValidate('target')
         }
         this.columnDisabled = true

+ 1 - 1
xvji-ui/src/views/tasks/predict/processingForm.vue

@@ -110,7 +110,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
-          console.log('error submit!!');
+          this.$message.warning(this.processing.componentType+'模块校验未通过')
           return false;
         }
       });

+ 1 - 1
xvji-ui/src/views/tasks/training/dataCleanForm.vue

@@ -176,7 +176,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
-          console.log('error submit!!');
+          this.$message.warning(this.dataCleaning.componentType+'模块校验未通过')
           return false;
         }
       });

+ 213 - 99
xvji-ui/src/views/tasks/training/index.vue

@@ -38,7 +38,7 @@
         >
           <template slot-scope="{row}">
             <el-button @click="handleClick(row)" type="primary" plain size="mini">编辑</el-button>
-            <el-button type="danger" plain size="mini">删除</el-button>
+            <el-button @click="handleDeleteClick(row)" type="danger" plain size="mini">删除</el-button>
           </template>
         </el-table-column>
       </el-table>
@@ -73,21 +73,24 @@
 
         </el-form>
         <div class="mode-table">
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0"></span>
-            <span class="pa-0 td td1 font-bold">是否开启</span>
-            <span class="pa-0 td2 font-bold">参数</span>
+          <div class="mode-table-thead">
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0"></span>
+              <span class="pa-0 td td1 font-bold">是否开启</span>
+              <span class="pa-0 td2 font-bold">参数</span>
+            </div>
           </div>
-          <!--    数据获取        -->
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0">数据获取</span>
-            <span class="pa-0 td td1">
+          <div class="mode-table-body">
+            <!--    数据获取        -->
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0">数据获取</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.dataAcquisition.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                    <el-form ref="ruleForm" :rules="dataAcquisitionRules" :model="formData.dataAcquisition.params"
                             class="demo-form-inline"
@@ -115,27 +118,28 @@
                    </el-form>
                 </div>
               </span>
-          </div>
-          <!--    数据处理        -->
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0">数据处理</span>
-            <span class="pa-0 td td1">
+            </div>
+            <!--    数据处理        -->
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0">数据处理</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.dataCleaning.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <data-clean-form ref="dataCleaning" :form-data="formData.dataCleaning"
                                    @child-event="getDataCleaning"></data-clean-form>
                 </div>
               </span>
-          </div>
-          <!--    限电        -->
-          <div class="flex model-table-tr">
+            </div>
+            <!--    限电        -->
+            <div class="flex model-table-tr">
             <span class="pa-0 td td0">
-              <el-select v-model="formData.powerRationing.componentType" @change="powerRationingNameChange" placeholder="请选择"
+              <el-select v-model="formData.powerRationing.componentType" @change="powerRationingNameChange"
+                         placeholder="请选择"
                          size="small" style="width: 100%">
                 <el-option
                   v-for="item in powerRationingName"
@@ -145,23 +149,24 @@
                 </el-option>
               </el-select>
             </span>
-            <span class="pa-0 td td1">
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.powerRationing.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <power-rationing-form ref="powerRationing" :form-data="formData.powerRationing"
                                         @child-event="getPowerRationing"></power-rationing-form>
                 </div>
               </span>
-          </div>
-          <!--    模型        -->
-          <div class="flex model-table-tr">
+            </div>
+            <!--    模型        -->
+            <div class="flex model-table-tr">
             <span class="pa-0 td td0">
-              <el-select v-model="formData.model.componentType" @change="isDisableModeTest" placeholder="请选择" size="small"
+              <el-select v-model="formData.model.componentType" @change="isDisableModeTest" placeholder="请选择"
+                         size="small"
                          style="width: 100%">
                 <el-option
                   v-for="item in modelName"
@@ -171,67 +176,69 @@
                 </el-option>
               </el-select>
             </span>
-            <span class="pa-0 td td1">
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.model.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false" disabled>关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <model-form ref="model" :form-data="formData.model" @child-event="getModel"></model-form>
                 </div>
               </span>
-          </div>
-          <!--    模型测试        -->
-          <div class="flex model-table-tr" v-if="!modelTestDisable">
-            <span class="pa-0 td td0">{{ formData.modelTest.componentType }}</span>
-            <span class="pa-0 td td1">
+            </div>
+            <!--    模型测试        -->
+            <div class="flex model-table-tr" v-if="!modelTestDisable">
+              <span class="pa-0 td td0">{{ formData.modelTest.componentType }}</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.modelTest.isEnable" size="mini">
                   <el-radio-button :label="true" :disabled="modelTestDisable">开启</el-radio-button>
                   <el-radio-button :label="false" disabled>关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <model-test-form ref="modelTest" :form-data="formData.modelTest"
                                    @child-event="getModelTest"></model-test-form>
                 </div>
               </span>
-          </div>
-          <!--    后处理        -->
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0">后处理</span>
-            <span class="pa-0 td td1">
+            </div>
+            <!--    后处理        -->
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0">后处理</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.processing.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <processing-form ref="processing" :form-data="formData.processing"
                                    @child-event="getProcessing"></processing-form>
                 </div>
               </span>
-          </div>
-          <!--    分析报告        -->
-          <div class="flex model-table-tr">
-            <span class="pa-0 td td0">分析报告</span>
-            <span class="pa-0 td td1">
+            </div>
+            <!--    分析报告        -->
+            <div class="flex model-table-tr">
+              <span class="pa-0 td td0">分析报告</span>
+              <span class="pa-0 td td1">
                  <el-radio-group v-model="formData.report.isEnable" size="mini">
                   <el-radio-button :label="true">开启</el-radio-button>
                   <el-radio-button :label="false">关闭</el-radio-button>
                 </el-radio-group>
               </span>
-            <span class="pa-0 td2">
+              <span class="pa-0 td2">
                 <div class="form-table-item">
                   <report-form ref="report" :form-data="formData.report"
                                @child-event="getReport"></report-form>
                 </div>
               </span>
-          </div>
+            </div>
+
 
+          </div>
 
         </div>
       </div>
@@ -244,7 +251,7 @@
       title="运行信息"
       :visible.sync="dialogInfoVisible"
       width="30%"
-     >
+    >
       <div>
         {{ info }}
       </div>
@@ -261,7 +268,7 @@ import modelForm from './modelForm.vue'
 import modelTestForm from './modelTestForm.vue'
 import processingForm from './processingForm.vue'
 import reportForm from './reportForm.vue'
-import {addTask, queryTasks} from "@/api/xvji/training";
+import {addTask, deleteId, queryTasks, updateTask} from "@/api/xvji/training";
 
 export default {
   components: {modelForm, modelTestForm, dataCleanForm, powerRationingForm, processingForm, reportForm},
@@ -270,13 +277,13 @@ export default {
       loading: false,
       tableData: [],
       formData: {
-        dataAcquisition: {componentType: '数据获取', isEnable: true, params:{}},
-        dataCleaning: {componentType: '数据处理', isEnable: true, params:{}},
+        dataAcquisition: {componentType: '数据获取', isEnable: true, params: {}},
+        dataCleaning: {componentType: '数据处理', isEnable: true, params: {}},
         powerRationing: {componentType: '限电清洗', isEnable: true, params: {}},
-        model: {componentType: '模型', isEnable: true, params:{}},
-        modelTest: {componentType: '模型测试', isEnable: true, params:{}},
-        processing: {componentType: '后处理', isEnable: true, params:{}},
-        report: {componentType: '分析报告', isEnable: true, params:{}},
+        model: {componentType: '模型', isEnable: true, params: {}},
+        modelTest: {componentType: '模型测试', isEnable: true, params: {}},
+        processing: {componentType: '后处理', isEnable: true, params: {}},
+        report: {componentType: '分析报告', isEnable: true, params: {}},
       },
       modelTestDisable: true,
       // 总条数
@@ -325,8 +332,8 @@ export default {
         {label: 'LSTM', value: 'LSTM'},
         {label: '机器学习模型', value: '机器学习模型'}
       ],
-      modelOption:['光伏物理模型', '风电物理模型','Holtwinters模型','LSTM','机器学习模型',],
-      modelTestOption:['LSTM-测试','机器学习模型-测试',],
+      modelOption: ['光伏物理模型', '风电物理模型', 'Holtwinters模型', 'LSTM', '机器学习模型',],
+      modelTestOption: ['LSTM-测试', '机器学习模型-测试',],
     }
   },
   mounted() {
@@ -335,12 +342,12 @@ export default {
   methods: {
     getList() {
       this.loading = true
-      queryTasks(this.queryParams).then(res=>{
+      queryTasks(this.queryParams).then(res => {
         this.tableData = res.data.list
-        console.log(this.tableData[0])
+        // console.log(this.tableData[0])
         this.total = res.data.total
         this.loading = false
-      }).catch(err=>{
+      }).catch(err => {
         this.loading = false
       })
     },
@@ -352,15 +359,15 @@ export default {
       this.formData = {
         tTaskName: '',
         tCronExpression: '',
-        dataAcquisition: {componentType: '数据获取', isEnable: true, params:{}},
-        dataCleaning: {componentType: '数据处理', isEnable: true, params:{}},
-        powerRationing: {componentType: '限电清洗-光伏', isEnable: true, params:{}},
-        model: {componentType: '光伏物理模型', isEnable: true, params:{}},
-        modelTest: {componentType: '模型测试', isEnable: true, params:{}},
-        processing: {componentType: '后处理', isEnable: true, params:{}},
-        report: {componentType: '分析报告', isEnable: true, params:{}},
+        dataAcquisition: {componentType: '数据获取', isEnable: true, params: {}},
+        dataCleaning: {componentType: '数据处理', isEnable: true, params: {}},
+        powerRationing: {componentType: '限电清洗-光伏', isEnable: true, params: {}},
+        model: {componentType: '光伏物理模型', isEnable: true, params: {}},
+        modelTest: {componentType: '模型测试', isEnable: true, params: {}},
+        processing: {componentType: '后处理', isEnable: true, params: {}},
+        report: {componentType: '分析报告', isEnable: true, params: {}},
       }
-      this.$nextTick(()=>{
+      this.$nextTick(() => {
         this.powerRationingNameChange() // 无意义,限电清洗表单不渲染刷新操作
         this.$refs.ruleForm.clearValidate()
       })
@@ -369,26 +376,83 @@ export default {
     handleClick(row) {
       this.isEdit = true
       this.formData = {
-        tTaskId:row.ttaskId,
+        tTaskId: row.ttaskId,
         tTaskName: row.ttaskName,
         tTaskStatus: row.ttaskStatus,
-        tAnalysisReport:row.tanalysisReport,
-        tComponentIds:row.tcomponentIds,
-        tCreateTime:row.tcreateTime,
-        tCronExpression:row.tcronExpression,
-        tQuartzTask:row.tquartzTask,
-        tRunInfo:row.trunInfo,
-        dataAcquisition: row.components.find(w=>w.componentType.includes('数据获取'))|| {componentType: '数据获取', isEnable: true, params:{}},
-        dataCleaning: row.components.find(w=>w.componentType ==='数据处理')|| {componentType: '数据处理', isEnable: true, params:{}},
-        powerRationing: row.components.find(w=>w.componentType.includes('限电清洗'))|| {componentType: '限电清洗-光伏', isEnable: true, params:{}},
-        model: row.components.find(w=>this.modelOption.includes(w.componentType))|| {componentType: '光伏物理模型', isEnable: true, params:{}},
-        modelTest: row.components.find(w=>this.modelTestOption.includes(w.componentType))|| {componentType: '模型测试', isEnable: true, params:{}},
-        processing: row.components.find(w=>w.componentType ==='后处理') || {componentType: '后处理', isEnable: true, params:{}},
-        report: row.components.find(w=>w.componentType ==='分析报告')|| {componentType: '分析报告', isEnable: true, params:{}},
+        tAnalysisReport: row.tanalysisReport,
+        tComponentIds: row.tcomponentIds,
+        tCreateTime: row.tcreateTime,
+        tCronExpression: row.tcronExpression,
+        tQuartzTask: row.tquartzTask,
+        tRunInfo: row.trunInfo,
+        dataAcquisition: row.components.find(w => w.componentType.includes('数据获取')) || {
+          componentType: '数据获取',
+          isEnable: true,
+          params: {}
+        },
+        dataCleaning: row.components.find(w => w.componentType === '数据处理') || {
+          componentType: '数据处理',
+          isEnable: true,
+          params: {}
+        },
+        powerRationing: row.components.find(w => w.componentType.includes('限电清洗')) || {
+          componentType: '限电清洗-光伏',
+          isEnable: true,
+          params: {}
+        },
+        model: row.components.find(w => this.modelOption.includes(w.componentType)) || {
+          componentType: '光伏物理模型',
+          isEnable: true,
+          params: {}
+        },
+        modelTest: row.components.find(w => this.modelTestOption.includes(w.componentType)) || {
+          componentType: '模型测试',
+          isEnable: true,
+          params: {}
+        },
+        processing: row.components.find(w => w.componentType === '后处理') || {
+          componentType: '后处理',
+          isEnable: true,
+          params: {}
+        },
+        report: row.components.find(w => w.componentType === '分析报告') || {
+          componentType: '分析报告',
+          isEnable: true,
+          params: {}
+        },
       }
-      console.log(this.formData,row.components)
+      // console.log(this.formData.powerRationing)
       this.dialogVisible = true
     },
+    //删除
+    handleDeleteClick(row) {
+      this.$confirm('此操作将永久删除' + row.ttaskName + '任务, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        deleteId(row.ttaskId).then(res => {
+          if (res.code === 200) {
+            this.$message({
+              type: 'success',
+              message: res.msg
+            });
+          } else {
+            this.$message({
+              type: 'danger',
+              message: res.msg
+            });
+          }
+          this.getList()
+        })
+
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
+        });
+      });
+    },
     //保存
     saveTask() {
       this.$refs.ruleForm.validate(async (valid) => {
@@ -410,7 +474,7 @@ export default {
             if (JSON.stringify(this.formData.modelTest.params) === '{}') {
               return false
             }
-          }else{
+          } else {
             this.formData.modelTest = {}
           }
           await this.$refs.processing.saveTask()
@@ -421,8 +485,36 @@ export default {
           if (JSON.stringify(this.formData.report.params) === '{}') {
             return false
           }
-          if(!this.isEdit){
-            addTask(this.formData).then(res=>{
+          if (!this.isEdit) {
+            addTask(this.formData).then(res => {
+              if (res.code === 200) {
+                this.$message({
+                  type: 'success',
+                  message: res.msg
+                });
+              } else {
+                this.$message({
+                  type: 'danger',
+                  message: res.msg
+                });
+              }
+              this.getList()
+              this.dialogVisible = false
+            })
+          } else {
+            updateTask(this.formData).then(res => {
+              if (res.code === 200) {
+                this.$message({
+                  type: 'success',
+                  message: res.msg
+                });
+              } else {
+                this.$message({
+                  type: 'danger',
+                  message: res.msg
+                });
+              }
+              this.getList()
               this.dialogVisible = false
             })
           }
@@ -462,21 +554,21 @@ export default {
       if (!this.isEdit) {
         if (this.formData.powerRationing.componentType.includes('光伏')) {
           this.formData.powerRationing.params = {
-            mongodb_database:'',
-            mongodb_read_table:'',
-            mongodb_write_table:'',
-            col_power:'',
-            col_radiance:'',
+            mongodb_database: '',
+            mongodb_read_table: '',
+            mongodb_write_table: '',
+            col_power: '',
+            col_radiance: '',
             sigma: 1
           }
         } else {
           this.formData.powerRationing.params = {
-            mongodb_database:'',
-            mongodb_read_table:'',
-            mongodb_write_table:'',
-            col_power:'',
-            col_ws:'',
-            cap:'',
+            mongodb_database: '',
+            mongodb_read_table: '',
+            mongodb_write_table: '',
+            col_power: '',
+            col_ws: '',
+            cap: '',
             eps: 0.1,
             min_samples: '20'
           }
@@ -543,10 +635,32 @@ export default {
   width: calc(100% - 350px);
 }
 
-.mode-table .model-table-tr:last-child {
-  border-bottom: 1px solid #ebeef5;
+.mode-table {
+  max-height: 63vh;
+  overflow-y: auto;
+  position: relative;
+  border-collapse: separate;
 }
 
+.mode-table-thead {
+  position: sticky;
+  top: 0;
+  z-index: 1000000;
+  background-color: white;
+  &:first-child{
+    border-bottom: 1px solid #ebeef5;
+  }
+}
+.mode-table.mode-table-body .model-table-tr {
+  &:last-child{
+    border-bottom: 1px solid #ebeef5;
+  }
+}
+.mode-table .mode-table-body .model-table-tr{
+  &:first-child{
+    border-top: none;
+  }
+}
 .model-table-tr {
   width: 100%;
   text-align: center;

+ 24 - 20
xvji-ui/src/views/tasks/training/modelForm.vue

@@ -56,8 +56,8 @@
                   :autosize="{ minRows: 1 }"></el-input>
       </el-form-item>
 
-      <el-form-item label="是否配置生产" prop="forecast_file" v-if="modelType !== 3 && modelType !==4" @change="forecastFileChange">
-        <el-select v-model="form['forecast_file']" clearable placeholder="请选择" size="small" style="width: 100%">
+      <el-form-item label="是否配置生产" prop="forecast_file" v-if="modelType !== 3 && modelType !==4" >
+        <el-select v-model="form['forecast_file']" clearable placeholder="请选择" size="small" style="width: 100%" @change="forecastFileChange">
           <el-option
             v-for="item in forecastFileType" :disabled="!model.isEnable"
             :key="item.value"
@@ -208,26 +208,27 @@ export default {
   watch: {
     formData: {
       handler(newVal, oldVal) {
-        // console.log(newVal)
-        this.$nextTick(() => {
-          this.$refs.modelForm.clearValidate()
-        });
+        console.log(newVal)
+
         this.model = newVal
         this.modelType = this.modelName.find(w => w.label === newVal.componentType).value
         this.rules = {}
         if(this.modelType === 0){
-          this.rules = { ...this.commonRules, ...this.solarRules }
+          this.rules = { ...this.commonRules,...this.dynamicRules, ...this.solarRules }
         }else if(this.modelType === 1){
-          this.rules = { ...this.commonRules, ...this.windRules }
+          this.rules = { ...this.commonRules,...this.dynamicRules, ...this.windRules }
         }else if(this.modelType === 2){
-          this.rules = { ...this.commonRules, ...this.HoltwintersRules }
+          this.rules = { ...this.commonRules,...this.dynamicRules, ...this.HoltwintersRules }
         }else if(this.modelType === 3){
-          this.rules = { ...this.commonRules, ...this.LSTMRules }
+          this.rules = { ...this.commonRules,...this.dynamicRules, ...this.LSTMRules }
         }else if(this.modelType === 4){
-          this.rules = { ...this.commonRules, ...this.machineRules }
+          this.rules = { ...this.commonRules,...this.dynamicRules, ...this.machineRules }
         }
         this.form = JSON.parse(JSON.stringify(newVal.params))
-
+        this.forecastFileChange()
+        this.$nextTick(() => {
+          this.$refs.modelForm.clearValidate()
+        });
       },
       immediate: true,
       deep: true
@@ -285,14 +286,14 @@ export default {
         farm_id: [
           {required: true, message: '请填写站点编码', trigger: 'blur'}
         ],
+      },
+      dynamicRules:{
         target: [
           {required: true, message: '请填写目标列', trigger: 'blur'}
         ],
         model_name: [
           {required: true, message: '请填写模型名称', trigger: 'blur'}
         ],
-
-
       },
       solarRules: {
         radiance_max: [
@@ -374,10 +375,6 @@ export default {
   },
   methods: {
     saveTask() {
-      if(this.form['forecast_file'] === '0'){
-        this.$refs.modelForm.clearValidate('target')
-        this.$refs.modelForm.clearValidate('model_name')
-      }
       this.$refs.modelForm.validate((valid) => {
         if (valid) {
           // console.log('child submit!');
@@ -385,6 +382,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
+          this.$message.warning(this.model.componentType+'模块校验未通过')
           console.log('error submit!!');
           return false;
         }
@@ -403,9 +401,15 @@ export default {
     forecastFileChange(){
       if(this.form['forecast_file'] === '0'){
         this.form['howLongAgo'] = '1'
-        this.$refs.modelForm.clearValidate('target')
-        this.$refs.modelForm.clearValidate('model_name')
+        delete this.rules.target;
+        delete this.rules.model_name;
+        this.rules = Object.assign(this.dynamicRules,this.rules)
+        this.$nextTick(() => {
+          this.$refs.modelForm.clearValidate()
+        });
       }else{
+        delete this.rules.target;
+        delete this.rules.model_name;
         this.form['howLongAgo'] = ''
       }
     }

+ 1 - 1
xvji-ui/src/views/tasks/training/modelTestForm.vue

@@ -211,7 +211,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
-          console.log('error submit!!');
+          this.$message.warning(this.modelTest.componentType+'模块校验未通过')
           return false;
         }
       });

+ 1 - 3
xvji-ui/src/views/tasks/training/powerRationingForm.vue

@@ -71,7 +71,6 @@ export default {
         console.log(newVal)
         // this.$refs.powerRationingForm.resetFields()
         this.powerRationing = newVal
-        console.log(newVal)
         this.stationType = newVal.componentType.includes('光伏')?0:1
         this.rules = {}
         if(this.stationType === 0){
@@ -80,7 +79,6 @@ export default {
           this.rules = { ...this.commonRules, ...this.windRules }
         }
         this.form = JSON.parse(JSON.stringify(newVal.params))
-        console.log(this.rules)
         this.$nextTick(() => {
           this.$refs.powerRationingForm.resetFields();
         });
@@ -139,7 +137,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
-          console.log('error submit!!');
+          this.$message.warning(this.powerRationing.componentType+'模块校验未通过')
           return false;
         }
       });

+ 1 - 1
xvji-ui/src/views/tasks/training/processingForm.vue

@@ -110,7 +110,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
-          console.log('error submit!!');
+          this.$message.warning(this.processing.componentType+'模块校验未通过')
           return false;
         }
       });

+ 1 - 1
xvji-ui/src/views/tasks/training/reportForm.vue

@@ -111,7 +111,7 @@ export default {
           return true
         } else {
           this.$emit('child-event', {})
-          console.log('error submit!!');
+          this.$message.warning(this.report.componentType+'模块校验未通过')
           return false;
         }
       });