Browse Source

feat(add force cacultion formula): add forceCaculate parameter

default false , if true,formula will force to  refresh when first load sheet
master
liuyang 5 years ago
parent
commit
4dd82ad131
  1. 1
      src/config.js
  2. 3
      src/controllers/luckysheetConfigsetting.js
  3. 6
      src/controllers/sheetmanage.js
  4. 1
      src/core.js
  5. 22
      src/global/formula.js
  6. 1
      src/index.html

1
src/config.js

@ -52,4 +52,5 @@ export default {
fireMousedown: null, //单元格数据下钻
lang: 'en', //language
plugins: [], //plugins, e.g. ['chart']
forceCaculation:false,//强制刷新公式,公式较多会有性能问题,慎用
}

3
src/controllers/luckysheetConfigsetting.js

@ -28,7 +28,8 @@ const luckysheetConfigsetting = {
chartConfigChange: null,
beforeCreateDom: null,
fireMousedown: null,
plugins:[]
plugins:[],
forceCaculation:false,//强制刷新公式,公式较多会有性能问题,慎用
}
export default luckysheetConfigsetting;

6
src/controllers/sheetmanage.js

@ -671,7 +671,7 @@ const sheetmanage = {
_this.restoreselect();
_this.CacheNotLoadControll = [];
_this.restoreCache();
formula.execFunctionGroup();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCaculation);
_this.restoreSheetAll(Store.currentSheetIndex);
// luckysheetrefreshgrid(0, 0);
@ -901,7 +901,7 @@ const sheetmanage = {
setTimeout(function () {
_this.restoreCache();
formula.execFunctionGroup();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCaculation);
_this.restoreSheetAll(Store.currentSheetIndex);
luckysheetrefreshgrid();
}, 1);
@ -944,7 +944,7 @@ const sheetmanage = {
setTimeout(function () {
_this.restoreCache();
formula.execFunctionGroup();
formula.execFunctionGroupForce(luckysheetConfigsetting.forceCaculation);
_this.restoreSheetAll(Store.currentSheetIndex);
luckysheetrefreshgrid();
}, 1);

1
src/core.js

@ -86,6 +86,7 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.beforeCreateDom = extendsetting.beforeCreateDom;
luckysheetConfigsetting.fireMousedown = extendsetting.fireMousedown;
luckysheetConfigsetting.forceCaculation = extendsetting.forceCaculation;
luckysheetConfigsetting.plugins = extendsetting.plugins;
// Register plugins

22
src/global/formula.js

@ -4432,7 +4432,15 @@ const luckysheetformula = {
execvertex: {},
execFunctionGroupData: null,
execFunctionExist: null,
execFunctionGroup: function(origin_r, origin_c, value, index, data) {
execFunctionGroupForce:function(isForce){
if(isForce){
this.execFunctionGroup(undefined, undefined, undefined, undefined, undefined,true);
}
else{
this.execFunctionGroup();
}
},
execFunctionGroup: function(origin_r, origin_c, value, index, data, isForce=false) {
let _this = this;
if (data == null) {
@ -4489,7 +4497,10 @@ const luckysheetformula = {
vertex1["r" + item.r.toString() + "c" + item.c.toString()] = item;
_this.isFunctionRangeSave = false;
if (origin_r != null && origin_c != null) {
if(isForce){
_this.isFunctionRangeSave = true;
}
else if (origin_r != null && origin_c != null) {
_this.isFunctionRange(item.func[2], origin_r, origin_c);
}
else {
@ -4522,7 +4533,12 @@ const luckysheetformula = {
vertex1["r" + item.r.toString() + "c" + item.c.toString()] = item;
_this.isFunctionRangeSave = false;
_this.isFunctionRange(item.func[2], cell.r, cell.c);
if(isForce){
_this.isFunctionRangeSave = true;
}
else{
_this.isFunctionRange(item.func[2], cell.r, cell.c);
}
if (_this.isFunctionRangeSave) {
stack.push(item);

1
src/index.html

@ -35,6 +35,7 @@
container: 'luckysheet',
lang: 'en',
allowEdit:true,
forceCaculation:false,
plugins: ['chart'],
data: [sheetCell,sheetFormula,sheetConditionFormat,sheetTable,sheetSparkline,sheetComment,sheetPivotTableData,sheetPivotTable,sheetChart]
})

Loading…
Cancel
Save