Ver código fonte

报表类型添加

FinalYu 2 anos atrás
pai
commit
8b06bfa18f
1 arquivos alterados com 45 adições e 36 exclusões
  1. 45 36
      chuanyi_client2/src/views/my_report/index.vue

+ 45 - 36
chuanyi_client2/src/views/my_report/index.vue

@@ -79,7 +79,7 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="数据类型" prop="reportValueFormat">
+        <el-form-item label="取值方式" prop="reportValueFormat">
           <el-radio v-model="reportForm.reportValueFormat" label="0">时段数据</el-radio>
         </el-form-item>
         <el-form-item style="text-align: center;">
@@ -651,6 +651,7 @@ export default {
       getAllUserGroup().then(res => {
         this.$nextTick(() => {
           this.userGroupList = res.data
+          this.userGroupInfo = data.userGroupId
         })
       }).catch((e) => {
       })
@@ -846,56 +847,61 @@ export default {
         visibledatarow // 所有列的位置
       } = optionData
       // 动态图表
-      luckyData.charts.forEach((chart, i) => {
-        let myChart = echarts.init(
-            document.getElementsByClassName(chart.info.className)[0]
-        )
-        let baseData = myChart.getConnectedDataURL({
-          type: 'png',
-          pixelRatio: 2,
-          backgroundColor: '#ffffff'
-        })
-        // luckysheet.cancelRangeMerge(chart.info.pos)
-        luckysheet.insertImage(baseData, {
-          rowIndex: chart.info.pos[0],
-          colIndex: chart.info.pos[1],
-          cellSize: this.getCellSize(optionData, chart.info.pos[0], chart.info.pos[1], luckysheet),
-          success: function () {
-            console.log("插入成功")
-          }
-        })
-      })
-      // 静态图表
-      luckyData.data.forEach((data, i) => {
-        data.chart.forEach((chart, j) => {
+      if (luckyData.charts && luckyData.charts.length > 0) {
+        luckyData.charts.forEach((chart, i) => {
           let myChart = echarts.init(
-              document.getElementById(chart.chart_id)
+              document.getElementsByClassName(chart.info.className)[0]
           )
-          myChart.setOption(chart.chartOptions);
           let baseData = myChart.getConnectedDataURL({
             type: 'png',
             pixelRatio: 2,
             backgroundColor: '#ffffff'
           })
-          let col_st = this.getImagePosition(chart.left, visibledatacolumn)
-          let row_st = this.getImagePosition(chart.top, visibledatarow)
+          // luckysheet.cancelRangeMerge(chart.info.pos)
           luckysheet.insertImage(baseData, {
-            rowIndex: parseInt(row_st),
-            colIndex: parseInt(col_st),
-            cellSize: {
-              w: chart.width,
-              h: chart.height,
-            },
+            rowIndex: chart.info.pos[0],
+            colIndex: chart.info.pos[1],
+            cellSize: this.getCellSize(optionData, chart.info.pos[0], chart.info.pos[1], luckysheet),
             success: function () {
               console.log("插入成功")
             }
           })
         })
-      })
+      }
+      // 静态图表
+      if (luckyData.data && luckyData.data.length > 0) {
+        luckyData.data.forEach((data, i) => {
+          if (data.chart && data.chart.length > 0) {
+            data.chart.forEach((chart, j) => {
+              let myChart = echarts.init(
+                  document.getElementById(chart.chart_id)
+              )
+              myChart.setOption(chart.chartOptions);
+              let baseData = myChart.getConnectedDataURL({
+                type: 'png',
+                pixelRatio: 2,
+                backgroundColor: '#ffffff'
+              })
+              let col_st = this.getImagePosition(chart.left, visibledatacolumn)
+              let row_st = this.getImagePosition(chart.top, visibledatarow)
+              luckysheet.insertImage(baseData, {
+                rowIndex: parseInt(row_st),
+                colIndex: parseInt(col_st),
+                cellSize: {
+                  w: chart.width,
+                  h: chart.height,
+                },
+                success: function () {
+                  console.log("插入成功")
+                }
+              })
+            })
+          }
+        })
+      }
     },
     /** 保存报表信息 */
     saveReportInfo() {
-      this.convertChart()
       this.$prompt('请输入报表名称', '保存', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -916,8 +922,10 @@ export default {
           return
         }
         const loading = showLoading(this, '保存中,请稍候···')
+        this.convertChart()
         let data = {
           'reportTableName': value,
+          'reportValueFormat': this.reportForm.reportValueFormat,
           'reportTableData': JSON.stringify(this.chooseReportTemplate)
         }
         saveReport(data).then(res => {
@@ -934,7 +942,8 @@ export default {
         }).catch((e) => {
           loading.close()
         })
-      }).catch(() => {
+      }).catch((e) => {
+        console.log(e)
       })
     },
     /** 报表下载 */