Skip to content
This repository has been archived by the owner on Mar 28, 2024. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wpxp123456 committed Jan 6, 2021
2 parents 06636f6 + 2da6f81 commit 7f6ea99
Show file tree
Hide file tree
Showing 21 changed files with 538 additions and 54 deletions.
8 changes: 2 additions & 6 deletions docs/guide/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2560,17 +2560,13 @@ Use note:

### refreshFormula([setting])

[todo]

- **Parameter**

- {PlainObject} [setting]: optional parameters
+ {Object | String} [range]: Set the target selection range of the parameter. The supported selection format is `"A1:B2"`, `"sheetName!A1:B2"` or `{row:[0,1], column:[0,1]}`, allows an array of multiple selections; the default is the current selection ;The default is the entire current worksheet
+ {Function} [success]: callback function for the end of the operation
- {Function} [success]: callback function for the end of the operation

- **Explanation**

Force refresh formula. When you directly modify the values of multiple cells without triggering a refresh, and these cells are associated with formulas, you can use this API to force a formula refresh to be triggered at the end. It is generally recommended to specify the affected cell range to prevent For performance issues, if you can't determine it, leave it blank to keep the entire worksheet traversed and refreshed.
Force refresh formula. When you directly modify the values of multiple cells without triggering a refresh, and these cells are associated with formulas, you can use this API to force a formula refresh to be triggered at the end.

------------

Expand Down
28 changes: 28 additions & 0 deletions docs/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ The following are all supported setting parameters
- The height of the column header area [columnHeaderHeight](#columnHeaderHeight)
- Whether to show the formula bar [sheetFormulaBar](#sheetFormulaBar)
- Initialize the default font size [defaultFontSize](#defaultFontSize)
- Pager [pager](#pager)

### container
- Type: String
Expand Down Expand Up @@ -567,6 +568,21 @@ Note that you also need to configure `loadUrl` and `loadSheetUrl` to take effect

------------

### pager
- Type:Object
- Default:null
- Usage:Pager button settings, the first version of the solution is directly used jquery plug-in [sPage](https://github.com/jvbei/sPage)
Clicking the paging button will trigger the hook function `onTogglePager`, which returns the current page number, which is the same as the `backFun` method of `sPage`. This pager setting is only responsible for the UI part. For the specific data request and data rendering after switching paging, please enter the `onTogglePager` custom processing in the number of hook lines.
```js
pager: {
pageIndex: 1, //Current page number
pageSize: 10, //How many rows of data are displayed on each page
total: 50, //Total number of rows of data
selectOption: [10, 20] //Options that allow setting the number of rows per page
}
```

------------

## Hook Function (TODO)

Expand Down Expand Up @@ -1251,4 +1267,16 @@ The hook functions are uniformly configured under ʻoptions.hook`, and configura
- Default: null
- Usage: Customized method of drilling down cell data, note that this hook function is mounted under options: `options.fireMousedown`

------------

## Pager

### onTogglePager

- Type: Function
- Default: null
- Usage: Click the page button to call back the function, return the current page number, refer to [sPage backFun](https://github.com/jvbei/sPage)
- Parameter:
- {Object} [page]: Return the current page object

------------
10 changes: 3 additions & 7 deletions docs/zh/guide/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2474,19 +2474,15 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开

------------

### refreshFormula([setting])

[todo]
### refreshFormula([success])

- **参数**

- {PlainObject} [setting]: 可选参数
+ {Object | String} [range]: 选区范围,支持选区的格式为`"A1:B2"`、`"sheetName!A1:B2"`或者`{row:[0,1],column:[0,1]}`,只能为单个选区;默认为整个当前工作表
+ {Function} [success]: 操作结束的回调函数
- {Function} [success]: 操作结束的回调函数

- **说明**

强制刷新公式。当你直接修改了多个单元格的值,且没有触发刷新,且这些单元格跟公式相关联,则可以使用这个api最后强制触发一次公式刷新,一般是建议指定受影响的单元格范围便于防止性能问题,如果无法确定,则留空保持整个工作表遍历刷新
强制刷新公式。当你直接修改了多个单元格的值,且没有触发刷新,且这些单元格跟公式相关联,则可以使用这个api最后强制触发一次公式刷新。

------------

Expand Down
41 changes: 41 additions & 0 deletions docs/zh/guide/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 初始化默认字体大小 [defaultFontSize](#defaultFontSize)
- 是否限制工作表名长度 [limitSheetNameLength](#limitSheetNameLength)
- 默认允许工作表名的最大长度 [defaultSheetNameMaxLength](#defaultSheetNameMaxLength)
- 分页器 [pager](#pager)

### container
- 类型:String
Expand Down Expand Up @@ -661,6 +662,22 @@ Luckysheet开放了更细致的自定义配置选项,分别有

------------

### pager
- 类型:Object
- 默认值:null
- 作用:分页器按钮设置,初版方案是直接使用的jquery插件 [sPage](https://github.com/jvbei/sPage)
点击分页按钮会触发钩子函数 `onTogglePager`,返回当前页码,同`sPage`的`backFun`方法,此分页器设置只负责UI部分,具体切换分页后的数据请求和数据渲染,请在`onTogglePager`钩子行数里自定义处理。
```js
pager: {
pageIndex: 1, //当前的页码
pageSize: 10, //每页显示多少行数据
total: 50, //数据总行数
selectOption: [10, 20] //允许设置每页行数的选项
}
```

------------

## 钩子函数

钩子函数应用于二次开发时,会在各个常用鼠标或者键盘操作时植入钩子,调用开发者传入的函数,起到扩展Luckysheet功能的作用。
Expand Down Expand Up @@ -932,6 +949,18 @@ Luckysheet开放了更细致的自定义配置选项,分别有
+ {Boolean} [hyperlinkClick]:点击超链接
- {Object} [ctx]: 当前画布的context

------------
### scroll

- 类型:Function
- 默认值:null
- 作用:鼠标滚动事件
- 参数:{, , }
- {Object} [position]:
+ {Number} [scrollLeft]:横向滚动条的位置
+ {Number} [scrollTop]:垂直滚动条的位置
+ {Number} [canvasHeight]:canvas高度

------------

## 选区操作(包括单元格)
Expand Down Expand Up @@ -1519,4 +1548,16 @@ Luckysheet开放了更细致的自定义配置选项,分别有
- 默认值:null
- 作用:单元格数据下钻自定义方法,注意此钩子函数是挂载在options下:`options.fireMousedown`

------------

## 分页器

### onTogglePager

- 类型:Function
- 默认值:null
- 作用:点击分页按钮回调函数,返回当前页码,具体参数参照[sPage backFun](https://github.com/jvbei/sPage)
- 参数:
- {Object} [page]: 返回当前分页对象

------------
3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ const paths = {
'src/plugins/js/localforage.min.js',
'src/plugins/js/lodash.min.js',
'src/plugins/js/jstat.min.js',
'src/plugins/js/crypto-api.min.js'
'src/plugins/js/crypto-api.min.js',
'src/plugins/js/jquery.sPage.min.js'
],

//plugins concat
Expand Down
5 changes: 4 additions & 1 deletion src/controllers/controlHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,11 @@ const controlHistory = {
}
Store.clearjfundo = true;

// 撤销的时候curdata 跟 data 数据要调换一下
let newCtr = {...ctr, ...{data: ctr.curdata, curdata: ctr.data}}
// 钩子函数
method.createHookFunction('updated',ctr)
method.createHookFunction('updated', newCtr)

},
undo: function () {
if (Store.jfundo.length == 0) {
Expand Down
17 changes: 14 additions & 3 deletions src/controllers/protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ export function checkProtectionLocked(r, c, sheetIndex){
return true;
}

if(cell!=null && cell.lo!=null && cell.lo!=1){
if(cell && !cell.lo){
return true;
}

Expand All @@ -922,7 +922,7 @@ export function checkProtectionLocked(r, c, sheetIndex){
//cell hidden state
export function checkProtectionCellHidden(r, c, sheetIndex){
let sheetFile = sheetmanage.getSheetByIndex(sheetIndex);
if(sheetFile==null){
if(!sheetFile || !sheetFile.data[r] || !sheetFile.data[r][c]){
return true;
}

Expand All @@ -945,6 +945,10 @@ export function checkProtectionCellHidden(r, c, sheetIndex){

//cell range locked state
export function checkProtectionLockedRangeList(rangeList, sheetIndex){
//EPM-BUDGET-START
if (rangeList[0].column[0] !== rangeList[0].column[1]) return true
//EPM-BUDGET-END

let sheetFile = sheetmanage.getSheetByIndex(sheetIndex);
if(sheetFile==null){
return true;
Expand All @@ -964,6 +968,13 @@ export function checkProtectionLockedRangeList(rangeList, sheetIndex){
return true;
}

//EPM-BUDGET-START
let cell = sheetFile.data[rangeList[0].row[0]][rangeList[0].column[0]]
if(cell&& !cell.lo){
return true;
}
//EPM-BUDGET-END

const _locale = locale();
const local_protection = _locale.protection;

Expand Down Expand Up @@ -1003,7 +1014,7 @@ export function checkProtectionSelectLockedOrUnLockedCells(r, c, sheetIndex){
return true;
}

if(cell!=null && cell.lo!=null && cell.lo!=1){//unlocked
if(cell && !cell.lo){//unlocked
if(aut.selectunLockedCells==1 || aut.selectunLockedCells==null){
return true;
}
Expand Down
10 changes: 7 additions & 3 deletions src/controllers/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,16 @@ const selection = {
for (let r = 0; r < rlen; r++) {
let x = [].concat(d[r + curR]);
for (let c = 0; c < clen; c++) {

let originCell = x[c + curC];
let value = dataChe[r][c];
if(isRealNum(value)){
value = parseFloat(value);
// 如果单元格设置了纯文本格式,那么就不要转成数值类型了,防止数值过大自动转成科学计数法
if (originCell && originCell.ct && originCell.ct.fa === '@') {
value = String(value);
} else {
value = parseFloat(value);
}
}
let originCell = x[c + curC];
if(originCell instanceof Object){
originCell.v = value;
if(originCell.ct!=null && originCell.ct.fa!=null){
Expand Down
7 changes: 6 additions & 1 deletion src/controllers/sheetBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {selectTextDom} from '../global/cursorPos';
import locale from '../locale/locale';
import Store from '../store';
import luckysheetConfigsetting from './luckysheetConfigsetting';

import {pagerInit} from '../global/api'


//表格底部名称栏区域 相关事件(增、删、改、隐藏显示、颜色等等)
Expand Down Expand Up @@ -525,4 +525,9 @@ export function initialSheetBar(){
$("#luckysheet-input-box").removeAttr("style");
});

// 初始化分页器
if (luckysheetConfigsetting.pager) {
pagerInit(luckysheetConfigsetting.pager)
}

}
50 changes: 28 additions & 22 deletions src/controllers/sheetmanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,33 +592,39 @@ const sheetmanage = {
return ret;
},
buildGridData: function(file) {
// 如果已经存在二维数据data,那么直接返回data;如果只有celldata,那么就转化成二维数组data,再返回
let row = file.row == null ? Store.defaultrowNum : file.row,
column = file.column == null ? Store.defaultcolumnNum : file.column;
let data = datagridgrowth([], row, column);

let celldata = file.celldata;
if(celldata != null){
for(let i = 0; i < celldata.length; i++){
let item = celldata[i];
let r = item.r;
let c = item.c;
let v = item.v;

if(r >= data.length){
data = datagridgrowth(data, r - data.length + 1, 0);
column = file.column == null ? Store.defaultcolumnNum : file.column,
data = file.data && file.data.length > 0 ? file.data : datagridgrowth([], row, column),
celldata = file.celldata;
if (file.data && file.data.length > 0) {
for (let i = 0; i < data.length; i++) {
for (let j = 0; j < data[0].length; j++) {
setcellvalue(i, j, data, data[i][j]);
}
if(c >= data[0].length){
data = datagridgrowth(data, 0, c - data[0].length + 1);
}
} else {
if(celldata && celldata.length > 0){
for(let i = 0; i < celldata.length; i++){
let item = celldata[i];
let r = item.r;
let c = item.c;
let v = item.v;

if(r >= data.length){
data = datagridgrowth(data, r - data.length + 1, 0);
}
if(c >= data[0].length){
data = datagridgrowth(data, 0, c - data[0].length + 1);
}
setcellvalue(r, c, data, v);
}

setcellvalue(r, c, data, v);
}
}

//亿万格式+精确度 恢复全局初始化
luckysheetConfigsetting.autoFormatw = false;
luckysheetConfigsetting.accuracy = undefined;

return data;
},
cutGridData: function(d) {
Expand Down Expand Up @@ -1145,9 +1151,8 @@ const sheetmanage = {
_this.storeSheetParamALL();
_this.setCurSheet(index);

let file = Store.luckysheetfile[_this.getSheetIndex(index)],
data = file.data,
cfg = file.config;
let file = Store.luckysheetfile[_this.getSheetIndex(index)]

if (!!file.isPivotTable) {
Store.luckysheetcurrentisPivotTable = true;
if (!isPivotInitial) {
Expand All @@ -1162,7 +1167,8 @@ const sheetmanage = {

let load = file["load"];
if (load != null) {

let data = _this.buildGridData(file);
file.data = data;
// _this.loadOtherFile(file);

_this.mergeCalculation(index);
Expand Down
2 changes: 2 additions & 0 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ luckysheet.create = function (setting) {
luckysheetConfigsetting.container = extendsetting.container;
luckysheetConfigsetting.hook = extendsetting.hook;

luckysheetConfigsetting.pager = extendsetting.pager;

if (Store.lang === 'zh') flatpickr.localize(Mandarin.zh);

// Store the currently used plugins for monitoring asynchronous loading
Expand Down
4 changes: 2 additions & 2 deletions src/css/luckysheet-core.css
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ div.luckysheet-sheets-m:hover {
padding: 0px 0px;
margin-left: 0px;
position: relative;
width: 70%;
max-width: 50%;
vertical-align: bottom;
}

Expand Down Expand Up @@ -7220,7 +7220,7 @@ fieldset[disabled] .btn-danger.focus {
border: 1px solid #ccc;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
position: absolute;
z-index: 1000;
z-index: 10000;
box-sizing: border-box;
}
#luckysheet-dataVerification-dropdown-List .dropdown-List-item{
Expand Down
Loading

0 comments on commit 7f6ea99

Please sign in to comment.