ocpview-plus 0.0.1
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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/efviewplus.min.esm.js +99954 -0
- package/dist/efviewplus.min.js +142 -0
- package/dist/locale/lang.js +1 -0
- package/dist/locale/zh-CN.js +1 -0
- package/dist/locale/zh-TW.js +1 -0
- package/dist/locale/zh-UG.js +1 -0
- package/dist/style.css +9 -0
- package/dist/styles/efviewplus.css +1 -0
- package/package.json +144 -0
- package/src/components/base/controlbase.vue +191 -0
- package/src/components/base/controlbox.vue +102 -0
- package/src/components/base/index.js +3 -0
- package/src/components/base/load.js +20 -0
- package/src/components/base/probase.js +220 -0
- package/src/components/base/size.js +78 -0
- package/src/components/billbox/billbox.vue +68 -0
- package/src/components/billbox/index.js +2 -0
- package/src/components/cascaderbox/cascaderbox.vue +184 -0
- package/src/components/cascaderbox/index.js +2 -0
- package/src/components/checkbox/checkbox.vue +76 -0
- package/src/components/checkbox/checkgroupbox.vue +104 -0
- package/src/components/checkbox/index.js +3 -0
- package/src/components/colorbox/colorbox.vue +44 -0
- package/src/components/colorbox/index.js +2 -0
- package/src/components/combobox/combobox.vue +220 -0
- package/src/components/combobox/index.js +2 -0
- package/src/components/conditionbox/conditionbase.vue +195 -0
- package/src/components/conditionbox/conditionbox.vue +63 -0
- package/src/components/conditionbox/conditionfilterbox.vue +477 -0
- package/src/components/conditionbox/conditionselectorbox.vue +237 -0
- package/src/components/conditionbox/index.js +5 -0
- package/src/components/conditionbox/queryconditionbox.vue +26 -0
- package/src/components/conditionbox/queryconditionboxbase.vue +124 -0
- package/src/components/conditionbox/searchconditionbox.vue +114 -0
- package/src/components/conditionbox/searchgrid.vue +391 -0
- package/src/components/datebox/datebox.vue +129 -0
- package/src/components/datebox/daterangebox.vue +155 -0
- package/src/components/datebox/index.js +3 -0
- package/src/components/form/baseform.vue +677 -0
- package/src/components/form/detailsbox.vue +487 -0
- package/src/components/form/formbox.vue +29 -0
- package/src/components/form/formcardbox.vue +268 -0
- package/src/components/form/formcardgroupbox.vue +252 -0
- package/src/components/form/formcompro.js +19 -0
- package/src/components/form/formdetail.vue +129 -0
- package/src/components/form/formdetailtwo.vue +302 -0
- package/src/components/form/index.js +8 -0
- package/src/components/form/toolanchor.js +46 -0
- package/src/components/form/workform.vue +168 -0
- package/src/components/grid/basegrid.vue +1061 -0
- package/src/components/grid/editgrid.vue +51 -0
- package/src/components/grid/editgridbase.vue +947 -0
- package/src/components/grid/editgridcard.vue +193 -0
- package/src/components/grid/expandrow.vue +137 -0
- package/src/components/grid/index.js +6 -0
- package/src/components/grid/viewgrid.vue +122 -0
- package/src/components/grid/viewgridbase.vue +1284 -0
- package/src/components/icon/common-icon.vue +53 -0
- package/src/components/icon/eicon.vue +29 -0
- package/src/components/icon/icons.vue +42 -0
- package/src/components/icon/index.js +2 -0
- package/src/components/label/index.js +3 -0
- package/src/components/label/showtext.vue +95 -0
- package/src/components/load/loadcartoon.vue +228 -0
- package/src/components/map/index.js +2 -0
- package/src/components/map/mapbox.vue +348 -0
- package/src/components/masterplate/appendix.vue +586 -0
- package/src/components/masterplate/approval.vue +803 -0
- package/src/components/masterplate/base.vue +985 -0
- package/src/components/masterplate/billasyncimport.vue +614 -0
- package/src/components/masterplate/billconditionbox.vue +224 -0
- package/src/components/masterplate/billconditionsbox.vue +427 -0
- package/src/components/masterplate/billdetailform.vue +990 -0
- package/src/components/masterplate/billimport.vue +263 -0
- package/src/components/masterplate/billquerygrid.vue +316 -0
- package/src/components/masterplate/billsinglegrid.vue +234 -0
- package/src/components/masterplate/birtreport.vue +185 -0
- package/src/components/masterplate/detailbtntoolbar.vue +311 -0
- package/src/components/masterplate/detailsbox.vue +386 -0
- package/src/components/masterplate/editgridcard.vue +222 -0
- package/src/components/masterplate/editgridcard2.vue +109 -0
- package/src/components/masterplate/formcard.vue +106 -0
- package/src/components/masterplate/formcardgroupbox.vue +168 -0
- package/src/components/masterplate/formdetailtwo.vue +356 -0
- package/src/components/masterplate/gridcolset.vue +227 -0
- package/src/components/masterplate/index.js +23 -0
- package/src/components/masterplate/layouttemplate.vue +33 -0
- package/src/components/masterplate/leftlistrightdetails.vue +474 -0
- package/src/components/masterplate/leftlistrightlist.vue +465 -0
- package/src/components/masterplate/lefttreerightdetails.vue +619 -0
- package/src/components/masterplate/levelreport.vue +510 -0
- package/src/components/masterplate/listbtntoolbar.vue +257 -0
- package/src/components/masterplate/listdetails.vue +769 -0
- package/src/components/masterplate/operlog.vue +272 -0
- package/src/components/masterplate/options.vue +110 -0
- package/src/components/masterplate/page.vue +102 -0
- package/src/components/masterplate/promptmessage.vue +74 -0
- package/src/components/masterplate/querybar.vue +490 -0
- package/src/components/masterplate/report.vue +357 -0
- package/src/components/masterplate/rowbtntoolbar.vue +126 -0
- package/src/components/masterplate/simpletree.vue +129 -0
- package/src/components/masterplate/simpleviewgrid.vue +144 -0
- package/src/components/mychart/bar/bar.vue +202 -0
- package/src/components/mychart/basechart.vue +190 -0
- package/src/components/mychart/complexmychart/barline.vue +154 -0
- package/src/components/mychart/gauge/gauge.vue +83 -0
- package/src/components/mychart/index.js +9 -0
- package/src/components/mychart/line/line.vue +202 -0
- package/src/components/mychart/liquidfill/liquidfill.vue +109 -0
- package/src/components/mychart/pie/pie.vue +96 -0
- package/src/components/mychart/radar/radar.vue +122 -0
- package/src/components/mychart/scatter/scatter.vue +76 -0
- package/src/components/numberbox/append.js +11 -0
- package/src/components/numberbox/index.js +3 -0
- package/src/components/numberbox/numberbox.vue +303 -0
- package/src/components/numberbox/numberrangebox.vue +423 -0
- package/src/components/picturebox/filebox.vue +365 -0
- package/src/components/picturebox/index.js +3 -0
- package/src/components/picturebox/picturebox.vue +541 -0
- package/src/components/picturebox/uploadbox.vue +164 -0
- package/src/components/poptagbox/index.js +2 -0
- package/src/components/poptagbox/poptagbox.vue +389 -0
- package/src/components/poptextbox/index.js +2 -0
- package/src/components/poptextbox/poptextbox.vue +601 -0
- package/src/components/radiobox/index.js +2 -0
- package/src/components/radiobox/radiogroupbox.vue +76 -0
- package/src/components/richtextbox/editor.vue +150 -0
- package/src/components/richtextbox/index.js +2 -0
- package/src/components/richtextbox/richtextbox.vue +448 -0
- package/src/components/textbox/index.js +2 -0
- package/src/components/textbox/textbox.vue +98 -0
- package/src/components/timebox/index.js +2 -0
- package/src/components/timebox/timebox.vue +76 -0
- package/src/components/toolbar/ebutton.vue +169 -0
- package/src/components/toolbar/index.js +3 -0
- package/src/components/toolbar/toolbar.vue +446 -0
- package/src/components/tree/basetree.vue +725 -0
- package/src/components/tree/index.js +3 -0
- package/src/components/tree/treedata.vue +51 -0
- package/src/components/tree/treedatabase.vue +189 -0
- package/src/components/upload/billimport.vue +233 -0
- package/src/components/upload/index.js +2 -0
- package/src/components/videobox/index.js +2 -0
- package/src/components/videobox/uploadbox.vue +148 -0
- package/src/components/videobox/videobox.vue +503 -0
- package/src/components/wrichtextbox/editor.vue +219 -0
- package/src/components/wrichtextbox/index.js +2 -0
- package/src/components/wrichtextbox/wrichtextbox.vue +63 -0
- package/src/index.js +215 -0
- package/src/locale/format.js +51 -0
- package/src/locale/index.js +63 -0
- package/src/locale/lang/zh-CN.js +123 -0
- package/src/locale/lang/zh-TW.js +114 -0
- package/src/locale/lang/zh-UG.js +115 -0
- package/src/locale/lang.js +15 -0
- package/src/method/case/case.js +1180 -0
- package/src/method/config/queryconfig.js +24 -0
- package/src/method/const/const.js +815 -0
- package/src/method/index.js +8 -0
- package/src/static/excel/exportexcel.js +627 -0
- package/src/static/iview/coustom.js +463 -0
- package/src/store/index.js +19 -0
- package/src/store/modules/app.js +53 -0
- package/src/styles/README.md +3 -0
- package/src/styles/common.less +75 -0
- package/src/styles/components/anchor.less +74 -0
- package/src/styles/components/approval.less +136 -0
- package/src/styles/components/button.less +208 -0
- package/src/styles/components/card.less +51 -0
- package/src/styles/components/content.less +38 -0
- package/src/styles/components/font.less +314 -0
- package/src/styles/components/form.less +72 -0
- package/src/styles/components/iconfont/fonts/iconfont.less +1376 -0
- package/src/styles/components/iconfont/fonts/iconfont.svg +699 -0
- package/src/styles/components/iconfont/fonts/iconfont.ttf +0 -0
- package/src/styles/components/iconfont/fonts/iconfont.woff +0 -0
- package/src/styles/components/iconfont/fonts/iconfont.woff2 +0 -0
- package/src/styles/components/index.less +16 -0
- package/src/styles/components/input.less +290 -0
- package/src/styles/components/modal.less +203 -0
- package/src/styles/components/page.less +340 -0
- package/src/styles/components/select.less +361 -0
- package/src/styles/components/steps.less +367 -0
- package/src/styles/components/table.less +544 -0
- package/src/styles/components/tabs.less +249 -0
- package/src/styles/components/upload.less +83 -0
- package/src/styles/custom.less +67 -0
- package/src/styles/index.less +6 -0
- package/src/styles/pack.less +6 -0
- package/src/utils/EfuMessenger.js +155 -0
- package/src/utils/assist.js +353 -0
- package/src/utils/index.js +1 -0
- package/src/utils/random_str.js +10 -0
|
@@ -0,0 +1,815 @@
|
|
|
1
|
+
|
|
2
|
+
import {deepCopy} from '../../utils/assist';
|
|
3
|
+
import storage from 'good-storage';
|
|
4
|
+
import {exportExcel, exportMultiSheetExcel, exportExcelStyle} from '../../static/excel/exportexcel';
|
|
5
|
+
import { client as EfuClient } from '../../utils/EfuMessenger.js'
|
|
6
|
+
window.EfuMessenger = new EfuClient()
|
|
7
|
+
let commom = {};
|
|
8
|
+
commom.padLeftZero = function (res, str) {
|
|
9
|
+
return (res + str).substr(str.length);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
commom.formatDate = function (date, fmt) {
|
|
13
|
+
if (/(y+)/.test(fmt)) {
|
|
14
|
+
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
|
|
15
|
+
}
|
|
16
|
+
let o = {
|
|
17
|
+
'M+': date.getMonth() + 1,
|
|
18
|
+
'd+': date.getDate(),
|
|
19
|
+
'H+': date.getHours(),
|
|
20
|
+
'h+': date.getHours(),
|
|
21
|
+
'm+': date.getMinutes(),
|
|
22
|
+
's+': date.getSeconds()
|
|
23
|
+
};
|
|
24
|
+
for (let k in o) {
|
|
25
|
+
if (new RegExp(`(${k})`).test(fmt)) {
|
|
26
|
+
let str = o[k] + '';
|
|
27
|
+
fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? str : commom.padLeftZero('00', str));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return fmt;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
commom.getToday = function () {
|
|
34
|
+
let to=new Date();
|
|
35
|
+
let M=Number(to.getMonth())+1;
|
|
36
|
+
return to.getFullYear()+ '-'+commom.padLeftZero('00', M+'') + '-'+ commom.padLeftZero('00', to.getDate()+'');
|
|
37
|
+
};
|
|
38
|
+
commom.getTomorrow = function (str) {
|
|
39
|
+
let tom;
|
|
40
|
+
if (str) {
|
|
41
|
+
tom = new Date(str);
|
|
42
|
+
} else {
|
|
43
|
+
tom = new Date();
|
|
44
|
+
}
|
|
45
|
+
tom.setDate(tom.getDate()+1);
|
|
46
|
+
let M=Number(tom.getMonth())+1;
|
|
47
|
+
return tom.getFullYear()+'-'+commom.padLeftZero('00', M+'')+'-'+commom.padLeftZero('00', tom.getDate()+'');
|
|
48
|
+
};
|
|
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()+'');
|
|
55
|
+
};
|
|
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()+'');
|
|
63
|
+
};
|
|
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()+'');
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
commom.getMonthLastDay = function (str) {
|
|
73
|
+
let Nowdate;
|
|
74
|
+
if (str) {
|
|
75
|
+
Nowdate = new Date(str);
|
|
76
|
+
} else {
|
|
77
|
+
Nowdate = new Date();
|
|
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()+'');
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
commom.getNextMonthFirstDay = function (str) {
|
|
86
|
+
let Nowdate;
|
|
87
|
+
if (str) {
|
|
88
|
+
Nowdate = new Date(str);
|
|
89
|
+
} else {
|
|
90
|
+
Nowdate = new Date();
|
|
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()+'');
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
commom.getPreMonthFirstDay = function (str) {
|
|
98
|
+
let Nowdate;
|
|
99
|
+
if (str) {
|
|
100
|
+
Nowdate = new Date(str);
|
|
101
|
+
} else {
|
|
102
|
+
Nowdate = new Date();
|
|
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()+'');
|
|
107
|
+
};
|
|
108
|
+
commom.getYearFirstDay = function () {
|
|
109
|
+
let Nowdate=new Date();
|
|
110
|
+
return Nowdate.getFullYear()+'-01-01';
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
commom.getYearLastDay = function () {
|
|
114
|
+
let Nowdate=new Date();
|
|
115
|
+
return Nowdate.getFullYear()+'-12-31';
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
commom.getWeek = function (str) {
|
|
119
|
+
let Nowdate=new Date(str);
|
|
120
|
+
return Nowdate.getDay();
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
commom.copy = function (data) {
|
|
125
|
+
let obj = {};
|
|
126
|
+
obj = JSON.parse(JSON.stringify(data));
|
|
127
|
+
return obj;
|
|
128
|
+
};*/
|
|
129
|
+
commom.copy = deepCopy;
|
|
130
|
+
|
|
131
|
+
commom.getUrlParam = function (name) {
|
|
132
|
+
let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); // 构造一个含有目标参数的正则表达式对象
|
|
133
|
+
|
|
134
|
+
let list = window.location.href.split('?');
|
|
135
|
+
let r = '';
|
|
136
|
+
if (list.length > 1) {
|
|
137
|
+
r = list[1].match(reg); // 匹配目标参数
|
|
138
|
+
}
|
|
139
|
+
if (!r) {
|
|
140
|
+
if (list.length > 2) {
|
|
141
|
+
r = list[2].match(reg); // 匹配目标参数
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (r) return decodeURI(r[2]); return ''; // 返回参数值
|
|
145
|
+
};
|
|
146
|
+
commom.formatNumber= function (value,style, notzero) {
|
|
147
|
+
let precision = 0;
|
|
148
|
+
if (!value) {
|
|
149
|
+
value = '0';
|
|
150
|
+
} else {
|
|
151
|
+
if (!isNaN(value)) value = value +'';
|
|
152
|
+
}
|
|
153
|
+
if (!style) {
|
|
154
|
+
style = 'n';
|
|
155
|
+
} else {
|
|
156
|
+
if (style.length === 2) {
|
|
157
|
+
if (Number(style[1])) {
|
|
158
|
+
precision = Number(style[1]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
let reData = Number(value).toFixed(precision);
|
|
163
|
+
if (style.startsWith('p')) {
|
|
164
|
+
reData = (Number(value)*100).toFixed(precision);
|
|
165
|
+
}
|
|
166
|
+
let value2Array = reData.split('.');
|
|
167
|
+
let intPartFormat = '';
|
|
168
|
+
let floatPart = '';
|
|
169
|
+
if (value2Array.length > 0) {
|
|
170
|
+
intPartFormat = value2Array[0];
|
|
171
|
+
}
|
|
172
|
+
if (style.startsWith('c')) {
|
|
173
|
+
intPartFormat = intPartFormat.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
|
|
174
|
+
}
|
|
175
|
+
if (value2Array.length > 1) {
|
|
176
|
+
floatPart = value2Array[1];
|
|
177
|
+
}
|
|
178
|
+
if (floatPart) {
|
|
179
|
+
let valueFloatPart =floatPart;
|
|
180
|
+
if (notzero) {
|
|
181
|
+
for (let i= floatPart.length - 1; i>=0; i--) {
|
|
182
|
+
if (Number(floatPart[i]) === 0) {
|
|
183
|
+
valueFloatPart = valueFloatPart.slice(0, -1);
|
|
184
|
+
} else {
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
floatPart = valueFloatPart;
|
|
190
|
+
}
|
|
191
|
+
let result = '';
|
|
192
|
+
if (floatPart) {
|
|
193
|
+
result = intPartFormat + '.' + floatPart;
|
|
194
|
+
} else {
|
|
195
|
+
result = intPartFormat;
|
|
196
|
+
}
|
|
197
|
+
if (style.startsWith('p')) {
|
|
198
|
+
result = result + '%';
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
commom.precisionNumber= function (value,style) {
|
|
204
|
+
let precision = 0;
|
|
205
|
+
if (!value) {
|
|
206
|
+
value = '0';
|
|
207
|
+
} else {
|
|
208
|
+
if (!isNaN(value)) value = value +'';
|
|
209
|
+
}
|
|
210
|
+
if (!style) {
|
|
211
|
+
style = 'n';
|
|
212
|
+
} else {
|
|
213
|
+
if (style.length === 2) {
|
|
214
|
+
if (Number(style[1])) {
|
|
215
|
+
precision = Number(style[1]);
|
|
216
|
+
}
|
|
217
|
+
if (style.startsWith('p')) {
|
|
218
|
+
precision = precision + 2;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return Number(value).toFixed(precision);
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
function randomHsl () {
|
|
226
|
+
let H = Math.random();
|
|
227
|
+
let S = Math.random();
|
|
228
|
+
let L = Math.random();
|
|
229
|
+
return [H, S, L];
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function hslToRgb (hsl) {
|
|
233
|
+
for (let i = 0; i < hsl.length; i++) {
|
|
234
|
+
let H = hsl[i][0];
|
|
235
|
+
let S = hsl[i][1];
|
|
236
|
+
let L = hsl[i][2];
|
|
237
|
+
let R, G, B;
|
|
238
|
+
if (+S === 0) {
|
|
239
|
+
R = G = B = L; // 饱和度为0 为灰色
|
|
240
|
+
} else {
|
|
241
|
+
let hue2Rgb = function (p, q, t) {
|
|
242
|
+
if (t < 0) t += 1;
|
|
243
|
+
if (t > 1) t -= 1;
|
|
244
|
+
if (t < 1 / 6) return p + (q - p) * 6 * t;
|
|
245
|
+
if (t < 1 / 2) return q;
|
|
246
|
+
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
|
|
247
|
+
return p;
|
|
248
|
+
};
|
|
249
|
+
let Q = L < 0.5 ? L * (1 + S) : L + S - L * S;
|
|
250
|
+
let P = 2 * L - Q;
|
|
251
|
+
R = hue2Rgb(P, Q, H + 1 / 3);
|
|
252
|
+
G = hue2Rgb(P, Q, H);
|
|
253
|
+
B = hue2Rgb(P, Q, H - 1 / 3);
|
|
254
|
+
}
|
|
255
|
+
hsl[i][0] = Math.round(R * 255);
|
|
256
|
+
hsl[i][1] = Math.round(G * 255);
|
|
257
|
+
hsl[i][2] = Math.round(B * 255);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function colorHex (hsl) {
|
|
261
|
+
let colorHex = [];
|
|
262
|
+
let strHex = '';
|
|
263
|
+
for (let i = 0; i < hsl.length; i++) {
|
|
264
|
+
let aColor = hsl[i];
|
|
265
|
+
strHex = '#';
|
|
266
|
+
for (let j = 0; j < aColor.length; j++) {
|
|
267
|
+
let hex = Number(aColor[j]).toString(16);
|
|
268
|
+
if (hex === '0') {
|
|
269
|
+
hex += hex;
|
|
270
|
+
}
|
|
271
|
+
strHex += hex;
|
|
272
|
+
}
|
|
273
|
+
colorHex.push(strHex);
|
|
274
|
+
}
|
|
275
|
+
return colorHex;
|
|
276
|
+
}
|
|
277
|
+
function getHslArray (hslLength) {
|
|
278
|
+
let HSL = [];
|
|
279
|
+
for (let i = 0; i < hslLength; i++) {
|
|
280
|
+
let ret = randomHsl();
|
|
281
|
+
|
|
282
|
+
// 颜色相邻颜色差异须大于 0.25
|
|
283
|
+
if (i > 0 && Math.abs(ret[0] - HSL[i - 1][0]) < 0.25) {
|
|
284
|
+
i--;
|
|
285
|
+
continue; // 重新获取随机色
|
|
286
|
+
}
|
|
287
|
+
ret[1] = 0.7 + (ret[1] * 0.2); // [0.7 - 0.9] 排除过灰颜色
|
|
288
|
+
ret[2] = 0.4 + (ret[2] * 0.4); // [0.4 - 0.8] 排除过亮过暗色
|
|
289
|
+
|
|
290
|
+
// 数据转化到小数点后两位
|
|
291
|
+
ret = ret.map(function (item) {
|
|
292
|
+
return parseFloat(item.toFixed(2));
|
|
293
|
+
});
|
|
294
|
+
HSL.push(ret);
|
|
295
|
+
}
|
|
296
|
+
hslToRgb(HSL);
|
|
297
|
+
return colorHex(HSL);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
commom.getColorList = function (old, size) {
|
|
301
|
+
let num = Number(size) - old.length;
|
|
302
|
+
if (num === 0) {
|
|
303
|
+
return old;
|
|
304
|
+
}
|
|
305
|
+
let newcolor = getHslArray(num);
|
|
306
|
+
let flag = false;
|
|
307
|
+
for (;;) {
|
|
308
|
+
flag = false;
|
|
309
|
+
for (let i = 0; i < newcolor.length; i++) {
|
|
310
|
+
for (let j = 0; j < old.length; j++) {
|
|
311
|
+
if (newcolor[i] === old[j]) {
|
|
312
|
+
flag = true;
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (!flag) {
|
|
318
|
+
newcolor = old.concat(newcolor);
|
|
319
|
+
break;
|
|
320
|
+
} else {
|
|
321
|
+
newcolor = getHslArray(num);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return newcolor;
|
|
325
|
+
};
|
|
326
|
+
commom.getColor = function () {
|
|
327
|
+
let newcolor = getHslArray(1);
|
|
328
|
+
return newcolor[0];
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
commom.getGlobalColor = function (n,isRandom,pro,that) {
|
|
332
|
+
let newColor = [];
|
|
333
|
+
if (n > 0) {
|
|
334
|
+
let color = that.$Store.state.app.mychartColor[pro];
|
|
335
|
+
if (n > color.length) {
|
|
336
|
+
if (isRandom) {
|
|
337
|
+
newColor = that.$Method.getColorList(color,n);
|
|
338
|
+
that.$nextTick(()=>{
|
|
339
|
+
that.$Store.commit('setMychartColor',pro,newColor);
|
|
340
|
+
});
|
|
341
|
+
} else {
|
|
342
|
+
newColor = color.concat(color.slice(0, n - color.length));
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
newColor = color.slice(0,n);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return newColor;
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
commom.getHeight = function(that) {
|
|
352
|
+
// let height = window.innerHeight? window.innerHeight: document.documentElement.clientHeight? document.documentElement.clientHeight: screen.height;
|
|
353
|
+
// return height;
|
|
354
|
+
return that.$Store.state.app.clientHeight;
|
|
355
|
+
};
|
|
356
|
+
commom.getWidth = function(that) {
|
|
357
|
+
// let width = window.innerWidth? window.innerWidth: document.documentElement.clientWidth? document.documentElement.clientWidth: screen.width;
|
|
358
|
+
// return width;
|
|
359
|
+
return that.$Store.state.app.clientWidth;
|
|
360
|
+
};
|
|
361
|
+
commom.getXDpi = function() {
|
|
362
|
+
let xDpi = 0;
|
|
363
|
+
if (window.screen.deviceXDPI) {
|
|
364
|
+
xDpi = window.screen.deviceXDPI;
|
|
365
|
+
} else {
|
|
366
|
+
let tmpNode = document.createElement('DIV');
|
|
367
|
+
tmpNode.style.cssText = 'width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden';
|
|
368
|
+
document.body.appendChild(tmpNode);
|
|
369
|
+
xDpi = parseInt(tmpNode.offsetWidth);
|
|
370
|
+
document.body.removeChild(tmpNode);
|
|
371
|
+
}
|
|
372
|
+
return xDpi;
|
|
373
|
+
}
|
|
374
|
+
commom.getYDpi = function() {
|
|
375
|
+
let yDpi = 0;
|
|
376
|
+
if (window.screen.deviceXDPI) {
|
|
377
|
+
yDpi = window.screen.deviceYDPI;
|
|
378
|
+
} else {
|
|
379
|
+
let tmpNode = document.createElement('DIV');
|
|
380
|
+
tmpNode.style.cssText = 'width:1in;height:1in;position:absolute;left:0px;top:0px;z-index:99;visibility:hidden';
|
|
381
|
+
document.body.appendChild(tmpNode);
|
|
382
|
+
yDpi = parseInt(tmpNode.offsetHeight);
|
|
383
|
+
document.body.removeChild(tmpNode);
|
|
384
|
+
}
|
|
385
|
+
return yDpi;
|
|
386
|
+
}
|
|
387
|
+
commom.mmToYpixe = function(value,ydpi) {
|
|
388
|
+
let tmp = ydpi;
|
|
389
|
+
if (!tmp) {
|
|
390
|
+
tmp = commom.getYDpi();;
|
|
391
|
+
}
|
|
392
|
+
let y = (value / 25.4) * tmp;
|
|
393
|
+
return Number(y.toFixed(2));
|
|
394
|
+
},
|
|
395
|
+
commom.mmToXpixe = function(value,xdpi) {
|
|
396
|
+
let tmp = xdpi;
|
|
397
|
+
if (!tmp) {
|
|
398
|
+
tmp = commom.getXDpi();;
|
|
399
|
+
}
|
|
400
|
+
let x = (value / 25.4) * tmp;
|
|
401
|
+
return Number(x.toFixed(2));
|
|
402
|
+
},
|
|
403
|
+
commom.xPixelToMm = function(value,xdpi) {
|
|
404
|
+
let tmp = xdpi;
|
|
405
|
+
if (!tmp) {
|
|
406
|
+
tmp = commom.getXDpi();;
|
|
407
|
+
}
|
|
408
|
+
let xmm = (value / tmp) * 25.4;
|
|
409
|
+
return Number(xmm.toFixed(2));
|
|
410
|
+
},
|
|
411
|
+
commom.yPixelToMm = function(value,ydpi) {
|
|
412
|
+
let tmp = ydpi;
|
|
413
|
+
if (!tmp) {
|
|
414
|
+
tmp = commom.getYDpi();;
|
|
415
|
+
}
|
|
416
|
+
let ymm = (value / tmp) * 25.4;
|
|
417
|
+
return Number(ymm.toFixed(2));
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
commom.unique = function (arr) {
|
|
421
|
+
//定义常量 res,值为一个Map对象实例
|
|
422
|
+
const res = new Map();
|
|
423
|
+
|
|
424
|
+
//返回arr数组过滤后的结果,结果为一个数组
|
|
425
|
+
//过滤条件是,如果res中没有某个键,就设置这个键的值为1
|
|
426
|
+
return arr.filter((a) => !res.has(a) && res.set(a, 1));
|
|
427
|
+
};
|
|
428
|
+
commom.formatComboBox= function (value, config) {
|
|
429
|
+
if (!value && value !== 0) {
|
|
430
|
+
return value;
|
|
431
|
+
}
|
|
432
|
+
if (config.renderValue == undefined) {
|
|
433
|
+
config.renderValue = {};
|
|
434
|
+
}
|
|
435
|
+
if (config.renderValue[value]) {
|
|
436
|
+
return config.renderValue[value];
|
|
437
|
+
}
|
|
438
|
+
let result = value;
|
|
439
|
+
if (config.data && config.data.length > 0) {
|
|
440
|
+
let valueField = 'code';
|
|
441
|
+
let textField = 'name';
|
|
442
|
+
|
|
443
|
+
if (config.valueField) {
|
|
444
|
+
valueField = config.valueField;
|
|
445
|
+
}
|
|
446
|
+
if (config.textField) {
|
|
447
|
+
textField = config.textField;
|
|
448
|
+
}
|
|
449
|
+
const index = config.data.findIndex(item => item[valueField] === value);
|
|
450
|
+
if (index > -1) {
|
|
451
|
+
if (config.data[index][textField]) {
|
|
452
|
+
if (config.codeWithName === false) {
|
|
453
|
+
result = config.data[index][textField];
|
|
454
|
+
} else {
|
|
455
|
+
result = '['+ value +']' + config.data[index][textField];
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
config.renderValue[value] = result;
|
|
461
|
+
return result;
|
|
462
|
+
};
|
|
463
|
+
commom.formatDataBox = function (value,config) {
|
|
464
|
+
if (!value) {
|
|
465
|
+
return '';
|
|
466
|
+
}
|
|
467
|
+
if (config.renderFormat == undefined) {
|
|
468
|
+
config.renderFormat = 'yyyy-MM-dd';
|
|
469
|
+
if (config && config.format === undefined) {
|
|
470
|
+
if (config.vtype === 'date') {
|
|
471
|
+
config.renderFormat = 'yyyy-MM-dd';
|
|
472
|
+
} else if (config.vtype === 'datetime') {
|
|
473
|
+
config.renderFormat = 'yyyy-MM-dd hh:mm:ss';
|
|
474
|
+
} else if (config.vtype ==='month') {
|
|
475
|
+
config.renderFormat = 'yyyy-MM';
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
if (config.format) {
|
|
479
|
+
config.renderFormat = config.format;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
|
484
|
+
return commom.formatDate(new Date(value),config.renderFormat);
|
|
485
|
+
} else if (value.constructor === Date){
|
|
486
|
+
return commom.formatDate(value,config.renderFormat);
|
|
487
|
+
} else {
|
|
488
|
+
return value;
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
commom.formatValue= function (value,row,config) {
|
|
492
|
+
if (config) {
|
|
493
|
+
if (config.type) {
|
|
494
|
+
let type = config.type.toLowerCase();
|
|
495
|
+
if (type === 'textbox') {
|
|
496
|
+
return value;
|
|
497
|
+
} else if (type === 'numberbox') {
|
|
498
|
+
if (!value) {
|
|
499
|
+
if (value === config.defaultValue) {
|
|
500
|
+
return value;
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
return commom.formatNumber(value,config.format,config.notzero);
|
|
504
|
+
} else if (type === 'combobox') {
|
|
505
|
+
return commom.formatComboBox(value,config);
|
|
506
|
+
} else if (type === 'datebox') {
|
|
507
|
+
return commom.formatDataBox(value,config);
|
|
508
|
+
} else {
|
|
509
|
+
if (config.textName) {
|
|
510
|
+
if (row[config.textName]) {
|
|
511
|
+
return row[config.textName];
|
|
512
|
+
} else {
|
|
513
|
+
return value?value:'';
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return value;
|
|
517
|
+
}
|
|
518
|
+
} else {
|
|
519
|
+
return value;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
} else {
|
|
523
|
+
return value;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
commom.getDefaultFieldStyle = function (column,dictData,dictConfig) {
|
|
528
|
+
let tempStyle = '';
|
|
529
|
+
if (column.type === 'DateBox') {
|
|
530
|
+
let format ='';
|
|
531
|
+
if (column.format !== undefined) {
|
|
532
|
+
format = column.format;
|
|
533
|
+
} else {
|
|
534
|
+
if (column.vtype === 'date') {
|
|
535
|
+
format = 'yyyy-MM-dd';
|
|
536
|
+
} else if (column.vtype === 'datetime') {
|
|
537
|
+
format = 'yyyy-MM-dd hh:mm:ss';
|
|
538
|
+
} else if (column.vtype ==='month') {
|
|
539
|
+
format = 'yyyy-MM';
|
|
540
|
+
} else {
|
|
541
|
+
format = 'yyyy-MM-dd';
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
tempStyle = tempStyle +'d' + '=' + format + '=center';
|
|
545
|
+
}
|
|
546
|
+
if (column.type === 'NumberBox') {
|
|
547
|
+
let format ='';
|
|
548
|
+
if (column.format !== undefined) {
|
|
549
|
+
format = column.format;
|
|
550
|
+
} else {
|
|
551
|
+
format = 'n2';
|
|
552
|
+
}
|
|
553
|
+
tempStyle = tempStyle + format +'=right';
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
if (column.type === 'ComboBox') {
|
|
557
|
+
let dictkey = column.dictkey;
|
|
558
|
+
if (!dictkey) {
|
|
559
|
+
dictkey = column.name;
|
|
560
|
+
}
|
|
561
|
+
let format ='t' + '=' + dictkey;
|
|
562
|
+
if (column.codeWithName === false) {
|
|
563
|
+
format = format + '=N';
|
|
564
|
+
} else {
|
|
565
|
+
format = format + '=Y';
|
|
566
|
+
}
|
|
567
|
+
tempStyle = tempStyle + format +'=left';
|
|
568
|
+
let valueField = 'code';
|
|
569
|
+
let textField = 'name'
|
|
570
|
+
if (column.valueField) {
|
|
571
|
+
valueField = column.valueField;
|
|
572
|
+
}
|
|
573
|
+
if (column.textField) {
|
|
574
|
+
textField = column.textField;
|
|
575
|
+
}
|
|
576
|
+
if (dictData[dictkey] && !dictConfig[dictkey]) {
|
|
577
|
+
dictConfig[dictkey] = [];
|
|
578
|
+
dictData[dictkey].forEach(el => {
|
|
579
|
+
let tmp = {};
|
|
580
|
+
tmp.code = el[valueField];
|
|
581
|
+
tmp.name = el[textField];
|
|
582
|
+
dictConfig[dictkey].push(tmp);
|
|
583
|
+
});
|
|
584
|
+
} else {
|
|
585
|
+
if (column.data != undefined) {
|
|
586
|
+
dictConfig[dictkey] = commom.copy(column.data);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
return tempStyle;
|
|
591
|
+
};
|
|
592
|
+
|
|
593
|
+
commom.getGridField = function(columns, separator, dictData, dictConfig) {
|
|
594
|
+
let fields = '';
|
|
595
|
+
for (let i = 0; i < columns.length; i++) {
|
|
596
|
+
let column = columns[i];
|
|
597
|
+
if (column.visible !== false && column.isExport !== false) {
|
|
598
|
+
if (column.name) {
|
|
599
|
+
fields += column.name + separator + column.label;
|
|
600
|
+
let style = '';
|
|
601
|
+
if (column.excel && column.excel.type) {
|
|
602
|
+
style = column.excel.type;
|
|
603
|
+
if (column.excel.format) {
|
|
604
|
+
style += '=' + column.excel.format;
|
|
605
|
+
} else {
|
|
606
|
+
style += '=' ;
|
|
607
|
+
}
|
|
608
|
+
if (column.excel.align) {
|
|
609
|
+
style += '=' + column.excel.align;
|
|
610
|
+
} else {
|
|
611
|
+
style += '=' ;
|
|
612
|
+
}
|
|
613
|
+
} else {
|
|
614
|
+
style = commom.getDefaultFieldStyle(column,dictData,dictConfig);
|
|
615
|
+
}
|
|
616
|
+
if (style) {
|
|
617
|
+
fields += separator + style + ',';
|
|
618
|
+
} else {
|
|
619
|
+
fields += ',';
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
if (column.children) {
|
|
623
|
+
for (let j = 0; j < column.children.length; j++) {
|
|
624
|
+
let tempcolumn = column.children[j];
|
|
625
|
+
if (tempcolumn.name) {
|
|
626
|
+
let header = '';
|
|
627
|
+
if (column.label) {
|
|
628
|
+
header = column.label + '('
|
|
629
|
+
+ tempcolumn.label + ')';
|
|
630
|
+
} else {
|
|
631
|
+
header = tempcolumn.label;
|
|
632
|
+
}
|
|
633
|
+
fields += tempcolumn.name + separator + header;
|
|
634
|
+
let style = '';
|
|
635
|
+
if (tempcolumn.excel && tempcolumn.excel.type) {
|
|
636
|
+
style = tempcolumn.excel.type;
|
|
637
|
+
if (tempcolumn.excel.format) {
|
|
638
|
+
style += '=' + tempcolumn.excel.format;
|
|
639
|
+
} else {
|
|
640
|
+
style += '=';
|
|
641
|
+
}
|
|
642
|
+
if (tempcolumn.excel.align) {
|
|
643
|
+
style += '=' + tempcolumn.excel.align;
|
|
644
|
+
} else {
|
|
645
|
+
style += '=';
|
|
646
|
+
}
|
|
647
|
+
} else {
|
|
648
|
+
style = commom.getDefaultFieldStyle(tempcolumn,dictData,dictConfig);
|
|
649
|
+
}
|
|
650
|
+
if (style) {
|
|
651
|
+
fields += separator + style + ',';
|
|
652
|
+
} else {
|
|
653
|
+
fields += ',';
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
if (fields.length > 0) {
|
|
661
|
+
fields = fields.substring(0, fields.length - 1);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
return fields;
|
|
665
|
+
};
|
|
666
|
+
commom.print = function(object,printCss) {
|
|
667
|
+
let printStr = '<html><head>' + document.head.innerHTML +'</head>';
|
|
668
|
+
if (object) {
|
|
669
|
+
printStr = printStr + '<body>' + object.$el.innerHTML +'</body></html>';
|
|
670
|
+
} else {
|
|
671
|
+
printStr = printStr + '<body>' + document.body.innerHTML +'</body></html>';
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
// 如果是本地测试,需要先新建Print.htm 如果是在域中使用,则不需要
|
|
675
|
+
let pwin = window.open('Print.htm', 'print');
|
|
676
|
+
pwin.document.write(printStr);
|
|
677
|
+
if (printCss) {
|
|
678
|
+
let styles=document.createElement('style');
|
|
679
|
+
styles.setAttribute('type','text/css');//media="print"
|
|
680
|
+
styles.innerHTML = printCss;
|
|
681
|
+
pwin.document.getElementsByTagName('head')[0].appendChild(styles);
|
|
682
|
+
}
|
|
683
|
+
pwin.document.close(); // 这句很重要,没有就无法实现
|
|
684
|
+
pwin.print();
|
|
685
|
+
pwin.close();
|
|
686
|
+
};
|
|
687
|
+
commom.openPage = function(modulecode,params) {
|
|
688
|
+
let result = {};
|
|
689
|
+
result.moduleCode = modulecode;
|
|
690
|
+
result.params = params;
|
|
691
|
+
window.EfuMessenger.openPortalTabByModuleCode(result)
|
|
692
|
+
// window.parent.postMessage({data:result, type:'pageJump'}, '*');
|
|
693
|
+
};
|
|
694
|
+
commom.setLocalStorage = function(key,value, expire) {
|
|
695
|
+
let obj = {};
|
|
696
|
+
obj.data = value;
|
|
697
|
+
obj.time = Date.now();
|
|
698
|
+
obj.expire = expire;
|
|
699
|
+
storage.set(key,JSON.stringify(obj));
|
|
700
|
+
};
|
|
701
|
+
|
|
702
|
+
commom.getLocalStorage = function(key) {
|
|
703
|
+
let val = storage.get(key);
|
|
704
|
+
if(!val){
|
|
705
|
+
return null;
|
|
706
|
+
}
|
|
707
|
+
val =JSON.parse(val);
|
|
708
|
+
let expire = Number(val.expire) * 60 * 60 * 1000;
|
|
709
|
+
if(Date.now()- val.time> expire){
|
|
710
|
+
storage.remove(key);
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
713
|
+
return val.data;
|
|
714
|
+
};
|
|
715
|
+
commom.getTextWidth = function(text) {
|
|
716
|
+
const dom = document.createElement('span');
|
|
717
|
+
dom.style.display='inline-block;';
|
|
718
|
+
dom.textContent = text;
|
|
719
|
+
document.body.appendChild(dom);
|
|
720
|
+
const width = dom.offsetWidth;
|
|
721
|
+
document.body.removeChild(dom);
|
|
722
|
+
let resultWidth = Math.ceil(width/100) *100 + 40;
|
|
723
|
+
return resultWidth;
|
|
724
|
+
};
|
|
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 = '元'; //整型完以后的单位
|
|
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
|
+
}
|
|
754
|
+
//提供对负数的支持
|
|
755
|
+
if(money < 0){
|
|
756
|
+
ChineseStr = cnIntLast_F;
|
|
757
|
+
money = money*-1;
|
|
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;
|
|
809
|
+
},
|
|
810
|
+
|
|
811
|
+
commom.exportExcel = exportExcel;
|
|
812
|
+
|
|
813
|
+
commom.exportMultiSheetExcel = exportMultiSheetExcel;
|
|
814
|
+
commom.exportExcelStyle = exportExcelStyle;
|
|
815
|
+
export default commom;
|