Browse Source

Merge pull request #588 from zhangsimu1992/dev

增加快捷删除和增加行的钩子函数
master
Dushusir 4 years ago
committed by GitHub
parent
commit
c90ebc8585
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      src/controllers/rowColumnOperation.js
  2. 79
      src/global/api.js

20
src/controllers/rowColumnOperation.js

@ -4,6 +4,7 @@ import luckysheetPostil from './postil';
import imageCtrl from './imageCtrl';
import menuButton from './menuButton';
import server from './server';
import method from '../global/method';
import { selectHightlightShow, luckysheet_count_show,selectHelpboxFill } from './select';
import {
getObjType,
@ -1103,7 +1104,10 @@ export function rowColumnOperationInitial(){
}
let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][0];
luckysheetextendtable(Store.luckysheetRightHeadClickIs, st_index, value, "lefttop");
if(!method.createHookFunction("rowInsertBefore", st_index, value, "lefttop")){
return;
}
luckysheetextendtable(Store.luckysheetRightHeadClickIs, st_index, value, "lefttop");
});
@ -1117,6 +1121,9 @@ export function rowColumnOperationInitial(){
}
let st_index = Store.luckysheet_select_save[0].row[0];
if(!method.createHookFunction("rowInsertBefore", st_index, 1, "lefttop")){
return;
}
luckysheetextendtable('row', st_index, 1, "lefttop");
@ -1330,6 +1337,9 @@ export function rowColumnOperationInitial(){
}
let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][1];
if(!method.createHookFunction("rowInsertBefore", st_index, value, "rightbottom")){
return;
}
luckysheetextendtable(Store.luckysheetRightHeadClickIs, st_index, value, "rightbottom");
});
@ -1476,7 +1486,10 @@ export function rowColumnOperationInitial(){
let st_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][0],
ed_index = Store.luckysheet_select_save[0][Store.luckysheetRightHeadClickIs][1];
luckysheetdeletetable(Store.luckysheetRightHeadClickIs, st_index, ed_index);
if(!method.createHookFunction("rowDeleteBefore", st_index, ed_index)){
return;
}
luckysheetdeletetable(Store.luckysheetRightHeadClickIs, st_index, ed_index);
});
$("#luckysheet-delRows").click(function (event) {
$("#luckysheet-rightclick-menu").hide();
@ -1506,6 +1519,9 @@ export function rowColumnOperationInitial(){
let st_index = Store.luckysheet_select_save[0].row[0],
ed_index = Store.luckysheet_select_save[0].row[1];
if(!method.createHookFunction("rowDeleteBefore", st_index, ed_index)){
return;
}
luckysheetdeletetable('row', st_index, ed_index);
})
$("#luckysheet-delCols").click(function (event) {

79
src/global/api.js

@ -1082,7 +1082,62 @@ export function insertRowOrColumn(type, index = 0, options = {}) {
success();
}
}
/**
* 在第index行或列的位置插入number行或列
* @param {String} type 插入行或列 row- column-
* @param {Number} index 在第几行插入空白行从0开始
* @param {Object} options 可选参数
* @param {Number} options.number 插入的空白行数默认为 1
* @param {Number} options.order 工作表索引默认值为当前工作表索引
* @param {Function} options.success 操作结束的回调函数
*/
export function insertRowBottomOrColumnRight(type, index = 0, options = {}) {
if(!isRealNum(index)){
return tooltip.info('The index parameter is invalid.', '');
}
let curSheetOrder = getSheetIndex(Store.currentSheetIndex);
let {
number = 1,
order = curSheetOrder,
success
} = {...options}
let _locale = locale();
let locale_info = _locale.info;
if (!isRealNum(number)) {
if(isEditMode()){
alert(locale_info.tipInputNumber);
} else{
tooltip.info(locale_info.tipInputNumber, "");
}
return;
}
number = parseInt(number);
if (number < 1 || number > 100) {
if(isEditMode()){
alert(locale_info.tipInputNumberLimit);
} else{
tooltip.info(locale_info.tipInputNumberLimit, "");
}
return;
}
// 默认在行上方增加行,列左侧增加列
let sheetIndex;
if(order){
if(Store.luckysheetfile[order]){
sheetIndex = Store.luckysheetfile[order].index;
}
}
luckysheetextendtable(type, index, number, "rightbottom", sheetIndex);
if (success && typeof success === 'function') {
success();
}
}
/**
* 在第row行的位置插入number行空白行
* @param {Number} row 在第几行插入空白行从0开始
@ -1094,7 +1149,17 @@ export function insertRowOrColumn(type, index = 0, options = {}) {
export function insertRow(row = 0, options = {}) {
insertRowOrColumn('row', row, options)
}
/**
* 在第row行的位置插入number行空白行
* @param {Number} row 在第几行插入空白行从0开始
* @param {Object} options 可选参数
* @param {Number} options.number 插入的空白行数默认为 1
* @param {Number} options.order 工作表索引默认值为当前工作表索引
* @param {Function} options.success 操作结束的回调函数
*/
export function insertRowBottom(row = 0, options = {}) {
insertRowBottomOrColumnRight('row', row, options)
}
/**
* 在第column列的位置插入number列空白列
* @param {Number} column 在第几列插入空白列从0开始
@ -1106,7 +1171,17 @@ export function insertRow(row = 0, options = {}) {
export function insertColumn(column = 0, options = {}) {
insertRowOrColumn('column', column, options)
}
/**
* 在第column列的位置插入number列空白列
* @param {Number} column 在第几列插入空白列从0开始
* @param {Object} options 可选参数
* @param {Number} options.number 插入的空白列数默认为 1
* @param {Number} options.order 工作表索引默认值为当前工作表索引
* @param {Function} options.success 操作结束的回调函数
*/
export function insertColumnRight(column = 0, options = {}) {
insertRowBottomOrColumnRight('column', column, options)
}
/**
* 删除指定的行或列删除行列之后行列的序号并不会变化下面的行右侧的列会补充到上注意观察数据是否被正确删除即可
* @param {String} type 删除行或列 row- column-

Loading…
Cancel
Save