瀏覽代碼

添加批量操作

FinalYu 2 年之前
父節點
當前提交
811a4ca542

+ 64 - 0
chuanyi_client2/src/api/datasource.js

@@ -276,6 +276,22 @@ export function getItemById(id) {
 }
 
 /**
+ * 批量设置表达式
+ * @param data
+ * @returns {AxiosPromise}
+ */
+export function batchSetExpresses(data) {
+    return request({
+        url: '/itemGroup/batchSetExpresses',
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data
+    })
+}
+
+/**
  * 查询所有模型数据
  * @param params
  * @returns {AxiosPromise}
@@ -751,4 +767,52 @@ export function getUserByGroupId(id) {
         },
         method: 'get'
     })
+}
+
+/**
+ * 删除通知信息
+ * @param id
+ * @returns {AxiosPromise}
+ */
+export function deleteMessageNoticeById(id) {
+    let uri = '/messageNotice/deleteMessageNoticeById?id=' + id
+    return request({
+        url: uri,
+        headers: {
+            isToken: true
+        },
+        method: 'post'
+    })
+}
+
+/**
+ * 批量删除通知信息
+ * @param data
+ * @returns {AxiosPromise}
+ */
+export function delMesNotByIdList(data) {
+    let uri = '/messageNotice/delMesNotByIdList'
+    return request({
+        url: uri,
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data
+    })
+}
+
+/**
+ * 清空所有通知信息
+ * @returns {AxiosPromise}
+ */
+export function clearMessage() {
+    let uri = '/messageNotice/clearMessage'
+    return request({
+        url: uri,
+        headers: {
+            isToken: true
+        },
+        method: 'post'
+    })
 }

+ 12 - 3
chuanyi_client2/src/components/HeaderMain/index.vue

@@ -94,7 +94,7 @@
     <ul v-show="visibleGroupChildMenu"
         :style="{ left: menuLeft + 'px', top: menuTop + 'px' }"
         class="contextmenu contextmenu-black">
-      <li v-if="this.chooseGroupData && this.chooseGroupData.runState == 0" @click="runOrStopGroup(1)">运行</li>
+      <li v-if="this.chooseGroupData && this.chooseGroupData.runState != 1" @click="runOrStopGroup(1)">运行</li>
       <li v-if="this.chooseGroupData && this.chooseGroupData.runState == 1" @click="runOrStopGroup(0)">停止</li>
       <li @click="updateGroup">修改</li>
       <li @click="delGroup">删除</li>
@@ -597,7 +597,6 @@ export default {
         modeValueH: 0,
         modeValueM: 0,
         modeValueS: 0,
-        modeValueUnit: '1',
         daySetting: [],
         valuePeriod: ['00:00:00', '23:59:59']
       },
@@ -942,7 +941,6 @@ export default {
         modeValueH: 0,
         modeValueM: 0,
         modeValueS: 0,
-        modeValueUnit: '1',
         daySetting: [],
         valuePeriod: ['00:00:00', '23:59:59']
       }
@@ -1345,6 +1343,17 @@ export default {
     /** 记录模式值改变事件 */
     readModeChange(val) {
       this.groupRateForm.modeValue = null
+      this.groupRateForm.readModeType = null
+      this.groupRateForm.eventMode = null
+      this.groupRateForm.modeValueH = 0
+      this.groupRateForm.modeValueM = 0
+      this.groupRateForm.modeValueS = 0
+      this.reportEventConfigForm = {
+        itemName: '',
+        tableReportId: null,
+        tableReportName: null
+      },
+
       this.groupRateForm.readMode = val
       this.$refs.groupRateForm.clearValidate()
     },

+ 111 - 2
chuanyi_client2/src/components/HeaderPersonal/index.vue

@@ -88,13 +88,27 @@
         v-if="dialogNoticeVisible"
         :before-close="dialogClose"
         :visible.sync="dialogNoticeVisible"
-        :close-on-click-modal="true"
+        :close-on-click-modal="false"
         :append-to-body="true">
+      <el-button type="danger"
+                 icon="el-icon-delete"
+                 size="mini"
+                 @click="delMsgAllEvent"
+                 style="float: right;margin-bottom: 10px;">清空</el-button>
+      <el-button icon="el-icon-delete"
+                 size="mini"
+                 @click="multipleDelMsgEvent"
+                 style="float: right;margin-bottom: 10px; margin-right: 10px;">批量删除</el-button>
       <el-table
           :data="tableNoticeData" border :stripe="true"
           @sort-change="sortChange"
           :header-cell-style="{background: '#E8E8E8'}"
-          style="width: 100%; height: calc(100% - 50px); overflow: auto;">
+          @selection-change="handleSelectionChange"
+          style="width: 100%; height: calc(100% - 100px); overflow: auto;">
+        <el-table-column
+            type="selection"
+            width="55">
+        </el-table-column>
         <el-table-column label="序号" align="center" width="80">
           <template slot-scope="scope">
             {{ scope.$index + 1 }}
@@ -106,6 +120,15 @@
         </el-table-column>
         <el-table-column align="center" sortable label="报警时间" prop="createTime" width="200">
         </el-table-column>
+        <el-table-column label="操作" align="center" width="300">
+          <template slot-scope="scope">
+            <el-button type="text"
+                       size="small"
+                       icon="el-icon-delete"
+                       style="color: red;"
+                       @click="handleDelete(scope.$index, scope.row)">删除</el-button>
+          </template>
+        </el-table-column>
       </el-table>
       <el-pagination
           style="margin-top: 20px;"
@@ -128,6 +151,7 @@ import {getPubKey} from '@/utils/auth'
 import {encrypt} from '@/utils/jsencrypt'
 import {customCompare, showAlertWin, showLoading} from '@/utils/cqcy'
 import {getAllMessageNotice} from "@/api/basic";
+import {clearMessage, delDataModelById, deleteMessageNoticeById, delMesNotByIdList} from "@/api/datasource";
 
 let pkg = require('../../../package.json')
 
@@ -155,6 +179,7 @@ export default {
       tablePage: 1,
       tableLimit: 10,
       tableTotal: 0,
+      multipleSelectionMsg: [],
       userPwdForm: {
         password: '',
         newPassword: '',
@@ -320,6 +345,90 @@ export default {
       }).catch(() => {
       });
     },
+    /** 删除报警信息 */
+    handleDelete(index, row) {
+      this.$confirm('您确定要删除该报警信息吗?', '温馨提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        customClass: 'close_confirm',
+        closeOnClickModal: false
+      }).then(() => {
+        const loading = showLoading(this, '删除中,请稍候···')
+        deleteMessageNoticeById(row.id).then(res => {
+          loading.close()
+          this.$message({
+            message: '删除成功!',
+            type: 'success'
+          })
+          this.tablePage = 1
+          this.getWarnInfo()
+        }).catch((e) => {
+          loading.close()
+          showAlertWin(this, e)
+        })
+      }).catch(() => {
+      })
+    },
+    /** 表格选择事件 */
+    handleSelectionChange(val) {
+      this.multipleSelectionMsg = val
+    },
+    /** 批量删除报警信息 */
+    multipleDelMsgEvent() {
+      if (this.multipleSelectionMsg.length == 0) {
+        this.$message({
+          message: '请至少选择一项报警信息',
+          type: 'warning'
+        })
+        return
+      }
+      this.$confirm('您确定要删除选中的' + this.multipleSelectionMsg.length + '条报警信息吗?', '温馨提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        customClass: 'close_confirm',
+        closeOnClickModal: false
+      }).then(() => {
+        const loading = showLoading(this, '删除中,请稍候···')
+        let ids = Array.from(this.multipleSelectionMsg, ({ id }) => id)
+        delMesNotByIdList(ids).then(res => {
+          loading.close()
+          this.$message({
+            message: '删除成功!',
+            type: 'success'
+          })
+          this.tablePage = 1
+          this.getWarnInfo()
+        }).catch((e) => {
+          loading.close()
+          showAlertWin(this, e)
+        })
+      }).catch(() => {
+      })
+    },
+    /** 清空所有消息 */
+    delMsgAllEvent() {
+      this.$confirm('清除后不可恢复,您确定要继续吗?', '温馨提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        customClass: 'close_confirm',
+        closeOnClickModal: false
+      }).then(() => {
+        const loading = showLoading(this, '清除中,请稍候···')
+        clearMessage().then(res => {
+          loading.close()
+          this.$message({
+            message: '清除成功!',
+            type: 'success'
+          })
+          this.tablePage = 1
+          this.getWarnInfo()
+        }).catch((e) => {
+          loading.close()
+          showAlertWin(this, e)
+        })
+      }).catch(() => {
+      })
+    },
     /** 弹出层关闭事件 */
     dialogClose(done) {
       if (this.$refs['userPwdForm'])

+ 88 - 2
chuanyi_client2/src/views/group_item/index.vue

@@ -25,7 +25,13 @@
                  icon="el-icon-delete"
                  size="mini"
                  @click="multipleDelItemEvent"
-                 style="float: right; margin-right: 20px;">批量删除</el-button>
+                 style="float: right;">批量删除</el-button>
+      <el-button type="primary"
+                 v-show="!groupRunStatus"
+                 icon="el-icon-s-tools"
+                 size="mini"
+                 @click="multipleModelItemEvent"
+                 style="float: right; margin-right: 15px;">批量设置表达式</el-button>
     </div>
     <el-table :data="itemDataList"
               border
@@ -167,11 +173,37 @@
         <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
       </span>
     </el-dialog>
+
+    <el-dialog
+        title="选择四则运算表达式"
+        width="500px"
+        top="10vh"
+        center
+        v-dialog-drag
+        v-if="dialogDataModelVisible"
+        :before-close="dialogDataModelClose"
+        :visible.sync="dialogDataModelVisible"
+        :close-on-click-modal="false"
+        :append-to-body="true">
+      <el-select v-model="chooseDataModel" filterable clearable placeholder="请选择表达式" style="width: 100%;">
+        <el-option
+            v-for="(item, index) in this.dataModelList"
+            :key="index"
+            :label="item.title"
+            :value="item.id">
+        </el-option>
+      </el-select>
+      <div style="width: 100%; text-align: center; margin-top: 20px;">
+        <el-button type="primary" @click="saveDataModelEvent">确定</el-button>
+        <el-button @click="dialogDataModelClose">取消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import {
+  batchSetExpresses,
   deleteItemByIdList,
   getAllDataModel, getAllReportTable,
   getItemById,
@@ -189,10 +221,12 @@ export default {
   data() {
     return {
       dialogItemVisible: false,
+      dialogDataModelVisible: false,
       itemDataList: [],
       itemDataListF: [],
       groupDataList: [],
       dataModelList: [],
+      chooseDataModel: null,
       selectionItems: [],
       eventReportList: [],
       chooseGroup: null,
@@ -496,6 +530,50 @@ export default {
     selectionLineChangeHandle(val) {
       this.selectionItems = val
     },
+    /** 批量设置组数据中数据项表达式 */
+    multipleModelItemEvent() {
+      if (!this.selectionItems || this.selectionItems.length == 0) {
+        this.$message({
+          message: '请至少选择一项数据',
+          type: 'warning'
+        })
+        return
+      }
+      this.getAllDataModel(status => {
+        this.dialogDataModelVisible = true
+      })
+    },
+    /** 批量设置组数据中数据项表达式 */
+    saveDataModelEvent() {
+      let ids = Array.from(this.selectionItems, ({ id }) => id)
+      let itemList = []
+      ids.forEach((id) => {
+        itemList.push({
+          'id': id,
+          'dataModelId': this.chooseDataModel
+        })
+      })
+      let params = {
+        'itemList': itemList
+      }
+      const loading = showLoading(this, '设置中,请稍候···')
+      batchSetExpresses(params).then(res => {
+        loading.close()
+        let msg = res.data ? '设置成功!' : '设置失败!'
+        let msgType = res.data ? 'success' : 'error'
+        this.$message({
+          message: msg,
+          type: msgType
+        })
+        this.dialogDataModelVisible = false
+        this.selectionItems = []
+        this.chooseDataModel = null
+        this.getGroupById(this.chooseGroupId)
+      }).catch((e) => {
+        loading.close()
+        showAlertWin(this, e)
+      })
+    },
     /** 批量删除组数据中数据项 */
     multipleDelItemEvent() {
       if (!this.selectionItems || this.selectionItems.length == 0) {
@@ -526,7 +604,15 @@ export default {
       } else {
         this.dialogItemVisible = false
       }
-    }
+    },
+    /** 数据模型弹出层关闭事件 */
+    dialogDataModelClose() {
+      if (typeof(done) === 'function') {
+        done()
+      } else {
+        this.dialogDataModelVisible = false
+      }
+    },
   }
 }
 </script>