From f7e30cf946f9c5945fd7e69bf4a3273f54e2616f Mon Sep 17 00:00:00 2001 From: liuyang Date: Wed, 26 Aug 2020 20:57:17 +0800 Subject: [PATCH] feat(add autocalculationmerge sheet attribute): it can auto calculate merge infomation --- src/controllers/sheetmanage.js | 49 +++++++++++++++++++++++++++++++--- src/demoData/sheetCell.js | 6 +++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/controllers/sheetmanage.js b/src/controllers/sheetmanage.js index 1afc7d2..d618271 100644 --- a/src/controllers/sheetmanage.js +++ b/src/controllers/sheetmanage.js @@ -694,6 +694,7 @@ const sheetmanage = { } let execF = function(){ + _this.mergeCalculation(file["index"]); _this.storeSheetParam(); _this.restoreselect(); _this.CacheNotLoadControll = []; @@ -903,6 +904,48 @@ const sheetmanage = { Store.luckysheetfile[index]["data"] = Store.flowdata; Store.luckysheetfile[index]["config"] = $.extend(true, {}, Store.config); }, + mergeCalculationSheet:{}, + mergeCalculation:function(index){ + let file = Store.luckysheetfile[this.getSheetIndex(index)]; + let config = file.config, data = file.data, mergeConfig = config.merge; + if(mergeConfig==null || index in this.mergeCalculationSheet || file["autoCalculationMerge"]===false){ + return; + } + + this.mergeCalculationSheet[index] = 1; + + for(let x in mergeConfig){ + let r = parseInt(x.substr(0, x.indexOf('_'))); + let c = parseInt(x.substr(x.indexOf('_') + 1)); + let mcInfo = mergeConfig[x]; + if(data[r][c]==null){ + data[r][c] = {}; + } + + data[r][c]["mc"] = { + r:r, + c:c, + rs:mcInfo.rs, + cs:mcInfo.cs, + } + + for(let ir=r;ir