|
|
@ -18,6 +18,7 @@ import { getdatabyselection, getcellvalue } from "./getdata"; |
|
|
|
import { luckysheetrefreshgrid, jfrefreshgrid, jfrefreshgrid_rhcw } from "./refresh"; |
|
|
|
import { luckysheetDeleteCell, luckysheetextendtable, luckysheetdeletetable } from "./extend"; |
|
|
|
import { isRealNull, valueIsError, isRealNum, isEditMode, hasPartMC } from "./validate"; |
|
|
|
import { isdatetime, diff } from "./datecontroll"; |
|
|
|
|
|
|
|
import server from "../controllers/server"; |
|
|
|
import selection from "../controllers/selection"; |
|
|
@ -25,10 +26,12 @@ import luckysheetConfigsetting from "../controllers/luckysheetConfigsetting"; |
|
|
|
import luckysheetFreezen from "../controllers/freezen"; |
|
|
|
import luckysheetsizeauto from '../controllers/resize'; |
|
|
|
import sheetmanage from '../controllers/sheetmanage'; |
|
|
|
import conditionformat from '../controllers/conditionformat'; |
|
|
|
import { luckysheet_searcharray } from "../controllers/sheetSearch"; |
|
|
|
import { selectIsOverlap } from '../controllers/select'; |
|
|
|
import { sheetHTML } from '../controllers/constant'; |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
/** |
|
|
@ -2261,6 +2264,549 @@ export function setRangeSortMulti(hasTitle, sort, options = {}) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 为指定索引的工作表,选定的范围开启条件格式,根据设置的条件格式规则突出显示部分单元格,返回开启条件格式后的数据。 |
|
|
|
* @param {String} conditionName 条件格式规则类型 |
|
|
|
* @param {Object} conditionValue 可以设置条件单元格或者条件值 |
|
|
|
* @param {Object} options 可选参数 |
|
|
|
* @param {Object} options.format 颜色设置 |
|
|
|
* @param {Array | Object | String} options.cellrange 选区范围 |
|
|
|
* @param {Number} options.order 工作表索引;默认值为当前工作表索引 |
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
*/ |
|
|
|
export function setRangeConditionalFormatDefault(conditionName, conditionValue, options = {}) { |
|
|
|
let conditionNameValues = [ |
|
|
|
'greaterThan', |
|
|
|
'lessThan', |
|
|
|
'betweenness', |
|
|
|
'equal', |
|
|
|
'textContains', |
|
|
|
'occurrenceDate', |
|
|
|
'duplicateValue', |
|
|
|
'top10', |
|
|
|
'top10%', |
|
|
|
'last10', |
|
|
|
'last10%', |
|
|
|
'AboveAverage', |
|
|
|
'SubAverage' |
|
|
|
]; |
|
|
|
|
|
|
|
if(!conditionName || !conditionNameValues.includes(conditionName)){ |
|
|
|
return tooltip.info('The conditionName parameter is invalid.', ''); |
|
|
|
} |
|
|
|
|
|
|
|
if(getObjType(conditionValue) != 'array' || conditionValue.length == 0){ |
|
|
|
return tooltip.info('The conditionValue parameter is invalid.', ''); |
|
|
|
} |
|
|
|
|
|
|
|
let { |
|
|
|
format = { |
|
|
|
"textColor": "#000000", |
|
|
|
"cellColor": "#ff0000" |
|
|
|
}, |
|
|
|
cellrange = Store.luckysheet_select_save, |
|
|
|
order = getSheetIndex(Store.currentSheetIndex), |
|
|
|
success |
|
|
|
} = {...options} |
|
|
|
|
|
|
|
let file = Store.luckysheetfile[order]; |
|
|
|
let data = file.data; |
|
|
|
|
|
|
|
if(file == null){ |
|
|
|
return tooltip.info('Incorrect worksheet index', ''); |
|
|
|
} |
|
|
|
|
|
|
|
const conditionformat_Text = locale().conditionformat; |
|
|
|
|
|
|
|
let conditionRange = [], conditionValue2 = []; |
|
|
|
|
|
|
|
if(conditionName == 'betweenness'){ |
|
|
|
let v1 = conditionValue[0]; |
|
|
|
let v2 = conditionValue[1]; |
|
|
|
|
|
|
|
//条件值是否是选区
|
|
|
|
let rangeArr1 = conditionformat.getRangeByTxt(v1); |
|
|
|
if(rangeArr1.length > 1){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else if(rangeArr1.length == 1){ |
|
|
|
let r1 = rangeArr1[0].row[0], r2 = rangeArr1[0].row[1]; |
|
|
|
let c1 = rangeArr1[0].column[0], c2 = rangeArr1[0].column[1]; |
|
|
|
|
|
|
|
if(r1 == r2 && c1 == c2){ |
|
|
|
v1 = getcellvalue(r1, c1, data); |
|
|
|
|
|
|
|
conditionRange.push({ "row": rangeArr1[0].row, "column": rangeArr1[0].column }); |
|
|
|
conditionValue2.push(v1); |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(rangeArr1.length == 0){ |
|
|
|
if(isNaN(v1) || v1 == ""){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionValue2.push(v1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let rangeArr2 = conditionformat.getRangeByTxt(v2); |
|
|
|
if(rangeArr2.length > 1){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else if(rangeArr2.length == 1){ |
|
|
|
let r1 = rangeArr2[0].row[0], r2 = rangeArr2[0].row[1]; |
|
|
|
let c1 = rangeArr2[0].column[0], c2 = rangeArr2[0].column[1]; |
|
|
|
|
|
|
|
if(r1 == r2 && c1 == c2){ |
|
|
|
v2 = getcellvalue(r1, c1, data); |
|
|
|
|
|
|
|
conditionRange.push({ "row": rangeArr2[0].row, "column": rangeArr2[0].column }); |
|
|
|
conditionValue2.push(v2); |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(rangeArr2.length == 0){ |
|
|
|
if(isNaN(v2) || v2 == ""){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionValue2.push(v2); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(conditionName == 'greaterThan' || conditionName == 'lessThan' || conditionName == 'equal'){ |
|
|
|
let v = conditionValue[0]; |
|
|
|
|
|
|
|
//条件值是否是选区
|
|
|
|
let rangeArr = conditionformat.getRangeByTxt(v); |
|
|
|
if(rangeArr.length > 1){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else if(rangeArr.length == 1){ |
|
|
|
let r1 = rangeArr[0].row[0], r2 = rangeArr[0].row[1]; |
|
|
|
let c1 = rangeArr[0].column[0], c2 = rangeArr[0].column[1]; |
|
|
|
|
|
|
|
if(r1 == r2 && c1 == c2){ |
|
|
|
v = getcellvalue(r1, c1, data); |
|
|
|
|
|
|
|
conditionRange.push({ "row": rangeArr[0].row, "column": rangeArr[0].column }); |
|
|
|
conditionValue2.push(v); |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(rangeArr.length == 0){ |
|
|
|
if(isNaN(v) || v == ""){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionValue2.push(v); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(conditionName == 'textContains'){ |
|
|
|
let v = conditionValue[0]; |
|
|
|
|
|
|
|
//条件值是否是选区
|
|
|
|
let rangeArr = conditionformat.getRangeByTxt(v); |
|
|
|
if(rangeArr.length > 1){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else if(rangeArr.length == 1){ |
|
|
|
let r1 = rangeArr[0].row[0], r2 = rangeArr[0].row[1]; |
|
|
|
let c1 = rangeArr[0].column[0], c2 = rangeArr[0].column[1]; |
|
|
|
|
|
|
|
if(r1 == r2 && c1 == c2){ |
|
|
|
v = getcellvalue(r1, c1, data); |
|
|
|
|
|
|
|
conditionRange.push({ "row": rangeArr[0].row, "column": rangeArr[0].column }); |
|
|
|
conditionValue2.push(v); |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.onlySingleCell, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(rangeArr.length == 0){ |
|
|
|
if(v == ""){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.conditionValueCanOnly, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
else{ |
|
|
|
conditionValue2.push(v); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if(conditionName == 'occurrenceDate'){ |
|
|
|
let v1 = conditionValue[0]; |
|
|
|
let v2 = conditionValue[1]; |
|
|
|
|
|
|
|
if(!isdatetime(v1) || !isdatetime(v2)){ |
|
|
|
return tooltip.info('The conditionValue parameter is invalid.', ''); |
|
|
|
} |
|
|
|
|
|
|
|
let v; |
|
|
|
if(diff(v1, v2) > 0){ |
|
|
|
v = moment(v2).format("YYYY/MM/DD") + "-" + moment(v1).format("YYYY/MM/DD"); |
|
|
|
} |
|
|
|
else{ |
|
|
|
v = moment(v1).format("YYYY/MM/DD") + "-" + moment(v2).format("YYYY/MM/DD"); |
|
|
|
} |
|
|
|
|
|
|
|
conditionValue2.push(v); |
|
|
|
} |
|
|
|
else if(conditionName == 'duplicateValue'){ |
|
|
|
let v = conditionValue[0]; |
|
|
|
|
|
|
|
if(v != '0' || v != '1'){ |
|
|
|
return tooltip.info('The conditionValue parameter is invalid.', ''); |
|
|
|
} |
|
|
|
|
|
|
|
conditionValue2.push(v); |
|
|
|
} |
|
|
|
else if(conditionName == 'top10' || conditionName == 'top10%' || conditionName == 'last10' || conditionName == 'last10%'){ |
|
|
|
let v = conditionValue[0]; |
|
|
|
|
|
|
|
if(parseInt(v) != v || parseInt(v) < 1 || parseInt(v) > 1000){ |
|
|
|
conditionformat.infoDialog(conditionformat_Text.pleaseEnterInteger, ""); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
conditionValue2.push(parseInt(v)); |
|
|
|
} |
|
|
|
else if(conditionName == 'AboveAverage' || conditionName == 'SubAverage'){ |
|
|
|
conditionValue2.push(conditionName); |
|
|
|
} |
|
|
|
|
|
|
|
if(!format.hasOwnProperty("textColor") || !format.hasOwnProperty("cellColor")){ |
|
|
|
return tooltip.info('The format parameter is invalid.', ''); |
|
|
|
} |
|
|
|
|
|
|
|
if(getObjType(cellrange) == 'string'){ |
|
|
|
cellrange = conditionformat.getRangeByTxt(cellrange); |
|
|
|
} |
|
|
|
else if(getObjType(cellrange) == 'object'){ |
|
|
|
cellrange = [cellrange]; |
|
|
|
} |
|
|
|
|
|
|
|
let rule = { |
|
|
|
"type": "default", |
|
|
|
"cellrange": cellrange, |
|
|
|
"format": format, |
|
|
|
"conditionName": conditionName, |
|
|
|
"conditionRange": conditionRange, |
|
|
|
"conditionValue": conditionValue2 |
|
|
|
}; |
|
|
|
|
|
|
|
//保存之前的规则
|
|
|
|
let fileH = $.extend(true, [], Store.luckysheetfile); |
|
|
|
let historyRules = conditionformat.getHistoryRules(fileH); |
|
|
|
|
|
|
|
//保存当前的规则
|
|
|
|
let ruleArr = file["luckysheet_conditionformat_save"] || []; |
|
|
|
ruleArr.push(rule); |
|
|
|
file["luckysheet_conditionformat_save"] = ruleArr; |
|
|
|
|
|
|
|
let fileC = $.extend(true, [], Store.luckysheetfile); |
|
|
|
let currentRules = conditionformat.getCurrentRules(fileC); |
|
|
|
|
|
|
|
//刷新一次表格
|
|
|
|
conditionformat.ref(historyRules, currentRules); |
|
|
|
|
|
|
|
//发送给后台
|
|
|
|
if(server.allowUpdate){ |
|
|
|
server.saveParam("all", file.index, ruleArr, { "k": "luckysheet_conditionformat_save" }); |
|
|
|
} |
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
success(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 为指定索引的工作表,选定的范围开启条件格式,返回开启条件格式后的数据。 |
|
|
|
* @param {String} type 条件格式规则类型 |
|
|
|
* @param {Object} options 可选参数 |
|
|
|
* @param {Array | String} options.format 颜色设置 |
|
|
|
* @param {Array | Object | String} options.cellrange 选区范围 |
|
|
|
* @param {Number} options.order 工作表索引;默认值为当前工作表索引 |
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
*/ |
|
|
|
export function setRangeConditionalFormat(type, options = {}) { |
|
|
|
let typeValues = [ |
|
|
|
'dataBar', |
|
|
|
'colorGradation', |
|
|
|
'icons' |
|
|
|
]; |
|
|
|
|
|
|
|
if(!type || !typeValues.includes(type)){ |
|
|
|
return tooltip.info('The type parameter is invalid.', ''); |
|
|
|
} |
|
|
|
|
|
|
|
let { |
|
|
|
format, |
|
|
|
cellrange = Store.luckysheet_select_save, |
|
|
|
order = getSheetIndex(Store.currentSheetIndex), |
|
|
|
success |
|
|
|
} = {...options} |
|
|
|
|
|
|
|
let file = Store.luckysheetfile[order]; |
|
|
|
|
|
|
|
if(file == null){ |
|
|
|
return tooltip.info('Incorrect worksheet index', ''); |
|
|
|
} |
|
|
|
|
|
|
|
if(type == 'dataBar'){ |
|
|
|
if(format == null){ |
|
|
|
format = ["#638ec6", "#ffffff"]; |
|
|
|
} |
|
|
|
|
|
|
|
if(getObjType(format) != 'array' || format.length < 1 || format.length > 2){ |
|
|
|
return tooltip.info('The format parameter is invalid.', ''); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(type == 'colorGradation'){ |
|
|
|
if(format == null){ |
|
|
|
format = ["rgb(99, 190, 123)", "rgb(255, 235, 132)", "rgb(248, 105, 107)"]; |
|
|
|
} |
|
|
|
|
|
|
|
if(getObjType(format) != 'array' || format.length < 2 || format.length > 3){ |
|
|
|
return tooltip.info('The format parameter is invalid.', ''); |
|
|
|
} |
|
|
|
} |
|
|
|
else if(type == 'icons'){ |
|
|
|
if(format == null){ |
|
|
|
format = "threeWayArrowMultiColor"; |
|
|
|
} |
|
|
|
|
|
|
|
let formatValues = [ |
|
|
|
'threeWayArrowMultiColor', |
|
|
|
'threeTriangles', |
|
|
|
'fourWayArrowMultiColor', |
|
|
|
'fiveWayArrowMultiColor', |
|
|
|
'threeWayArrowGrayColor', |
|
|
|
'fourWayArrowGrayColor', |
|
|
|
'fiveWayArrowGrayColor', |
|
|
|
'threeColorTrafficLightRimless', |
|
|
|
'threeSigns', |
|
|
|
'greenRedBlackGradient', |
|
|
|
'threeColorTrafficLightBordered', |
|
|
|
'fourColorTrafficLight', |
|
|
|
'threeSymbolsCircled', |
|
|
|
'tricolorFlag', |
|
|
|
'threeSymbolsnoCircle', |
|
|
|
'threeStars', |
|
|
|
'fiveQuadrantDiagram', |
|
|
|
'fiveBoxes', |
|
|
|
'grade4', |
|
|
|
'grade5' |
|
|
|
]; |
|
|
|
|
|
|
|
if(getObjType(format) != 'string' || !formatValues.includes(format)){ |
|
|
|
return tooltip.info('The format parameter is invalid.', ''); |
|
|
|
} |
|
|
|
|
|
|
|
switch (format) { |
|
|
|
case 'threeWayArrowMultiColor': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 0 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeTriangles': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 1 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'fourWayArrowMultiColor': |
|
|
|
format = { |
|
|
|
"len": 4, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 2 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'fiveWayArrowMultiColor': |
|
|
|
format = { |
|
|
|
"len": 5, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 3 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeWayArrowGrayColor': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 0 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'fourWayArrowGrayColor': |
|
|
|
format = { |
|
|
|
"len": 4, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 1 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'fiveWayArrowGrayColor': |
|
|
|
format = { |
|
|
|
"len": 5, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 2 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeColorTrafficLightRimless': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 4 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeSigns': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 5 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'greenRedBlackGradient': |
|
|
|
format = { |
|
|
|
"len": 4, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 6 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeColorTrafficLightBordered': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 4 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'fourColorTrafficLight': |
|
|
|
format = { |
|
|
|
"len": 4, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 5 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeSymbolsCircled': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 7 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'tricolorFlag': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 8 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeSymbolsnoCircle': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 7 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'threeStars': |
|
|
|
format = { |
|
|
|
"len": 3, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 9 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'fiveQuadrantDiagram': |
|
|
|
format = { |
|
|
|
"len": 5, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 10 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'fiveBoxes': |
|
|
|
format = { |
|
|
|
"len": 5, |
|
|
|
"leftMin": 0, |
|
|
|
"top": 11 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'grade4': |
|
|
|
format = { |
|
|
|
"len": 4, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 9 |
|
|
|
}; |
|
|
|
break; |
|
|
|
case 'grade5': |
|
|
|
format = { |
|
|
|
"len": 5, |
|
|
|
"leftMin": 5, |
|
|
|
"top": 10 |
|
|
|
}; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(getObjType(cellrange) == 'string'){ |
|
|
|
cellrange = conditionformat.getRangeByTxt(cellrange); |
|
|
|
} |
|
|
|
else if(getObjType(cellrange) == 'object'){ |
|
|
|
cellrange = [cellrange]; |
|
|
|
} |
|
|
|
|
|
|
|
let rule = { |
|
|
|
"type": type, |
|
|
|
"cellrange": cellrange, |
|
|
|
"format": format |
|
|
|
}; |
|
|
|
|
|
|
|
//保存之前的规则
|
|
|
|
let fileH = $.extend(true, [], Store.luckysheetfile); |
|
|
|
let historyRules = conditionformat.getHistoryRules(fileH); |
|
|
|
|
|
|
|
//保存当前的规则
|
|
|
|
let ruleArr = file["luckysheet_conditionformat_save"] || []; |
|
|
|
ruleArr.push(rule); |
|
|
|
file["luckysheet_conditionformat_save"] = ruleArr; |
|
|
|
|
|
|
|
let fileC = $.extend(true, [], Store.luckysheetfile); |
|
|
|
let currentRules = conditionformat.getCurrentRules(fileC); |
|
|
|
|
|
|
|
//刷新一次表格
|
|
|
|
conditionformat.ref(historyRules, currentRules); |
|
|
|
|
|
|
|
//发送给后台
|
|
|
|
if(server.allowUpdate){ |
|
|
|
server.saveParam("all", file.index, ruleArr, { "k": "luckysheet_conditionformat_save" }); |
|
|
|
} |
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
success(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* |
|
|
|
* @param {String} move 删除后,右侧还是下方的单元格移动 |
|
|
@ -2780,8 +3326,11 @@ export function setSheetAdd(options = {}) { |
|
|
|
Store.luckysheetfile.splice(order, 0, sheetconfig); |
|
|
|
} |
|
|
|
|
|
|
|
let orders = {}; |
|
|
|
|
|
|
|
Store.luckysheetfile.forEach((item, i, arr) => { |
|
|
|
arr[i].order = i; |
|
|
|
orders[item.index.toString()] = i; |
|
|
|
}) |
|
|
|
|
|
|
|
$("#luckysheet-sheet-area div.luckysheet-sheets-item").removeClass("luckysheet-sheets-item-active"); |
|
|
@ -2790,6 +3339,7 @@ export function setSheetAdd(options = {}) { |
|
|
|
cleargridelement(true); |
|
|
|
|
|
|
|
server.saveParam("sha", null, $.extend(true, {}, sheetconfig)); |
|
|
|
server.saveParam("shr", null, orders); |
|
|
|
|
|
|
|
if (Store.clearjfundo) { |
|
|
|
Store.jfundo = []; |
|
|
@ -2802,6 +3352,103 @@ export function setSheetAdd(options = {}) { |
|
|
|
} |
|
|
|
|
|
|
|
sheetmanage.changeSheetExec(index, false, true); |
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
success(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 指定工作表向左边或右边移动一个位置,或者指定索引,返回指定的工作表对象 |
|
|
|
* @param {String | Number} type 工作表移动方向或者移动的目标索引 |
|
|
|
* @param {Object} options 可选参数 |
|
|
|
* @param {Number} options.order 工作表索引;默认值为当前工作表索引 |
|
|
|
* @param {Function} options.success 操作结束的回调函数 |
|
|
|
*/ |
|
|
|
export function setSheetMove(type, options = {}) { |
|
|
|
if(type != 'left' && type != 'right' && !isRealNum(type)){ |
|
|
|
return tooltip.info("Type parameter not available", ""); |
|
|
|
} |
|
|
|
|
|
|
|
if(isRealNum(type)){ |
|
|
|
type = parseInt(type); |
|
|
|
} |
|
|
|
|
|
|
|
let curOrder = getSheetIndex(Store.currentSheetIndex); |
|
|
|
let { |
|
|
|
order = curOrder, |
|
|
|
success |
|
|
|
} = {...options} |
|
|
|
|
|
|
|
let file = Store.luckysheetfile[order]; |
|
|
|
|
|
|
|
if(file == null){ |
|
|
|
return tooltip.info("ncorrect worksheet index", ""); |
|
|
|
} |
|
|
|
|
|
|
|
let sheetIndex = file.index; |
|
|
|
|
|
|
|
if(type == 'left'){ |
|
|
|
if(order == 0){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
let prevIndex = Store.luckysheetfile[order - 1].index; |
|
|
|
$("#luckysheet-sheets-item" + sheetIndex).insertBefore($("#luckysheet-sheets-item" + prevIndex)); |
|
|
|
|
|
|
|
Store.luckysheetfile.splice(order, 1); |
|
|
|
Store.luckysheetfile.splice(order - 1, 0, file); |
|
|
|
} |
|
|
|
else if(type == 'right'){ |
|
|
|
if(order == Store.luckysheetfile.length - 1){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
let nextIndex = Store.luckysheetfile[order + 1].index; |
|
|
|
$("#luckysheet-sheets-item" + sheetIndex).insertAfter($("#luckysheet-sheets-item" + nextIndex)); |
|
|
|
|
|
|
|
Store.luckysheetfile.splice(order, 1); |
|
|
|
Store.luckysheetfile.splice(order + 1, 0, file); |
|
|
|
} |
|
|
|
else{ |
|
|
|
if(type < 0){ |
|
|
|
type = 0; |
|
|
|
} |
|
|
|
|
|
|
|
if(type > Store.luckysheetfile.length - 1){ |
|
|
|
type = Store.luckysheetfile.length - 1; |
|
|
|
} |
|
|
|
|
|
|
|
if(type == order){ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if(type < order){ |
|
|
|
let prevIndex = Store.luckysheetfile[type].index; |
|
|
|
$("#luckysheet-sheets-item" + sheetIndex).insertBefore($("#luckysheet-sheets-item" + prevIndex)); |
|
|
|
} |
|
|
|
else{ |
|
|
|
let nextIndex = Store.luckysheetfile[type].index; |
|
|
|
$("#luckysheet-sheets-item" + sheetIndex).insertAfter($("#luckysheet-sheets-item" + nextIndex)); |
|
|
|
} |
|
|
|
|
|
|
|
Store.luckysheetfile.splice(order, 1); |
|
|
|
Store.luckysheetfile.splice(type, 0, file); |
|
|
|
} |
|
|
|
|
|
|
|
let orders = {}; |
|
|
|
|
|
|
|
Store.luckysheetfile.forEach((item, i, arr) => { |
|
|
|
arr[i].order = i; |
|
|
|
orders[item.index.toString()] = i; |
|
|
|
}) |
|
|
|
|
|
|
|
server.saveParam("shr", null, orders); |
|
|
|
|
|
|
|
if (success && typeof success === 'function') { |
|
|
|
success(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|