Browse Source

Merge branch 'master' of https://github.com/mengshukeji/Luckysheet into master

master
CN\wuwx26 5 years ago
parent
commit
1e68ac8489
  1. 30
      docs/guide/api.md
  2. 26
      docs/zh/guide/api.md
  3. 6
      src/controllers/controlHistory.js
  4. 14
      src/controllers/handler.js
  5. 9
      src/controllers/menuButton.js
  6. 60
      src/global/api.js

30
docs/guide/api.md

@ -2512,8 +2512,6 @@ Use note:
### setWorkbookName(name [,setting])
[todo]
- **Parameter**
- {Number} [name]: Workbook name
@ -2526,6 +2524,19 @@ Use note:
------------
### getWorkbookName(name [,setting])
- **Parameter**
- {PlainObject} [setting]: optional parameters
+ {Function} [success]: callback function for the end of the operation
- **Explanation**
get workbook name
------------
### undo([setting])
[todo]
@ -2570,6 +2581,21 @@ Use note:
------------
### refreshMenuButtonFocus([data],[r],[c],[success])
- **Parameter**
- {Array} [data]: Operational data
- {Number} [r]: Specified row
- {Number} [c]: Specified column
- {Function} [success]: callback function for the end of the operation
- **Explanation**
Refreshes the top status bar status of the specified cell.
------------
## Chart
### insertChart([setting])

26
docs/zh/guide/api.md

@ -2448,6 +2448,19 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
------------
### getWorkbookName([,setting])
- **参数**
- {PlainObject} [setting]: 可选参数
+ {Function} [success]: 操作结束的回调函数
- **说明**
获取工作簿名称
------------
### undo([setting])
- **参数**
@ -2508,6 +2521,19 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开
初始化分页器。ps:create阶段,可以直接配置options.pager参数,渲染阶段会将options.pager作为参数来初始化分页器,可通过钩子函数onTogglePager来监听页码的切换
### refreshMenuButtonFocus([data],[r],[c],[success])
- **参数**
- {Array} [data]: 操作数据
- {Number} [r]: 指定的行
- {Number} [c]: 指定的列
- {Function} [success]: 操作结束的回调函数
- **说明**
刷新指定单元格的顶部状态栏状态。
------------
## 图表

6
src/controllers/controlHistory.js

@ -25,6 +25,7 @@ import { getSheetIndex } from '../methods/get';
import Store from '../store';
import { selectHightlightShow } from './select';
import method from '../global/method';
import {refreshMenuButtonFocus} from "../global/api";
function formulaHistoryHanddler(ctr, type="redo"){
if(ctr==null){
@ -428,6 +429,9 @@ const controlHistory = {
}
Store.clearjfundo = true;
/* 刷新当前状态栏 */
refreshMenuButtonFocus();
// 撤销的时候curdata 跟 data 数据要调换一下
let newCtr = {...ctr, ...{data: ctr.curdata, curdata: ctr.data}}
// 钩子函数
@ -744,6 +748,8 @@ const controlHistory = {
}
Store.clearjfundo = true;
/* 刷新当前状态栏 */
refreshMenuButtonFocus();
}
};

14
src/controllers/handler.js

@ -1440,8 +1440,17 @@ export default function luckysheetHandler() {
menuButton.cancelPaintModel();
}
// 检查当前坐标和焦点坐标是否一致,如果不一致那么进行修正
let column_focus = Store.luckysheet_select_save[0]["column_focus"];
let row_focus = Store.luckysheet_select_save[0]["row_focus"];
if(column_focus !== col_index || row_focus !== row_index){
row_index = row_focus;
col_index = column_focus;
};
luckysheetupdateCell(row_index, col_index, Store.flowdata);
/* 设置选区高亮 */
selectHightlightShow();
}
});
@ -5021,6 +5030,9 @@ export default function luckysheetHandler() {
clearTimeout(Store.countfuncTimeout);
Store.countfuncTimeout = setTimeout(function () { countfunc() }, 500);
/* 选中区域:发送网络请求 */
server.saveParam("mv", Store.currentSheetIndex, Store.luckysheet_select_save);
event.stopPropagation();
});

9
src/controllers/menuButton.js

@ -544,6 +544,8 @@ const menuButton = {
_this.updateFormat(d, "fc", color);
});
$("#luckysheet-icon-text-color-menu").mousedown(function(e){
hideMenuByCancel(e);
e.stopPropagation();
@ -598,7 +600,6 @@ const menuButton = {
["#900","#b45f06","#bf9000","#38761d","#134f5c","#0b5394","#351c75","#741b47"],
["#600","#783f04","#7f6000","#274e13","#0c343d","#073763","#20124d","#4c1130"]],
change: function (color) {
let $input = $(this);
if (color != null) {
color = color.toHexString();
}
@ -606,7 +607,6 @@ const menuButton = {
color = "#000";
}
let oldcolor = null;
// $("#luckysheet-icon-text-color .luckysheet-color-menu-button-indicator").css("border-bottom-color", color);
// 下边框换成了一个DIV
$("#luckysheet-icon-text-color .text-color-bar").css("background-color", color);
@ -617,6 +617,9 @@ const menuButton = {
$menuButton.hide();
luckysheetContainerFocus();
/* 备注:在单元格编辑状态下切换了文本的颜色存在bug,此处需设置编辑框的color样式, */
$("#luckysheet-input-box").css("color",color);
},
});
@ -738,7 +741,6 @@ const menuButton = {
["#600", "#783f04", "#7f6000", "#274e13", "#0c343d", "#073763", "#20124d", "#4c1130"]
],
change: function (color) {
let $input = $(this);
if (color != null) {
color = color.toHexString();
}
@ -746,7 +748,6 @@ const menuButton = {
color = "#fff";
}
let oldcolor = null;
// $("#luckysheet-icon-cell-color .luckysheet-color-menu-button-indicator").css("border-bottom-color", color);
// 下边框换成了一个DIV
$("#luckysheet-icon-cell-color .text-color-bar").css("background-color", color);

60
src/global/api.js

@ -5625,6 +5625,39 @@ export function setWorkbookName(name, options = {}) {
}
}
/**
* 获取工作簿名称
* @param {Object} options 可选参数
* @param {Function} options.success 操作结束的回调函数
* @returns {String} 返回工作簿名称如果读取失败则返回空字符串并弹窗提示
*/
export function getWorkbookName(options = {}) {
let name = "";
let element = $("#luckysheet_info_detail_input");
if(element.length == 0){
tooltip.info('Failed to get workbook name, label loading failed!');
return name;
}
name = $.trim(element.val());
let {
success
} = {...options}
setTimeout(() => {
if (success && typeof success === 'function') {
success()
}
}, 1)
return name;
}
/**
* 撤销当前操作返回刚刚撤销的操作对象
@ -6538,7 +6571,6 @@ export function getTxtByRange(range=Store.luckysheet_select_save){
return conditionformat.getTxtByRange(range);
}
/**
* 初始化分页器
* @param {Object} config 分页器配置
@ -6582,3 +6614,29 @@ export function refreshFormula (success) {
}
})
}
/**
* 刷新状态栏的状态
* @param {Array} data 操作数据
* @param {Number} r 指定的行
* @param {Number} c 指定的列
* @param {Function} success 回调函数
*/
export function refreshMenuButtonFocus(data ,r,c , success){
data = data || Store.flowdata;
if(r == null && c == null){
/* 获取选取范围 */
let last = Store.luckysheet_select_save[Store.luckysheet_select_save.length -1];
r = last.row_focus || last.row[0];
c = last.column_focus || last.column[0];
}
menuButton.menuButtonFocus(data, r, c);
setTimeout(() => {
if (success && typeof success === 'function') {
success();
}
})
}
Loading…
Cancel
Save