Browse Source

feat(gloabe improve and bug fix): global improve and bug fix,include formula,find and replace,filter

master
liuyang 5 years ago
parent
commit
e6cfa3156a
  1. 30
      src/controllers/constant.js
  2. 408
      src/controllers/handler.js
  3. 2
      src/controllers/insertFormula.js
  4. 6
      src/controllers/searchReplace.js
  5. 8
      src/controllers/select.js
  6. 26
      src/controllers/sheetmanage.js
  7. 3
      src/core.js
  8. 13
      src/global/count.js
  9. 19
      src/global/createdom.js
  10. 45
      src/global/formula.js
  11. 4
      src/global/method.js
  12. 2
      src/global/tooltip.js
  13. 64
      src/locale/en.js
  14. 76
      src/locale/zh.js

30
src/controllers/constant.js

@ -1,19 +1,24 @@
import locale from '../locale/locale';
//dom variable
const gridHTML = '<div class="luckysheet">' +
const gridHTML = function(){
const _locale = locale();
const locale_info = _locale.info;
return '<div class="luckysheet">' +
'<canvas id="luckysheetTableContentF" style="display:none;" class="luckysheetTableContent"></canvas>' +
'<div class="luckysheet-work-area luckysheet-noselected-text">' +
'<div class="luckysheet-share-logo" title="${logotitle}"></div>' +
'<div id ="luckysheet_info_detail" class="luckysheet_info_detail">' +
'<div data-tips="返回" id="luckysheet_info_detail_title" class="luckysheet_info_detail_title">' +
'<div data-tips="'+locale_info.return+'" id="luckysheet_info_detail_title" class="luckysheet_info_detail_title">' +
'<i style="margin-left: -2px;" class="fa fa-chevron-left" aria-hidden="true"></i>' +
'</div>' +
'<div>' +
'<input data-tips="表格重命名" id="luckysheet_info_detail_input" class="luckysheet_info_detail_input luckysheet-mousedown-cancel" value="无标题的电子表格" tabindex="0" dir="ltr" aria-label="重命名" style="visibility: visible; width: 149px;" data-tooltip="重命名">' +
'<input data-tips="'+locale_info.tips+'" id="luckysheet_info_detail_input" class="luckysheet_info_detail_input luckysheet-mousedown-cancel" value="'+locale_info.noName+'" tabindex="0" dir="ltr" aria-label="'+locale_info.rename+'" style="visibility: visible; width: 149px;" data-tooltip="'+locale_info.rename+'">' +
'</div>' +
'<div id="luckysheet_info_detail_update" class="luckysheet_info_detail_update"> 新打开 </div>' +
'<div id="luckysheet_info_detail_save" class="luckysheet_info_detail_save"> 待更新 </div>' +
'<div id="luckysheet_info_detail_update" class="luckysheet_info_detail_update"> '+locale_info.detailUpdate+' </div>' +
'<div id="luckysheet_info_detail_save" class="luckysheet_info_detail_save"> '+locale_info.wait+' </div>' +
'<div class="luckysheet_info_detail_user"> ${functionButton} <span id="luckysheet_info_detail_user"></span> </div>' +
'</div>' +
'<div id="luckysheet-wa-editor" class="luckysheet-wa-editor"> ${menu} </div>' +
@ -160,8 +165,10 @@ const gridHTML = '<div class="luckysheet">' +
'<div id="luckysheet-copy-content" contenteditable="true"></div>' +
'<input id="luckysheet-copy-btn" type="button" data-clipboard-target="luckysheet-copy-content">' +
'<div id="testdpidiv" style="height: 1in; left: -100%; position: absolute; top: -100%; width: 1in;"></div>' +
'</div>',
columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
'</div>';
}
const columeHeader_word = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
columeHeader_word_index = { 'A': 0, 'B': 1, 'C': 2, 'D': 3, 'E': 4, 'F': 5, 'G': 6, 'H': 7, 'I': 8, 'J': 9, 'K': 10, 'L': 11, 'M': 12, 'N': 13, 'O': 14, 'P': 15, 'Q': 16, 'R': 17, 'S': 18, 'T': 19, 'U': 20, 'V': 21, 'W': 22, 'X': 23, 'Y': 24, 'Z': 25 },
flow = '<div id="luckysheet-cell-flow_${index}" class="luckysheet-cell-flow luckysheetsheetchange" style="width:${width}px;"><div class="luckysheet-cell-flow-clip"><div class="luckysheet-grdblkpush"></div>${flow}</div></div>',
colsmenuHTML = '';
@ -434,7 +441,7 @@ const pivottableconfigHTML = '<div class="luckysheet-cols-menu luckysheet-rightg
sheetselectlistHTML = '<div class="luckysheet-cols-menu luckysheet-rightgclick-menu luckysheet-mousedown-cancel" id="luckysheet-sheet-list">${item}</div>',
sheetselectlistitemHTML = '<div class="luckysheet-cols-menuitem luckysheet-mousedown-cancel" id="luckysheet-sheet-btn${index}" data-index="${index}"><div class="luckysheet-cols-menuitem-content luckysheet-mousedown-cancel" style="${style}" ><span class="icon luckysheet-mousedown-cancel">${icon}</span>${name}</div></div>',
inputHTML = '<div dir="ltr"><div class="luckysheet-input-box-index" id="luckysheet-input-box-index"></div><div id="luckysheet-input-box" spellcheck="false" aria-hidden="false" class="luckysheet-input-box"><div class="luckysheet-cell-input editable" tabindex="0" role="combobox" contenteditable="true" id="luckysheet-rich-text-editor" dir="ltr" g_editable="true" aria-autocomplete="list"></div></div></div>',
modelHTML = '<div id="${id}" style="${style}" class="luckysheet-modal-dialog ${addclass}" tabindex="0" role="dialog" aria-labelledby=":41e" dir="ltr"> <div class="luckysheet-modal-dialog-title luckysheet-modal-dialog-title-draggable"> <span class="luckysheet-modal-dialog-title-text" role="heading">${title}</span> <span class="luckysheet-modal-dialog-title-close" role="button" tabindex="0" aria-label="关闭"><i class="fa fa-times" aria-hidden="true"></i></span> </div> <div class="luckysheet-modal-dialog-content">${content}</div> <div class="luckysheet-modal-dialog-buttons"> ${botton} </div></div>',
modelHTML = '<div id="${id}" style="${style}" class="luckysheet-modal-dialog ${addclass}" tabindex="0" role="dialog" aria-labelledby=":41e" dir="ltr"> <div class="luckysheet-modal-dialog-title luckysheet-modal-dialog-title-draggable"> <span class="luckysheet-modal-dialog-title-text" role="heading">${title}</span> <span class="luckysheet-modal-dialog-title-close" role="button" tabindex="0" aria-label="${close}"><i class="fa fa-times" aria-hidden="true"></i></span> </div> <div class="luckysheet-modal-dialog-content">${content}</div> <div class="luckysheet-modal-dialog-buttons"> ${botton} </div></div>',
maskHTML = '<div class="luckysheet-modal-dialog-mask" id="luckysheet-modal-dialog-mask"></div>';
@ -1150,8 +1157,13 @@ function menuToolBar (){
${toolbar.splitColumn}
</div>`;
}
const luckysheetlodingHTML = '<div id="luckysheetloadingdata" style="width:100%;text-align:center;position:absolute;top:0px;height:100%;font-size: 16px;z-index:1000000000;background:#fff;"><div style="position:relative;top:45%;width:100%;"> <div class="luckysheetLoaderGif"></div> <span>渲染中...</span></div></div>';
const luckysheetlodingHTML = function(){
const _locale = locale()
const info =_locale.info;
return'<div id="luckysheetloadingdata" style="width:100%;text-align:center;position:absolute;top:0px;height:100%;font-size: 16px;z-index:1000000000;background:#fff;"><div style="position:relative;top:45%;width:100%;"> <div class="luckysheetLoaderGif"></div> <span>'+info.loading+'...</span></div></div>';
}
// var menusetting = {
// menu_selectall: '<div id="luckysheet-selectall-btn-title"><i class="fa fa-i-cursor"></i> 全选</div>',
// menu_copy: '<div id="luckysheet-copy-btn-title"><i class="fa fa-copy"></i> 复制</div>',

408
src/controllers/handler.js

File diff suppressed because it is too large

2
src/controllers/insertFormula.js

@ -194,7 +194,7 @@ const insertFormula = {
"id": "luckysheet-search-formula",
"addclass": "luckysheet-search-formula",
"title": "",
"content": "<div class='inpbox'><label for='searchFormulaListInput'>"+ locale_formulaMore.findFunctionTitle +":</label><input class='formulaInputFocus' id='searchFormulaListInput' placeholder='"+ locale_formulaMore.tipInputFunctionName +"' spellcheck='false'/></div><div class='selbox'><label>或选择类别:</label><select id='formulaTypeSelect'><option value='0'>"+locale_formulaMore.Math+"</option><option value='1'>"+locale_formulaMore.Statistical+"</option><option value='2'>"+locale_formulaMore.Lookup+"</option><option value='3'>"+locale_formulaMore.luckysheet+"</option><option value='4'>"+locale_formulaMore.dataMining+"</option><option value='5'>"+locale_formulaMore.Database+"</option><option value='6'>"+locale_formulaMore.Date+"</option><option value='7'>"+locale_formulaMore.Filter+"</option><option value='8'>"+locale_formulaMore.Financial+"</option><option value='9'>"+locale_formulaMore.Engineering+"</option><option value='10'>"+locale_formulaMore.Logical+"</option><option value='11'>"+locale_formulaMore.Operator+"</option><option value='12'>"+locale_formulaMore.Text+"</option><option value='13'>"+locale_formulaMore.Parser+"</option><option value='14'>"+locale_formulaMore.Array+"</option><option value='-1'>"+locale_formulaMore.other+"</option></select></div><div class='listbox'><label>"+locale_formulaMore.selectFunctionTitle+":</label><div id='formulaTypeList'></div></div>",
"content": "<div class='inpbox'><label for='searchFormulaListInput'>"+ locale_formulaMore.findFunctionTitle +":</label><input class='formulaInputFocus' id='searchFormulaListInput' placeholder='"+ locale_formulaMore.tipInputFunctionName +"' spellcheck='false'/></div><div class='selbox'><label>"+locale_formulaMore.selectCategory+":</label><select id='formulaTypeSelect'><option value='0'>"+locale_formulaMore.Math+"</option><option value='1'>"+locale_formulaMore.Statistical+"</option><option value='2'>"+locale_formulaMore.Lookup+"</option><option value='3'>"+locale_formulaMore.luckysheet+"</option><option value='4'>"+locale_formulaMore.dataMining+"</option><option value='5'>"+locale_formulaMore.Database+"</option><option value='6'>"+locale_formulaMore.Date+"</option><option value='7'>"+locale_formulaMore.Filter+"</option><option value='8'>"+locale_formulaMore.Financial+"</option><option value='9'>"+locale_formulaMore.Engineering+"</option><option value='10'>"+locale_formulaMore.Logical+"</option><option value='11'>"+locale_formulaMore.Operator+"</option><option value='12'>"+locale_formulaMore.Text+"</option><option value='13'>"+locale_formulaMore.Parser+"</option><option value='14'>"+locale_formulaMore.Array+"</option><option value='-1'>"+locale_formulaMore.other+"</option></select></div><div class='listbox'><label>"+locale_formulaMore.selectFunctionTitle+":</label><div id='formulaTypeList'></div></div>",
"botton": '<button id="luckysheet-search-formula-confirm" class="btn btn-primary">'+locale_button.confirm+'</button><button class="btn btn-default luckysheet-model-close-btn">'+locale_button.cancel+'</button>',
"style": "z-index:100003"
}));

6
src/controllers/searchReplace.js

@ -21,6 +21,7 @@ const luckysheetSearchReplace = {
const _locale = locale();
const locale_findAndReplace = _locale.findAndReplace;
const locale_button = _locale.button;
let content = '<div class="tabBox">' +
'<span id="searchTab">'+ locale_findAndReplace.find +'</span>' +
@ -58,8 +59,9 @@ const luckysheetSearchReplace = {
"addclass": "luckysheet-search-replace",
"title": "",
"content": content,
"botton": '<button class="btn btn-default luckysheet-model-close-btn">关闭</button>',
"style": "z-index:100003"
"botton": '<button class="btn btn-default luckysheet-model-close-btn">'+locale_button.close+'</button>',
"style": "z-index:100003",
"close":locale_button.close
}));
let $t = $("#luckysheet-search-replace").find(".luckysheet-modal-dialog-content").css("min-width", 500).end(),
myh = $t.outerHeight(),

8
src/controllers/select.js

@ -5,6 +5,7 @@ import { rowLocationByIndex, colLocationByIndex } from '../global/location';
import browser from '../global/browser';
import { getSheetIndex, getRangetxt } from '../methods/get';
import Store from '../store';
import locale from '../locale/locale';
//公式函数 选区实体框
function seletedHighlistByindex(id, r1, r2, c1, c2) {
@ -347,6 +348,9 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet
let scrollWidth = $("#luckysheet-cell-main").scrollLeft(),
scrollHeight = $("#luckysheet-cell-main").scrollTop();
const _locale = locale();
const locale_info = _locale.info;
if (rowl >= 4) {
let leftv = left - 25;
if (leftv < 0) {
@ -362,7 +366,7 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet
topv = scrollHeight + drawHeight / 2;
}
$("#luckysheet-row-count-show").css({ "left": leftv, "top": topv, "display": "block" }).html("<div>" + rowl.toString().split("").join("</div><div>") + "</div><div></div>");
$("#luckysheet-row-count-show").css({ "left": leftv, "top": topv, "display": "block" }).html("<div>" + rowl.toString().split("").join("</div><div>") + "</div><div>"+locale_info.row+"</div>");
}
else {
$("#luckysheet-row-count-show").hide();
@ -383,7 +387,7 @@ function luckysheet_count_show(left, top, width, height, rowseleted, columnselet
leftv = scrollWidth + drawWidth / 2;
}
$("#luckysheet-column-count-show").css({ "left": leftv, "top": topv, "display": "block" }).text(coll + "列");
$("#luckysheet-column-count-show").css({ "left": leftv, "top": topv, "display": "block" }).text(coll + locale_info.column);
}
else {
$("#luckysheet-column-count-show").hide();

26
src/controllers/sheetmanage.js

@ -10,7 +10,7 @@ import editor from '../global/editor';
import { luckysheetextendtable, luckysheetdeletetable } from '../global/extend';
import { isRealNum } from '../global/validate';
import { replaceHtml, getObjType, chatatABC } from '../utils/util';
import { sheetHTML } from './constant';
import { sheetHTML,luckysheetlodingHTML } from './constant';
import server from './server';
import luckysheetConfigsetting from './luckysheetConfigsetting';
import pivotTable from './pivotTable';
@ -20,6 +20,7 @@ import luckysheetFreezen from './freezen';
import { createFilterOptions, labelFilterOptionState } from './filter';
import { selectHightlightShow, selectionCopyShow } from './select';
import Store from '../store';
import locale from '../locale/locale';
const sheetmanage = {
generateRandomSheetIndex: function(prefix) {
@ -62,9 +63,12 @@ const sheetmanage = {
generateCopySheetName: function(file, name) {
let copySheetName = "";
if(name.toString().indexOf("(副本") > -1){
let copy_i = name.toString().indexOf("(副本");
let name2 = name.toString().substring(0, copy_i) + "(副本";
let _locale = locale();
let locale_info = _locale.info;
if(name.toString().indexOf("("+locale_info.copy) > -1){
let copy_i = name.toString().indexOf("("+locale_info.copy);
let name2 = name.toString().substring(0, copy_i) + "("+locale_info.copy;
let index = null;
for(let i = 0; i < file.length; i++){
@ -94,7 +98,7 @@ const sheetmanage = {
else{
let index = null;
let hascopy = false;
let name2 = name + "(副本";
let name2 = name + "("+locale_info.copy;
for(let i = 0; i < file.length; i++){
let fileName = file[i].name.toString();
@ -115,15 +119,15 @@ const sheetmanage = {
if(hascopy){
if(index == null){
copySheetName = name + "(副本2)";
copySheetName = name + "("+ locale_info.copy +"2)";
}
else{
index++;
copySheetName = name + "(副本" + index + ")";
copySheetName = name + "("+ locale_info.copy +"" + index + ")";
}
}
else{
copySheetName = name + "(副本)";
copySheetName = name + "("+ locale_info.copy +")";
}
}
@ -632,7 +636,7 @@ const sheetmanage = {
width: Store.luckysheetTableContentHW[0],
height: Store.luckysheetTableContentHW[1]
}).get(0).getContext("2d");
let locale_info = locale().info;
let key = server.gridKey;
let cahce_key = key + "__qkcache";
@ -663,7 +667,7 @@ const sheetmanage = {
_this.restoreSheetAll(Store.currentSheetIndex);
luckysheetrefreshgrid(0, 0);
$("#luckysheet_info_detail_save").html("已恢复本地缓存");
$("#luckysheet_info_detail_save").html(locale_info.detailSave);
if (!!file.isPivotTable) {
Store.luckysheetcurrentisPivotTable = true;
@ -875,7 +879,7 @@ const sheetmanage = {
server.saveParam("shs", null, Store.currentSheetIndex);
}
else{
$("#luckysheet-grid-window-1").append('<div id="luckysheetloadingdata" style="width:100%;text-align:center;position:absolute;top:0px;height:100%;font-size: 16px;z-index:1000000000;background:#fff;"><div style="position:relative;top:45%;width:100%;"> <div class="luckysheetLoaderGif"></div> <span>渲染中...</span></div></div>');
$("#luckysheet-grid-window-1").append(luckysheetlodingHTML());
let sheetindex = _this.checkLoadSheetIndex(file);

3
src/core.js

@ -20,6 +20,7 @@ import {
} from './methods/set';
import { luckysheetrefreshgrid } from './global/refresh';
import functionlist from './function/functionlist';
import { luckysheetlodingHTML } from './controllers/constant';
let luckysheet = {};
@ -92,7 +93,7 @@ luckysheet.create = function (setting) {
Store.devicePixelRatio = Math.ceil(devicePixelRatio);
//loading
$("#" + container).append('<div id="luckysheetloadingdata" style="width:100%;text-align:center;position:absolute;top:0px;height:100%;font-size: 16px;z-index:1000000000;background:#fff;"><div style="position:relative;top:45%;width:100%;"> <div class="luckysheetLoaderGif"> </div> <span>渲染中...</span></div></div>');
$("#" + container).append(luckysheetlodingHTML());
let data = [];
if (loadurl == "") {

13
src/global/count.js

@ -2,6 +2,7 @@ import Store from '../store';
import { getdatabyselectionNoCopy } from './getdata';
import { isRealNull, isRealNum } from './validate';
import { update } from './format';
import locale from '../locale/locale';
//表格计数栏
export function countfunc() {
@ -51,21 +52,23 @@ export function countfunc() {
}
}
let locale_formula = locale().formula;
let ret = "";
ret += "<span>计数:" + count + "</span>";
ret += "<span>"+locale_formula.count+":" + count + "</span>";
//处理成亿万格式
if (isFinite(max) || isFinite(min)) {
ret += "<span>求和:" + update("w", sum) + "</span>";
ret += "<span>平均值:" + update("w", Math.round(sum / count * 10000) / 10000) + "</span>";
ret += "<span>"+locale_formula.sum+":" + update("w", sum) + "</span>";
ret += "<span>"+locale_formula.average+":" + update("w", Math.round(sum / count * 10000) / 10000) + "</span>";
}
if (isFinite(max)) {
ret += "<span>最大值:" + update("w", max) + "</span>";
ret += "<span>"+locale_formula.max+":" + update("w", max) + "</span>";
}
if (isFinite(min)) {
ret += "<span>最小值:" + update("w", min) + "</span>";
ret += "<span>"+locale_formula.min+":" + update("w", min) + "</span>";
}
$("#luckysheet-sta-content").html(ret);

19
src/global/createdom.js

@ -18,6 +18,7 @@ import editor from './editor';
import rhchInit from './rhchInit';
import { replaceHtml } from '../utils/util';
import Store from '../store';
import locale from '../locale/locale';
export default function luckysheetcreatedom(colwidth, rowheight, data, menu, title) {
//最少30行
@ -30,7 +31,7 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit
colwidth = 22;
}
let gh = gridHTML;
let gh = gridHTML();
gh = replaceHtml(gh, { "logotitle": title });//设置title
gh = replaceHtml(gh, { "menu": menuToolBar() });//设置需要显示的菜单
@ -59,11 +60,19 @@ export default function luckysheetcreatedom(colwidth, rowheight, data, menu, tit
rhchInit(rowheight, colwidth);
let addControll = '<button id="luckysheet-bottom-add-row" class="btn btn-default">添加</button><input id="luckysheet-bottom-add-row-input" type="text" class="luckysheet-datavisual-config-input luckysheet-mousedown-cancel" placeholder="100"><span style="font-size: 14px;">行</span><span style="font-size: 14px;color: #9c9c9c;">(在底部添加)</span>';
let backControll = ' <button id="luckysheet-bottom-bottom-top" class="btn btn-default" style="">回到顶部</button>';
const _locale = locale();
const locale_info = _locale.info;
let addControll = '<button id="luckysheet-bottom-add-row" class="btn btn-default">'+locale_info.add+'</button><input id="luckysheet-bottom-add-row-input" type="text" class="luckysheet-datavisual-config-input luckysheet-mousedown-cancel" placeholder="100"><span style="font-size: 14px;">'+ locale_info.row +'</span><span style="font-size: 14px;color: #9c9c9c;">('+locale_info.addLast+')</span>';
let backControll = ' <button id="luckysheet-bottom-bottom-top" class="btn btn-default" style="">'+ locale_info.backTop +'</button>';
// let pageControll = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">共'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页,每页'+ luckysheetConfigsetting.pageInfo.pageSize +'条</span> <button id="luckysheet-bottom-page-next" class="btn btn-danger" style="">下一页</button>';
let pageControll = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">共'+ luckysheetConfigsetting.total +'条,'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页</span> <button id="luckysheet-bottom-page-next" class="btn btn-danger" style="">下一页</button>';
let pageControll2 = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">共'+ luckysheetConfigsetting.total +'条,'+ luckysheetConfigsetting.pageInfo.totalPage +'页,当前已显示'+ (luckysheetConfigsetting.pageInfo.currentPage) +'页</span>';
let pageInfo = replaceHtml(locale_info.pageInfo,{
total:luckysheetConfigsetting.total?luckysheetConfigsetting.total:"",
totalPage:luckysheetConfigsetting.pageInfo.totalPage?luckysheetConfigsetting.pageInfo.totalPage:"",
currentPage:luckysheetConfigsetting.pageInfo.currentPage?luckysheetConfigsetting.pageInfo.currentPage:"",
});
let pageControll = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">'+ pageInfo +'</span> <button id="luckysheet-bottom-page-next" class="btn btn-danger" style="">下一页</button>';
let pageControll2 = ' <span id="luckysheet-bottom-page-info" style="font-size: 14px;color: #f34141;">'+pageInfo+'</span>';
let bottomControll = "";
if(luckysheetConfigsetting.enableAddRow){

45
src/global/formula.js

@ -22,6 +22,7 @@ import { jfrefreshgrid } from './refresh';
// import functionlist from '../function/functionlist';
import { luckysheet_compareWith, luckysheet_getcelldata, luckysheet_indirect_check, luckysheet_indirect_check_return, luckysheet_offset_check } from '../function/func';
import Store from '../store';
import locale from '../locale/locale';
const luckysheetformula = {
error: {
@ -39,6 +40,8 @@ const luckysheetformula = {
},
errorParamCheck: function(thisp, data, i) {
let type, require;
let _locale = locale();
let locale_formulaMore = _locale.formulaMore;
if(i < thisp.length){
type = thisp[i].type;
require = thisp[i].require;
@ -49,30 +52,30 @@ const luckysheetformula = {
}
if(require == "o" && (data == null || data == "")){
return [true, "成功"];
return [true, locale_formulaMore.tipSuccessText];
}
if(type.indexOf("all") > -1){
return [true, "成功"];
return [true, locale_formulaMore.tipSuccessText];
}
else{
if(type.indexOf("range") > -1 && (getObjType(data) == "object" || getObjType(data) == "array")){
return [true, "成功"];
return [true, locale_formulaMore.tipSuccessText];
}
if(type.indexOf("number") > -1 && (isRealNum(data) || getObjType(data) == "boolean")){
return [true, "成功"];
return [true, locale_formulaMore.tipSuccessText];
}
if(type.indexOf("string") > -1 && getObjType(data) == "string"){
return [true, "成功"];
return [true, locale_formulaMore.tipSuccessText];
}
if(type.indexOf("date") > -1 && isdatetime(data)){
return [true, "成功"];
return [true, locale_formulaMore.tipSuccessText];
}
return [false, "参数类型错误"];
return [false, locale_formulaMore.tipParamErrorText];
}
},
getPureValueByData: function(data){
@ -787,7 +790,7 @@ const luckysheetformula = {
$("#luckysheet-formula-functionrange .luckysheet-formula-functionrange-highlight").show();
},
searchHTML: '<div id="luckysheet-formula-search-c" class="luckysheet-formula-search-c"></div>',
helpHTML: '<div id="luckysheet-formula-help-c" class="luckysheet-formula-help-c"> <div class="luckysheet-formula-help-close" title="关闭"><i class="fa fa-times" aria-hidden="true"></i></div> <div class="luckysheet-formula-help-collapse" title="收起"><i class="fa fa-angle-up" aria-hidden="true"></i></div> <div class="luckysheet-formula-help-title"><div class="luckysheet-formula-help-title-formula"> <span class="luckysheet-arguments-help-function-name">SUM</span> <span class="luckysheet-arguments-paren">(</span> <span class="luckysheet-arguments-parameter-holder"> <span class="luckysheet-arguments-help-parameter luckysheet-arguments-help-parameter-active" dir="auto">A2:A100</span>, <span class="luckysheet-arguments-help-parameter" dir="auto">101</span> </span> <span class="luckysheet-arguments-paren">)</span> </div></div> <div class="luckysheet-formula-help-content"> <div class="luckysheet-formula-help-content-example"> <div class="luckysheet-arguments-help-section-title">示例</div> <div class="luckysheet-arguments-help-formula"> <span class="luckysheet-arguments-help-function-name">SUM</span> <span class="luckysheet-arguments-paren">(</span> <span class="luckysheet-arguments-parameter-holder"> <span class="luckysheet-arguments-help-parameter luckysheet-arguments-help-parameter-active" dir="auto">A2:A100</span>, <span class="luckysheet-arguments-help-parameter" dir="auto">101</span> </span> <span class="luckysheet-arguments-paren">)</span> </div> </div> <div class="luckysheet-formula-help-content-detail"> <div class="luckysheet-arguments-help-section"> <div class="luckysheet-arguments-help-section-title luckysheet-arguments-help-parameter-name">摘要</div> <span class="luckysheet-arguments-help-parameter-content">${detail}</span> </div> </div> <div class="luckysheet-formula-help-content-param"> ${param} </div> </div> <div class="luckysheet-formula-help-foot"></div></div>',
helpHTML: '<div id="luckysheet-formula-help-c" class="luckysheet-formula-help-c"> <div class="luckysheet-formula-help-close" title="${helpClose}"><i class="fa fa-times" aria-hidden="true"></i></div> <div class="luckysheet-formula-help-collapse" title="${helpCollapse}"><i class="fa fa-angle-up" aria-hidden="true"></i></div> <div class="luckysheet-formula-help-title"><div class="luckysheet-formula-help-title-formula"> <span class="luckysheet-arguments-help-function-name">SUM</span> <span class="luckysheet-arguments-paren">(</span> <span class="luckysheet-arguments-parameter-holder"> <span class="luckysheet-arguments-help-parameter luckysheet-arguments-help-parameter-active" dir="auto">A2:A100</span>, <span class="luckysheet-arguments-help-parameter" dir="auto">101</span> </span> <span class="luckysheet-arguments-paren">)</span> </div></div> <div class="luckysheet-formula-help-content"> <div class="luckysheet-formula-help-content-example"> <div class="luckysheet-arguments-help-section-title">${helpExample}</div> <div class="luckysheet-arguments-help-formula"> <span class="luckysheet-arguments-help-function-name">SUM</span> <span class="luckysheet-arguments-paren">(</span> <span class="luckysheet-arguments-parameter-holder"> <span class="luckysheet-arguments-help-parameter luckysheet-arguments-help-parameter-active" dir="auto">A2:A100</span>, <span class="luckysheet-arguments-help-parameter" dir="auto">101</span> </span> <span class="luckysheet-arguments-paren">)</span> </div> </div> <div class="luckysheet-formula-help-content-detail"> <div class="luckysheet-arguments-help-section"> <div class="luckysheet-arguments-help-section-title luckysheet-arguments-help-parameter-name">${helpAbstract}</div> <span class="luckysheet-arguments-help-parameter-content">${helpAbstract}</span> </div> </div> <div class="luckysheet-formula-help-content-param"> ${param} </div> </div> <div class="luckysheet-formula-help-foot"></div></div>',
getrangeseleciton: function() {
let currSelection = window.getSelection();
let anchor = $(currSelection.anchorNode);
@ -997,6 +1000,9 @@ const luckysheetformula = {
return;
}
let _locale = locale();
let locale_formulaMore = _locale.formulaMore;
$("#luckysheet-formula-help-c .luckysheet-arguments-help-function-name").html($func.n);
$("#luckysheet-formula-help-c .luckysheet-arguments-help-parameter-content").html($func.d);
@ -1022,11 +1028,11 @@ const luckysheetformula = {
if (paramitem.repeat == "y") {
name += ", ...";
nameli += '<span class="luckysheet-arguments-help-argument-info">...-可重复</span>';
nameli += '<span class="luckysheet-arguments-help-argument-info">...-'+locale_formulaMore.allowRepeatText+'</span>';
}
if (paramitem.require == "o") {
name = "[" + name + "]";
nameli += '<span class="luckysheet-arguments-help-argument-info">-[可选]</span>';
nameli += '<span class="luckysheet-arguments-help-argument-info">-['+locale_formulaMore.allowOptionText+']</span>';
}
fht += '<span class="luckysheet-arguments-help-parameter" dir="auto">' + name + '</span>, ';
@ -1065,9 +1071,15 @@ const luckysheetformula = {
helpFunctionExe: function($editer, currSelection) {
let _this = this;
let functionlist = Store.functionlist;
let _locale = locale();
let locale_formulaMore = _locale.formulaMore;
if ($("#luckysheet-formula-help-c").length == 0) {
$("body").after(_this.helpHTML);
$("body").after(replaceHtml(_this.helpHTML,{
helpClose:locale_formulaMore.helpClose,
helpCollapse:locale_formulaMore.helpCollapse,
helpExample:locale_formulaMore.helpExample,
helpAbstract:locale_formulaMore.helpAbstract,
}));
$("#luckysheet-formula-help-c .luckysheet-formula-help-close").click(function() {
$("#luckysheet-formula-help-c").hide();
});
@ -4742,6 +4754,9 @@ const luckysheetformula = {
},
execfunction: function(txt, r, c, isrefresh, notInsertFunc) {
let _this = this;
let _locale = locale();
let locale_formulaMore = _locale.formulaMore;
if(txt.indexOf(_this.error.r) > -1){
return [false, _this.error.r, txt];
@ -4758,7 +4773,7 @@ const luckysheetformula = {
}
if (!_this.testFunction(txt, fp) || fp == "") {
tooltip.info("提示", "公式存在错误");
tooltip.info("",locale_formulaMore.execfunctionError);
return [false, _this.error.n, txt];
}
@ -4783,10 +4798,10 @@ const luckysheetformula = {
if(funcgRange.sheetIndex == Store.currentSheetIndex && r >= funcgRange.row[0] && r <= funcgRange.row[1] && c >= funcgRange.column[0] && c <= funcgRange.column[1]){
if(isEditMode()){
alert("公式不可引用其本身的单元格");
alert(locale_formulaMore.execfunctionSelfError);
}
else{
tooltip.info("公式不可引用其本身的单元格,会导致计算结果不准确", "");
tooltip.info("", locale_formulaMore.execfunctionSelfErrorResult);
}

4
src/global/method.js

@ -21,7 +21,7 @@ const method = {
url = server.loadSheetUrl;
}
$("#luckysheet-grid-window-1").append(luckysheetlodingHTML);
$("#luckysheet-grid-window-1").append(luckysheetlodingHTML());
param.currentPage++;
let dataType = 'application/json;charset=UTF-8';
@ -67,7 +67,7 @@ const method = {
url = server.loadSheetUrl;
}
$("#luckysheet-grid-window-1").append(luckysheetlodingHTML);
$("#luckysheet-grid-window-1").append(luckysheetlodingHTML());
let arg = {"gridKey" : server.gridKey, "index": index};
param = $.extend(true, param, arg);

2
src/global/tooltip.js

@ -16,7 +16,7 @@ const tooltip = {
"addclass": "",
"title": title,
"content": content,
"botton": '<button class="btn btn-default luckysheet-model-close-btn">&nbsp;&nbsp;'+locale_button.colse+'&nbsp;&nbsp;</button>',
"botton": '<button class="btn btn-default luckysheet-model-close-btn">&nbsp;&nbsp;'+locale_button.close+'&nbsp;&nbsp;</button>',
"style": "z-index:100003"
}));
let $t = $("#luckysheet-info").find(".luckysheet-modal-dialog-content").css("min-width", 300).end(),

64
src/locale/en.js

@ -50,6 +50,7 @@ export default {
noColorSelectedText:"No color is selected",
toolMore:"More",
toolLess:"Less",
toolClose:"Close",
toolMoreTip:"More features",
},
@ -93,8 +94,28 @@ export default {
info:{
detailUpdate: 'New opened',
detailSave: 'Local cache restored',
row: 'row',
column: 'column'
row: '',
column: '',
loading:"Loading",
copy:"Copy",
return:"Exit",
rename:"Rename",
tips:"WorkBook rename",
noName:"Untitled spreadsheet",
wait:"waiting for update",
add:"Add",
addLast:"more rows at bottom",
backTop:"Back to the top",
pageInfo:'Total ${total},${totalPage} page,current ${currentPage}',
nextPage:"Next",
tipInputNumber:"Please enter the number",
tipInputNumberLimit:"The increase range is limited to 1-100",
tipRowHeightLimit:"The value must be between 0 ~ 255",
pageInfoFull:'Total ${total},${totalPage} page,All data displayed',
},
currencyDetail:{
RMB:'RMB',
@ -443,6 +464,14 @@ export default {
conditionCellBetween:"Is between",
conditionCellNotBetween:"Is not between",
filiterMoreDataTip:"Big amount of data! please wait",
filiterMonthText:"Month",
filiterYearText:"Year",
filiterByColorTip:"Filter by cell color",
filiterByTextColorTip:"Filter by font color",
filterContainerOneColorTip:"This column contains only one color",
filterDateFormatTip:"Date format",
},
rightclick: {
copy: 'Copy',
@ -533,6 +562,9 @@ export default {
splitDataPreview:"Preview",
splitTextTitle:"Split text",
splitConfirmToExe:"There is already data here, do you want to replace it?",
tipNoMulti:"Cannot perform this operation on multiple selection areas, please select a single area and try again",
tipNoMultiColumn:"Only one column of data can be converted at a time. The selected area can have multiple rows but not multiple columns. Please try again after selecting a single column range",
},
punctuation:{
"tab":"Tab",
@ -738,6 +770,34 @@ export default {
"selectFunctionTitle":"Select a function",
"calculationResult":"Result",
tipSuccessText:"Success",
tipParamErrorText:"Parameter type error",
"helpClose":"Close",
"helpCollapse":"Collapse",
"helpExample":"Example",
"helpAbstract":"Abstract",
"execfunctionError":'Error in the formula',
"execfunctionSelfError":'Formula cannot refer to its own cell',
"execfunctionSelfErrorResult":'The formula cannot refer to its own cell, which will lead to inaccurate calculation results',
"allowRepeatText":"Repeat",
"allowOptionText":"Option",
"selectCategory":"Or select a category",
},
drag:{
noMerge:"Cannot perform this operation on merged cells",
affectPivot:"This change cannot be made to the selected cell because it will affect the pivot table!",
noMulti:"Cannot perform this operation on multiple selection areas, please select a single area",
noPaste:"Unable to paste this content here, please select a cell in the paste area and try to paste again",
noPartMerge:"Cannot perform this operation on partially merged cells",
inputCorrect:"Please enter the correct value",
notLessOne:"The number of rows and columns cannot be less than 1",
offsetColumnLessZero:"The offset column cannot be negative!",
}
};

76
src/locale/zh.js

@ -49,6 +49,7 @@ export default {
noColorSelectedText:"没有颜色被选择",
toolMore:"更多",
toolLess:"少于",
toolClose:"收起",
toolMoreTip:"更多功能",
@ -94,7 +95,28 @@ export default {
detailUpdate: '新打开',
detailSave: '已恢复本地缓存',
row: '行',
column: '列'
column: '列',
loading:"渲染中",
copy:"副本",
return:"返回",
rename:"重命名",
tips:"表格重命名",
noName:"无标题的电子表格",
wait:"待更新",
add:"添加",
addLast:"在底部添加",
backTop:"回到顶部",
pageInfo:'共${total}条,${totalPage}页,当前已显示${currentPage}页',
nextPage:"下一页",
tipInputNumber:"请输入数字",
tipInputNumberLimit:"增加范围限制在1-100",
tipRowHeightLimit:"数值必须在0 ~ 255之间",
pageInfoFull:'共${total}条,${totalPage}页,已显示全部数据',
},
currencyDetail:{
RMB:'人民币',
@ -411,6 +433,8 @@ export default {
"columnOperation":"列",
"secondaryTitle":"次要排序",
"sortTitle":"排序范围",
"sortRangeTitle":"排序范围从",
"sortRangeTitleTo":"到",
@ -443,6 +467,8 @@ export default {
filterCancel:"取 消",
clearFilter:"清除筛选",
conditionNone:"无",
conditionCellIsNull:"单元格为空",
conditionCellNotNull:"单元格有数据",
@ -462,6 +488,15 @@ export default {
conditionCellNotEqual:"不等于",
conditionCellBetween:"介于",
conditionCellNotBetween:"不在其中",
filiterMoreDataTip:"数据量大!请稍后",
filiterMonthText:"月",
filiterYearText:"年",
filiterByColorTip:"按单元格颜色筛选",
filiterByTextColorTip:"按单元格字体颜色筛选",
filterContainerOneColorTip:"本列仅包含一种颜色",
filterDateFormatTip:"日期格式",
},
rightclick: {
copy: '复制',
@ -551,6 +586,9 @@ export default {
splitDataPreview:"数据预览",
splitTextTitle:"文本分列",
splitConfirmToExe:"此处已有数据,是否替换它?",
tipNoMulti:"不能对多重选择区域执行此操作,请选择单个区域,然后再试",
tipNoMultiColumn:"一次只能转换一列数据,选定区域可以有多行,但不能有多列,请在选定单列区域以后再试",
},
punctuation:{
"tab":"Tab 键",
@ -630,6 +668,14 @@ export default {
resetColor: '重置颜色',
cancelText: '取消',
chooseText: '确定颜色',
tipNameRepeat:"标签页的名称不能重复!请重新修改",
noMoreSheet:"工作薄内至少含有一张可视工作表。若需删除选定的工作表,请先插入一张新工作表或显示一张隐藏的工作表。",
confirmDelete:"是否删除",
redoDelete:"可以通过Ctrl+Z撤销删除",
noHide:"不能隐藏, 至少保留一个sheet标签",
chartEditNoOpt:"图表编辑模式下不允许该操作!",
},
conditionformat: {
rule: '规则',
@ -755,5 +801,33 @@ export default {
"selectFunctionTitle":"选择函数",
"calculationResult":"计算结果",
tipSuccessText:"成功",
tipParamErrorText:"参数类型错误",
"helpClose":"关闭",
"helpCollapse":"收起",
"helpExample":"示例",
"helpAbstract":"摘要",
"execfunctionError":'提示", "公式存在错误',
"execfunctionSelfError":'公式不可引用其本身的单元格',
"execfunctionSelfErrorResult":'公式不可引用其本身的单元格,会导致计算结果不准确',
"allowRepeatText":"可重复",
"allowOptionText":"可选",
"selectCategory":"或选择类别",
},
drag:{
noMerge:"无法对合并单元格执行此操作",
affectPivot:"无法对所选单元格进行此更改,因为它会影响数据透视表!",
noMulti:"无法对多重选择区域执行此操作,请选择单个区域",
noPaste:"无法在此处粘贴此内容,请选择粘贴区域的一个单元格,然后再次尝试粘贴",
noPartMerge:"无法对部分合并单元格执行此操作",
inputCorrect:"请输入正确的数值",
notLessOne:"行列数不能小于1",
offsetColumnLessZero:"偏移列不能为负数!",
}
};

Loading…
Cancel
Save