Преглед на файлове

删除常用策略功能

xusl преди 6 месеца
родител
ревизия
a614c03c6d
променени са 2 файла, в които са добавени 174 реда и са изтрити 119 реда
  1. 13 0
      cpp-admin/src/main/java/com/cpp/web/controller/regulation/DqUsualController.java
  2. 161 119
      cpp-ui/src/views/regulation/dqRegulation/index.vue

+ 13 - 0
cpp-admin/src/main/java/com/cpp/web/controller/regulation/DqUsualController.java

@@ -73,6 +73,19 @@ public class DqUsualController {
         tempShortUsualDetailService.saveBatch(tempShortUsualDetailList);
         return R.ok();
     }
+    @PostMapping("/deleteUsual")
+    public R deleteUsual(String usualName) {
+        QueryWrapper<TempShortUsual> tempShortUsualQueryWrapper = new QueryWrapper<>();
+        tempShortUsualQueryWrapper.eq("usual_name", usualName);
+        TempShortUsual tempShortUsual = tempShortUsualService.getOne(tempShortUsualQueryWrapper);
+        long id = tempShortUsual.getId();
+        // 先删除子表数据
+        tempShortUsualDetailService.remove(new QueryWrapper<TempShortUsualDetail>().eq("usual_id", id));
+        // 再删除主表数据
+        tempShortUsualService.removeById(id);
+
+        return R.ok();
+    }
 
     /**
      * 获取常用策略列表

+ 161 - 119
cpp-ui/src/views/regulation/dqRegulation/index.vue

@@ -4,20 +4,20 @@
       <el-form ref="queryForm" size="small" :inline="true" popper-class="cpp-popper">
         <el-form-item label="预测日期">
           <el-date-picker
-            :clearable="false"
-            v-model="dateTime"
-            type="date"
-            :picker-options="expireDateOption"
-            placeholder="选择生成日期">
+              :clearable="false"
+              v-model="dateTime"
+              type="date"
+              :picker-options="expireDateOption"
+              placeholder="选择生成日期">
           </el-date-picker>
         </el-form-item>
         <el-form-item label="场站名称">
           <el-select v-model="stationCode" placeholder="请选择" popper-class="cpp-popper">
             <el-option
-              v-for="item in stationList"
-              :key="item.value"
-              :label="item.label"
-              :value="item.value">
+                v-for="item in stationList"
+                :key="item.value"
+                :label="item.label"
+                :value="item.value">
             </el-option>
           </el-select>
         </el-form-item>
@@ -42,51 +42,51 @@
 
         <div class="divTable">
           <el-table
-            :data="tableData"
-            height="550px"
-            :loading="loading"
-            size="mini"
-            style="width: 100%">
+              :data="tableData"
+              height="550px"
+              :loading="loading"
+              size="mini"
+              style="width: 100%">
             <el-table-column
-              prop="time"
-              header-align="center"
-              align="center"
-              label="时间"
+                prop="time"
+                header-align="center"
+                align="center"
+                label="时间"
             >
             </el-table-column>
             <el-table-column
-              prop="xs"
-              header-align="center"
-              align="center"
-              label="系数">
+                prop="xs"
+                header-align="center"
+                align="center"
+                label="系数">
               <template slot-scope="scope">
                 <vxe-input type="number" v-model="scope.row.xs" size="small" style="width:100%" min="0"
                            placeholder="" @change="setValueByManual(scope.row,scope.$index)"></vxe-input>
               </template>
             </el-table-column>
             <el-table-column
-              prop="sz"
-              header-align="center"
-              align="center"
-              label="数值">
+                prop="sz"
+                header-align="center"
+                align="center"
+                label="数值">
               <template slot-scope="scope">
                 <vxe-input type="number" v-model="scope.row.sz" size="small" style="width:100%"
                            placeholder="" @change="setValueByManual(scope.row,scope.$index)"></vxe-input>
               </template>
             </el-table-column>
             <el-table-column
-              prop="ysValue"
-              header-align="center"
-              align="center"
-              label="原始值">
+                prop="ysValue"
+                header-align="center"
+                align="center"
+                label="原始值">
             </el-table-column>
             <el-table-column
-              prop="tkValue"
-              header-align="center"
-              align="center"
-              label="调控值"
-              :max="capacity"
-              :min="0"
+                prop="tkValue"
+                header-align="center"
+                align="center"
+                label="调控值"
+                :max="capacity"
+                :min="0"
             >
             </el-table-column>
           </el-table>
@@ -144,44 +144,46 @@
     </div>
 
     <div class="dark-el-dialog">
-      <el-dialog :visible.sync="quickUseOpen" :before-close="cancelQuickUse" :close-on-click-modal="false" style="height: calc(100% - 50px)">
+      <el-dialog :visible.sync="quickUseOpen" :before-close="cancelQuickUse" :close-on-click-modal="false"
+                 style="height: calc(100% - 50px)">
         <div class="reg-config-container flex justify-between">
           <div>
-<!--  策略列表          -->
-            <div  class="reg-config flex items-center">
-            <el-radio v-model="vradio" label="1" @click.native.prevent="radioChange('1')">快捷选择历史策略:</el-radio>
-            <div>
-              <!-- 循环生成按钮 -->
-              <el-button
-                v-for="(button, index) in buttons"
-                :key="index"
-                @click="handleButtonClick(button.usualName)"
-              >
-                {{ button.usualName }}
-              </el-button>
+            <!--  策略列表          -->
+            <div class="reg-config flex items-center">
+              <el-radio v-model="vradio" label="1" @click.native.prevent="radioChange('1')">快捷选择历史策略:</el-radio>
+              <div>
+                <!-- 循环生成按钮 -->
+                <el-button
+                    v-for="(button, index) in buttons"
+                    :key="index"
+                    @click="handleButtonClick(button.usualName)"
+                >
+                  {{ button.usualName }}
+                </el-button>
+              </div>
             </div>
-          </div>
             <div class="reg-config flex items-center">
               <el-radio v-model="vradio" label="2" @click.native.prevent="radioChange('2')">选择历史策略:</el-radio>
               <div>
-                <el-select ref="selectUsualName" v-model="usualId" placeholder="请选择" popper-class="cpp-popper" :disabled="disabled" @change="changeUsualName">
+                <el-select ref="selectUsualName" v-model="usualId" placeholder="请选择" popper-class="cpp-popper"
+                           :disabled="disabled" @change="changeUsualName">
                   <el-option
-                    v-for="item in usualList"
-                    :key="item.id"
-                    :label="item.usualName"
-                    :value="item.id">
+                      v-for="item in usualList"
+                      :key="item.id"
+                      :label="item.usualName"
+                      :value="item.id">
                   </el-option>
                 </el-select>
               </div>
             </div>
-            <div  class="reg-config flex items-center">
+            <div id="currentSelectFunction" style="display: none" class="reg-config flex items-center">
               <div>当前选择策略:</div>
               <div style="width: 200px">
                 {{ this.currentStrategy }}
               </div>
               <div>
-                <el-button @click="trialClick">预览</el-button>
-                <el-button>删除</el-button>
+                <el-button @click="trialPreview">预览</el-button>
+                <el-button @click="trialDelete">删除</el-button>
               </div>
             </div>
             <div slot="footer" class="dialog-footer">
@@ -189,47 +191,47 @@
               <el-button @click="cancelQuickUse">取 消</el-button>
             </div>
           </div>
-<!--          <el-divider direction="vertical" style="height: calc(100% - 30px)"></el-divider>-->
+          <!--          <el-divider direction="vertical" style="height: calc(100% - 30px)"></el-divider>-->
           <div>
-<!--   预览表格         -->
+            <!--   预览表格         -->
             <el-table
-              :data="trialData"
-              height="550px"
-              :loading="loading"
-              size="mini"
-              style="width: 100%">
+                :data="trialData"
+                height="550px"
+                :loading="loading"
+                size="mini"
+                style="width: 100%">
               <el-table-column
-                prop="time"
-                header-align="center"
-                align="center"
-                label="时间"
+                  prop="time"
+                  header-align="center"
+                  align="center"
+                  label="时间"
               >
               </el-table-column>
               <el-table-column
-                prop="xs"
-                header-align="center"
-                align="center"
-                label="系数">
+                  prop="xs"
+                  header-align="center"
+                  align="center"
+                  label="系数">
               </el-table-column>
               <el-table-column
-                prop="sz"
-                header-align="center"
-                align="center"
-                label="数值">
+                  prop="sz"
+                  header-align="center"
+                  align="center"
+                  label="数值">
               </el-table-column>
               <el-table-column
-                prop="ysValue"
-                header-align="center"
-                align="center"
-                label="原始值">
+                  prop="ysValue"
+                  header-align="center"
+                  align="center"
+                  label="原始值">
               </el-table-column>
               <el-table-column
-                prop="tkValue"
-                header-align="center"
-                align="center"
-                label="调控值"
-                :max="capacity"
-                :min="0"
+                  prop="tkValue"
+                  header-align="center"
+                  align="center"
+                  label="调控值"
+                  :max="capacity"
+                  :min="0"
               >
               </el-table-column>
             </el-table>
@@ -251,8 +253,8 @@ export default {
   name: 'inverterinfo',
   data() {
     return {
-      trialData:[],
-      disabled:true,
+      trialData: [],
+      disabled: true,
       vradio: '1',
       buttons: new Array(),
       usualId: '',
@@ -344,9 +346,8 @@ export default {
         },
         xAxis: [{
           type: 'category',
-          // boundaryGap: false,
+          boundaryGap: false,
           axisLine: {onZero: false},
-          // data: this.hoursArray
         }],
         yAxis: [{
           type: 'value',
@@ -474,19 +475,22 @@ export default {
   computed: {},
   methods: {
     // 策略名称下拉框选择
-    changeUsualName(id){
+    changeUsualName(id) {
       const item = this.usualList.find(item => item.id == id)
       let usualName = item ? item.usualName : ''
       this.currentStrategy = usualName
+      document.getElementById("currentSelectFunction").style.display = ''
     },
     radioChange(radioValue) {
+      document.getElementById("currentSelectFunction").style.display = 'none'
       this.currentStrategy = ''
+      this.trialData = []
       if (radioValue == '1') {
-        this.vradio='1'
-        this.usualId=''
+        this.vradio = '1'
+        this.usualId = ''
         this.disabled = true
       } else {
-        this.vradio='2'
+        this.vradio = '2'
         this.disabled = false
 
       }
@@ -496,30 +500,63 @@ export default {
       if (this.vradio == '1') {
         // 执行常用按钮点击
         this.currentStrategy = usualName
+        document.getElementById("currentSelectFunction").style.display = ''
       }
     },
-    async executeTrial(){
+    async executeTrial() {
       const param = {
         "usualName": this.currentStrategy,
         "stationCode": this.tableData[0].stationCode,
-        "time":new Date(this.tableData[0].forecastDate).getTime()
+        "time": new Date(this.tableData[0].forecastDate).getTime()
       }
       // 获取策略名称的系数和数值
-      await this.$axios.get('/dqRegulationController/trialData',{params: param}).then(response => {
+      await this.$axios.get('/dqRegulationController/trialData', {params: param}).then(response => {
         this.trialData = response.data
       })
     },
+    // 删除按钮点击
+    trialDelete() {
+      if (this.currentStrategy == '') {
+        this.$message.warning("请选择策略名称进行删除!")
+        return
+      }
+      this.$confirm('是否确认删除【' + this.currentStrategy + '】?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        // 提交名称及系数配置
+        const formData = new FormData()
+        formData.append('usualName', this.currentStrategy)
+        this.$axios.post('/dqUsualController/deleteUsual', formData, {
+          headers: {
+            'Content-Type': 'multipart/form-data' // 设置请求头,确保服务器正确解析 FormData
+          }
+        }).then((res) => {
+          this.$message.success('删除策略成功!')
+          document.getElementById("currentSelectFunction").style.display = "none"
+          this.trialData = []
+          // 重新渲染下拉框
+          this.renderUsual()
+        }).catch((error) => {
+        })
+      })
+    },
     // 预览按钮点击
-    trialClick(){
-      if (this.currentStrategy==''){
+    trialPreview() {
+      if (this.currentStrategy == '') {
         this.$message.warning("请选择策略名称进行预览!")
         return
       }
       this.executeTrial()
     },
     // 一键应用中确定
-    quickUseCommit(){
-      this.executeTrial()
+    async quickUseCommit() {
+      if (this.currentStrategy == '') {
+        this.$message.warning("请选择策略进行应用!")
+        return
+      }
+      await this.executeTrial()
       // 将列表数据赋值给底层列表
       this.tableData = this.trialData
       // 将预算的调控曲线赋值给底层曲线上
@@ -540,19 +577,17 @@ export default {
     // 一键应用中取消按钮
     cancelQuickUse() {
       this.quickUseOpen = false;
-      this.trialData=[]
-      console.log(this.trialData)
-      this.currentStrategy=''
-      this.buttons=[]
-      this.vradio='1'
-      this.disabled=true
+      this.trialData = []
+      this.currentStrategy = ''
+      this.buttons = []
+      this.vradio = '1'
+      this.disabled = true
+      document.getElementById("currentSelectFunction").style.display = 'none'
     },
-    quickUse() {
-      if (this.tableData.length==0){
-        this.$message.warning("调控列表为空,不能操作!")
-        return
-      }
-
+    renderUsual() {
+      this.buttons = []
+      this.usualId = ''
+      this.currentStrategy=''
       // 先获取常用下拉框
       this.$axios.get('/dqUsualController/getUsualList').then(response => {
         this.usualList = response.data
@@ -565,12 +600,18 @@ export default {
           }
         }
       })
-
+    },
+    quickUse() {
+      if (this.tableData.length == 0) {
+        this.$message.warning("调控列表为空,不能操作!")
+        return
+      }
+      this.renderUsual()
       this.quickUseOpen = true
     },
     // 点击设为常用按钮触发
     usualSet() {
-      if (this.tableData.length==0){
+      if (this.tableData.length == 0) {
         this.$message.warning("调控列表为空,不能操作!")
         return
       }
@@ -609,7 +650,7 @@ export default {
       this.usualForm = {
         usualName: undefined,
       },
-        this.resetForm("usualForm");
+          this.resetForm("usualForm");
     },
     // 取消按钮
     cancelUsual() {
@@ -617,7 +658,7 @@ export default {
       this.resetUsual();
     },
     tkDialog() {
-      if (this.tableData.length==0){
+      if (this.tableData.length == 0) {
         this.$message.warning("调控列表为空,不能操作!")
         return
       }
@@ -863,7 +904,8 @@ export default {
   width: 100%;
   text-align: center
 }
-.reg-config{
+
+.reg-config {
   margin-top: 5px;
 }
 </style>