Kaynağa Gözat

修改时间驱动报表条件

FinalYu 1 yıl önce
ebeveyn
işleme
25e152d2f5

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

@@ -1250,6 +1250,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

+ 72 - 26
chuanyi_client2/src/views/report_template/index.vue

@@ -360,6 +360,7 @@
           <label>数据组:</label>
           <el-select filterable
                      v-model="chooseDataGroup"
+                     @change="getGroupById"
                      placeholder="请选择数据组"
                      style="width: 330px;">
             <el-option
@@ -388,11 +389,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"
@@ -677,7 +687,7 @@ import RulerView from '@/components/RulerView'
 import LuckyExcel from 'luckyexcel'
 import {
   getAllDataModel,
-  getAllItemGroup, getSysTableTemplate, getSysTableTemplateById,
+  getAllItemGroup, getItemGroupById, getSysTableTemplate, getSysTableTemplateById,
   getTableItemGroupById,
   getTableTemplateById,
   saveReportTemplate,
@@ -763,6 +773,12 @@ export default {
         {'label': '小于', 'value': 1},
         {'label': '等于', 'value': 2}
       ],
+      // 条件值
+      conditionObj: {
+        itemName: '',
+        eventModeName: '',
+        modeValue: ''
+      },
       // 数据项取值条件
       itemConditionForm: {
         valueType: 0, // 0原始值1计算值
@@ -1257,8 +1273,8 @@ 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;
@@ -1823,36 +1839,33 @@ export default {
       }
       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
-        }
-        c = 1
-        r = 1
-        luckysheet.setCellValue(0, 0, '时间')
-      } else {
-        let rangeWithFlatten = luckysheet.getRangeWithFlatten()
-        c = rangeWithFlatten[0].c
-        r = rangeWithFlatten[0].r
+        // 清空之前选择的数据组、数据项信息
+        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++
       }
       // 值显示数量
       for (let n = 0; n < this.itemShowParams.valLine; n++) {
@@ -1880,7 +1893,7 @@ export default {
           item.yaxis = p_c
           // 事件驱动报表格式设置
           if (this.templateReportType == 2) {
-            luckysheet.setCellValue(0, p_c, describe ? describe : name)
+            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 +2276,39 @@ export default {
         this.itemShowParams.valType = '1'
       }
     },
+    /** 根据ID查询组信息 */
+    getGroupById(val) {
+      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, '请稍候···')

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

@@ -1387,7 +1387,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 {