Browse Source

feat: 实现 sheetCreateBefore sheetCreateAfter 钩子

master
cdswyda 4 years ago
parent
commit
5038508842
  1. 6
      docs/zh/guide/config.md
  2. 12
      src/controllers/sheetmanage.js

6
docs/zh/guide/config.md

@ -1256,15 +1256,15 @@ Luckysheet开放了更细致的自定义配置选项,分别有
## 工作表
### sheetCreatekBefore
(TODO)
### sheetCreateBefore
- 类型:Function
- 默认值:null
- 作用:创建sheet页前触发,sheet页新建也包含数据透视表新建
------------
### sheetCreateAfter
(TODO)
- 类型:Function
- 默认值:null
- 作用:创建sheet页后触发,sheet页新建也包含数据透视表新建

12
src/controllers/sheetmanage.js

@ -228,6 +228,10 @@ const sheetmanage = {
// alert("非编辑模式下不允许该操作!");
return;
}
// 钩子 sheetCreateBefore
if(!method.createHookFunction('sheetCreateBefore')){
return;
}
let _this = this;
@ -271,6 +275,8 @@ const sheetmanage = {
}
_this.changeSheetExec(index, isPivotTable, true);
// 钩子 sheetCreateAfter 不应该在这里 应在绘制完成后 因此在 changeSheet 实现
},
setSheetHide: function(index) {
let _this = this;
@ -1147,6 +1153,11 @@ const sheetmanage = {
$("#luckysheet-cell-main #luckysheet-multipleRange-show").empty();
server.multipleIndex = 0;
}
let file = Store.luckysheetfile[_this.getSheetIndex(index)]
// 钩子 sheetCreateAfter
if (isNewSheet) {
method.createHookFunction('sheetCreateAfter', { sheet: file });
}
// 钩子函数
method.createHookFunction('sheetActivate', index, isPivotInitial, isNewSheet);
@ -1157,7 +1168,6 @@ const sheetmanage = {
_this.storeSheetParamALL();
_this.setCurSheet(index);
let file = Store.luckysheetfile[_this.getSheetIndex(index)]
if (!!file.isPivotTable) {
Store.luckysheetcurrentisPivotTable = true;

Loading…
Cancel
Save