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,627 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
import * as XLSX from "xlsx"
|
|
3
|
+
import * as XLSXS from "xlsx-style-vite"
|
|
4
|
+
import {saveAs} from 'file-saver'
|
|
5
|
+
|
|
6
|
+
(function (view) {
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
view.URL = view.URL || view.webkitURL;
|
|
10
|
+
|
|
11
|
+
if (view.Blob && view.URL) {
|
|
12
|
+
try {
|
|
13
|
+
new Blob;
|
|
14
|
+
return;
|
|
15
|
+
} catch (e) {}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Internally we use a BlobBuilder implementation to base Blob off of
|
|
19
|
+
// in order to support older browsers that only have BlobBuilder
|
|
20
|
+
var BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function(view) {
|
|
21
|
+
var
|
|
22
|
+
get_class = function(object) {
|
|
23
|
+
return Object.prototype.toString.call(object).match(/^\[object\s(.*)\]$/)[1];
|
|
24
|
+
}
|
|
25
|
+
, FakeBlobBuilder = function BlobBuilder() {
|
|
26
|
+
this.data = [];
|
|
27
|
+
}
|
|
28
|
+
, FakeBlob = function Blob(data, type, encoding) {
|
|
29
|
+
this.data = data;
|
|
30
|
+
this.size = data.length;
|
|
31
|
+
this.type = type;
|
|
32
|
+
this.encoding = encoding;
|
|
33
|
+
}
|
|
34
|
+
, FBB_proto = FakeBlobBuilder.prototype
|
|
35
|
+
, FB_proto = FakeBlob.prototype
|
|
36
|
+
, FileReaderSync = view.FileReaderSync
|
|
37
|
+
, FileException = function(type) {
|
|
38
|
+
this.code = this[this.name = type];
|
|
39
|
+
}
|
|
40
|
+
, file_ex_codes = (
|
|
41
|
+
"NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
|
|
42
|
+
+ "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
|
|
43
|
+
).split(" ")
|
|
44
|
+
, file_ex_code = file_ex_codes.length
|
|
45
|
+
, real_URL = view.URL || view.webkitURL || view
|
|
46
|
+
, real_create_object_URL = real_URL.createObjectURL
|
|
47
|
+
, real_revoke_object_URL = real_URL.revokeObjectURL
|
|
48
|
+
, URL = real_URL
|
|
49
|
+
, btoa = view.btoa
|
|
50
|
+
, atob = view.atob
|
|
51
|
+
|
|
52
|
+
, ArrayBuffer = view.ArrayBuffer
|
|
53
|
+
, Uint8Array = view.Uint8Array
|
|
54
|
+
;
|
|
55
|
+
FakeBlob.fake = FB_proto.fake = true;
|
|
56
|
+
while (file_ex_code--) {
|
|
57
|
+
FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
|
|
58
|
+
}
|
|
59
|
+
if (!real_URL.createObjectURL) {
|
|
60
|
+
URL = view.URL = {};
|
|
61
|
+
}
|
|
62
|
+
URL.createObjectURL = function(blob) {
|
|
63
|
+
var
|
|
64
|
+
type = blob.type
|
|
65
|
+
, data_URI_header
|
|
66
|
+
;
|
|
67
|
+
if (type === null) {
|
|
68
|
+
type = "application/octet-stream";
|
|
69
|
+
}
|
|
70
|
+
if (blob instanceof FakeBlob) {
|
|
71
|
+
data_URI_header = "data:" + type;
|
|
72
|
+
if (blob.encoding === "base64") {
|
|
73
|
+
return data_URI_header + ";base64," + blob.data;
|
|
74
|
+
} else if (blob.encoding === "URI") {
|
|
75
|
+
return data_URI_header + "," + decodeURIComponent(blob.data);
|
|
76
|
+
} if (btoa) {
|
|
77
|
+
return data_URI_header + ";base64," + btoa(blob.data);
|
|
78
|
+
} else {
|
|
79
|
+
return data_URI_header + "," + encodeURIComponent(blob.data);
|
|
80
|
+
}
|
|
81
|
+
} else if (real_create_object_URL) {
|
|
82
|
+
return real_create_object_URL.call(real_URL, blob);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
URL.revokeObjectURL = function(object_URL) {
|
|
86
|
+
if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
|
|
87
|
+
real_revoke_object_URL.call(real_URL, object_URL);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
FBB_proto.append = function(data/*, endings*/) {
|
|
91
|
+
var bb = this.data;
|
|
92
|
+
// decode data to a binary string
|
|
93
|
+
if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
|
|
94
|
+
var
|
|
95
|
+
str = ""
|
|
96
|
+
, buf = new Uint8Array(data)
|
|
97
|
+
, i = 0
|
|
98
|
+
, buf_len = buf.length
|
|
99
|
+
;
|
|
100
|
+
for (; i < buf_len; i++) {
|
|
101
|
+
str += String.fromCharCode(buf[i]);
|
|
102
|
+
}
|
|
103
|
+
bb.push(str);
|
|
104
|
+
} else if (get_class(data) === "Blob" || get_class(data) === "File") {
|
|
105
|
+
if (FileReaderSync) {
|
|
106
|
+
var fr = new FileReaderSync;
|
|
107
|
+
bb.push(fr.readAsBinaryString(data));
|
|
108
|
+
} else {
|
|
109
|
+
// async FileReader won't work as BlobBuilder is sync
|
|
110
|
+
throw new FileException("NOT_READABLE_ERR");
|
|
111
|
+
}
|
|
112
|
+
} else if (data instanceof FakeBlob) {
|
|
113
|
+
if (data.encoding === "base64" && atob) {
|
|
114
|
+
bb.push(atob(data.data));
|
|
115
|
+
} else if (data.encoding === "URI") {
|
|
116
|
+
bb.push(decodeURIComponent(data.data));
|
|
117
|
+
} else if (data.encoding === "raw") {
|
|
118
|
+
bb.push(data.data);
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
if (typeof data !== "string") {
|
|
122
|
+
data += ""; // convert unsupported types to strings
|
|
123
|
+
}
|
|
124
|
+
// decode UTF-16 to binary string
|
|
125
|
+
bb.push(unescape(encodeURIComponent(data)));
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
FBB_proto.getBlob = function(type) {
|
|
129
|
+
if (!arguments.length) {
|
|
130
|
+
type = null;
|
|
131
|
+
}
|
|
132
|
+
return new FakeBlob(this.data.join(""), type, "raw");
|
|
133
|
+
};
|
|
134
|
+
FBB_proto.toString = function() {
|
|
135
|
+
return "[object BlobBuilder]";
|
|
136
|
+
};
|
|
137
|
+
FB_proto.slice = function(start, end, type) {
|
|
138
|
+
var args = arguments.length;
|
|
139
|
+
if (args < 3) {
|
|
140
|
+
type = null;
|
|
141
|
+
}
|
|
142
|
+
return new FakeBlob(
|
|
143
|
+
this.data.slice(start, args > 1 ? end : this.data.length)
|
|
144
|
+
, type
|
|
145
|
+
, this.encoding
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
FB_proto.toString = function() {
|
|
149
|
+
return "[object Blob]";
|
|
150
|
+
};
|
|
151
|
+
FB_proto.close = function() {
|
|
152
|
+
this.size = this.data.length = 0;
|
|
153
|
+
};
|
|
154
|
+
return FakeBlobBuilder;
|
|
155
|
+
}(view));
|
|
156
|
+
|
|
157
|
+
view.Blob = function Blob(blobParts, options) {
|
|
158
|
+
var type = options ? (options.type || "") : "";
|
|
159
|
+
var builder = new BlobBuilder();
|
|
160
|
+
if (blobParts) {
|
|
161
|
+
for (var i = 0, len = blobParts.length; i < len; i++) {
|
|
162
|
+
builder.append(blobParts[i]);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return builder.getBlob(type);
|
|
166
|
+
};
|
|
167
|
+
}(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
|
|
168
|
+
|
|
169
|
+
function generateArray(table) {
|
|
170
|
+
var out = [];
|
|
171
|
+
var rows = table.querySelectorAll('tr');
|
|
172
|
+
var ranges = [];
|
|
173
|
+
for (var R = 0; R < rows.length; ++R) {
|
|
174
|
+
var outRow = [];
|
|
175
|
+
var row = rows[R];
|
|
176
|
+
var columns = row.querySelectorAll('td');
|
|
177
|
+
for (var C = 0; C < columns.length; ++C) {
|
|
178
|
+
var cell = columns[C];
|
|
179
|
+
var colspan = cell.getAttribute('colspan');
|
|
180
|
+
var rowspan = cell.getAttribute('rowspan');
|
|
181
|
+
var cellValue = cell.innerText;
|
|
182
|
+
if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
|
|
183
|
+
|
|
184
|
+
//Skip ranges
|
|
185
|
+
ranges.forEach(function (range) {
|
|
186
|
+
if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
|
|
187
|
+
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
//Handle Row Span
|
|
192
|
+
if (rowspan || colspan) {
|
|
193
|
+
rowspan = rowspan || 1;
|
|
194
|
+
colspan = colspan || 1;
|
|
195
|
+
ranges.push({s: {r: R, c: outRow.length}, e: {r: R + rowspan - 1, c: outRow.length + colspan - 1}});
|
|
196
|
+
}
|
|
197
|
+
;
|
|
198
|
+
|
|
199
|
+
//Handle Value
|
|
200
|
+
outRow.push(cellValue !== "" ? cellValue : null);
|
|
201
|
+
|
|
202
|
+
//Handle Colspan
|
|
203
|
+
if (colspan) for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
|
|
204
|
+
}
|
|
205
|
+
out.push(outRow);
|
|
206
|
+
}
|
|
207
|
+
return [out, ranges];
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
function datenum(v, date1904) {
|
|
211
|
+
if (date1904) v += 1462;
|
|
212
|
+
var epoch = Date.parse(v);
|
|
213
|
+
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function sheet_from_array_of_arrays(data, opts) {
|
|
217
|
+
var ws = {};
|
|
218
|
+
var range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}};
|
|
219
|
+
for (var R = 0; R != data.length; ++R) {
|
|
220
|
+
for (var C = 0; C != data[R].length; ++C) {
|
|
221
|
+
if (range.s.r > R) range.s.r = R;
|
|
222
|
+
if (range.s.c > C) range.s.c = C;
|
|
223
|
+
if (range.e.r < R) range.e.r = R;
|
|
224
|
+
if (range.e.c < C) range.e.c = C;
|
|
225
|
+
var cell = {v: data[R][C]};
|
|
226
|
+
if (cell.v == null) continue;
|
|
227
|
+
var cell_ref = XLSX.utils.encode_cell({c: C, r: R});
|
|
228
|
+
|
|
229
|
+
if (typeof cell.v === 'number') cell.t = 'n';
|
|
230
|
+
else if (typeof cell.v === 'boolean') cell.t = 'b';
|
|
231
|
+
else if (cell.v instanceof Date) {
|
|
232
|
+
cell.t = 'n';
|
|
233
|
+
cell.z = XLSX.SSF._table[14];
|
|
234
|
+
cell.v = datenum(cell.v);
|
|
235
|
+
}
|
|
236
|
+
else cell.t = 's';
|
|
237
|
+
|
|
238
|
+
ws[cell_ref] = cell;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
|
|
242
|
+
return ws;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
function Workbook() {
|
|
246
|
+
if (!(this instanceof Workbook)) return new Workbook();
|
|
247
|
+
this.SheetNames = [];
|
|
248
|
+
this.Sheets = {};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function s2ab(s) {
|
|
252
|
+
var buf = new ArrayBuffer(s.length);
|
|
253
|
+
var view = new Uint8Array(buf);
|
|
254
|
+
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
|
|
255
|
+
return buf;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function export_table_to_excel(id) {
|
|
259
|
+
var theTable = document.getElementById(id);
|
|
260
|
+
console.log('a')
|
|
261
|
+
var oo = generateArray(theTable);
|
|
262
|
+
var ranges = oo[1];
|
|
263
|
+
|
|
264
|
+
/* original data */
|
|
265
|
+
var data = oo[0];
|
|
266
|
+
var ws_name = "SheetJS";
|
|
267
|
+
console.log(data);
|
|
268
|
+
|
|
269
|
+
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
|
|
270
|
+
|
|
271
|
+
/* add ranges to worksheet */
|
|
272
|
+
// ws['!cols'] = ['apple', 'banan'];
|
|
273
|
+
ws['!merges'] = ranges;
|
|
274
|
+
|
|
275
|
+
/* add worksheet to workbook */
|
|
276
|
+
wb.SheetNames.push(ws_name);
|
|
277
|
+
wb.Sheets[ws_name] = ws;
|
|
278
|
+
|
|
279
|
+
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
|
|
280
|
+
|
|
281
|
+
saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx")
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function formatJson(names,jsonData) {
|
|
285
|
+
return jsonData.map(v => names.map(j =>v[j]));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function exportExcel(config, jsonData, sheetName, defaultTitle) {
|
|
289
|
+
/* original data */
|
|
290
|
+
var th = [];
|
|
291
|
+
var names = [];
|
|
292
|
+
config.forEach(el => {
|
|
293
|
+
if (el.label) {
|
|
294
|
+
th.push(el.label);
|
|
295
|
+
} else {
|
|
296
|
+
th.push(el.name);
|
|
297
|
+
}
|
|
298
|
+
names.push(el.name);
|
|
299
|
+
})
|
|
300
|
+
|
|
301
|
+
var data = formatJson(names,jsonData);
|
|
302
|
+
data.unshift(th);
|
|
303
|
+
var ws_name = "SheetJS";
|
|
304
|
+
if (sheetName) {
|
|
305
|
+
ws_name = sheetName;
|
|
306
|
+
}
|
|
307
|
+
var wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
|
|
308
|
+
|
|
309
|
+
/* add worksheet to workbook */
|
|
310
|
+
wb.SheetNames.push(ws_name);
|
|
311
|
+
wb.Sheets[ws_name] = ws;
|
|
312
|
+
|
|
313
|
+
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
|
|
314
|
+
var title = defaultTitle || '列表'
|
|
315
|
+
saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx")
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export function exportMultiSheetExcel(obj, defaultTitle) {
|
|
319
|
+
var wb = new Workbook();
|
|
320
|
+
var th = [];
|
|
321
|
+
var names = [];
|
|
322
|
+
var ws_name = "";
|
|
323
|
+
obj.forEach((tmp, index) => {
|
|
324
|
+
th = [];
|
|
325
|
+
names = [];
|
|
326
|
+
tmp.config.forEach(el => {
|
|
327
|
+
if (el.label) {
|
|
328
|
+
th.push(el.label);
|
|
329
|
+
} else {
|
|
330
|
+
th.push(el.name);
|
|
331
|
+
}
|
|
332
|
+
names.push(el.name);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
var data = formatJson(names,tmp.data);
|
|
336
|
+
data.unshift(th);
|
|
337
|
+
ws_name = "SheetJS" + index;
|
|
338
|
+
if (tmp.sheetName) {
|
|
339
|
+
ws_name = tmp.sheetName;
|
|
340
|
+
}
|
|
341
|
+
wb.SheetNames.push(ws_name);
|
|
342
|
+
wb.Sheets[ws_name] = sheet_from_array_of_arrays(data);
|
|
343
|
+
});
|
|
344
|
+
var wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
|
|
345
|
+
var title = defaultTitle || '列表';
|
|
346
|
+
saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx");
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function getExcelCellConfig(config) {
|
|
350
|
+
let pro = {};
|
|
351
|
+
pro.alignment = {
|
|
352
|
+
vertical: 'center',
|
|
353
|
+
wrapText: true
|
|
354
|
+
};
|
|
355
|
+
if (config.type === 'NumberBox') {
|
|
356
|
+
pro.alignment.horizontal = 'right';
|
|
357
|
+
if (config.format && config.format.length > 1) {
|
|
358
|
+
let numType = config.format[0];
|
|
359
|
+
let precisionNum = config.format[1];
|
|
360
|
+
let excelstyle = '0';
|
|
361
|
+
if (numType === 'n' || numType === 'p') {
|
|
362
|
+
excelstyle = '0';
|
|
363
|
+
} else if (numType === 'c') {
|
|
364
|
+
excelstyle = '¥#,##0';
|
|
365
|
+
}
|
|
366
|
+
let tempStyle = '';
|
|
367
|
+
if (Number(precisionNum) > 0) {
|
|
368
|
+
for (let i = 0; i < Number(precisionNum); i++) {
|
|
369
|
+
tempStyle = tempStyle + '0';
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (tempStyle) {
|
|
373
|
+
excelstyle = excelstyle + '.'+ tempStyle;
|
|
374
|
+
}
|
|
375
|
+
if (numType === 'p') {
|
|
376
|
+
excelstyle = excelstyle + '%';
|
|
377
|
+
}
|
|
378
|
+
pro.numFmt = excelstyle;
|
|
379
|
+
}
|
|
380
|
+
pro.t = 'n';
|
|
381
|
+
} else if (config.type === 'DataBox') {
|
|
382
|
+
pro.alignment.horizontal = 'center';
|
|
383
|
+
let excelstyle = 'yyyy年m月d日';
|
|
384
|
+
if (config.vtype === 'datetime') {
|
|
385
|
+
excelstyle = 'yyyy年m月d日 h:mm:ss';
|
|
386
|
+
}
|
|
387
|
+
pro.numFmt = excelstyle;
|
|
388
|
+
pro.t = 'd';
|
|
389
|
+
} else {
|
|
390
|
+
pro.alignment.horizontal = 'left';
|
|
391
|
+
pro.numFmt='@';
|
|
392
|
+
pro.t = 's';
|
|
393
|
+
}
|
|
394
|
+
return pro;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
function getHeadPro(names, heads, excelData, mergelist) {
|
|
399
|
+
let sIndex = 0;
|
|
400
|
+
for (let i=0;i<heads.length;i++) {
|
|
401
|
+
let temp = new Array(names.length).fill('');
|
|
402
|
+
sIndex = 0;
|
|
403
|
+
|
|
404
|
+
let preFsIndes = '';
|
|
405
|
+
for (let j=0;j<heads[i].length;j++) {
|
|
406
|
+
if (heads[i][j].fIndex || heads[i][j].fIndex === 0) {
|
|
407
|
+
let findex = i- 1;
|
|
408
|
+
let fsIndex = heads[findex][heads[i][j].fIndex].sIndex;
|
|
409
|
+
if (preFsIndes !== fsIndex) {
|
|
410
|
+
sIndex = fsIndex;
|
|
411
|
+
preFsIndes = fsIndex;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
temp[sIndex] = heads[i][j].label;
|
|
415
|
+
heads[i][j].sIndex = sIndex;
|
|
416
|
+
let tempMerge = {};
|
|
417
|
+
tempMerge.s = {};
|
|
418
|
+
tempMerge.s.r = i;
|
|
419
|
+
tempMerge.s.c = sIndex;
|
|
420
|
+
tempMerge.e = {};
|
|
421
|
+
tempMerge.e.r = tempMerge.s.r;
|
|
422
|
+
sIndex = sIndex + heads[i][j].num;
|
|
423
|
+
if (heads[i][j].num === 1) {
|
|
424
|
+
if (i === 0) {
|
|
425
|
+
tempMerge.e.r = heads.length -1;
|
|
426
|
+
tempMerge.e.c = tempMerge.s.c;
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
tempMerge.e.c = sIndex - 1;
|
|
430
|
+
}
|
|
431
|
+
if (i !== heads.length -1) {
|
|
432
|
+
mergelist.push(tempMerge);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
excelData.push(temp);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
function getExportConfig (config, head, n, names, fIndex) {
|
|
439
|
+
if (config instanceof Array) {
|
|
440
|
+
config.forEach(el => {
|
|
441
|
+
getExportConfig(el,head, n, names, fIndex);
|
|
442
|
+
});
|
|
443
|
+
} else {
|
|
444
|
+
if (config.visible !== false) {
|
|
445
|
+
let obj = {};
|
|
446
|
+
obj.label = config.label;
|
|
447
|
+
obj.num = 1;
|
|
448
|
+
let childRenNum = 0;
|
|
449
|
+
let tempIndex = head[n].length;
|
|
450
|
+
if (config.children && config.children.length > 0) {
|
|
451
|
+
config.children.forEach(el => {
|
|
452
|
+
let num = getExportConfig(el, head, n+1, names, tempIndex);
|
|
453
|
+
childRenNum = childRenNum + num;
|
|
454
|
+
});
|
|
455
|
+
obj.num = childRenNum;
|
|
456
|
+
} else {
|
|
457
|
+
if (config.name) {
|
|
458
|
+
obj.name = config.name;
|
|
459
|
+
let width = 100;
|
|
460
|
+
if (config.width) {
|
|
461
|
+
if (config.width > 100) {
|
|
462
|
+
width = config.width;
|
|
463
|
+
}
|
|
464
|
+
} else if (config.maxWidth) {
|
|
465
|
+
if (config.maxWidth > 100) {
|
|
466
|
+
width = config.maxWidth;
|
|
467
|
+
}
|
|
468
|
+
} else if (config.minWidth) {
|
|
469
|
+
if (config.minWidth > 100) {
|
|
470
|
+
width = config.minWidth;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
obj.width = width;
|
|
474
|
+
obj.excelPro = getExcelCellConfig(config);
|
|
475
|
+
names.push(obj);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (fIndex||fIndex === 0) {
|
|
479
|
+
if (n !== 0) {
|
|
480
|
+
obj.fIndex = fIndex;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
head[n].push(obj);
|
|
484
|
+
return obj.num;
|
|
485
|
+
} else {
|
|
486
|
+
return 0;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
export function exportExcelStyle(config, data, headNum, filename) {
|
|
492
|
+
let head = [];
|
|
493
|
+
for (let i=0;i<headNum; i++) {
|
|
494
|
+
head.push([]);
|
|
495
|
+
}
|
|
496
|
+
let num = 0;
|
|
497
|
+
let names = [];
|
|
498
|
+
getExportConfig(config,head,num,names);
|
|
499
|
+
let mergeslist = [];
|
|
500
|
+
// 需要导出的数据
|
|
501
|
+
let excelData = [];
|
|
502
|
+
getHeadPro(names, head, excelData, mergeslist);
|
|
503
|
+
let widthCol = [];
|
|
504
|
+
names.forEach(el => {
|
|
505
|
+
widthCol.push({wpx: el.width});
|
|
506
|
+
});
|
|
507
|
+
data.forEach(el => {
|
|
508
|
+
let temp = [];
|
|
509
|
+
names.forEach(el2 => {
|
|
510
|
+
if (el2.excelPro.t === 'n') {
|
|
511
|
+
temp.push(Number(el[el2.name]));
|
|
512
|
+
} else if (el2.excelPro.t === 'd') {
|
|
513
|
+
let value = datenum(new Date(el[el2.name]));
|
|
514
|
+
temp.push(value);
|
|
515
|
+
el2.excelPro.t = 'n';
|
|
516
|
+
} else {
|
|
517
|
+
temp.push(el[el2.name]);
|
|
518
|
+
}
|
|
519
|
+
})
|
|
520
|
+
excelData.push(temp);
|
|
521
|
+
});
|
|
522
|
+
let namesNum = names.length;
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
let defaultHeadCellStyle = {
|
|
526
|
+
// 字体
|
|
527
|
+
font: {
|
|
528
|
+
name: '宋体',
|
|
529
|
+
sz: 9,
|
|
530
|
+
bold: true
|
|
531
|
+
},
|
|
532
|
+
border: {
|
|
533
|
+
top: {
|
|
534
|
+
style: 'thin'
|
|
535
|
+
},
|
|
536
|
+
bottom: {
|
|
537
|
+
style: 'thin'
|
|
538
|
+
},
|
|
539
|
+
left: {
|
|
540
|
+
style: 'thin'
|
|
541
|
+
},
|
|
542
|
+
right: {
|
|
543
|
+
style: 'thin'
|
|
544
|
+
}
|
|
545
|
+
},
|
|
546
|
+
alignment: {
|
|
547
|
+
horizontal: 'center',
|
|
548
|
+
vertical: 'center',
|
|
549
|
+
wrapText: true
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
let defaultCellStyle = {
|
|
553
|
+
// 字体
|
|
554
|
+
font: {
|
|
555
|
+
name: '宋体',
|
|
556
|
+
sz: 9
|
|
557
|
+
},
|
|
558
|
+
border: {
|
|
559
|
+
top: {
|
|
560
|
+
style: 'thin'
|
|
561
|
+
},
|
|
562
|
+
bottom: {
|
|
563
|
+
style: 'thin'
|
|
564
|
+
},
|
|
565
|
+
left: {
|
|
566
|
+
style: 'thin'
|
|
567
|
+
},
|
|
568
|
+
right: {
|
|
569
|
+
style: 'thin'
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
};
|
|
573
|
+
|
|
574
|
+
// 导出的excel文件名
|
|
575
|
+
let tempfilename = 'example.xlsx'
|
|
576
|
+
if (filename) {
|
|
577
|
+
tempfilename = filename;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// Excel第一个sheet的名称
|
|
581
|
+
const ws_name = 'Sheet1'
|
|
582
|
+
const wb = XLSX.utils.book_new();
|
|
583
|
+
const ws = XLSX.utils.aoa_to_sheet(excelData)
|
|
584
|
+
XLSX.utils.book_append_sheet(wb, ws, ws_name) // 将数据添加到工作薄
|
|
585
|
+
|
|
586
|
+
|
|
587
|
+
// 设置标题行单元格合并
|
|
588
|
+
// s即start, e即end, r即row, c即column
|
|
589
|
+
// 合并从--0行0列开始,到0行3列
|
|
590
|
+
if (mergeslist.length > 0) {
|
|
591
|
+
ws['!merges'] = mergeslist
|
|
592
|
+
}
|
|
593
|
+
let x=0;
|
|
594
|
+
// 可以遍历全部单元格,进行样式设置
|
|
595
|
+
for (let i in ws) {
|
|
596
|
+
if (i === '!merges' || i === '!ref' || i === '!cols') continue;
|
|
597
|
+
ws[i].s = defaultHeadCellStyle
|
|
598
|
+
if (x < namesNum*headNum) {
|
|
599
|
+
ws[i].s = defaultHeadCellStyle
|
|
600
|
+
} else {
|
|
601
|
+
let pro =Object.assign({},{},defaultCellStyle);
|
|
602
|
+
let num = x%namesNum;
|
|
603
|
+
Object.assign(pro,names[num].excelPro);
|
|
604
|
+
ws[i].s = pro
|
|
605
|
+
}
|
|
606
|
+
x++;
|
|
607
|
+
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// 设置单元格宽度
|
|
611
|
+
ws['!cols'] = widthCol;
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
// 导出Excel, 注意这里用到的是XLSXS对象
|
|
615
|
+
let wbout = XLSXS.write(wb, {
|
|
616
|
+
bookType: 'xlsx',
|
|
617
|
+
bookSST: false,
|
|
618
|
+
type: 'binary'
|
|
619
|
+
})
|
|
620
|
+
saveAs(
|
|
621
|
+
new Blob([s2ab(wbout)], {
|
|
622
|
+
type: 'application/octet-stream'
|
|
623
|
+
}),
|
|
624
|
+
tempfilename
|
|
625
|
+
)
|
|
626
|
+
}
|
|
627
|
+
|