Bläddra i källkod

Merge remote-tracking branch 'origin/master'

zhoupeng 1 år sedan
förälder
incheckning
a7aa40d227

+ 1 - 1
chuanyi_client2/src/api/datasource.js

@@ -128,7 +128,7 @@ export function getDriverList(data) {
  * @returns {AxiosPromise}
  */
 export function getAllItemGroup(readMode) {
-    if (readMode) {
+    if (readMode && readMode != 5) {
         return request({
             url: '/itemGroup/getAllItemGroup?readMode=' + readMode,
             headers: {

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 0
chuanyi_client2/src/assets/icons/svg/report_d.svg


+ 6 - 5
chuanyi_client2/src/components/CustomDialog/DataSourceItem.vue

@@ -556,6 +556,7 @@ export default {
       }
       if (chooseChannelNameList.length == 0) {
         showAlertMsgWin(this, null, '请选择子数据项!')
+        return
       }
       // 去重
       let arr = JSON.parse(JSON.stringify(this.chooseItemDataListByTree))
@@ -576,14 +577,14 @@ export default {
           }
         }
       }
-      this.chooseItemDataListByTree = arr
-      this.isSelectAllItem = false
-      this.leavesChooseList = []
-      setTimeout(() => {
+      this.$nextTick(() => {
+        this.chooseItemDataListByTree = arr
+        this.leavesChooseList = []
+        this.isSelectAllItem = false
         this.isSelectAllItemData = false
         this.$refs.itemTree.setCheckedKeys([])
         this.$refs.chooseItemTree.setCheckedNodes([])
-      }, 100)
+      })
     },
     /** 移除数据项 */
     removeCheckNodesBtnEvent() {

+ 10 - 6
chuanyi_client2/src/components/HeaderMain/index.vue

@@ -22,6 +22,7 @@
                 <template v-else>
                   <svg-icon v-if="data.templateType == 1" icon-class="report_a"/>
                   <svg-icon v-else-if="data.templateType == 2" icon-class="report_e"/>
+                  <svg-icon v-else-if="data.templateType == 5" icon-class="report_d"/>
                   <svg-icon v-else icon-class="report_m"/>
                 </template>
                 <span :title='data.reportNameTips' style="margin-left: 2px;">{{ data.reportName || data.itemName }}</span>
@@ -927,7 +928,8 @@ export default {
           let temp = res.data.tableTemplateList[i]
           let type = temp.templateType == 0 ? '[手动报表]  ' :
               temp.templateType == 1 ? '[自动报表]  ' :
-              temp.templateType == 2 ? '[事件驱动报表]  ' : ''
+              temp.templateType == 2 ? '[事件驱动报表]  ' :
+              temp.templateType == 5 ? '[设备报表]  ' : ''
           dataList.push({
             id: temp.id,
             reportName: temp.templateName,
@@ -1737,6 +1739,7 @@ export default {
       }
       if (chooseChannelNameList.length == 0) {
         showAlertMsgWin(this, null, '请选择子数据项!')
+        return
       }
       // 去重
       let arr = JSON.parse(JSON.stringify(this.chooseItemDataListByTree))
@@ -1757,13 +1760,14 @@ export default {
           }
         }
       }
-      this.chooseItemDataListByTree = arr
-      this.isSelectAllItem = false
-      this.leavesChooseList = []
-      setTimeout(() => {
+      this.$nextTick(() => {
+        this.chooseItemDataListByTree = arr
+        this.isSelectAllItem = false
+        this.isSelectAllItemData = false
+        this.leavesChooseList = []
         this.$refs.itemTree.setCheckedKeys([])
         this.$refs.chooseItemTree.setCheckedNodes([])
-      }, 100)
+      })
     },
     /** 移除全部数据项 */
     removeAllCheckNodesBtnEvent() {

+ 7 - 4
chuanyi_client2/src/utils/export.js

@@ -189,10 +189,12 @@ var setImages = function (table, worksheet, workbook) {
         } else {
             col_st = getImagePosition(item.default.left, visibledatacolumn);
             row_st = getImagePosition(item.default.top, visibledatarow);
-            imgWidth = item.default.width;
-            imgHeight = item.default.height;
-            let w_ed = item.default.left + item.default.width;
-            let h_ed = item.default.top + item.default.height;
+            imgWidth = item.originWidth;
+            imgHeight = item.originHeight;
+            // imgWidth = item.default.width;
+            // imgHeight = item.default.height;
+            let w_ed = item.default.left + imgWidth;
+            let h_ed = item.default.top + imgHeight;
             let col_ed = getImagePosition(w_ed, visibledatacolumn);
             let row_ed = getImagePosition(h_ed, visibledatarow);
             cellConfig = {
@@ -437,6 +439,7 @@ export var exportExcel = function (luckysheet, value) {
 
     // 4.写入 buffer
     const buffer = workbook.xlsx.writeBuffer().then(data => {
+        console.log(data)
         const blob = new Blob([data], {
             type: 'application/vnd.ms-excel;charset=utf-8'
         })

+ 1 - 0
chuanyi_client2/src/utils/luckysheettool.js

@@ -71,6 +71,7 @@ export function insertLuckysheetEChart({
     n(l + " #luckysheet-cell-main").append(x);
     n('.'+u).mousedown(function(){return false});
     let S = r.init(document.getElementsByClassName(u)[0]);
+    f.animation = false;
     S.setOption(f);
     let k = S.getConnectedDataURL({
         type: "png",

+ 18 - 0
chuanyi_client2/src/views/my_report/index.vue

@@ -60,6 +60,7 @@
                 <el-tag v-if="scope.row.reportTableType == 0" style="margin-right: 5px;">手动报表</el-tag>
                 <el-tag v-if="scope.row.reportTableType == 1" style="margin-right: 5px;">自动报表</el-tag>
                 <el-tag v-if="scope.row.reportTableType == 2" style="margin-right: 5px;">事件驱动报表</el-tag>
+                <el-tag v-if="scope.row.reportTableType == 5" style="margin-right: 5px;">设备报表</el-tag>
               </template>
             </el-table-column>
             <el-table-column
@@ -187,6 +188,7 @@
             <el-radio label="0">手动报表</el-radio>
             <el-radio label="1">自动报表</el-radio>
             <el-radio label="2">事件驱动报表</el-radio>
+            <el-radio label="5">设备报表</el-radio>
           </el-radio-group>
         </el-form-item>
         <el-form-item label="报表模板" prop="tableTemplateId" v-if="!reportForm.id">
@@ -362,6 +364,7 @@
         <el-radio v-model="reportType" label="0">手动报表</el-radio>
         <el-radio v-model="reportType" label="1">自动报表</el-radio>
         <el-radio v-model="reportType" label="2">事件驱动报表</el-radio>
+        <el-radio v-model="reportType" label="5">设备报表</el-radio>
       </div>
       <span slot='footer'>
           <el-button type="primary" @click="chooseReportTypeEvent">确定</el-button>
@@ -623,6 +626,9 @@ export default {
       }, {
         label: '事件驱动报表',
         value: 2
+      }, {
+        label: '设备报表',
+        value: 5
       }],
       groupUserData: [],
       reportHistoryData: [],
@@ -1250,6 +1256,18 @@ export default {
       // 事件驱动报表
       if (type == 2 || type == 4) {
         tableItemList.forEach((tableItem, i) => {
+          if (i == 0) {
+            let valueTimeList = tableItem.valueTimeList ? tableItem.valueTimeList.split(',') : []
+            let xAxis = tableItem.xaxis
+            let yAxis = tableItem.yaxis - 1
+            if (valueTimeList.length == 0) {
+              luckysheet.setCellValue(xAxis, yAxis, '')
+            } else {
+              valueTimeList.forEach((v, j) => {
+                luckysheet.setCellValue(xAxis + j, yAxis, v)
+              })
+            }
+          }
           let valueList = tableItem.valueList ? tableItem.valueList.split(',') : []
           let xAxis = tableItem.xaxis
           let yAxis = tableItem.yaxis

+ 324 - 36
chuanyi_client2/src/views/report_template/index.vue

@@ -46,11 +46,11 @@
           <span>关闭</span>
         </div>
         <el-divider></el-divider>
-        <div class="cy-chart-div" @click="templateEvent()" v-if="templateReportType != 2">
+        <div class="cy-chart-div" @click="templateEvent()" v-if="templateReportType != 2 && templateReportType != 5">
           <svg-icon icon-class="report_template" style="width: 35px;"/>
           <span>模板库</span>
         </div>
-        <div class="cy-chart-div" @click="dataEvent(1)" v-if="templateReportType != 2">
+        <div class="cy-chart-div" @click="dataEvent(1)" v-if="templateReportType != 2 && templateReportType != 5">
           <svg-icon icon-class="report_basedata" style="width: 35px;"/>
           <span>基础数据项</span>
         </div>
@@ -62,15 +62,15 @@
           <svg-icon icon-class="report_data" style="width: 35px;"/>
           <span>数据项</span>
         </div>
-        <div class="cy-chart-div" @click="barEvent('bar')" v-if="templateReportType != 2">
+        <div class="cy-chart-div" @click="barEvent('bar')" v-if="templateReportType != 2 && templateReportType != 5">
           <svg-icon icon-class="bar_chart"/>
           <span>柱状图</span>
         </div>
-        <div class="cy-chart-div" @click="barEvent('line')" v-if="templateReportType != 2">
+        <div class="cy-chart-div" @click="barEvent('line')" v-if="templateReportType != 2 && templateReportType != 5">
           <svg-icon icon-class="line_chart"/>
           <span>折线图</span>
         </div>
-        <div class="cy-chart-div" @click="barEvent('pie')" v-if="templateReportType != 2">
+        <div class="cy-chart-div" @click="barEvent('pie')" v-if="templateReportType != 2 && templateReportType != 5">
           <svg-icon icon-class="pie_chart"/>
           <span>饼状图</span>
         </div>
@@ -227,6 +227,57 @@
       </div>
     </el-dialog>
 
+    <!-- 数据组选择(设备报表) -->
+    <el-dialog
+        title="选择条件数据项"
+        width="600px"
+        top="10vh"
+        center
+        v-dialog-drag-and-zoom
+        v-if="dialogDeviceDataItemVisible"
+        :before-close="dialogItemClose"
+        :visible.sync="dialogDeviceDataItemVisible"
+        :close-on-click-modal="false"
+        :append-to-body="true">
+      <div>
+        <div style="margin-bottom: 10px;">
+          <span>组名称:{{ itemDataListByGroupName }}(共 {{ itemDeviceDataListByTree.length }} 项)</span>
+        </div>
+        <el-input placeholder="请输入关键字进行过滤" v-model="filterDeviceItemData"></el-input>
+        <div style="height: 50vh; margin-top: 10px; overflow: auto;">
+          <el-tree class="cy-item-tree"
+                   ref="deviceItemTree"
+                   :data="itemDeviceDataListByTree"
+                   :indent="10"
+                   node-key="id"
+                   show-checkbox
+                   :check-on-click-node="true"
+                   :filter-node-method="filterItemDataNode"
+                   :highlight-current="true"
+                   :default-expand-all="true">
+              <span class="custom-tree-node" slot-scope="{ node, data }">
+                <svg-icon v-if="!data.children || data.children.length == 0" icon-class="file"/>
+                <svg-icon v-else-if="node.expanded" icon-class="folder-open"/>
+                <svg-icon v-else icon-class="folder"/>
+                <span :title='data.itemName || "-"' style="margin-left: 2px;">
+                  {{
+                    data.describe
+                        ? ((data.itemName ? data.itemName : '') + '(' + data.describe + ')')
+                        : data.itemName ? data.itemName : ''
+                  }}
+                </span>
+              </span>
+          </el-tree>
+        </div>
+      </div>
+      <div style="width: 100%;text-align: center;">
+        <el-button type="primary"
+                   @click="chooseDeviceItemTreeEvent"
+                   style="margin-top: 20px;">确定
+        </el-button>
+      </div>
+    </el-dialog>
+
     <!-- 选择基础数据项 -->
     <el-dialog
         title="选择基础数据项"
@@ -355,11 +406,12 @@
         :visible.sync="dialogGroupItemVisible"
         :close-on-click-modal="false"
         :append-to-body="true">
-      <div>
+      <div style="height: 60vh; overflow: auto;">
         <div>
           <label>数据组:</label>
           <el-select filterable
                      v-model="chooseDataGroup"
+                     @change="getGroupById"
                      placeholder="请选择数据组"
                      style="width: 330px;">
             <el-option
@@ -388,11 +440,20 @@
             <el-button size="mini" type="primary" @click="multipleDataItemEvent"
                        style="width: 100px;margin-top: 4px;">设置数据条件
             </el-button>
-            <el-button v-if="templateReportType==2" size="mini" type="primary" @click="setDriverCondition"
-                       style="width: 100px;margin-top: 4px;">配置驱动条件
-            </el-button>
+<!--            <el-button v-if="templateReportType==2" size="mini" type="primary" @click="setDriverCondition"-->
+<!--                       style="width: 100px;margin-top: 4px;">配置驱动条件-->
+<!--            </el-button>-->
           </template>
         </div>
+        <div v-if="chooseDataGroup && !hasBelongDataFlag && templateReportType == 2"
+             style="margin-top: 10px; display: flex;">
+          <label>条件:</label>
+          <div style="color: #a5a5a5;">
+            <span>{{ this.conditionObj.itemName }}</span>&nbsp;&nbsp;
+            <span>{{ this.conditionObj.eventModeName }}</span>&nbsp;&nbsp;
+            <span>{{ this.conditionObj.modeValue }}</span>
+          </div>
+        </div>
         <div style="height: 30vh; margin-top: 10px; overflow: auto;">
           <template v-if="!hasBelongDataFlag">
             <el-table :data="chooseGroupItemList"
@@ -485,7 +546,57 @@
             </el-table>
           </template>
         </div>
-        <div v-if="chooseGroupItemList.length > 0 && templateReportType != 2">
+        <!-- 设备报表 -->
+        <div v-if="templateReportType == 5">
+          <el-divider content-position="left">设备报表条件配置</el-divider>
+          <div class="cy-line custom-tree" style="display: flex; flex-direction: column;">
+            <div class="device-condition">
+              <label>条件类型:</label>
+              <el-radio v-model="deviceReportCondition.variableType" label="1">单变量</el-radio>
+              <el-radio v-model="deviceReportCondition.variableType" label="2">多变量</el-radio>
+            </div>
+            <div class="device-condition">
+              <label>开始变量:</label>
+              <template v-if="deviceReportCondition.variableType == 2">
+                <el-button size="mini" @click="addDataItemByDevice(1)">
+                  选择开始变量
+                </el-button>
+              </template>
+              <template v-else>
+                <el-button size="mini" @click="addDataItemByDevice(0)">
+                  选择变量
+                </el-button>
+              </template>
+              <div v-if="deviceReportCondition.startItemId" style="margin-left: 20px;">
+                <span>{{ deviceReportCondition.startItemName }}</span>&nbsp;&nbsp;
+                <span><b>等于</b></span>&nbsp;&nbsp;
+                <el-input-number v-model="deviceReportCondition.startValue" placeholder="请输入值"
+                                 :min="0" :max="99999" :controls="false" :precision="0"
+                                 style="width: 120px;margin-right: 50px;"></el-input-number>
+              </div>
+            </div>
+            <div class="device-condition">
+              <label>结束变量:</label>
+              <el-button v-if="deviceReportCondition.variableType == 2"
+                         size="mini" @click="addDataItemByDevice(2)">
+                选择结束变量
+              </el-button>
+              <div v-if="deviceReportCondition.endItemId" style="margin-left: 20px;">
+                <span>{{ deviceReportCondition.endItemName }}</span>&nbsp;&nbsp;
+                <span><b>等于</b></span>&nbsp;&nbsp;
+                <el-input-number v-model="deviceReportCondition.endValue" placeholder="请输入值"
+                                 :min="0" :max="99999" :controls="false" :precision="0"
+                                 style="width: 120px;margin-right: 50px;"></el-input-number>
+              </div>
+            </div>
+            <div class="device-condition">
+              <label>是否自动计算运行时间:</label>
+              <el-radio v-model="deviceReportCondition.isGenCountTime" label="0">不计算</el-radio>
+              <el-radio v-model="deviceReportCondition.isGenCountTime" label="1">计算</el-radio>
+            </div>
+          </div>
+        </div>
+        <div v-if="chooseGroupItemList.length > 0 && templateReportType != 2 && templateReportType != 5">
           <template>
             <el-divider content-position="left">{{ hasBelongDataFlag ? '显示方式' : '数据项排列方式' }}</el-divider>
             <div class="cy-line custom-tree">
@@ -638,7 +749,7 @@
     <!-- 模板报表类型选择 -->
     <el-dialog
         title="选择模板报表类型"
-        width="500px"
+        width="600px"
         center
         v-dialog-drag
         v-if="dialogReportTypeVisible"
@@ -651,8 +762,9 @@
         <el-radio v-model="templateReportType" label="0">手动报表</el-radio>
         <el-radio v-model="templateReportType" label="1">自动报表</el-radio>
         <el-radio v-model="templateReportType" label="2">事件驱动报表</el-radio>
+        <el-radio v-model="templateReportType" label="5">设备报表</el-radio>
       </div>
-      <div v-if="templateReportType == 2" style="margin-top: 20px;">
+      <div v-if="templateReportType == 2 || templateReportType == 5" style="margin-top: 20px;">
         <label>记录数量:</label>
         <el-input-number label="请输入事件驱动显示记录数量"
                          v-model="templateEventReportNum"
@@ -677,7 +789,7 @@ import RulerView from '@/components/RulerView'
 import LuckyExcel from 'luckyexcel'
 import {
   getAllDataModel,
-  getAllItemGroup, getSysTableTemplate, getSysTableTemplateById,
+  getAllItemGroup, getItemGroupById, getSysTableTemplate, getSysTableTemplateById,
   getTableItemGroupById,
   getTableTemplateById,
   saveReportTemplate,
@@ -708,6 +820,7 @@ export default {
       showReportData: true,
       dialogBarChartVisible: false,
       dialogDataItemVisible: false,
+      dialogDeviceDataItemVisible: false,
       dialogDataModelVisible: false,
       dialogCommReportVisible: false,
       dialogGroupItemVisible: false,
@@ -763,6 +876,24 @@ export default {
         {'label': '小于', 'value': 1},
         {'label': '等于', 'value': 2}
       ],
+      // 条件值
+      conditionObj: {
+        itemName: '',
+        eventModeName: '',
+        modeValue: ''
+      },
+      // 设备报表条件
+      deviceReportCondition: {
+        type: null,
+        variableType: '1',
+        isGenCountTime: '0',
+        startItemId: null,
+        startItemName: null,
+        startValue: 0,
+        endItemId: null,
+        endItemName: null,
+        endValue: 0
+      },
       // 数据项取值条件
       itemConditionForm: {
         valueType: 0, // 0原始值1计算值
@@ -799,6 +930,7 @@ export default {
         {'label': '附属项', 'value': 0},
         {'label': '数据项', 'value': 1}
       ],
+      itemDeviceDataListByTree: [],
       itemDataListByTree: [],
       itemDataListByGroupName: '',
       itemDataListByCalc: [],
@@ -813,6 +945,7 @@ export default {
       chooseDataGroupType: null,
       chooseItemData: [],
       filterItemData: '',
+      filterDeviceItemData: '',
       searchReportTxt: '',
       keyType: 'report_template',
       reportTypes: [],
@@ -895,6 +1028,9 @@ export default {
     filterItemData(val) {
       this.$refs.itemTree.filter(val)
     },
+    filterDeviceItemData(val) {
+      this.$refs.deviceItemTree.filter(val)
+    },
     visibleChartMenu(value) {
       if (value) {
         document.body.addEventListener('click', this.closeMenu)
@@ -1257,12 +1393,43 @@ export default {
       if (this.templateReportType == 2) {
         data.eventNum = this.templateEventReportNum;
         if (this.eventMode == null || this.modeValue == null) {
-          showAlertMsgWin(this, null, '保存失败!驱动条件或驱动值未设置')
-          return
+          // showAlertMsgWin(this, null, '保存失败!驱动条件或驱动值未设置')
+          // return
         }
         data.eventMode = this.eventMode;
         data.modeValue = this.modeValue;
       }
+      // 设备报表模板
+      if (this.templateReportType == 5) {
+        data.eventNum = this.templateEventReportNum
+        data.isGenCountTime = this.deviceReportCondition.isGenCountTime
+        data.variableType = this.deviceReportCondition.variableType
+        data.startItemId = this.deviceReportCondition.startItemId
+        data.endItemId = this.deviceReportCondition.endItemId
+        data.startValue = this.deviceReportCondition.startValue
+        data.endValue = this.deviceReportCondition.endValue
+        let _temp = null
+        data.tableTemplateItemList.forEach((_t) => {
+          // 单变量
+          if (data.variableType == 1) {
+            if (data.startItemId == _t.itemId) {
+              _t.timeItemType = 0
+              _temp = JSON.parse(JSON.stringify(_t))
+            }
+          } else {
+            if (data.startItemId == _t.itemId) {
+              _t.timeItemType = 0
+            }
+            if (data.endItemId == _t.itemId) {
+              _t.timeItemType = 1
+            }
+          }
+        })
+        if (_temp) {
+          _temp.timeItemType = 1
+          data.tableTemplateItemList.push(_temp)
+        }
+      }
       if (this.templateId && type != 'saveAs') {
         data.id = this.templateId
         data.version = this.templateVersion
@@ -1522,6 +1689,18 @@ export default {
         showAlertWin(this, null, e)
       })
     },
+    /** 添加数据项(设备报表条件数据项) */
+    addDataItemByDevice(type) {
+      if (!this.deviceReportCondition.variableType) {
+        showAlertMsgWin(this, null, '请选择条件类型!')
+        return
+      }
+      this.deviceReportCondition.type = type
+      this.filterDeviceItemData = ''
+      let _data = this.chooseGroupItemList
+      this.itemDeviceDataListByTree = _data ? _data : []
+      this.dialogDeviceDataItemVisible = true
+    },
     /** 选择的数据项:第一步 */
     chooseItemTreeEvent() {
       let checkedNodes = this.$refs.itemTree.getCheckedNodes(false, true)
@@ -1558,6 +1737,33 @@ export default {
       this.filterItemData = ''
       // this.getAllDataModel(chooseList)
     },
+    /** 选择的设备报表数据 */
+    chooseDeviceItemTreeEvent() {
+      let checkedNodes = this.$refs.deviceItemTree.getCheckedNodes(false, true)
+      if (checkedNodes.length != 1) {
+        showAlertMsgWin(this, null, '请选择一项数据项!')
+        return
+      }
+      // 单变量
+      if (this.deviceReportCondition.type == 0) {
+        this.deviceReportCondition.startItemId = checkedNodes[0].id
+        this.deviceReportCondition.startItemName = checkedNodes[0].itemName
+        this.deviceReportCondition.endItemId = checkedNodes[0].id
+        this.deviceReportCondition.endItemName = checkedNodes[0].itemName
+      }
+      // 双变量:开始
+      else if (this.deviceReportCondition.type == 1) {
+        this.deviceReportCondition.startItemId = checkedNodes[0].id
+        this.deviceReportCondition.startItemName = checkedNodes[0].itemName
+      }
+      // 双变量:结束
+      else if (this.deviceReportCondition.type == 2) {
+        this.deviceReportCondition.endItemId = checkedNodes[0].id
+        this.deviceReportCondition.endItemName = checkedNodes[0].itemName
+      }
+      this.deviceReportCondition.type = null
+      this.dialogDeviceDataItemVisible = false
+    },
     initGroupItem() {
       let group = null
       for (let i = 0; i < this.dataGroupList.length; i++) {
@@ -1773,6 +1979,17 @@ export default {
         valLine: 1,
         dataId: new Date().getTime()
       }
+      this.deviceReportCondition = {
+        type: null,
+        variableType: '1',
+        isGenCountTime: '0',
+        startItemId: null,
+        startItemName: null,
+        startValue: 0,
+        endItemId: null,
+        endItemName: null,
+        endValue: 0
+      }
       this.hasBelongDataFlag = false
       if (type == 2) this.hasBelongDataFlag = true
       this.chooseDataGroup = null
@@ -1821,38 +2038,66 @@ export default {
         showAlertMsgWin(this, null, '请设置数据条件!')
         return
       }
+      // 设备报表
+      if (this.templateReportType == 5) {
+        if (!this.deviceReportCondition.startItemId || !this.deviceReportCondition.endItemId) {
+          showAlertMsgWin(this, null, '请设置设备报表条件!')
+          return
+        }
+        if (this.deviceReportCondition.startItemId == this.deviceReportCondition.endItemId
+            && this.deviceReportCondition.startValue == this.deviceReportCondition.endValue) {
+          showAlertMsgWin(this, null, '设备报表开始和结束变量条件不合法!')
+          return
+        }
+      }
       let c, r
       condCount = 0;
-      let driverCount = 0;
+      let rangeWithFlatten = luckysheet.getRangeWithFlatten()
+      c = rangeWithFlatten[0].c
+      r = rangeWithFlatten[0].r
       // 事件驱动报表格式设置
       if (this.templateReportType == 2) {
         this.chooseGroupItemList.forEach((item, i) => {
           if (item.valueType == null) {
             condCount++
           }
-          if (item.isDriverItem == 1) {
-            driverCount++;
-          }
         })
         if (condCount > 0) {
           showAlertMsgWin(this, null, '请设置数据条件!')
           return
         }
-        if (this.eventMode == null || this.modeValue == null) {
-          showAlertMsgWin(this, null, '请配置驱动条件!')
-          return
-        }
-        if (driverCount != 1) {
-          showAlertMsgWin(this, null, '事件驱动项有且仅有一个!')
-          return
+        // 清空之前选择的数据组、数据项信息
+        let tempItem = JSON.parse(JSON.stringify(this.toolItemTable))
+        tempItem.forEach((t, i) => {
+          if (i == 0) {
+            luckysheet.setCellValue(t.xaxis - 1, t.yaxis - 1, '')
+          }
+          luckysheet.setCellValue(t.xaxis - 1, t.yaxis, '')
+          luckysheet.setCellValue(t.xaxis, t.yaxis, '')
+        })
+        this.toolItemTable = []
+        luckysheet.setCellValue(r, c, '数据时间')
+        r++
+        c++
+      }
+      // 设备报表
+      else if (this.templateReportType == 5) {
+        console.log(this.deviceReportCondition)
+        luckysheet.setCellValue(r, c, '序号')
+        luckysheet.setCellValue(r + 1, c, '${index}')
+        c++
+        luckysheet.setCellValue(r, c, '开始时间')
+        luckysheet.setCellValue(r + 1, c, '${startTime}')
+        c++
+        luckysheet.setCellValue(r, c, '停止时间')
+        luckysheet.setCellValue(r + 1, c, '${stopTime}')
+        if (this.deviceReportCondition.isGenCountTime == 1) {
+          c++
+          luckysheet.setCellValue(r, c, '运行时间(分钟)')
+          luckysheet.setCellValue(r + 1, c, '${runMinute}')
         }
-        c = 1
-        r = 1
-        luckysheet.setCellValue(0, 0, '时间')
-      } else {
-        let rangeWithFlatten = luckysheet.getRangeWithFlatten()
-        c = rangeWithFlatten[0].c
-        r = rangeWithFlatten[0].r
+        r++
+        c++
       }
       // 值显示数量
       for (let n = 0; n < this.itemShowParams.valLine; n++) {
@@ -1878,9 +2123,9 @@ export default {
           }
           item.xaxis = p_r
           item.yaxis = p_c
-          // 事件驱动报表格式设置
-          if (this.templateReportType == 2) {
-            luckysheet.setCellValue(0, p_c, describe ? describe : name)
+          // 事件驱动报表和设备报表格式设置
+          if (this.templateReportType == 2 || this.templateReportType == 5) {
+            luckysheet.setCellValue((p_r > 1 ? (p_r - 1) : 0), p_c, describe ? describe : name)
           }
           luckysheet.setCellValue(p_r, p_c, v)
           this.pushToItemTable(item)
@@ -2263,6 +2508,42 @@ export default {
         this.itemShowParams.valType = '1'
       }
     },
+    /** 根据ID查询组信息 */
+    getGroupById(val) {
+      if (this.templateReportType == 2 || this.templateReportType == 5) {
+        this.chooseGroupItemList = []
+      }
+      if (this.templateReportType != 2) {
+        return
+      }
+      const loading = showLoading(this, '加载中,请稍候···')
+      getItemGroupById(val, null).then(res => {
+        loading.close()
+        let data = res.data
+        let itemList = data.itemList
+        let itemName = ''
+        itemList.forEach((item) => {
+          if (item.isDriverItem == 1) {
+            itemName = item.itemName
+          }
+        })
+        let list = [
+          {'label': '大于', 'value': 0},
+          {'label': '小于', 'value': 1},
+          {'label': '等于', 'value': 2},
+          {'label': '动态大于', 'value': 3},
+          {'label': '动态小于', 'value': 4}
+        ]
+        this.conditionObj = {
+          itemName: itemName,
+          eventModeName: this.getValByProp(list, data.eventMode),
+          modeValue: data.modeValue
+        }
+      }).catch((e) => {
+        loading.close()
+        showAlertWin(this, null, e)
+      })
+    },
     /** 打印操作 */
     printExcel() {
       const loading = showLoading(this, '请稍候···')
@@ -2365,6 +2646,7 @@ export default {
       this.chooseItemData = []
       this.chooseGroupItemList = []
       this.filterItemData = ''
+      this.filterDeviceItemData = ''
       this.clearRt()
 
       this.commTemplate = null
@@ -2384,10 +2666,12 @@ export default {
     dialogItemClose(done) {
       this.itemDataListByTree = []
       this.filterItemData = ''
+      this.filterDeviceItemData = ''
       if (typeof (done) === 'function') {
         done()
       } else {
         this.dialogDataItemVisible = false
+        this.dialogDeviceDataItemVisible = false
       }
     },
     /** 弹出层关闭事件 */
@@ -2530,4 +2814,8 @@ export default {
 .el-transfer-panel {
   width: 300px !important;
 }
+
+.device-condition {
+  margin: 5px;
+}
 </style>

+ 7 - 1
chuanyi_client2/src/views/run_config/index.vue

@@ -60,6 +60,7 @@
                 <el-tag v-if="scope.row.reportTableType == 0" style="margin-right: 5px;">手动报表</el-tag>
                 <el-tag v-if="scope.row.reportTableType == 1" style="margin-right: 5px;">自动报表</el-tag>
                 <el-tag v-if="scope.row.reportTableType == 2" style="margin-right: 5px;">事件驱动报表</el-tag>
+                <el-tag v-if="scope.row.reportTableType == 5" style="margin-right: 5px;">设备报表</el-tag>
               </template>
             </el-table-column>
             <el-table-column
@@ -199,6 +200,7 @@
             <el-radio label="0">手动报表</el-radio>
             <el-radio label="1">自动报表</el-radio>
             <el-radio label="2">事件驱动报表</el-radio>
+            <el-radio label="5">设备报表</el-radio>
           </el-radio-group>
         </el-form-item>
         <el-form-item label="报表模板" prop="tableTemplateId" v-if="!reportForm.id">
@@ -472,6 +474,7 @@
         <el-radio v-model="reportType" label="0">手动报表</el-radio>
         <el-radio v-model="reportType" label="1">自动报表</el-radio>
         <el-radio v-model="reportType" label="2">事件驱动报表</el-radio>
+        <el-radio v-model="reportType" label="5">设备报表</el-radio>
       </div>
       <span slot='footer'>
           <el-button type="primary" @click="chooseReportTypeEvent">确定</el-button>
@@ -747,6 +750,9 @@ export default {
       }, {
         label: '事件驱动报表',
         value: 2
+      }, {
+        label: '设备报表',
+        value: 5
       }],
       groupUserData: [],
       reportHistoryData: [],
@@ -1387,7 +1393,7 @@ export default {
           if (i == 0) {
             let valueTimeList = tableItem.valueTimeList ? tableItem.valueTimeList.split(',') : []
             let xAxis = tableItem.xaxis
-            let yAxis = 0
+            let yAxis = tableItem.yaxis - 1
             if (valueTimeList.length == 0) {
               luckysheet.setCellValue(xAxis, yAxis, '')
             } else {

Vissa filer visades inte eftersom för många filer har ändrats