vue2-client 1.4.6 → 1.4.8

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +355 -347
  2. package/index.js +30 -30
  3. package/package.json +78 -78
  4. package/src/base-client/components/common/AddressSearchCombobox/AddressSearchCombobox.vue +225 -225
  5. package/src/base-client/components/common/CreateQuery/CreateQuery.vue +5 -3
  6. package/src/base-client/components/common/CreateQuery/CreateQueryItem.vue +777 -777
  7. package/src/base-client/components/common/CreateSimpleFormQuery/CreateSimpleFormQueryItem.vue +553 -553
  8. package/src/base-client/components/common/FormGroupQuery/FormGroupQuery.vue +165 -165
  9. package/src/base-client/components/common/JSONToTree/jsontotree.vue +275 -275
  10. package/src/base-client/components/common/XAddForm/XAddForm.vue +354 -354
  11. package/src/base-client/components/common/XAddNativeForm/XAddNativeForm.vue +327 -327
  12. package/src/base-client/components/common/XCard/XCard.vue +64 -64
  13. package/src/base-client/components/common/XForm/XForm.vue +274 -274
  14. package/src/base-client/components/common/XForm/XFormItem.vue +389 -389
  15. package/src/base-client/components/common/XFormTable/XFormTable.vue +547 -546
  16. package/src/base-client/components/common/XFormTable/index.md +96 -96
  17. package/src/base-client/components/common/XTable/XTable.vue +262 -262
  18. package/src/base-client/components/system/QueryParamsDetailsView/QueryParamsDetailsView.vue +281 -281
  19. package/src/base-client/components/ticket/TicketDetailsView/TicketDetailsView.vue +807 -807
  20. package/src/base-client/components/ticket/TicketDetailsView/index.md +29 -29
  21. package/src/base-client/components/ticket/TicketDetailsView/part/TicketDetailsFlow.vue +260 -260
  22. package/src/base-client/components/ticket/TicketSubmitSuccessView/TicketSubmitSuccessView.vue +532 -532
  23. package/src/base-client/components/ticket/TicketSubmitSuccessView/index.md +29 -29
  24. package/src/base-client/plugins/AppData.js +69 -69
  25. package/src/base-client/plugins/GetLoginInfoService.js +179 -179
  26. package/src/base-client/plugins/PagedList.js +177 -177
  27. package/src/base-client/plugins/compatible/LoginServiceOA.js +20 -20
  28. package/src/base-client/plugins/i18n-extend.js +32 -32
  29. package/src/components/Ellipsis/index.md +38 -38
  30. package/src/components/NumberInfo/index.md +43 -43
  31. package/src/components/STable/README.md +341 -341
  32. package/src/components/STable/index.js +318 -318
  33. package/src/components/Trend/index.md +45 -45
  34. package/src/components/checkbox/ColorCheckbox.vue +157 -157
  35. package/src/components/checkbox/ImgCheckbox.vue +163 -163
  36. package/src/components/exception/ExceptionPage.vue +70 -70
  37. package/src/components/form/FormRow.vue +52 -52
  38. package/src/components/index.js +36 -36
  39. package/src/components/menu/SideMenu.vue +62 -62
  40. package/src/components/menu/menu.js +273 -273
  41. package/src/components/setting/Setting.vue +235 -235
  42. package/src/components/table/StandardTable.vue +141 -141
  43. package/src/components/table/advance/ActionColumns.vue +158 -158
  44. package/src/components/table/advance/SearchArea.vue +355 -355
  45. package/src/components/tool/AStepItem.vue +60 -60
  46. package/src/components/tool/AvatarList.vue +68 -68
  47. package/src/components/tool/Drawer.vue +142 -142
  48. package/src/components/tool/TagSelect.vue +83 -83
  49. package/src/components/transition/PageToggleTransition.vue +97 -97
  50. package/src/config/replacer/resolve.config.js +67 -67
  51. package/src/layouts/AdminLayout.vue +174 -174
  52. package/src/layouts/header/AdminHeader.vue +104 -104
  53. package/src/layouts/header/HeaderNotice.vue +167 -167
  54. package/src/layouts/header/HeaderSearch.vue +67 -67
  55. package/src/layouts/header/InstitutionDetail.vue +181 -181
  56. package/src/layouts/tabs/TabsHead.vue +190 -190
  57. package/src/layouts/tabs/TabsView.vue +379 -379
  58. package/src/mock/goods/index.js +108 -108
  59. package/src/pages/CreateQueryPage.vue +65 -65
  60. package/src/pages/report/ReportTable.js +124 -124
  61. package/src/pages/report/ReportTableHome.vue +28 -28
  62. package/src/pages/resourceManage/orgListManage.vue +98 -98
  63. package/src/pages/system/dictionary/index.vue +43 -43
  64. package/src/pages/system/file/index.vue +317 -317
  65. package/src/pages/system/queryParams/index.vue +43 -43
  66. package/src/router/async/config.async.js +27 -27
  67. package/src/router/async/router.map.js +56 -56
  68. package/src/router/index.js +27 -27
  69. package/src/services/api/DictionaryDetailsViewApi.js +6 -6
  70. package/src/services/api/LogDetailsViewApi.js +10 -10
  71. package/src/services/api/QueryParamsDetailsViewApi.js +6 -6
  72. package/src/services/api/TicketDetailsViewApi.js +34 -34
  73. package/src/services/api/commonTempTable.js +10 -10
  74. package/src/services/api/index.js +17 -17
  75. package/src/services/api/manage.js +8 -8
  76. package/src/store/mutation-types.js +2 -2
  77. package/src/theme/default/nprogress.less +76 -76
  78. package/src/theme/default/style.less +47 -47
  79. package/src/utils/colors.js +103 -103
  80. package/src/utils/excel/Blob.js +180 -180
  81. package/src/utils/excel/Export2Excel.js +141 -141
  82. package/src/utils/formatter.js +68 -68
  83. package/src/utils/i18n.js +80 -80
  84. package/src/utils/request.js +225 -225
  85. package/src/utils/routerUtil.js +364 -364
  86. package/src/utils/theme-color-replacer-extend.js +91 -91
  87. package/src/utils/themeUtil.js +100 -100
  88. package/src/utils/util.js +230 -230
  89. package/vue.config.js +99 -99
@@ -1,180 +1,180 @@
1
- /* eslint-disable */
2
- /* Blob.js
3
- * A Blob implementation.
4
- * 2014-05-27
5
- *
6
- * By Eli Grey, http://eligrey.com
7
- * By Devin Samarin, https://github.com/eboyjr
8
- * License: X11/MIT
9
- * See LICENSE.md
10
- */
11
-
12
- /*global self, unescape */
13
- /*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
14
- plusplus: true */
15
-
16
- /*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
17
-
18
- (function (view) {
19
- "use strict";
20
-
21
- view.URL = view.URL || view.webkitURL;
22
-
23
- if (view.Blob && view.URL) {
24
- try {
25
- new Blob;
26
- return;
27
- } catch (e) {
28
- }
29
- }
30
-
31
- // Internally we use a BlobBuilder implementation to base Blob off of
32
- // in order to support older browsers that only have BlobBuilder
33
- const BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function (view) {
34
- const get_class = function (object) {
35
- return Object.prototype.toString.call(object).match(/^\[object\s(.*)]$/)[1];
36
- }
37
- , FakeBlobBuilder = function BlobBuilder() {
38
- this.data = [];
39
- }
40
- , FakeBlob = function Blob(data, type, encoding) {
41
- this.data = data;
42
- this.size = data.length;
43
- this.type = type;
44
- this.encoding = encoding;
45
- }
46
- , FBB_proto = FakeBlobBuilder.prototype
47
- , FB_proto = FakeBlob.prototype
48
- , FileReaderSync = view.FileReaderSync
49
- , FileException = function (type) {
50
- this.code = this[this.name = type];
51
- }
52
- , file_ex_codes = (
53
- "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
54
- + "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
55
- ).split(" ")
56
- ;let file_ex_code = file_ex_codes.length
57
- ;const real_URL = view.URL || view.webkitURL || view
58
- , real_create_object_URL = real_URL.createObjectURL
59
- , real_revoke_object_URL = real_URL.revokeObjectURL
60
- ;let URL = real_URL
61
- ;const btoa = view.btoa
62
- , atob = view.atob
63
-
64
- , ArrayBuffer = view.ArrayBuffer
65
- , Uint8Array = view.Uint8Array
66
- ;
67
- FakeBlob.fake = FB_proto.fake = true;
68
- while (file_ex_code--) {
69
- FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
70
- }
71
- if (!real_URL.createObjectURL) {
72
- URL = view.URL = {};
73
- }
74
- URL.createObjectURL = function (blob) {
75
- let type = blob.type
76
- , data_URI_header
77
- ;
78
- if (type === null) {
79
- type = "application/octet-stream";
80
- }
81
- if (blob instanceof FakeBlob) {
82
- data_URI_header = "data:" + type;
83
- if (blob.encoding === "base64") {
84
- return data_URI_header + ";base64," + blob.data;
85
- } else if (blob.encoding === "URI") {
86
- return data_URI_header + "," + decodeURIComponent(blob.data);
87
- }
88
- if (btoa) {
89
- return data_URI_header + ";base64," + btoa(blob.data);
90
- } else {
91
- return data_URI_header + "," + encodeURIComponent(blob.data);
92
- }
93
- } else if (real_create_object_URL) {
94
- return real_create_object_URL.call(real_URL, blob);
95
- }
96
- };
97
- URL.revokeObjectURL = function (object_URL) {
98
- if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
99
- real_revoke_object_URL.call(real_URL, object_URL);
100
- }
101
- };
102
- FBB_proto.append = function (data/*, endings*/) {
103
- const bb = this.data;
104
- // decode data to a binary string
105
- if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
106
- let str = ""
107
- ;const buf = new Uint8Array(data)
108
- ;let i = 0
109
- ;const buf_len = buf.length
110
- ;
111
- for (; i < buf_len; i++) {
112
- str += String.fromCharCode(buf[i]);
113
- }
114
- bb.push(str);
115
- } else if (get_class(data) === "Blob" || get_class(data) === "File") {
116
- if (FileReaderSync) {
117
- const fr = new FileReaderSync;
118
- bb.push(fr.readAsBinaryString(data));
119
- } else {
120
- // async FileReader won't work as BlobBuilder is sync
121
- throw new FileException("NOT_READABLE_ERR");
122
- }
123
- } else if (data instanceof FakeBlob) {
124
- if (data.encoding === "base64" && atob) {
125
- bb.push(atob(data.data));
126
- } else if (data.encoding === "URI") {
127
- bb.push(decodeURIComponent(data.data));
128
- } else if (data.encoding === "raw") {
129
- bb.push(data.data);
130
- }
131
- } else {
132
- if (typeof data !== "string") {
133
- data += ""; // convert unsupported types to strings
134
- }
135
- // decode UTF-16 to binary string
136
- bb.push(unescape(encodeURIComponent(data)));
137
- }
138
- };
139
- FBB_proto.getBlob = function (type) {
140
- if (!arguments.length) {
141
- type = null;
142
- }
143
- return new FakeBlob(this.data.join(""), type, "raw");
144
- };
145
- FBB_proto.toString = function () {
146
- return "[object BlobBuilder]";
147
- };
148
- FB_proto.slice = function (start, end, type) {
149
- const args = arguments.length;
150
- if (args < 3) {
151
- type = null;
152
- }
153
- return new FakeBlob(
154
- this.data.slice(start, args > 1 ? end : this.data.length)
155
- , type
156
- , this.encoding
157
- );
158
- };
159
- FB_proto.toString = function () {
160
- return "[object Blob]";
161
- };
162
- FB_proto.close = function () {
163
- this.size = this.data.length = 0;
164
- };
165
- return FakeBlobBuilder;
166
- }(view));
167
-
168
- view.Blob = function Blob(blobParts, options) {
169
- const type = options ? (options.type || "") : "";
170
- const builder = new BlobBuilder();
171
- if (blobParts) {
172
- let i = 0;
173
- const len = blobParts.length;
174
- for (; i < len; i++) {
175
- builder.append(blobParts[i]);
176
- }
177
- }
178
- return builder.getBlob(type);
179
- };
180
- }(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
1
+ /* eslint-disable */
2
+ /* Blob.js
3
+ * A Blob implementation.
4
+ * 2014-05-27
5
+ *
6
+ * By Eli Grey, http://eligrey.com
7
+ * By Devin Samarin, https://github.com/eboyjr
8
+ * License: X11/MIT
9
+ * See LICENSE.md
10
+ */
11
+
12
+ /*global self, unescape */
13
+ /*jslint bitwise: true, regexp: true, confusion: true, es5: true, vars: true, white: true,
14
+ plusplus: true */
15
+
16
+ /*! @source http://purl.eligrey.com/github/Blob.js/blob/master/Blob.js */
17
+
18
+ (function (view) {
19
+ "use strict";
20
+
21
+ view.URL = view.URL || view.webkitURL;
22
+
23
+ if (view.Blob && view.URL) {
24
+ try {
25
+ new Blob;
26
+ return;
27
+ } catch (e) {
28
+ }
29
+ }
30
+
31
+ // Internally we use a BlobBuilder implementation to base Blob off of
32
+ // in order to support older browsers that only have BlobBuilder
33
+ const BlobBuilder = view.BlobBuilder || view.WebKitBlobBuilder || view.MozBlobBuilder || (function (view) {
34
+ const get_class = function (object) {
35
+ return Object.prototype.toString.call(object).match(/^\[object\s(.*)]$/)[1];
36
+ }
37
+ , FakeBlobBuilder = function BlobBuilder() {
38
+ this.data = [];
39
+ }
40
+ , FakeBlob = function Blob(data, type, encoding) {
41
+ this.data = data;
42
+ this.size = data.length;
43
+ this.type = type;
44
+ this.encoding = encoding;
45
+ }
46
+ , FBB_proto = FakeBlobBuilder.prototype
47
+ , FB_proto = FakeBlob.prototype
48
+ , FileReaderSync = view.FileReaderSync
49
+ , FileException = function (type) {
50
+ this.code = this[this.name = type];
51
+ }
52
+ , file_ex_codes = (
53
+ "NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR "
54
+ + "NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR"
55
+ ).split(" ")
56
+ ;let file_ex_code = file_ex_codes.length
57
+ ;const real_URL = view.URL || view.webkitURL || view
58
+ , real_create_object_URL = real_URL.createObjectURL
59
+ , real_revoke_object_URL = real_URL.revokeObjectURL
60
+ ;let URL = real_URL
61
+ ;const btoa = view.btoa
62
+ , atob = view.atob
63
+
64
+ , ArrayBuffer = view.ArrayBuffer
65
+ , Uint8Array = view.Uint8Array
66
+ ;
67
+ FakeBlob.fake = FB_proto.fake = true;
68
+ while (file_ex_code--) {
69
+ FileException.prototype[file_ex_codes[file_ex_code]] = file_ex_code + 1;
70
+ }
71
+ if (!real_URL.createObjectURL) {
72
+ URL = view.URL = {};
73
+ }
74
+ URL.createObjectURL = function (blob) {
75
+ let type = blob.type
76
+ , data_URI_header
77
+ ;
78
+ if (type === null) {
79
+ type = "application/octet-stream";
80
+ }
81
+ if (blob instanceof FakeBlob) {
82
+ data_URI_header = "data:" + type;
83
+ if (blob.encoding === "base64") {
84
+ return data_URI_header + ";base64," + blob.data;
85
+ } else if (blob.encoding === "URI") {
86
+ return data_URI_header + "," + decodeURIComponent(blob.data);
87
+ }
88
+ if (btoa) {
89
+ return data_URI_header + ";base64," + btoa(blob.data);
90
+ } else {
91
+ return data_URI_header + "," + encodeURIComponent(blob.data);
92
+ }
93
+ } else if (real_create_object_URL) {
94
+ return real_create_object_URL.call(real_URL, blob);
95
+ }
96
+ };
97
+ URL.revokeObjectURL = function (object_URL) {
98
+ if (object_URL.substring(0, 5) !== "data:" && real_revoke_object_URL) {
99
+ real_revoke_object_URL.call(real_URL, object_URL);
100
+ }
101
+ };
102
+ FBB_proto.append = function (data/*, endings*/) {
103
+ const bb = this.data;
104
+ // decode data to a binary string
105
+ if (Uint8Array && (data instanceof ArrayBuffer || data instanceof Uint8Array)) {
106
+ let str = ""
107
+ ;const buf = new Uint8Array(data)
108
+ ;let i = 0
109
+ ;const buf_len = buf.length
110
+ ;
111
+ for (; i < buf_len; i++) {
112
+ str += String.fromCharCode(buf[i]);
113
+ }
114
+ bb.push(str);
115
+ } else if (get_class(data) === "Blob" || get_class(data) === "File") {
116
+ if (FileReaderSync) {
117
+ const fr = new FileReaderSync;
118
+ bb.push(fr.readAsBinaryString(data));
119
+ } else {
120
+ // async FileReader won't work as BlobBuilder is sync
121
+ throw new FileException("NOT_READABLE_ERR");
122
+ }
123
+ } else if (data instanceof FakeBlob) {
124
+ if (data.encoding === "base64" && atob) {
125
+ bb.push(atob(data.data));
126
+ } else if (data.encoding === "URI") {
127
+ bb.push(decodeURIComponent(data.data));
128
+ } else if (data.encoding === "raw") {
129
+ bb.push(data.data);
130
+ }
131
+ } else {
132
+ if (typeof data !== "string") {
133
+ data += ""; // convert unsupported types to strings
134
+ }
135
+ // decode UTF-16 to binary string
136
+ bb.push(unescape(encodeURIComponent(data)));
137
+ }
138
+ };
139
+ FBB_proto.getBlob = function (type) {
140
+ if (!arguments.length) {
141
+ type = null;
142
+ }
143
+ return new FakeBlob(this.data.join(""), type, "raw");
144
+ };
145
+ FBB_proto.toString = function () {
146
+ return "[object BlobBuilder]";
147
+ };
148
+ FB_proto.slice = function (start, end, type) {
149
+ const args = arguments.length;
150
+ if (args < 3) {
151
+ type = null;
152
+ }
153
+ return new FakeBlob(
154
+ this.data.slice(start, args > 1 ? end : this.data.length)
155
+ , type
156
+ , this.encoding
157
+ );
158
+ };
159
+ FB_proto.toString = function () {
160
+ return "[object Blob]";
161
+ };
162
+ FB_proto.close = function () {
163
+ this.size = this.data.length = 0;
164
+ };
165
+ return FakeBlobBuilder;
166
+ }(view));
167
+
168
+ view.Blob = function Blob(blobParts, options) {
169
+ const type = options ? (options.type || "") : "";
170
+ const builder = new BlobBuilder();
171
+ if (blobParts) {
172
+ let i = 0;
173
+ const len = blobParts.length;
174
+ for (; i < len; i++) {
175
+ builder.append(blobParts[i]);
176
+ }
177
+ }
178
+ return builder.getBlob(type);
179
+ };
180
+ }(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content || this));
@@ -1,141 +1,141 @@
1
- /* eslint-disable */
2
- require('script-loader!file-saver');
3
- require('./Blob.js');
4
- require('script-loader!xlsx/dist/xlsx.core.min');
5
-
6
- function generateArray(table) {
7
- const out = [];
8
- const rows = table.querySelectorAll('tr');
9
- const ranges = [];
10
- for (let R = 0; R < rows.length; ++R) {
11
- const outRow = [];
12
- const row = rows[R];
13
- const columns = row.querySelectorAll('td');
14
- for (let C = 0; C < columns.length; ++C) {
15
- const cell = columns[C];
16
- let colspan = cell.getAttribute('colspan');
17
- let rowspan = cell.getAttribute('rowspan');
18
- let cellValue = cell.innerText;
19
- if (cellValue !== "" && cellValue === +cellValue) cellValue = +cellValue;
20
-
21
- //Skip ranges
22
- ranges.forEach(function (range) {
23
- if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
24
- for (let i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
25
- }
26
- });
27
-
28
- //Handle Row Span
29
- if (rowspan || colspan) {
30
- rowspan = rowspan || 1;
31
- colspan = colspan || 1;
32
- ranges.push({s: {r: R, c: outRow.length}, e: {r: R + rowspan - 1, c: outRow.length + colspan - 1}});
33
- }
34
-
35
- //Handle Value
36
- outRow.push(cellValue !== "" ? cellValue : null);
37
-
38
- //Handle Colspan
39
- if (colspan) for (let k = 0; k < colspan - 1; ++k) outRow.push(null);
40
- }
41
- out.push(outRow);
42
- }
43
- return [out, ranges];
44
- }
45
-
46
- function datenum(v, date1904) {
47
- if (date1904) v += 1462;
48
- const epoch = Date.parse(v);
49
- return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
50
- }
51
-
52
- function sheet_from_array_of_arrays(data, opts) {
53
- const ws = {};
54
- const range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}};
55
- for (let R = 0; R !== data.length; ++R) {
56
- for (let C = 0; C !== data[R].length; ++C) {
57
- if (range.s.r > R) range.s.r = R;
58
- if (range.s.c > C) range.s.c = C;
59
- if (range.e.r < R) range.e.r = R;
60
- if (range.e.c < C) range.e.c = C;
61
- const cell = {v: data[R][C]};
62
- if (cell.v == null) continue;
63
- const cell_ref = XLSX.utils.encode_cell({c: C, r: R});
64
-
65
- if (typeof cell.v === 'number') cell.t = 'n';
66
- else if (typeof cell.v === 'boolean') cell.t = 'b';
67
- else if (cell.v instanceof Date) {
68
- cell.t = 'n';
69
- cell.z = XLSX.SSF._table[14];
70
- cell.v = datenum(cell.v);
71
- } else cell.t = 's';
72
-
73
- ws[cell_ref] = cell;
74
- }
75
- }
76
- if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
77
- return ws;
78
- }
79
-
80
- function Workbook() {
81
- if (!(this instanceof Workbook)) return new Workbook();
82
- this.SheetNames = [];
83
- this.Sheets = {};
84
- }
85
-
86
- function s2ab(s) {
87
- const buf = new ArrayBuffer(s.length);
88
- const view = new Uint8Array(buf);
89
- for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
90
- return buf;
91
- }
92
-
93
- export function exportTable(id) {
94
- const theTable = document.getElementById(id);
95
- console.log('a')
96
- const oo = generateArray(theTable);
97
- const ranges = oo[1];
98
-
99
- /* original data */
100
- const data = oo[0];
101
- const ws_name = "SheetJS";
102
- console.log(data);
103
-
104
- const wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
105
-
106
- /* add ranges to worksheet */
107
- // ws['!cols'] = ['apple', 'banan'];
108
- ws['!merges'] = ranges;
109
-
110
- /* add worksheet to workbook */
111
- wb.SheetNames.push(ws_name);
112
- wb.Sheets[ws_name] = ws;
113
-
114
- const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
115
-
116
- saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx")
117
- }
118
-
119
- function formatJson(jsonData) {
120
- console.log(jsonData)
121
- }
122
-
123
- export function exportJson(th, jsonData, defaultTitle) {
124
-
125
- /* original data */
126
-
127
- const data = jsonData;
128
- data.unshift(th);
129
- const ws_name = "SheetJS";
130
-
131
- const wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
132
-
133
-
134
- /* add worksheet to workbook */
135
- wb.SheetNames.push(ws_name);
136
- wb.Sheets[ws_name] = ws;
137
-
138
- const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
139
- const title = defaultTitle || '列表';
140
- saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx")
141
- }
1
+ /* eslint-disable */
2
+ require('script-loader!file-saver');
3
+ require('./Blob.js');
4
+ require('script-loader!xlsx/dist/xlsx.core.min');
5
+
6
+ function generateArray(table) {
7
+ const out = [];
8
+ const rows = table.querySelectorAll('tr');
9
+ const ranges = [];
10
+ for (let R = 0; R < rows.length; ++R) {
11
+ const outRow = [];
12
+ const row = rows[R];
13
+ const columns = row.querySelectorAll('td');
14
+ for (let C = 0; C < columns.length; ++C) {
15
+ const cell = columns[C];
16
+ let colspan = cell.getAttribute('colspan');
17
+ let rowspan = cell.getAttribute('rowspan');
18
+ let cellValue = cell.innerText;
19
+ if (cellValue !== "" && cellValue === +cellValue) cellValue = +cellValue;
20
+
21
+ //Skip ranges
22
+ ranges.forEach(function (range) {
23
+ if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
24
+ for (let i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
25
+ }
26
+ });
27
+
28
+ //Handle Row Span
29
+ if (rowspan || colspan) {
30
+ rowspan = rowspan || 1;
31
+ colspan = colspan || 1;
32
+ ranges.push({s: {r: R, c: outRow.length}, e: {r: R + rowspan - 1, c: outRow.length + colspan - 1}});
33
+ }
34
+
35
+ //Handle Value
36
+ outRow.push(cellValue !== "" ? cellValue : null);
37
+
38
+ //Handle Colspan
39
+ if (colspan) for (let k = 0; k < colspan - 1; ++k) outRow.push(null);
40
+ }
41
+ out.push(outRow);
42
+ }
43
+ return [out, ranges];
44
+ }
45
+
46
+ function datenum(v, date1904) {
47
+ if (date1904) v += 1462;
48
+ const epoch = Date.parse(v);
49
+ return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
50
+ }
51
+
52
+ function sheet_from_array_of_arrays(data, opts) {
53
+ const ws = {};
54
+ const range = {s: {c: 10000000, r: 10000000}, e: {c: 0, r: 0}};
55
+ for (let R = 0; R !== data.length; ++R) {
56
+ for (let C = 0; C !== data[R].length; ++C) {
57
+ if (range.s.r > R) range.s.r = R;
58
+ if (range.s.c > C) range.s.c = C;
59
+ if (range.e.r < R) range.e.r = R;
60
+ if (range.e.c < C) range.e.c = C;
61
+ const cell = {v: data[R][C]};
62
+ if (cell.v == null) continue;
63
+ const cell_ref = XLSX.utils.encode_cell({c: C, r: R});
64
+
65
+ if (typeof cell.v === 'number') cell.t = 'n';
66
+ else if (typeof cell.v === 'boolean') cell.t = 'b';
67
+ else if (cell.v instanceof Date) {
68
+ cell.t = 'n';
69
+ cell.z = XLSX.SSF._table[14];
70
+ cell.v = datenum(cell.v);
71
+ } else cell.t = 's';
72
+
73
+ ws[cell_ref] = cell;
74
+ }
75
+ }
76
+ if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
77
+ return ws;
78
+ }
79
+
80
+ function Workbook() {
81
+ if (!(this instanceof Workbook)) return new Workbook();
82
+ this.SheetNames = [];
83
+ this.Sheets = {};
84
+ }
85
+
86
+ function s2ab(s) {
87
+ const buf = new ArrayBuffer(s.length);
88
+ const view = new Uint8Array(buf);
89
+ for (let i = 0; i !== s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
90
+ return buf;
91
+ }
92
+
93
+ export function exportTable(id) {
94
+ const theTable = document.getElementById(id);
95
+ console.log('a')
96
+ const oo = generateArray(theTable);
97
+ const ranges = oo[1];
98
+
99
+ /* original data */
100
+ const data = oo[0];
101
+ const ws_name = "SheetJS";
102
+ console.log(data);
103
+
104
+ const wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
105
+
106
+ /* add ranges to worksheet */
107
+ // ws['!cols'] = ['apple', 'banan'];
108
+ ws['!merges'] = ranges;
109
+
110
+ /* add worksheet to workbook */
111
+ wb.SheetNames.push(ws_name);
112
+ wb.Sheets[ws_name] = ws;
113
+
114
+ const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
115
+
116
+ saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), "test.xlsx")
117
+ }
118
+
119
+ function formatJson(jsonData) {
120
+ console.log(jsonData)
121
+ }
122
+
123
+ export function exportJson(th, jsonData, defaultTitle) {
124
+
125
+ /* original data */
126
+
127
+ const data = jsonData;
128
+ data.unshift(th);
129
+ const ws_name = "SheetJS";
130
+
131
+ const wb = new Workbook(), ws = sheet_from_array_of_arrays(data);
132
+
133
+
134
+ /* add worksheet to workbook */
135
+ wb.SheetNames.push(ws_name);
136
+ wb.Sheets[ws_name] = ws;
137
+
138
+ const wbout = XLSX.write(wb, {bookType: 'xlsx', bookSST: false, type: 'binary'});
139
+ const title = defaultTitle || '列表';
140
+ saveAs(new Blob([s2ab(wbout)], {type: "application/octet-stream"}), title + ".xlsx")
141
+ }