Browse Source

数据回显渲染

Raod 4 years ago
parent
commit
efc3485d08

+ 6 - 0
report-core/src/main/java/com/anjiplus/template/gaea/business/filter/TokenFilter.java

@@ -57,6 +57,12 @@ public class TokenFilter implements Filter {
         HttpServletResponse response = (HttpServletResponse) servletResponse;
         String uri = request.getRequestURI();
 
+        //OPTIONS直接放行
+        if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
+            filterChain.doFilter(request, response);
+            return;
+        }
+
         if (SLASH.equals(uri)) {
             response.sendRedirect("/index.html");
             return;

+ 59 - 121
report-ui/src/views/report/excelreport/designer/index.vue

@@ -245,6 +245,7 @@ export default {
       reportCode: '',
       options: [],
       sheet: {},
+      sheetData: [],
       dataSetData: [],
       reportExcelDto: {
         id: null,
@@ -326,10 +327,49 @@ export default {
 
     }
   },
-  mounted () {
-    $(function () {
-
-      luckysheet.create({
+  mounted () {},
+  created () {
+    this.reportCode = this.$route.query.reportCode
+    this.accessKey = this.$route.query.accessKey
+    this.loadDataSet()
+    this.design()
+    this.initPaperList()
+    this.getWindowDpi()
+  },
+  methods: {
+    handleClose () {
+      this.printVisible = false
+    },
+    handleChange (val) {
+    },
+    // 右侧信息配置tabs
+    handleClick (tab, event) {
+    },
+    async design () {
+      // 根据reportCode获取单条报表
+      const { code, data } = await detailByReportCode(this.reportCode)
+      if (data != null) {
+        this.reportId = data.id
+      }
+      this.sheetData = (data == null ? [{}] : JSON.parse(data.jsonStr))
+      console.log(this.sheetData)
+      this.createSheet();
+      if (data != null) {
+        if (data.setCodes != null && data.setCodes !== '') {
+          var dataSetList = data.setCodes.split('|')
+          dataSetList.forEach((code) => {
+            this.dataSetData.forEach((setData) => {
+              if (code === setData.setCode) {
+                this.detail(setData.id)
+              }
+            })
+          })
+        }
+      }
+    },
+    //初始化表格
+    createSheet(){
+      const options = {
         container: 'luckysheet', // 设定DOM容器的id
         title: 'Luckysheet Demo', // 设定表格名称
         lang: 'zh', // 设定表格语言
@@ -458,49 +498,12 @@ export default {
             "dataVerification":{} //数据验证配置
           }
         ]
-      });
-    });
+      };
+      options.data = this.sheetData;
 
-
-
-    // this.load()
-  },
-  created () {
-    this.reportCode = this.$route.query.reportCode
-    this.accessKey = this.$route.query.accessKey
-    this.loadDataSet()
-    this.design()
-    this.initPaperList()
-    this.getWindowDpi()
-  },
-  methods: {
-    handleClose () {
-      this.printVisible = false
-    },
-    handleChange (val) {
-    },
-    // 右侧信息配置tabs
-    handleClick (tab, event) {
-    },
-    async design () {
-      // 根据reportCode获取单条报表
-      const { code, data } = await detailByReportCode(this.reportCode)
-      if (data != null) {
-        this.reportId = data.id
-      }
-      // this.sheet.loadData(data == null ? [{}] : JSON.parse(data.jsonStr)['sheet'])
-      if (data != null) {
-        if (data.setCodes != null && data.setCodes !== '') {
-          var dataSetList = data.setCodes.split('|')
-          dataSetList.forEach((code) => {
-            this.dataSetData.forEach((setData) => {
-              if (code === setData.setCode) {
-                this.detail(setData.id)
-              }
-            })
-          })
-        }
-      }
+      $(function () {
+        luckysheet.create(options);
+      });
     },
     async loadDataSet () {
       const { code, data } = await queryAllDataSet()
@@ -510,11 +513,11 @@ export default {
     doCancel () {
       this.pop = false
     },
-    save () {
+    async save() {
 
-      console.log(luckysheet.toJson())
-      console.log(luckysheet.getAllSheets())
-      console.log(luckysheet.getSheetData(0))
+      // console.log(luckysheet.toJson())
+      // console.log(luckysheet.getAllSheets())
+      // console.log(luckysheet.getSheetData(0))
 
       this.reportExcelDto.jsonStr = JSON.stringify(luckysheet.getAllSheets())
       var setCodeList = []
@@ -534,10 +537,14 @@ export default {
       this.reportExcelDto.setCodes = setCodeList.join('|')
       this.reportExcelDto.reportCode = this.reportCode
       if (this.reportId == null) {
-        const res = addReportExcel(this.reportExcelDto)
+        const {code} = await addReportExcel(this.reportExcelDto)
+        if (code != '200') return
+        this.$message.success('保存成功')
       } else {
         this.reportExcelDto.id = this.reportId
-        const res = editReportExcel(this.reportExcelDto)
+        const {code} = await editReportExcel(this.reportExcelDto)
+        if (code != '200') return
+        this.$message.success('更新成功')
       }
     },
 
@@ -622,75 +629,6 @@ export default {
     // 无论哪个输入框改变 都需要触发事件 将值回传
     changed (val, key) {
     },
-    load () {
-      // eslint-disable-next-line no-undef
-
-      luckysheet.create({
-        container: 'luckysheet', // 设定DOM容器的id
-        title: 'Luckysheet Demo', // 设定表格名称
-        lang: 'zh', // 设定表格语言
-        plugins: ['chart'],
-        data: [{
-          'name': 'Cell', // 工作表名称
-          'color': '', // 工作表颜色
-          'index': 0, // 工作表索引
-          'status': 1, // 激活状态
-          'order': 0, // 工作表的下标
-          'hide': 0, // 是否隐藏
-          'row': 36, // 行数
-          'column': 18, // 列数
-          'defaultRowHeight': 19, // 自定义行高
-          'defaultColWidth': 73, // 自定义列宽
-          'celldata': [], // 初始化使用的单元格数据
-          'config': {
-            'merge': {}, // 合并单元格
-            'rowlen': {}, // 表格行高
-            'columnlen': {}, // 表格列宽
-            'rowhidden': {}, // 隐藏行
-            'colhidden': {}, // 隐藏列
-            'borderInfo': {}, // 边框
-            'authority': {}, // 工作表保护
-
-          },
-          'scrollLeft': 0, // 左右滚动条位置
-          'scrollTop': 315, // 上下滚动条位置
-          'luckysheet_select_save': [], // 选中的区域
-          'calcChain': [], // 公式链
-          'isPivotTable': false, // 是否数据透视表
-          'pivotTable': {}, // 数据透视表设置
-          'filter_select': {}, // 筛选范围
-          'filter': null, // 筛选配置
-          'luckysheet_alternateformat_save': [], // 交替颜色
-          'luckysheet_alternateformat_save_modelCustom': [], // 自定义交替颜色
-          'luckysheet_conditionformat_save': {}, // 条件格式
-          'frozen': {}, // 冻结行列配置
-          'chart': [], // 图表配置
-          'zoomRatio': 1, // 缩放比例
-          'image': [], // 图片
-          'showGridLines': 1, // 是否显示网格线
-          'dataVerification': {} // 数据验证配置
-        },
-          {
-            'name': 'Sheet2',
-            'color': '',
-            'index': 1,
-            'status': 0,
-            'order': 1,
-            'celldata': [],
-            'config': {}
-          },
-          {
-            'name': 'Sheet3',
-            'color': '',
-            'index': 2,
-            'status': 0,
-            'order': 2,
-            'celldata': [],
-            'config': {},
-          }
-        ]
-      })
-    },
     testClick () {
       console.log('sdsdsddsd')
     },