Browse Source

修改批量设置表达式

FinalYu 2 years ago
parent
commit
9c3489ef31

+ 2 - 1
chuanyi_client2/src/components/HeaderMain/index.vue

@@ -486,7 +486,7 @@ import {getDictByKey} from "@/api/basic";
 import {
   customCompare,
   deepTreeFilter,
-  deepTreeKey,
+  deepTreeKey, diffObj, getLuckysheetConfig,
   showAlertWin,
   showLoading,
   traverseNode,
@@ -586,6 +586,7 @@ export default {
       chooseItemDataListByTree: [],
       dataLineListSelections: [],
       chooseItemDataView: false,
+      reportTemplateItem: this.$store.getters.sessionName.REPORT_TEMPLATE_ITEM,
       groupBasicForm: {
         id: null,
         groupName: '',

+ 1 - 16
chuanyi_client2/src/store/modules/dict.js

@@ -1,20 +1,4 @@
 const state = {
-  // 连接服务类型
-  serverConnectMode: [{
-    'key': 'KepServer',
-    'value': 0
-  }, {
-    'key': 'KingSCADA',
-    'value': 1
-  }],
-  // 连接协议类型
-  serverAgreementType: [{
-    'key': 'UA',
-    'value': 0
-  }, {
-    'key': 'DA',
-    'value': 1
-  }],
   // 是否匿名登录
   isAnonymous: [{
     'key': '不匿名',
@@ -30,6 +14,7 @@ const state = {
     BREADCRUMB_LIST: "BREADCRUMB_LIST",
     CHANNEL_TYPE: "CHANNEL_TYPE",
     CURR_DATA: "CURR_DATA",
+    REPORT_TEMPLATE_ITEM: "REPORT_TEMPLATE_ITEM",
   }
 }
 

+ 28 - 0
chuanyi_client2/src/utils/cqcy.js

@@ -448,4 +448,32 @@ export function customCompare(propertyName, sort) {
             return sort === 'ascending' ? res : -res
         }
     }
+}
+
+/**
+ * 获取在线表格数据信息
+ * @returns {string|null}
+ */
+export function getLuckysheetConfig() {
+    if (!luckysheet) return null
+    let ls = luckysheet.getLuckysheetfile()
+    if (!ls) return null
+    ls.forEach((item, index) => {
+        if(item.chart) {
+            item.chart.forEach((chart, i) => {
+                ls[index].chart[i] = {
+                    ...ls[index].chart[i],
+                    chartOptions: {...chartmix.default.getChartJson(chart.chart_id)}
+                }
+                let div = document.getElementById(chart.chart_id + '_c');
+                if(div.style) {
+                    ls[index].chart[i].left = parseInt(div.style.left)
+                    ls[index].chart[i].top = parseInt(div.style.top)
+                    ls[index].chart[i].width = parseInt(div.style.width)
+                    ls[index].chart[i].height = parseInt(div.style.height)
+                }
+            })
+        }
+    })
+    return JSON.stringify(ls)
 }

+ 4 - 3
chuanyi_client2/src/views/group_item/index.vue

@@ -560,11 +560,12 @@ export default {
     },
     /** 批量设置组数据中数据项表达式 */
     saveDataModelEvent() {
-      let ids = Array.from(this.selectionItems, ({ id }) => id)
+      // let ids = Array.from(this.selectionItems, ({ id }) => id)
       let itemList = []
-      ids.forEach((id) => {
+      this.selectionItems.forEach((item) => {
         itemList.push({
-          'id': id,
+          'id': item.id,
+          'itemGroupId': item.itemGroupId,
           'dataModelId': this.chooseDataModel
         })
       })

+ 2 - 24
chuanyi_client2/src/views/my_report/index.vue

@@ -432,7 +432,7 @@
 
 <script>
 import BreadcrumbView from '@/components/BreadcrumbView'
-import {customCompare, getNowFormatDate, showAlertWin, showLoading} from '@/utils/cqcy'
+import {customCompare, getLuckysheetConfig, getNowFormatDate, showAlertWin, showLoading} from '@/utils/cqcy'
 import {
   delReportTableById,
   getAllDataModel, getAllOkReportTable,
@@ -1655,7 +1655,7 @@ export default {
         }
       }).then(({value}) => {
         const loading = showLoading(this, '保存中,请稍候···')
-        let _data = JSON.parse(this.getLuckysheetConfig())
+        let _data = JSON.parse(getLuckysheetConfig())
         let _data2 = JSON.parse(this.chooseMyReport.reportTableData)
         let excelData = _data[0].data
         this.withDateData(excelData)
@@ -1683,28 +1683,6 @@ export default {
         console.log(e)
       })
     },
-    /** 保存数据格式转换 */
-    getLuckysheetConfig() {
-      let ls = luckysheet.getLuckysheetfile()
-      ls.forEach((item, index) => {
-        if(item.chart) {
-          item.chart.forEach((chart, i) => {
-            ls[index].chart[i] = {
-              ...ls[index].chart[i],
-              chartOptions: {...chartmix.default.getChartJson(chart.chart_id)}
-            }
-            let div = document.getElementById(chart.chart_id + '_c');
-            if(div.style) {
-              ls[index].chart[i].left = parseInt(div.style.left)
-              ls[index].chart[i].top = parseInt(div.style.top)
-              ls[index].chart[i].width = parseInt(div.style.width)
-              ls[index].chart[i].height = parseInt(div.style.height)
-            }
-          })
-        }
-      })
-      return JSON.stringify(ls)
-    },
     /** 报表下载 */
     downloadReport() {
       this.dialogDownloadReportTypeVisible = true

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

@@ -389,7 +389,7 @@ import {
   saveReportTemplate,
   updateReportTemplate
 } from "@/api/datasource";
-import {handleTree, showAlertWin, showLoading, traverseNode, traverseVisible} from "@/utils/cqcy";
+import {getLuckysheetConfig, handleTree, showAlertWin, showLoading, traverseNode, traverseVisible} from "@/utils/cqcy";
 import {getDictByKey} from "@/api/basic";
 import {exportExcel} from "@/utils/export";
 import {insertLuckysheetEChart} from "@/utils/luckysheettool";
@@ -457,7 +457,7 @@ export default {
       templateName: '',
       templateId: '',
       templateVersion: '',
-      reportTemplateItem: 'REPORT_TEMPLATE_ITEM',
+      reportTemplateItem: this.$store.getters.sessionName.REPORT_TEMPLATE_ITEM,
       reportInterval: null,
       toolChart: [],
       toolTable: [],
@@ -698,7 +698,7 @@ export default {
       }).then(({ value }) => {
         const loading = showLoading(this, '保存中,请稍候···')
         let option = JSON.parse(JSON.stringify(this.luckysheetOption))
-        let _data = JSON.parse(this.getLuckysheetConfig())
+        let _data = JSON.parse(getLuckysheetConfig())
         let excelData = _data[0].data
         this.withDateData(excelData)
         this.spliceToolTable()
@@ -844,28 +844,6 @@ export default {
         loading.close()
       })
     },
-    /** 保存数据格式转换 */
-    getLuckysheetConfig() {
-      let ls = luckysheet.getLuckysheetfile()
-      ls.forEach((item, index) => {
-        if(item.chart) {
-          item.chart.forEach((chart, i) => {
-            ls[index].chart[i] = {
-              ...ls[index].chart[i],
-              chartOptions: {...chartmix.default.getChartJson(chart.chart_id)}
-            }
-            let div = document.getElementById(chart.chart_id + '_c');
-            if(div.style) {
-              ls[index].chart[i].left = parseInt(div.style.left)
-              ls[index].chart[i].top = parseInt(div.style.top)
-              ls[index].chart[i].width = parseInt(div.style.width)
-              ls[index].chart[i].height = parseInt(div.style.height)
-            }
-          })
-        }
-      })
-      return JSON.stringify(ls)
-    },
     /** 生成唯一 ID 字符串 */
     generateRandomKey(prefix) {
       if (prefix == null) {
@@ -1546,7 +1524,7 @@ export default {
           let result = {
             'charts': _this.toolChart,
             'tables': _this.toolTable,
-            'data': JSON.parse(_this.getLuckysheetConfig())
+            'data': JSON.parse(getLuckysheetConfig())
           }
           localStorage.setItem(_this.reportTemplateItem, JSON.stringify(result))
           console.log(new Date().getTime(), 'auto save report template success.')

+ 2 - 24
chuanyi_client2/src/views/run_config/index.vue

@@ -525,7 +525,7 @@
 
 <script>
 import BreadcrumbView from '@/components/BreadcrumbView'
-import {customCompare, getNowFormatDate, showAlertWin, showLoading} from '@/utils/cqcy'
+import {customCompare, getLuckysheetConfig, getNowFormatDate, showAlertWin, showLoading} from '@/utils/cqcy'
 import {
   delReportTableById,
   getAllDataModel,
@@ -1923,7 +1923,7 @@ export default {
             luckysheet.setCellValue(field.r, field.c, field.name)
           })
         })
-        let _data = JSON.parse(this.getLuckysheetConfig())
+        let _data = JSON.parse(getLuckysheetConfig())
         let excelData = _data[0].data
         this.withDateData(excelData)
         _data2.data = _data
@@ -1950,28 +1950,6 @@ export default {
         console.log(e)
       })
     },
-    /** 保存数据格式转换 */
-    getLuckysheetConfig() {
-      let ls = luckysheet.getLuckysheetfile()
-      ls.forEach((item, index) => {
-        if (item.chart) {
-          item.chart.forEach((chart, i) => {
-            ls[index].chart[i] = {
-              ...ls[index].chart[i],
-              chartOptions: {...chartmix.default.getChartJson(chart.chart_id)}
-            }
-            let div = document.getElementById(chart.chart_id + '_c');
-            if (div.style) {
-              ls[index].chart[i].left = parseInt(div.style.left)
-              ls[index].chart[i].top = parseInt(div.style.top)
-              ls[index].chart[i].width = parseInt(div.style.width)
-              ls[index].chart[i].height = parseInt(div.style.height)
-            }
-          })
-        }
-      })
-      return JSON.stringify(ls)
-    },
     /** 报表下载 */
     downloadReport() {
       this.dialogDownloadReportTypeVisible = true