| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- /**
- * Created by CSL on 2017-06-06.
- * public functions for web.
- */
- // 忽略大小写判断字符串是否和参数指定的字符串相同
- String.prototype.sameText = function (str) {
- return this.toLowerCase() == str.toLowerCase();
- };
- // 忽略大小写判断字符串是否有参数指定的子串
- String.prototype.hasSubStr = function (str) {
- return this.toLowerCase().indexOf(str.toLowerCase()) > -1;
- };
- // 判断字符串是否是数字形式的字符串
- String.prototype.isNumberStr = function () {
- return this == +this;
- };
- // 树结点计算时,取费会出现值为NaN的情况,导致往父节点汇总(递归相加)会出现错误。
- function parseFloatPlus(value) {
- let rst = parseFloat(value);
- return isNaN(rst) ? 0 : rst;
- }
- 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;
- }
- return numstr;
- }
- 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日
- }
- 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]];
- }
- }
- }
- 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]];
- }
- }
- }
- function deletePropNames(object, namesArr) {
- if (!object) return;
- for (let name of namesArr) {
- if (object[name]) delete object[name];
- }
- }
|