|
@ -1,5 +1,5 @@ |
|
|
import Store from "../store"; |
|
|
import Store from "../store"; |
|
|
import { replaceHtml, getObjType, chatatABC } from "../utils/util"; |
|
|
import { replaceHtml, getObjType, chatatABC, luckysheetactiveCell } from "../utils/util"; |
|
|
import { getSheetIndex, getluckysheet_select_save, getluckysheetfile } from "../methods/get"; |
|
|
import { getSheetIndex, getluckysheet_select_save, getluckysheetfile } from "../methods/get"; |
|
|
import locale from "../locale/locale"; |
|
|
import locale from "../locale/locale"; |
|
|
|
|
|
|
|
@ -20,6 +20,7 @@ import { luckysheetDeleteCell, luckysheetextendtable, luckysheetdeletetable } fr |
|
|
import { isRealNull, valueIsError, isRealNum, isEditMode, hasPartMC } from "./validate"; |
|
|
import { isRealNull, valueIsError, isRealNum, isEditMode, hasPartMC } from "./validate"; |
|
|
import { isdatetime, diff } from "./datecontroll"; |
|
|
import { isdatetime, diff } from "./datecontroll"; |
|
|
import { getBorderInfoCompute } from './border'; |
|
|
import { getBorderInfoCompute } from './border'; |
|
|
|
|
|
import { luckysheetDrawMain } from './draw'; |
|
|
|
|
|
|
|
|
import server from "../controllers/server"; |
|
|
import server from "../controllers/server"; |
|
|
import menuButton from '../controllers/menuButton'; |
|
|
import menuButton from '../controllers/menuButton'; |
|
@ -31,8 +32,9 @@ import sheetmanage from '../controllers/sheetmanage'; |
|
|
import conditionformat from '../controllers/conditionformat'; |
|
|
import conditionformat from '../controllers/conditionformat'; |
|
|
import { luckysheet_searcharray } from "../controllers/sheetSearch"; |
|
|
import { luckysheet_searcharray } from "../controllers/sheetSearch"; |
|
|
import { selectHightlightShow, selectIsOverlap } from '../controllers/select'; |
|
|
import { selectHightlightShow, selectIsOverlap } from '../controllers/select'; |
|
|
import { sheetHTML } from '../controllers/constant'; |
|
|
import { sheetHTML, luckysheetdefaultstyle } from '../controllers/constant'; |
|
|
import { createFilterOptions } from '../controllers/filter'; |
|
|
import { createFilterOptions } from '../controllers/filter'; |
|
|
|
|
|
import controlHistory from '../controllers/controlHistory'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const IDCardReg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i; |
|
|
const IDCardReg = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i; |
|
@ -4662,6 +4664,64 @@ export function setSheetMove(type, options = {}) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 重新排序所有工作表的位置,指定工作表顺序的数组。 |
|
|
|
|
|
* @param {Array} orderList 工作表顺序,设置工作表的index和order来指定位置 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function setSheetOrder(orderList, options = {}) { |
|
|
|
|
|
if(orderList == null || orderList.length == 0){ |
|
|
|
|
|
return tooltip.info("Type orderList not available", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let orderListMap = {}; |
|
|
|
|
|
orderList.forEach((item) => { |
|
|
|
|
|
orderListMap[item.index.toString()] = item.order; |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
Store.luckysheetfile.sort((x, y) => { |
|
|
|
|
|
let order_x = orderListMap[x.index.toString()]; |
|
|
|
|
|
let order_y = orderListMap[y.index.toString()]; |
|
|
|
|
|
|
|
|
|
|
|
if(order_x != null && order_y != null){ |
|
|
|
|
|
return order_x - order_y; |
|
|
|
|
|
} |
|
|
|
|
|
else if(order_x != null){ |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
else if(order_y != null){ |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
let orders = {}; |
|
|
|
|
|
|
|
|
|
|
|
Store.luckysheetfile.forEach((item, i, arr) => { |
|
|
|
|
|
arr[i].order = i; |
|
|
|
|
|
orders[item.index.toString()] = i; |
|
|
|
|
|
|
|
|
|
|
|
if(i > 0){ |
|
|
|
|
|
let preIndex = arr[i - 1].index; |
|
|
|
|
|
$("#luckysheet-sheets-item" + item.index).insertAfter($("#luckysheet-sheets-item" + preIndex)); |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
server.saveParam("shr", null, orders); |
|
|
|
|
|
|
|
|
|
|
|
let { |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 显示指定下标工作表的网格线,返回操作的工作表对象 |
|
|
* 显示指定下标工作表的网格线,返回操作的工作表对象 |
|
|
* @param {Object} options 可选参数 |
|
|
* @param {Object} options 可选参数 |
|
@ -4738,6 +4798,24 @@ export function hideGridLines(options = {}){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 刷新canvas |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function refresh(options = {}) { |
|
|
|
|
|
luckysheetrefreshgrid(); |
|
|
|
|
|
|
|
|
|
|
|
let { |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 滚动当前工作表位置 |
|
|
* 滚动当前工作表位置 |
|
|
* @param {Object} options 可选参数 |
|
|
* @param {Object} options 可选参数 |
|
@ -4801,7 +4879,6 @@ export function scroll(options = {}){ |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据窗口大小自动resize画布 |
|
|
* 根据窗口大小自动resize画布 |
|
|
* |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
* @param {Object} options 可选参数 |
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
*/ |
|
|
*/ |
|
@ -4818,6 +4895,200 @@ export function resize(options = {}){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 返回指定选区截图后生成的base64格式的图片 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Object | String} options.range 选区范围,只能为单个选区;默认为当前选区 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function getScreenshot(options = {}) { |
|
|
|
|
|
let { |
|
|
|
|
|
range = Store.luckysheet_select_save[Store.luckysheet_select_save.length - 1], |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
if(getObjType(range) == 'string'){ |
|
|
|
|
|
if(!formula.iscelldata(range)){ |
|
|
|
|
|
return tooltip.info("The range parameter is invalid.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let cellrange = formula.getcellrange(range); |
|
|
|
|
|
range = { |
|
|
|
|
|
"row": cellrange.row, |
|
|
|
|
|
"column": cellrange.column |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(getObjType(range) != 'object' || range.row == null || range.column == null){ |
|
|
|
|
|
return tooltip.info("The range parameter is invalid.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let str = range.row[0], |
|
|
|
|
|
edr = range.row[1], |
|
|
|
|
|
stc = range.column[0], |
|
|
|
|
|
edc = range.column[1]; |
|
|
|
|
|
|
|
|
|
|
|
let has_PartMC = hasPartMC(Store.config, str, edr, stc, edc); |
|
|
|
|
|
|
|
|
|
|
|
if(has_PartMC){ |
|
|
|
|
|
return tooltip.info('Cannot perform this operation on partially merged cells', ''); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let visibledatarow = Store.visibledatarow; |
|
|
|
|
|
let visibledatacolumn = Store.visibledatacolumn; |
|
|
|
|
|
|
|
|
|
|
|
let scrollHeight, rh_height; |
|
|
|
|
|
if (str - 1 < 0) { |
|
|
|
|
|
scrollHeight = 0; |
|
|
|
|
|
rh_height = visibledatarow[edr]; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
scrollHeight = visibledatarow[str - 1]; |
|
|
|
|
|
rh_height = visibledatarow[edr] - visibledatarow[str - 1]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let scrollWidth, ch_width; |
|
|
|
|
|
if (stc - 1 < 0) { |
|
|
|
|
|
scrollWidth = 0; |
|
|
|
|
|
ch_width = visibledatacolumn[edc]; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
scrollWidth = visibledatacolumn[stc - 1]; |
|
|
|
|
|
ch_width = visibledatacolumn[edc] - visibledatacolumn[stc - 1]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let newCanvas = $("<canvas>").attr({ |
|
|
|
|
|
width: Math.ceil(ch_width * Store.devicePixelRatio), |
|
|
|
|
|
height: Math.ceil(rh_height * Store.devicePixelRatio) |
|
|
|
|
|
}).css({ width: ch_width, height: rh_height }); |
|
|
|
|
|
|
|
|
|
|
|
luckysheetDrawMain(scrollWidth, scrollHeight, ch_width, rh_height, 1, 1, null, null, newCanvas); |
|
|
|
|
|
let ctx_newCanvas = newCanvas.get(0).getContext("2d"); |
|
|
|
|
|
|
|
|
|
|
|
//补上 左边框和上边框
|
|
|
|
|
|
ctx_newCanvas.beginPath(); |
|
|
|
|
|
ctx_newCanvas.moveTo( |
|
|
|
|
|
0, |
|
|
|
|
|
0 |
|
|
|
|
|
); |
|
|
|
|
|
ctx_newCanvas.lineTo( |
|
|
|
|
|
0, |
|
|
|
|
|
Store.devicePixelRatio * rh_height |
|
|
|
|
|
); |
|
|
|
|
|
ctx_newCanvas.lineWidth = Store.devicePixelRatio * 2; |
|
|
|
|
|
ctx_newCanvas.strokeStyle = luckysheetdefaultstyle.strokeStyle; |
|
|
|
|
|
ctx_newCanvas.stroke(); |
|
|
|
|
|
ctx_newCanvas.closePath(); |
|
|
|
|
|
|
|
|
|
|
|
ctx_newCanvas.beginPath(); |
|
|
|
|
|
ctx_newCanvas.moveTo( |
|
|
|
|
|
0, |
|
|
|
|
|
0 |
|
|
|
|
|
); |
|
|
|
|
|
ctx_newCanvas.lineTo( |
|
|
|
|
|
Store.devicePixelRatio * ch_width, |
|
|
|
|
|
0 |
|
|
|
|
|
); |
|
|
|
|
|
ctx_newCanvas.lineWidth = Store.devicePixelRatio * 2; |
|
|
|
|
|
ctx_newCanvas.strokeStyle = luckysheetdefaultstyle.strokeStyle; |
|
|
|
|
|
ctx_newCanvas.stroke(); |
|
|
|
|
|
ctx_newCanvas.closePath(); |
|
|
|
|
|
|
|
|
|
|
|
let url = newCanvas.get(0).toDataURL("image/png"); |
|
|
|
|
|
|
|
|
|
|
|
return url; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 设置工作簿名称 |
|
|
|
|
|
* @param {String} name 工作簿名称 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function setWorkbookName(name, options = {}) { |
|
|
|
|
|
if(name == null || name.toString().length == 0){ |
|
|
|
|
|
return tooltip.info("The name parameter is invalid.", ""); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$("#luckysheet_info_detail_input").val(name); |
|
|
|
|
|
|
|
|
|
|
|
let { |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 撤销当前操作,返回刚刚撤销的操作对象 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function undo(options = {}) { |
|
|
|
|
|
let ctr = $.extend(true, {}, Store.jfredo[Store.jfredo.length - 1]); |
|
|
|
|
|
|
|
|
|
|
|
controlHistory.redo(new Event('custom')); |
|
|
|
|
|
luckysheetactiveCell(); |
|
|
|
|
|
|
|
|
|
|
|
let { |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
}, 1); |
|
|
|
|
|
|
|
|
|
|
|
return ctr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 重做当前操作,返回刚刚重做的操作对象 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function redo(options = {}) { |
|
|
|
|
|
let ctr = $.extend(true, {}, Store.jfundo[Store.jfundo.length - 1]); |
|
|
|
|
|
|
|
|
|
|
|
controlHistory.undo(new Event('custom')); |
|
|
|
|
|
luckysheetactiveCell(); |
|
|
|
|
|
|
|
|
|
|
|
let { |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
}, 1); |
|
|
|
|
|
|
|
|
|
|
|
return ctr; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 返回所有工作表配置 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function getAllSheets() { |
|
|
|
|
|
let data = $.extend(true, [], Store.luckysheetfile); |
|
|
|
|
|
|
|
|
|
|
|
data.forEach((item, index, arr) => { |
|
|
|
|
|
if(item.data != null && item.data.length > 0){ |
|
|
|
|
|
item.celldata = sheetmanage.getGridData(item.data); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
delete item.load; |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
return data; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 根据index获取sheet页配置 |
|
|
* 根据index获取sheet页配置 |
|
|
* |
|
|
* |
|
@ -4948,18 +5219,39 @@ export function getLuckysheetfile(){ |
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
*/ |
|
|
*/ |
|
|
export function transToCellData(data, options = {}){ |
|
|
export function transToCellData(data, options = {}){ |
|
|
|
|
|
|
|
|
let { |
|
|
let { |
|
|
success |
|
|
success |
|
|
} = {...options} |
|
|
} = {...options} |
|
|
|
|
|
|
|
|
setTimeout(()=>{ |
|
|
setTimeout(()=>{ |
|
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
if (success && typeof success === 'function') { |
|
|
success(); |
|
|
success(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
},0) |
|
|
},0) |
|
|
|
|
|
|
|
|
return sheetmanage.getGridData(data) |
|
|
return sheetmanage.getGridData(data) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* celldata => data ,celldata一维数组数据转化成表格所需二维数组 |
|
|
|
|
|
* |
|
|
|
|
|
* @param {Array} celldata 二维数组数据 |
|
|
|
|
|
* @param {Object} options 可选参数 |
|
|
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
|
|
*/ |
|
|
|
|
|
export function transToData(celldata, options = {}){ |
|
|
|
|
|
let { |
|
|
|
|
|
success |
|
|
|
|
|
} = {...options} |
|
|
|
|
|
|
|
|
|
|
|
setTimeout(()=>{ |
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
|
|
success(); |
|
|
|
|
|
} |
|
|
|
|
|
},0) |
|
|
|
|
|
|
|
|
|
|
|
return sheetmanage.buildGridData({ |
|
|
|
|
|
celldata: celldata |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|