Explorar o código

报表自动运行数据调整

FinalYu %!s(int64=2) %!d(string=hai) anos
pai
achega
f3a924e537
Modificáronse 1 ficheiros con 48 adicións e 9 borrados
  1. 48 9
      chuanyi_client2/src/views/my_report/index.vue

+ 48 - 9
chuanyi_client2/src/views/my_report/index.vue

@@ -224,6 +224,7 @@ export default {
       dialogUserGroupVisible: false,
       downloadType: '1',
       btnType: '',
+      hasUserGroup: false,
       userGroupInfo: null,
       userGroupList: [],
       cronVal: '',
@@ -686,6 +687,9 @@ export default {
         this.$nextTick(() => {
           this.userGroupList = res.data
           this.userGroupInfo = data.userGroupId
+          if (data.userGroupId) {
+            this.hasUserGroup = true
+          }
         })
       }).catch((e) => {
       })
@@ -702,10 +706,13 @@ export default {
         'id': this.reportId,
         'groupId': this.userGroupInfo
       }).then(res => {
-        this.$message({
-          message: res.data,
-          type: 'success'
-        })
+        if (this.hasUserGroup) {
+          this.$message({
+            message: res.data,
+            type: 'success'
+          })
+          this.hasUserGroup = false
+        }
         this.dialogClose()
         this.loadReport()
       }).catch((e) => {
@@ -713,7 +720,6 @@ export default {
     },
     /** 处理自动报表数据信息 */
     drawAutoReportData(datas) {
-      console.log(datas)
       if (!datas || datas.length == 0) {
         return
       }
@@ -721,15 +727,43 @@ export default {
         if (!data || !data.item) {
           return
         }
-        data.item.forEach((item) => {
-          if (item && item.dataList) {
-
+        let showInfo = data.showType
+        let fieldList = data.field
+        data.item.forEach((item, i) => {
+          if (!item || !item.dataList) {
+            return
+          }
+          let itemName = item.itemName
+          itemName = itemName.substring(itemName.lastIndexOf('.') + 1)
+          let tempName = '${' + item.itemGroupId + '.' + itemName + '.' + showInfo.dataId + '}'
+          let p_r, p_c
+          if (fieldList[i] && tempName == fieldList[i].name) {
+            p_r = parseInt(fieldList[i].r)
+            p_c = parseInt(fieldList[i].c)
+          } else {
+            for (let n = 0; n < fieldList.length; n ++) {
+              if (fieldList[n].name == tempName) {
+                p_r = parseInt(fieldList[n].r)
+                p_c = parseInt(fieldList[n].c)
+                break
+              }
+            }
+          }
+          // 数据信息
+          let dataList = item.dataList
+          for (let j = 0; j < showInfo.valLine; j++) {
+            let c = p_c
+            let r = p_r
+            if (showInfo.valType == '2') r += j
+            else c += j
+            luckysheet.setCellValue(r, c, dataList[j] + '')
           }
         })
       })
     },
     /** 报表点击事件 */
     handleReportNodeClick(data) {
+      let _this = this
       if (data.id == -1 || this.delFlag == 1) {
         return
       }
@@ -749,7 +783,6 @@ export default {
         let reportTableData = res.data.reportTableData
         let luckyData = JSON.parse(reportTableData)
         console.log(luckyData)
-        this.drawAutoReportData(luckyData.tables)
         // this.drawLuckyExcel(luckyData, () => {
         //   this.btnType = 'show'
         //   loading.close()
@@ -804,6 +837,12 @@ export default {
             })
           }
         }
+        // 钩子函数
+        option.hook = {
+          workbookCreateAfter() {
+            _this.drawAutoReportData(luckyData.tables)
+          }
+        }
         luckysheet.create(option)
         this.btnType = 'show'
       }).catch((e) => {