ocpview-plus 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import numberbox from "./numberbox.vue";
|
|
3
|
+
export default {
|
|
4
|
+
name: "NumberBoxV1",
|
|
5
|
+
extends: numberbox,
|
|
6
|
+
methods: {
|
|
7
|
+
init() {
|
|
8
|
+
// 获取默认属性
|
|
9
|
+
this.myConfig = Object.assign({}, this.globalConfig, this.myConfig);
|
|
10
|
+
|
|
11
|
+
// 获取动态属性
|
|
12
|
+
if (this.config) {
|
|
13
|
+
this.myConfig = Object.assign({}, this.myConfig, this.config);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this.myConfig.place = "unset";
|
|
17
|
+
|
|
18
|
+
if (this.customInit) {
|
|
19
|
+
this.customInit();
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
parser(event) {
|
|
23
|
+
this.label = this.getValueNumber(this.value);
|
|
24
|
+
if (event) {
|
|
25
|
+
const currentTarget = event.currentTarget;
|
|
26
|
+
setTimeout(() => {
|
|
27
|
+
currentTarget.select();
|
|
28
|
+
}, 0);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
// mounted() {
|
|
33
|
+
// // console.log("我继承覆写了");
|
|
34
|
+
// },
|
|
35
|
+
// beforeUnmount() {
|
|
36
|
+
// // console.log("我销毁了");
|
|
37
|
+
// },
|
|
38
|
+
};
|
|
39
|
+
</script>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import NumberBox from
|
|
2
|
-
import NumberRangeBox from
|
|
3
|
-
|
|
1
|
+
import NumberBox from "./numberbox.vue";
|
|
2
|
+
import NumberRangeBox from "./numberrangebox.vue";
|
|
3
|
+
import NumberBoxV1 from "./NumberBoxV1.vue";
|
|
4
|
+
export { NumberBox, NumberRangeBox, NumberBoxV1 };
|
package/src/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from './components/grid';
|
|
20
20
|
import TextBox from './components/textbox';
|
|
21
21
|
import RichTextBox from './components/richtextbox';
|
|
22
|
-
import { NumberBox, NumberRangeBox } from './components/numberbox';
|
|
22
|
+
import { NumberBox, NumberRangeBox,NumberBoxV1 } from './components/numberbox';
|
|
23
23
|
import { DateBox, DateRangeBox } from './components/datebox';
|
|
24
24
|
import TimePicBox from './components/timebox';
|
|
25
25
|
import PopTextBox from './components/poptextbox';
|
|
@@ -171,7 +171,8 @@ const components = {
|
|
|
171
171
|
mBillAsyncImport,
|
|
172
172
|
mBillImport,
|
|
173
173
|
wRichTextBox,
|
|
174
|
-
mBillListDetails
|
|
174
|
+
mBillListDetails,
|
|
175
|
+
NumberBoxV1
|
|
175
176
|
};
|
|
176
177
|
|
|
177
178
|
const iview = {
|
|
@@ -30,93 +30,93 @@ commom.formatDate = function (date, fmt) {
|
|
|
30
30
|
return fmt;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
commom.getToday = function () {
|
|
34
|
-
let to=new Date();
|
|
35
|
-
let M=Number(to.getMonth())+1;
|
|
33
|
+
commom.getToday = function () {
|
|
34
|
+
let to=new Date();
|
|
35
|
+
let M=Number(to.getMonth())+1;
|
|
36
36
|
return to.getFullYear()+ '-'+commom.padLeftZero('00', M+'') + '-'+ commom.padLeftZero('00', to.getDate()+'');
|
|
37
37
|
};
|
|
38
|
-
commom.getTomorrow = function (str) {
|
|
38
|
+
commom.getTomorrow = function (str) {
|
|
39
39
|
let tom;
|
|
40
40
|
if (str) {
|
|
41
41
|
tom = new Date(str);
|
|
42
42
|
} else {
|
|
43
43
|
tom = new Date();
|
|
44
44
|
}
|
|
45
|
-
tom.setDate(tom.getDate()+1);
|
|
46
|
-
let M=Number(tom.getMonth())+1;
|
|
45
|
+
tom.setDate(tom.getDate()+1);
|
|
46
|
+
let M=Number(tom.getMonth())+1;
|
|
47
47
|
return tom.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', tom.getDate()+'');
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
commom.getWeekFirstDay = function () {
|
|
51
|
-
let Nowdate=new Date();
|
|
52
|
-
let WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
|
|
53
|
-
let M=Number(WeekFirstDay.getMonth())+1;
|
|
54
|
-
return WeekFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', WeekFirstDay.getDate()+'');
|
|
50
|
+
commom.getWeekFirstDay = function () {
|
|
51
|
+
let Nowdate=new Date();
|
|
52
|
+
let WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
|
|
53
|
+
let M=Number(WeekFirstDay.getMonth())+1;
|
|
54
|
+
return WeekFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', WeekFirstDay.getDate()+'');
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
commom.getWeekLastDay = function () {
|
|
58
|
-
let Nowdate=new Date();
|
|
59
|
-
let WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
|
|
60
|
-
let WeekLastDay=new Date((WeekFirstDay/1000+6*86400)*1000);
|
|
61
|
-
let M=Number(WeekLastDay.getMonth())+1;
|
|
62
|
-
return WeekLastDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', WeekLastDay.getDate()+'');
|
|
57
|
+
commom.getWeekLastDay = function () {
|
|
58
|
+
let Nowdate=new Date();
|
|
59
|
+
let WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
|
|
60
|
+
let WeekLastDay=new Date((WeekFirstDay/1000+6*86400)*1000);
|
|
61
|
+
let M=Number(WeekLastDay.getMonth())+1;
|
|
62
|
+
return WeekLastDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', WeekLastDay.getDate()+'');
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
commom.getMonthFirstDay = function () {
|
|
66
|
-
let Nowdate=new Date();
|
|
67
|
-
let MonthFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth(),1);
|
|
68
|
-
let M=Number(MonthFirstDay.getMonth())+1;
|
|
69
|
-
return MonthFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthFirstDay.getDate()+'');
|
|
65
|
+
commom.getMonthFirstDay = function () {
|
|
66
|
+
let Nowdate=new Date();
|
|
67
|
+
let MonthFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth(),1);
|
|
68
|
+
let M=Number(MonthFirstDay.getMonth())+1;
|
|
69
|
+
return MonthFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthFirstDay.getDate()+'');
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
commom.getMonthLastDay = function (str) {
|
|
72
|
+
commom.getMonthLastDay = function (str) {
|
|
73
73
|
let Nowdate;
|
|
74
74
|
if (str) {
|
|
75
|
-
Nowdate = new Date(str);
|
|
75
|
+
Nowdate = new Date(str);
|
|
76
76
|
} else {
|
|
77
|
-
Nowdate = new Date();
|
|
77
|
+
Nowdate = new Date();
|
|
78
78
|
}
|
|
79
|
-
let MonthNextFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth()+1,1);
|
|
80
|
-
let MonthLastDay=new Date(MonthNextFirstDay-86400000);
|
|
81
|
-
let M=Number(MonthLastDay.getMonth())+1;
|
|
82
|
-
return MonthLastDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthLastDay.getDate()+'');
|
|
79
|
+
let MonthNextFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth()+1,1);
|
|
80
|
+
let MonthLastDay=new Date(MonthNextFirstDay-86400000);
|
|
81
|
+
let M=Number(MonthLastDay.getMonth())+1;
|
|
82
|
+
return MonthLastDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthLastDay.getDate()+'');
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
commom.getNextMonthFirstDay = function (str) {
|
|
86
86
|
let Nowdate;
|
|
87
87
|
if (str) {
|
|
88
|
-
Nowdate = new Date(str);
|
|
88
|
+
Nowdate = new Date(str);
|
|
89
89
|
} else {
|
|
90
|
-
Nowdate = new Date();
|
|
90
|
+
Nowdate = new Date();
|
|
91
91
|
}
|
|
92
|
-
let MonthNextFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth()+1,1);
|
|
93
|
-
let M=Number(MonthNextFirstDay.getMonth())+1;
|
|
94
|
-
return MonthNextFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthNextFirstDay.getDate()+'');
|
|
92
|
+
let MonthNextFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth()+1,1);
|
|
93
|
+
let M=Number(MonthNextFirstDay.getMonth())+1;
|
|
94
|
+
return MonthNextFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthNextFirstDay.getDate()+'');
|
|
95
95
|
};
|
|
96
96
|
|
|
97
97
|
commom.getPreMonthFirstDay = function (str) {
|
|
98
98
|
let Nowdate;
|
|
99
99
|
if (str) {
|
|
100
|
-
Nowdate = new Date(str);
|
|
100
|
+
Nowdate = new Date(str);
|
|
101
101
|
} else {
|
|
102
|
-
Nowdate = new Date();
|
|
102
|
+
Nowdate = new Date();
|
|
103
103
|
}
|
|
104
|
-
let MonthPreFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth()-1,1);
|
|
105
|
-
let M=Number(MonthPreFirstDay.getMonth())+1;
|
|
106
|
-
return MonthPreFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthPreFirstDay.getDate()+'');
|
|
104
|
+
let MonthPreFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth()-1,1);
|
|
105
|
+
let M=Number(MonthPreFirstDay.getMonth())+1;
|
|
106
|
+
return MonthPreFirstDay.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', MonthPreFirstDay.getDate()+'');
|
|
107
107
|
};
|
|
108
|
-
commom.getYearFirstDay = function () {
|
|
109
|
-
let Nowdate=new Date();
|
|
110
|
-
return Nowdate.getFullYear()+'-01-01';
|
|
108
|
+
commom.getYearFirstDay = function () {
|
|
109
|
+
let Nowdate=new Date();
|
|
110
|
+
return Nowdate.getFullYear()+'-01-01';
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
commom.getYearLastDay = function () {
|
|
114
|
-
let Nowdate=new Date();
|
|
115
|
-
return Nowdate.getFullYear()+'-12-31';
|
|
113
|
+
commom.getYearLastDay = function () {
|
|
114
|
+
let Nowdate=new Date();
|
|
115
|
+
return Nowdate.getFullYear()+'-12-31';
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
commom.getWeek = function (str) {
|
|
119
|
-
let Nowdate=new Date(str);
|
|
119
|
+
let Nowdate=new Date(str);
|
|
120
120
|
return Nowdate.getDay();
|
|
121
121
|
};
|
|
122
122
|
|
|
@@ -139,7 +139,7 @@ commom.getUrlParam = function (name) {
|
|
|
139
139
|
if (!r) {
|
|
140
140
|
if (list.length > 2) {
|
|
141
141
|
r = list[2].match(reg); // 匹配目标参数
|
|
142
|
-
}
|
|
142
|
+
}
|
|
143
143
|
}
|
|
144
144
|
if (r) return decodeURI(r[2]); return ''; // 返回参数值
|
|
145
145
|
};
|
|
@@ -228,7 +228,7 @@ function randomHsl () {
|
|
|
228
228
|
let L = Math.random();
|
|
229
229
|
return [H, S, L];
|
|
230
230
|
}
|
|
231
|
-
|
|
231
|
+
|
|
232
232
|
function hslToRgb (hsl) {
|
|
233
233
|
for (let i = 0; i < hsl.length; i++) {
|
|
234
234
|
let H = hsl[i][0];
|
|
@@ -278,7 +278,7 @@ function getHslArray (hslLength) {
|
|
|
278
278
|
let HSL = [];
|
|
279
279
|
for (let i = 0; i < hslLength; i++) {
|
|
280
280
|
let ret = randomHsl();
|
|
281
|
-
|
|
281
|
+
|
|
282
282
|
// 颜色相邻颜色差异须大于 0.25
|
|
283
283
|
if (i > 0 && Math.abs(ret[0] - HSL[i - 1][0]) < 0.25) {
|
|
284
284
|
i--;
|
|
@@ -286,7 +286,7 @@ function getHslArray (hslLength) {
|
|
|
286
286
|
}
|
|
287
287
|
ret[1] = 0.7 + (ret[1] * 0.2); // [0.7 - 0.9] 排除过灰颜色
|
|
288
288
|
ret[2] = 0.4 + (ret[2] * 0.4); // [0.4 - 0.8] 排除过亮过暗色
|
|
289
|
-
|
|
289
|
+
|
|
290
290
|
// 数据转化到小数点后两位
|
|
291
291
|
ret = ret.map(function (item) {
|
|
292
292
|
return parseFloat(item.toFixed(2));
|
|
@@ -296,7 +296,7 @@ function getHslArray (hslLength) {
|
|
|
296
296
|
hslToRgb(HSL);
|
|
297
297
|
return colorHex(HSL);
|
|
298
298
|
}
|
|
299
|
-
|
|
299
|
+
|
|
300
300
|
commom.getColorList = function (old, size) {
|
|
301
301
|
let num = Number(size) - old.length;
|
|
302
302
|
if (num === 0) {
|
|
@@ -327,7 +327,7 @@ commom.getColor = function () {
|
|
|
327
327
|
let newcolor = getHslArray(1);
|
|
328
328
|
return newcolor[0];
|
|
329
329
|
};
|
|
330
|
-
|
|
330
|
+
|
|
331
331
|
commom.getGlobalColor = function (n,isRandom,pro,that) {
|
|
332
332
|
let newColor = [];
|
|
333
333
|
if (n > 0) {
|
|
@@ -388,7 +388,7 @@ commom.mmToYpixe = function(value,ydpi) {
|
|
|
388
388
|
let tmp = ydpi;
|
|
389
389
|
if (!tmp) {
|
|
390
390
|
tmp = commom.getYDpi();;
|
|
391
|
-
}
|
|
391
|
+
}
|
|
392
392
|
let y = (value / 25.4) * tmp;
|
|
393
393
|
return Number(y.toFixed(2));
|
|
394
394
|
},
|
|
@@ -396,7 +396,7 @@ commom.mmToXpixe = function(value,xdpi) {
|
|
|
396
396
|
let tmp = xdpi;
|
|
397
397
|
if (!tmp) {
|
|
398
398
|
tmp = commom.getXDpi();;
|
|
399
|
-
}
|
|
399
|
+
}
|
|
400
400
|
let x = (value / 25.4) * tmp;
|
|
401
401
|
return Number(x.toFixed(2));
|
|
402
402
|
},
|
|
@@ -404,7 +404,7 @@ commom.xPixelToMm = function(value,xdpi) {
|
|
|
404
404
|
let tmp = xdpi;
|
|
405
405
|
if (!tmp) {
|
|
406
406
|
tmp = commom.getXDpi();;
|
|
407
|
-
}
|
|
407
|
+
}
|
|
408
408
|
let xmm = (value / tmp) * 25.4;
|
|
409
409
|
return Number(xmm.toFixed(2));
|
|
410
410
|
},
|
|
@@ -412,7 +412,7 @@ commom.yPixelToMm = function(value,ydpi) {
|
|
|
412
412
|
let tmp = ydpi;
|
|
413
413
|
if (!tmp) {
|
|
414
414
|
tmp = commom.getYDpi();;
|
|
415
|
-
}
|
|
415
|
+
}
|
|
416
416
|
let ymm = (value / tmp) * 25.4;
|
|
417
417
|
return Number(ymm.toFixed(2));
|
|
418
418
|
},
|
|
@@ -420,7 +420,7 @@ commom.yPixelToMm = function(value,ydpi) {
|
|
|
420
420
|
commom.unique = function (arr) {
|
|
421
421
|
//定义常量 res,值为一个Map对象实例
|
|
422
422
|
const res = new Map();
|
|
423
|
-
|
|
423
|
+
|
|
424
424
|
//返回arr数组过滤后的结果,结果为一个数组
|
|
425
425
|
//过滤条件是,如果res中没有某个键,就设置这个键的值为1
|
|
426
426
|
return arr.filter((a) => !res.has(a) && res.set(a, 1));
|
|
@@ -454,7 +454,7 @@ commom.formatComboBox= function (value, config) {
|
|
|
454
454
|
} else {
|
|
455
455
|
result = '['+ value +']' + config.data[index][textField];
|
|
456
456
|
}
|
|
457
|
-
}
|
|
457
|
+
}
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
config.renderValue[value] = result;
|
|
@@ -481,9 +481,9 @@ commom.formatDataBox = function (value,config) {
|
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
if (typeof value === 'string' || typeof value === 'number') {
|
|
484
|
-
return commom.formatDate(new Date(value),config.renderFormat);
|
|
484
|
+
return commom.formatDate(new Date(value),config.renderFormat);
|
|
485
485
|
} else if (value.constructor === Date){
|
|
486
|
-
return commom.formatDate(value,config.renderFormat);
|
|
486
|
+
return commom.formatDate(value,config.renderFormat);
|
|
487
487
|
} else {
|
|
488
488
|
return value;
|
|
489
489
|
}
|
|
@@ -494,7 +494,7 @@ commom.formatValue= function (value,row,config) {
|
|
|
494
494
|
let type = config.type.toLowerCase();
|
|
495
495
|
if (type === 'textbox') {
|
|
496
496
|
return value;
|
|
497
|
-
} else if (type === 'numberbox') {
|
|
497
|
+
} else if (type === 'numberbox'|| type === 'numberboxv1') {
|
|
498
498
|
if (!value) {
|
|
499
499
|
if (value === config.defaultValue) {
|
|
500
500
|
return value;
|
|
@@ -502,9 +502,9 @@ commom.formatValue= function (value,row,config) {
|
|
|
502
502
|
}
|
|
503
503
|
return commom.formatNumber(value,config.format,config.notzero);
|
|
504
504
|
} else if (type === 'combobox') {
|
|
505
|
-
return commom.formatComboBox(value,config);
|
|
505
|
+
return commom.formatComboBox(value,config);
|
|
506
506
|
} else if (type === 'datebox') {
|
|
507
|
-
return commom.formatDataBox(value,config);
|
|
507
|
+
return commom.formatDataBox(value,config);
|
|
508
508
|
} else {
|
|
509
509
|
if (config.textName) {
|
|
510
510
|
if (row[config.textName]) {
|
|
@@ -518,12 +518,12 @@ commom.formatValue= function (value,row,config) {
|
|
|
518
518
|
} else {
|
|
519
519
|
return value;
|
|
520
520
|
}
|
|
521
|
-
|
|
521
|
+
|
|
522
522
|
} else {
|
|
523
523
|
return value;
|
|
524
524
|
}
|
|
525
525
|
};
|
|
526
|
-
|
|
526
|
+
|
|
527
527
|
commom.getDefaultFieldStyle = function (column,dictData,dictConfig) {
|
|
528
528
|
let tempStyle = '';
|
|
529
529
|
if (column.type === 'DateBox') {
|
|
@@ -541,7 +541,7 @@ commom.getDefaultFieldStyle = function (column,dictData,dictConfig) {
|
|
|
541
541
|
format = 'yyyy-MM-dd';
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
-
tempStyle = tempStyle +'d' + '=' + format + '=center';
|
|
544
|
+
tempStyle = tempStyle +'d' + '=' + format + '=center';
|
|
545
545
|
}
|
|
546
546
|
if (column.type === 'NumberBox') {
|
|
547
547
|
let format ='';
|
|
@@ -660,17 +660,17 @@ commom.getGridField = function(columns, separator, dictData, dictConfig) {
|
|
|
660
660
|
if (fields.length > 0) {
|
|
661
661
|
fields = fields.substring(0, fields.length - 1);
|
|
662
662
|
}
|
|
663
|
-
|
|
663
|
+
|
|
664
664
|
return fields;
|
|
665
665
|
};
|
|
666
666
|
commom.print = function(object,printCss) {
|
|
667
667
|
let printStr = '<html><head>' + document.head.innerHTML +'</head>';
|
|
668
668
|
if (object) {
|
|
669
|
-
printStr = printStr + '<body>' + object.$el.innerHTML +'</body></html>';
|
|
669
|
+
printStr = printStr + '<body>' + object.$el.innerHTML +'</body></html>';
|
|
670
670
|
} else {
|
|
671
|
-
printStr = printStr + '<body>' + document.body.innerHTML +'</body></html>';
|
|
671
|
+
printStr = printStr + '<body>' + document.body.innerHTML +'</body></html>';
|
|
672
672
|
}
|
|
673
|
-
|
|
673
|
+
|
|
674
674
|
// 如果是本地测试,需要先新建Print.htm 如果是在域中使用,则不需要
|
|
675
675
|
let pwin = window.open('Print.htm', 'print');
|
|
676
676
|
pwin.document.write(printStr);
|
|
@@ -679,7 +679,7 @@ commom.print = function(object,printCss) {
|
|
|
679
679
|
styles.setAttribute('type','text/css');//media="print"
|
|
680
680
|
styles.innerHTML = printCss;
|
|
681
681
|
pwin.document.getElementsByTagName('head')[0].appendChild(styles);
|
|
682
|
-
}
|
|
682
|
+
}
|
|
683
683
|
pwin.document.close(); // 这句很重要,没有就无法实现
|
|
684
684
|
pwin.print();
|
|
685
685
|
pwin.close();
|
|
@@ -723,89 +723,89 @@ commom.getTextWidth = function(text) {
|
|
|
723
723
|
return resultWidth;
|
|
724
724
|
};
|
|
725
725
|
|
|
726
|
-
commom.changeMoneyToChinese = function(money) {
|
|
727
|
-
let cnNums = new Array('零','壹','贰','叁','肆','伍','陆','柒','捌','玖'); //汉字的数字
|
|
728
|
-
let cnIntRadice = new Array('','拾','佰','仟'); //基本单位
|
|
729
|
-
let cnIntUnits = new Array('','万','亿','兆'); //对应整数部分扩展单位
|
|
730
|
-
let cnDecUnits = new Array('角','分','毫','厘'); //对应小数部分单位
|
|
731
|
-
//let cnInteger = "整"; //整数金额时后面跟的字符
|
|
732
|
-
let cnIntLast = '元'; //整型完以后的单位
|
|
726
|
+
commom.changeMoneyToChinese = function(money) {
|
|
727
|
+
let cnNums = new Array('零','壹','贰','叁','肆','伍','陆','柒','捌','玖'); //汉字的数字
|
|
728
|
+
let cnIntRadice = new Array('','拾','佰','仟'); //基本单位
|
|
729
|
+
let cnIntUnits = new Array('','万','亿','兆'); //对应整数部分扩展单位
|
|
730
|
+
let cnDecUnits = new Array('角','分','毫','厘'); //对应小数部分单位
|
|
731
|
+
//let cnInteger = "整"; //整数金额时后面跟的字符
|
|
732
|
+
let cnIntLast = '元'; //整型完以后的单位
|
|
733
733
|
let cnIntLast_F = '负';
|
|
734
|
-
let maxNum = 999999999999999.9999; //最大处理的数字
|
|
735
|
-
|
|
736
|
-
let IntegerNum; //金额整数部分
|
|
737
|
-
let DecimalNum; //金额小数部分
|
|
738
|
-
let ChineseStr=''; //输出的中文金额字符串
|
|
739
|
-
let parts; //分离金额后用的数组,预定义
|
|
740
|
-
if(money == ''){
|
|
741
|
-
return '';
|
|
742
|
-
}
|
|
743
|
-
money = parseFloat(money);
|
|
744
|
-
if(money >= maxNum){
|
|
745
|
-
this.alert('超出最大处理数字');
|
|
746
|
-
return '';
|
|
747
|
-
}
|
|
748
|
-
if(money == 0){
|
|
749
|
-
//ChineseStr = cnNums[0]+cnIntLast+cnInteger;
|
|
750
|
-
ChineseStr = cnNums[0]+cnIntLast;
|
|
751
|
-
//document.getElementById("show").value=ChineseStr;
|
|
752
|
-
return ChineseStr;
|
|
753
|
-
}
|
|
734
|
+
let maxNum = 999999999999999.9999; //最大处理的数字
|
|
735
|
+
|
|
736
|
+
let IntegerNum; //金额整数部分
|
|
737
|
+
let DecimalNum; //金额小数部分
|
|
738
|
+
let ChineseStr=''; //输出的中文金额字符串
|
|
739
|
+
let parts; //分离金额后用的数组,预定义
|
|
740
|
+
if(money == ''){
|
|
741
|
+
return '';
|
|
742
|
+
}
|
|
743
|
+
money = parseFloat(money);
|
|
744
|
+
if(money >= maxNum){
|
|
745
|
+
this.alert('超出最大处理数字');
|
|
746
|
+
return '';
|
|
747
|
+
}
|
|
748
|
+
if(money == 0){
|
|
749
|
+
//ChineseStr = cnNums[0]+cnIntLast+cnInteger;
|
|
750
|
+
ChineseStr = cnNums[0]+cnIntLast;
|
|
751
|
+
//document.getElementById("show").value=ChineseStr;
|
|
752
|
+
return ChineseStr;
|
|
753
|
+
}
|
|
754
754
|
//提供对负数的支持
|
|
755
|
-
if(money < 0){
|
|
755
|
+
if(money < 0){
|
|
756
756
|
ChineseStr = cnIntLast_F;
|
|
757
757
|
money = money*-1;
|
|
758
758
|
}
|
|
759
|
-
money = money.toString(); //转换为字符串
|
|
760
|
-
if(money.indexOf('.') === -1){
|
|
761
|
-
IntegerNum = money;
|
|
762
|
-
DecimalNum = '';
|
|
763
|
-
}else{
|
|
764
|
-
parts = money.split('.');
|
|
765
|
-
IntegerNum = parts[0];
|
|
766
|
-
DecimalNum = parts[1].substr(0,4);
|
|
767
|
-
}
|
|
768
|
-
if(parseInt(IntegerNum,10) > 0){//获取整型部分转换
|
|
769
|
-
let zeroCount = 0;
|
|
770
|
-
let IntLen = IntegerNum.length;
|
|
771
|
-
for(let i=0;i<IntLen;i++ ){
|
|
772
|
-
let n = IntegerNum.substr(i,1);
|
|
773
|
-
let p = IntLen - i - 1;
|
|
774
|
-
let q = p / 4;
|
|
775
|
-
let m = p % 4;
|
|
776
|
-
if( n == '0' ){
|
|
777
|
-
zeroCount++;
|
|
778
|
-
}else{
|
|
779
|
-
if( zeroCount > 0 ){
|
|
780
|
-
ChineseStr += cnNums[0];
|
|
781
|
-
}
|
|
782
|
-
zeroCount = 0; //归零
|
|
783
|
-
ChineseStr += cnNums[parseInt(n)]+cnIntRadice[m];
|
|
784
|
-
}
|
|
785
|
-
if( m==0 && zeroCount<4 ){
|
|
786
|
-
ChineseStr += cnIntUnits[q];
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
ChineseStr += cnIntLast;
|
|
790
|
-
//整型部分处理完毕
|
|
791
|
-
}
|
|
792
|
-
if(DecimalNum !== ''){//小数部分
|
|
793
|
-
let decLen = DecimalNum.length;
|
|
794
|
-
for(let i=0; i<decLen; i++){
|
|
795
|
-
let n = DecimalNum.substr(i,1);
|
|
796
|
-
if( n != '0' ){
|
|
797
|
-
ChineseStr += cnNums[Number(n)]+cnDecUnits[i];
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
if(ChineseStr === ''){
|
|
802
|
-
//ChineseStr += cnNums[0]+cnIntLast+cnInteger;
|
|
803
|
-
ChineseStr += cnNums[0]+cnIntLast;
|
|
804
|
-
}/* else if( DecimalNum == '' ){
|
|
805
|
-
ChineseStr += cnInteger;
|
|
806
|
-
ChineseStr += cnInteger;
|
|
807
|
-
} */
|
|
808
|
-
return ChineseStr;
|
|
759
|
+
money = money.toString(); //转换为字符串
|
|
760
|
+
if(money.indexOf('.') === -1){
|
|
761
|
+
IntegerNum = money;
|
|
762
|
+
DecimalNum = '';
|
|
763
|
+
}else{
|
|
764
|
+
parts = money.split('.');
|
|
765
|
+
IntegerNum = parts[0];
|
|
766
|
+
DecimalNum = parts[1].substr(0,4);
|
|
767
|
+
}
|
|
768
|
+
if(parseInt(IntegerNum,10) > 0){//获取整型部分转换
|
|
769
|
+
let zeroCount = 0;
|
|
770
|
+
let IntLen = IntegerNum.length;
|
|
771
|
+
for(let i=0;i<IntLen;i++ ){
|
|
772
|
+
let n = IntegerNum.substr(i,1);
|
|
773
|
+
let p = IntLen - i - 1;
|
|
774
|
+
let q = p / 4;
|
|
775
|
+
let m = p % 4;
|
|
776
|
+
if( n == '0' ){
|
|
777
|
+
zeroCount++;
|
|
778
|
+
}else{
|
|
779
|
+
if( zeroCount > 0 ){
|
|
780
|
+
ChineseStr += cnNums[0];
|
|
781
|
+
}
|
|
782
|
+
zeroCount = 0; //归零
|
|
783
|
+
ChineseStr += cnNums[parseInt(n)]+cnIntRadice[m];
|
|
784
|
+
}
|
|
785
|
+
if( m==0 && zeroCount<4 ){
|
|
786
|
+
ChineseStr += cnIntUnits[q];
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
ChineseStr += cnIntLast;
|
|
790
|
+
//整型部分处理完毕
|
|
791
|
+
}
|
|
792
|
+
if(DecimalNum !== ''){//小数部分
|
|
793
|
+
let decLen = DecimalNum.length;
|
|
794
|
+
for(let i=0; i<decLen; i++){
|
|
795
|
+
let n = DecimalNum.substr(i,1);
|
|
796
|
+
if( n != '0' ){
|
|
797
|
+
ChineseStr += cnNums[Number(n)]+cnDecUnits[i];
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
if(ChineseStr === ''){
|
|
802
|
+
//ChineseStr += cnNums[0]+cnIntLast+cnInteger;
|
|
803
|
+
ChineseStr += cnNums[0]+cnIntLast;
|
|
804
|
+
}/* else if( DecimalNum == '' ){
|
|
805
|
+
ChineseStr += cnInteger;
|
|
806
|
+
ChineseStr += cnInteger;
|
|
807
|
+
} */
|
|
808
|
+
return ChineseStr;
|
|
809
809
|
},
|
|
810
810
|
|
|
811
811
|
commom.exportExcel = exportExcel;
|