|
@@ -5,89 +5,86 @@
|
|
|
|
|
|
|
|
// 忽略大小写判断字符串是否和参数指定的字符串相同
|
|
// 忽略大小写判断字符串是否和参数指定的字符串相同
|
|
|
String.prototype.sameText = function (str) {
|
|
String.prototype.sameText = function (str) {
|
|
|
- return this.toLowerCase() == str.toLowerCase();
|
|
|
|
|
|
|
+ return this.toLowerCase() == str.toLowerCase();
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 忽略大小写判断字符串是否有参数指定的子串
|
|
// 忽略大小写判断字符串是否有参数指定的子串
|
|
|
String.prototype.hasSubStr = function (str) {
|
|
String.prototype.hasSubStr = function (str) {
|
|
|
- return this.toLowerCase().indexOf(str.toLowerCase()) > -1;
|
|
|
|
|
|
|
+ return this.toLowerCase().indexOf(str.toLowerCase()) > -1;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 判断字符串是否是数字形式的字符串
|
|
// 判断字符串是否是数字形式的字符串
|
|
|
String.prototype.isNumberStr = function () {
|
|
String.prototype.isNumberStr = function () {
|
|
|
- return this == +this;
|
|
|
|
|
|
|
+ return this == +this;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// 树结点计算时,取费会出现值为NaN的情况,导致往父节点汇总(递归相加)会出现错误。
|
|
// 树结点计算时,取费会出现值为NaN的情况,导致往父节点汇总(递归相加)会出现错误。
|
|
|
-function parseFloatPlus(value){
|
|
|
|
|
- let rst = parseFloat(value);
|
|
|
|
|
- return isNaN(rst) ? 0 : rst;
|
|
|
|
|
-};
|
|
|
|
|
|
|
+function parseFloatPlus(value) {
|
|
|
|
|
+ let rst = parseFloat(value);
|
|
|
|
|
+ return isNaN(rst) ? 0 : rst;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
// 数组合并,并去重复。
|
|
// 数组合并,并去重复。
|
|
|
Array.prototype.merge = function (arr) {
|
|
Array.prototype.merge = function (arr) {
|
|
|
- if (arr.length > 0){
|
|
|
|
|
- for (let e of arr){
|
|
|
|
|
- if (!this.includes(e)) this.push(e);
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ if (arr.length > 0) {
|
|
|
|
|
+ for (let e of arr) {
|
|
|
|
|
+ if (!this.includes(e)) this.push(e);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-// 数组是否包含另一个数组。
|
|
|
|
|
-Array.prototype.hasSubArr = function (subArr){
|
|
|
|
|
- for(var i = 0, len = subArr.length; i < len; i++){
|
|
|
|
|
- if(this.indexOf(subArr[i]) == -1) return false;
|
|
|
|
|
|
|
+function mergeArr(arr1, arr2) { //
|
|
|
|
|
+ if (arr2.length > 0) {
|
|
|
|
|
+ for (let e of arr2) {
|
|
|
|
|
+ if (arr1.includes(e)) arr1.push(e);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-Array.prototype.delete = function (elem){
|
|
|
|
|
- let idx = this.findIndex(function (e){return e == elem});
|
|
|
|
|
- if (idx != -1) this.splice(idx, 1);
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-function seqString(num,length){
|
|
|
|
|
- var numstr = num.toString();
|
|
|
|
|
- var l=numstr.length;
|
|
|
|
|
- if (numstr.length>=length) {return numstr;}
|
|
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- for(var i = 0 ;i<length - l;i++){
|
|
|
|
|
- numstr = "0" + numstr;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+function seqString(num, length) {
|
|
|
|
|
+ var numstr = num.toString();
|
|
|
|
|
+ var l = numstr.length;
|
|
|
|
|
+ if (numstr.length >= length) {
|
|
|
return numstr;
|
|
return numstr;
|
|
|
-};
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (var i = 0; i < length - l; i++) {
|
|
|
|
|
+ numstr = "0" + numstr;
|
|
|
|
|
+ }
|
|
|
|
|
+ return numstr;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
function customRowHeader(sheet, dataLength) {
|
|
function customRowHeader(sheet, dataLength) {
|
|
|
- sheet.suspendPaint(); //提升焦点变换性能 2019年4月15日
|
|
|
|
|
- for (let i = 0; i < dataLength; i++) {
|
|
|
|
|
- sheet.setValue(i, 0, `F${i + 1}`, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
|
|
- }
|
|
|
|
|
- sheet.resumePaint(); //提升焦点变换性能 2019年4月12日
|
|
|
|
|
-};
|
|
|
|
|
|
|
+ sheet.suspendPaint(); //提升焦点变换性能 2019年4月15日
|
|
|
|
|
+ for (let i = 0; i < dataLength; i++) {
|
|
|
|
|
+ sheet.setValue(i, 0, `F${i + 1}`, GC.Spread.Sheets.SheetArea.rowHeader);
|
|
|
|
|
+ }
|
|
|
|
|
+ sheet.resumePaint(); //提升焦点变换性能 2019年4月12日
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
function changePropNames(object, oldNames, newNames) {
|
|
function changePropNames(object, oldNames, newNames) {
|
|
|
- if (!object) return;
|
|
|
|
|
- for (let i = 0; i < oldNames.length; i++) {
|
|
|
|
|
- if (object[oldNames[i]]){
|
|
|
|
|
- object[newNames[i]] = object[oldNames[i]];
|
|
|
|
|
- delete object[oldNames[i]];
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ if (!object) return;
|
|
|
|
|
+ for (let i = 0; i < oldNames.length; i++) {
|
|
|
|
|
+ if (object[oldNames[i]]) {
|
|
|
|
|
+ object[newNames[i]] = object[oldNames[i]];
|
|
|
|
|
+ delete object[oldNames[i]];
|
|
|
}
|
|
}
|
|
|
-};
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
function changePropNames(object, oldNames, newNames) {
|
|
function changePropNames(object, oldNames, newNames) {
|
|
|
- if (!object) return;
|
|
|
|
|
- for (let i = 0; i < oldNames.length; i++) {
|
|
|
|
|
- if (object[oldNames[i]]){
|
|
|
|
|
- object[newNames[i]] = object[oldNames[i]];
|
|
|
|
|
- delete object[oldNames[i]];
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ if (!object) return;
|
|
|
|
|
+ for (let i = 0; i < oldNames.length; i++) {
|
|
|
|
|
+ if (object[oldNames[i]]) {
|
|
|
|
|
+ object[newNames[i]] = object[oldNames[i]];
|
|
|
|
|
+ delete object[oldNames[i]];
|
|
|
}
|
|
}
|
|
|
-};
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
function deletePropNames(object, namesArr) {
|
|
function deletePropNames(object, namesArr) {
|
|
|
- if (!object) return;
|
|
|
|
|
- for (let name of namesArr){
|
|
|
|
|
- if (object[name]) delete object[name];
|
|
|
|
|
- };
|
|
|
|
|
-};
|
|
|
|
|
|
|
+ if (!object) return;
|
|
|
|
|
+ for (let name of namesArr) {
|
|
|
|
|
+ if (object[name]) delete object[name];
|
|
|
|
|
+ }
|
|
|
|
|
+}
|