orion-design 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Flex/Col.d.ts +25 -0
- package/dist/components/Flex/Item.d.ts +25 -0
- package/dist/components/Flex/Row.d.ts +25 -0
- package/dist/components/Flex/index.d.ts +10 -0
- package/dist/components/Flex/index.js +151 -0
- package/dist/components/Modal/Modal.d.ts +2 -0
- package/dist/components/Space/index.d.ts +76 -0
- package/dist/components/_util/classNames.d.ts +2 -0
- package/dist/components/_util/classNames.js +31 -0
- package/dist/components/_util/isValid.d.ts +2 -0
- package/dist/components/_util/isValid.js +5 -0
- package/dist/components/_util/props-util/index.d.ts +6 -0
- package/dist/components/_util/props-util/index.js +53 -0
- package/dist/components/_util/props-util/initDefaultProps.d.ts +6 -0
- package/dist/components/_util/props-util/initDefaultProps.js +25 -0
- package/dist/components/_util/type.d.ts +62 -0
- package/dist/components/_util/type.js +66 -0
- package/dist/components/_util/util.d.ts +18 -0
- package/dist/components/_util/util.js +83 -0
- package/dist/components/_util/vue-types/index.d.ts +12 -0
- package/dist/components/_util/vue-types/index.js +473 -0
- package/dist/components/components.d.ts +4 -0
- package/dist/components/components.js +10 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +23 -0
- package/dist/components-O4L3qYfM.js +61 -0
- package/dist/error/OrionError.js +9 -7
- package/dist/index.css +44 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/print/LodopFuncs.js +109 -140
- package/dist/print/index.js +204 -199
- package/dist/request/ErrorHandlerChain.js +13 -13
- package/dist/request/RequestFilterChain.js +13 -13
- package/dist/request/ResponseParserChain.js +13 -13
- package/dist/request/disivion/DateSerializer.js +43 -51
- package/dist/request/disivion/DivisionErrorHandler.js +42 -42
- package/dist/request/disivion/DivisionResponseParser.js +22 -18
- package/dist/request/disivion/index.d.ts +21 -1
- package/dist/request/disivion/index.js +174 -153
- package/dist/request/error/BizExceptionResponseError.js +10 -10
- package/dist/request/error/ExceptionResponseError.js +10 -10
- package/dist/request/error/ResponseError.js +11 -9
- package/dist/request/error/SessionExceptionResponseError.js +10 -10
- package/dist/request/index.d.ts +3 -0
- package/dist/request/index.js +3 -2
- package/dist/style/index.d.ts +3 -0
- package/dist/style/index.js +1 -0
- package/dist/utils/DateUtil.js +46 -50
- package/dist/utils/NumberUtil.js +5 -5
- package/dist/utils/cloneDeep.js +1 -2255
- package/dist/utils/delay.js +1 -1
- package/dist/utils/index.js +2 -2
- package/dist/utils/md5.js +215 -271
- package/dist/version/index.d.ts +2 -0
- package/dist/version/index.js +6 -0
- package/dist/version/version.d.ts +2 -0
- package/dist/version/version.js +3 -0
- package/global.d.ts +9 -0
- package/package.json +25 -9
- package/dist/bignumber-upqAL281.js +0 -2907
- package/dist/request/disivion/request.d.ts +0 -21
- package/dist/request/disivion/request.js +0 -476
- package/dist/request/postByOpenNewWindow.d.ts +0 -1
- package/dist/request/postByOpenNewWindow.js +0 -41
package/dist/print/index.js
CHANGED
@@ -3,228 +3,233 @@ import { getLodop } from './LodopFuncs.js';
|
|
3
3
|
|
4
4
|
// @ts-nocheck
|
5
5
|
function lodopInit() {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
// 获取lodop
|
7
|
+
const LODOP = getLodop();
|
8
|
+
return new Promise(resolve => {
|
9
|
+
resolve(LODOP);
|
10
|
+
});
|
11
11
|
}
|
12
12
|
// 获取打印机列表
|
13
13
|
function getPrinterList() {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
14
|
+
lodopInit();
|
15
|
+
const printers = [];
|
16
|
+
const count = LODOP.GET_PRINTER_COUNT();
|
17
|
+
for (let i = 0; i < count; i++) {
|
18
|
+
printers.push({
|
19
|
+
value: i,
|
20
|
+
content: LODOP.GET_PRINTER_NAME(i)
|
21
|
+
});
|
22
|
+
}
|
23
|
+
return printers;
|
24
24
|
}
|
25
25
|
// 获取打印机名称列表
|
26
26
|
function getPrinterNameList() {
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
lodopInit();
|
28
|
+
const printers = [];
|
29
|
+
const count = LODOP.GET_PRINTER_COUNT();
|
30
|
+
for (let i = 0; i < count; i++) {
|
31
|
+
const prname = LODOP.GET_PRINTER_NAME(i);
|
32
|
+
printers.push({
|
33
|
+
value: prname,
|
34
|
+
content: prname
|
35
|
+
});
|
36
|
+
}
|
37
|
+
return printers;
|
38
38
|
}
|
39
39
|
//////////////////////////////////// 接口
|
40
40
|
// 获取默认打印机名称
|
41
41
|
async function getDefaultPrinter() {
|
42
|
-
|
43
|
-
|
42
|
+
const LODOP = await lodopInit();
|
43
|
+
return LODOP.GET_PRINTER_NAME(-1); // 获取默认打印机名称(-1是指定默认打印机)
|
44
44
|
}
|
45
45
|
// 无打印模板,预览打印
|
46
46
|
async function preview(params) {
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
LODOP.SET_PRINT_MODE('PRINT_DEFAULTSOURCE', print_defaultsource ? print_defaultsource : 0);
|
89
|
-
LODOP.SET_PRINT_PAGESIZE(direction, page_width, page_height, page_type);
|
90
|
-
LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', new URL(pdfurl, import.meta.url));
|
91
|
-
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', true); // 移除预览的线条
|
92
|
-
LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, '预览查看.开始打印'); // 适高,工具条,弹出选择打印机,窗口宽,窗口高,窗口名
|
93
|
-
LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true); //返回打印机状态
|
94
|
-
return new Promise((resolve) => {
|
95
|
-
LODOP.On_Return = function (TaskID, Value) {
|
96
|
-
resolve(Value);
|
97
|
-
};
|
98
|
-
LODOP.PREVIEW();
|
47
|
+
if (!params) {
|
48
|
+
throw new OrionError('打印异常:入参为空,请检查');
|
49
|
+
}
|
50
|
+
const {
|
51
|
+
pdfurl,
|
52
|
+
print_para = {}
|
53
|
+
} = params;
|
54
|
+
if (!pdfurl) {
|
55
|
+
throw new OrionError('打印异常:未知的文件地址[' + pdfurl + '],无法进行打印');
|
56
|
+
}
|
57
|
+
const LODOP = await lodopInit();
|
58
|
+
//获取传入的打印参数
|
59
|
+
let page_width = 0;
|
60
|
+
if (print_para.page_width != 0 && typeof print_para.page_width != 'undefined') {
|
61
|
+
page_width = print_para.page_width;
|
62
|
+
}
|
63
|
+
let page_height = 0;
|
64
|
+
if (print_para.page_height != 0 && typeof print_para.page_height != 'undefined') {
|
65
|
+
page_height = print_para.page_height;
|
66
|
+
}
|
67
|
+
let page_type = '';
|
68
|
+
if (print_para.page_type) {
|
69
|
+
page_type = print_para.page_type;
|
70
|
+
}
|
71
|
+
let direction = 1;
|
72
|
+
if (print_para.direction) {
|
73
|
+
direction = print_para.direction;
|
74
|
+
}
|
75
|
+
let print_duplex = 0;
|
76
|
+
if (print_para.print_duplex) {
|
77
|
+
print_duplex = print_para.print_duplex;
|
78
|
+
}
|
79
|
+
let print_defaultsource = 0;
|
80
|
+
if (print_para.print_defaultsource) {
|
81
|
+
print_defaultsource = print_para.print_defaultsource;
|
82
|
+
}
|
83
|
+
// 历史问题,防止重复打印的问题
|
84
|
+
LODOP.PRINT_INIT('');
|
85
|
+
if (print_para.print_mode_map) {
|
86
|
+
Object.keys(print_para.print_mode_map).map(item => {
|
87
|
+
LODOP.SET_PRINT_MODE(item, print_para.print_mode_map[item]);
|
99
88
|
});
|
89
|
+
}
|
90
|
+
LODOP.SET_PRINT_MODE('PRINT_DUPLEX', print_duplex ? print_duplex : 0);
|
91
|
+
LODOP.SET_PRINT_MODE('PRINT_DEFAULTSOURCE', print_defaultsource ? print_defaultsource : 0);
|
92
|
+
LODOP.SET_PRINT_PAGESIZE(direction, page_width, page_height, page_type);
|
93
|
+
LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', new URL(pdfurl, import.meta.url));
|
94
|
+
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', true); // 移除预览的线条
|
95
|
+
LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, '预览查看.开始打印'); // 适高,工具条,弹出选择打印机,窗口宽,窗口高,窗口名
|
96
|
+
LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true); //返回打印机状态
|
97
|
+
return new Promise(resolve => {
|
98
|
+
LODOP.On_Return = function (TaskID, Value) {
|
99
|
+
resolve(Value);
|
100
|
+
};
|
101
|
+
LODOP.PREVIEW();
|
102
|
+
});
|
100
103
|
}
|
101
104
|
async function print(params) {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
105
|
+
if (!params) {
|
106
|
+
throw new OrionError('打印异常:入参为空,请检查');
|
107
|
+
}
|
108
|
+
const {
|
109
|
+
pdfurl,
|
110
|
+
print_para = {},
|
111
|
+
printer
|
112
|
+
} = params;
|
113
|
+
if (!pdfurl) {
|
114
|
+
throw new OrionError('打印异常:未知的文件地址[' + pdfurl + '],无法进行打印');
|
115
|
+
}
|
116
|
+
if (printer) {
|
117
|
+
return await printWithCertainPrinter(pdfurl, print_para, printer);
|
118
|
+
} else {
|
119
|
+
// 没设置打印机
|
120
|
+
return await printNeedSelectPrinter(pdfurl, print_para);
|
121
|
+
}
|
116
122
|
}
|
117
123
|
async function printWithCertainPrinter(pdfurl, print_para = {}, pr_name) {
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
LODOP.SET_PRINT_MODE(item, print_para.print_mode_map[item]);
|
163
|
-
});
|
164
|
-
}
|
165
|
-
LODOP.SET_PRINT_MODE('PRINT_DUPLEX', print_duplex ? print_duplex : 0);
|
166
|
-
LODOP.SET_PRINT_MODE('PRINT_DEFAULTSOURCE', print_defaultsource ? print_defaultsource : 0);
|
167
|
-
LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', new URL(pdfurl, import.meta.url));
|
168
|
-
LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true); //返回打印机状态
|
169
|
-
return new Promise((resolve) => {
|
170
|
-
LODOP.On_Return = function (TaskID, Value) {
|
171
|
-
resolve(Value);
|
172
|
-
};
|
173
|
-
LODOP.PRINT();
|
124
|
+
if (!pdfurl) {
|
125
|
+
throw new OrionError('打印异常:未知的文件地址[' + pdfurl + '],无法进行打印');
|
126
|
+
}
|
127
|
+
if (!pr_name) {
|
128
|
+
throw new OrionError('打印异常:未设置打印机,无法进行打印');
|
129
|
+
}
|
130
|
+
//获取传入的打印参数
|
131
|
+
let page_width = 0;
|
132
|
+
if (print_para.page_width != 0 && typeof print_para.page_width != 'undefined') {
|
133
|
+
page_width = print_para.page_width;
|
134
|
+
}
|
135
|
+
let page_height = 0;
|
136
|
+
if (print_para.page_height != 0 && typeof print_para.page_height != 'undefined') {
|
137
|
+
page_height = print_para.page_height;
|
138
|
+
}
|
139
|
+
let page_type = '';
|
140
|
+
if (print_para.page_type) {
|
141
|
+
page_type = print_para.page_type;
|
142
|
+
}
|
143
|
+
let direction = 1;
|
144
|
+
if (print_para.direction) {
|
145
|
+
direction = print_para.direction;
|
146
|
+
}
|
147
|
+
let print_duplex = 0;
|
148
|
+
if (print_para.print_duplex) {
|
149
|
+
print_duplex = print_para.print_duplex;
|
150
|
+
}
|
151
|
+
let print_defaultsource = 0;
|
152
|
+
if (print_para.print_defaultsource) {
|
153
|
+
print_defaultsource = print_para.print_defaultsource;
|
154
|
+
}
|
155
|
+
const LODOP = await lodopInit();
|
156
|
+
// 指定打印设备(打印机)
|
157
|
+
LODOP.PRINT_INIT('');
|
158
|
+
// 设置了打印机
|
159
|
+
if (pr_name === -1) {
|
160
|
+
LODOP.SET_PRINTER_INDEXA(LODOP.GET_PRINTER_NAME(-1));
|
161
|
+
} else {
|
162
|
+
LODOP.SET_PRINTER_INDEXA(pr_name);
|
163
|
+
}
|
164
|
+
LODOP.SET_PRINT_PAGESIZE(direction, page_width, page_height, page_type);
|
165
|
+
if (print_para.print_mode_map) {
|
166
|
+
Object.keys(print_para.print_mode_map).map(item => {
|
167
|
+
LODOP.SET_PRINT_MODE(item, print_para.print_mode_map[item]);
|
174
168
|
});
|
169
|
+
}
|
170
|
+
LODOP.SET_PRINT_MODE('PRINT_DUPLEX', print_duplex ? print_duplex : 0);
|
171
|
+
LODOP.SET_PRINT_MODE('PRINT_DEFAULTSOURCE', print_defaultsource ? print_defaultsource : 0);
|
172
|
+
LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', new URL(pdfurl, import.meta.url));
|
173
|
+
LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true); //返回打印机状态
|
174
|
+
return new Promise(resolve => {
|
175
|
+
LODOP.On_Return = function (TaskID, Value) {
|
176
|
+
resolve(Value);
|
177
|
+
};
|
178
|
+
LODOP.PRINT();
|
179
|
+
});
|
175
180
|
}
|
176
181
|
// 无打印模板,直接打印,需要选择打印机
|
177
182
|
async function printNeedSelectPrinter(url, print_para = {}) {
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
});
|
213
|
-
}
|
214
|
-
LODOP.SET_PRINT_MODE('PRINT_DUPLEX', print_duplex ? print_duplex : 0);
|
215
|
-
LODOP.SET_PRINT_MODE('PRINT_DEFAULTSOURCE', print_defaultsource ? print_defaultsource : 0);
|
216
|
-
LODOP.SET_PRINT_PAGESIZE(direction, page_width, page_height, page_type);
|
217
|
-
LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', url);
|
218
|
-
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', true); // 移除预览的线条
|
219
|
-
LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, '预览查看.开始打印'); // 适高,工具条,弹出选择打印机,窗口宽,窗口高,窗口名
|
220
|
-
//返回打印机状态
|
221
|
-
LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true);
|
222
|
-
return new Promise((resolve) => {
|
223
|
-
LODOP.On_Return = function (TaskID, Value) {
|
224
|
-
resolve(Value);
|
225
|
-
};
|
226
|
-
LODOP.PRINTA();
|
183
|
+
if (url === null || url === '' || typeof url === 'undefined') {
|
184
|
+
throw new OrionError('打印异常:未知的文件地址[' + url + '],无法进行打印');
|
185
|
+
}
|
186
|
+
const LODOP = await lodopInit();
|
187
|
+
//获取传入的打印参数
|
188
|
+
let page_width = 0;
|
189
|
+
if (print_para.page_width != 0 && typeof print_para.page_width != 'undefined') {
|
190
|
+
page_width = print_para.page_width;
|
191
|
+
}
|
192
|
+
let page_height = 0;
|
193
|
+
if (print_para.page_height != 0 && typeof print_para.page_height != 'undefined') {
|
194
|
+
page_height = print_para.page_height;
|
195
|
+
}
|
196
|
+
let page_type = '';
|
197
|
+
if (print_para.page_type) {
|
198
|
+
page_type = print_para.page_type;
|
199
|
+
}
|
200
|
+
let direction = 1;
|
201
|
+
if (print_para.direction) {
|
202
|
+
direction = print_para.direction;
|
203
|
+
}
|
204
|
+
let print_duplex = 0;
|
205
|
+
if (print_para.print_duplex) {
|
206
|
+
print_duplex = print_para.print_duplex;
|
207
|
+
}
|
208
|
+
let print_defaultsource = 0;
|
209
|
+
if (print_para.print_defaultsource) {
|
210
|
+
print_defaultsource = print_para.print_defaultsource;
|
211
|
+
}
|
212
|
+
// 历史问题,防止重复打印的问题
|
213
|
+
LODOP.PRINT_INIT('');
|
214
|
+
if (print_para.print_mode_map) {
|
215
|
+
Object.keys(print_para.print_mode_map).map(item => {
|
216
|
+
LODOP.SET_PRINT_MODE(item, print_para.print_mode_map[item]);
|
227
217
|
});
|
218
|
+
}
|
219
|
+
LODOP.SET_PRINT_MODE('PRINT_DUPLEX', print_duplex ? print_duplex : 0);
|
220
|
+
LODOP.SET_PRINT_MODE('PRINT_DEFAULTSOURCE', print_defaultsource ? print_defaultsource : 0);
|
221
|
+
LODOP.SET_PRINT_PAGESIZE(direction, page_width, page_height, page_type);
|
222
|
+
LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', url);
|
223
|
+
LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', true); // 移除预览的线条
|
224
|
+
LODOP.SET_PREVIEW_WINDOW(0, 0, 0, 0, 0, '预览查看.开始打印'); // 适高,工具条,弹出选择打印机,窗口宽,窗口高,窗口名
|
225
|
+
//返回打印机状态
|
226
|
+
LODOP.SET_PRINT_MODE('CATCH_PRINT_STATUS', true);
|
227
|
+
return new Promise(resolve => {
|
228
|
+
LODOP.On_Return = function (TaskID, Value) {
|
229
|
+
resolve(Value);
|
230
|
+
};
|
231
|
+
LODOP.PRINTA();
|
232
|
+
});
|
228
233
|
}
|
229
234
|
|
230
235
|
export { getDefaultPrinter, getPrinterList, getPrinterNameList, lodopInit, preview, print, printNeedSelectPrinter };
|
@@ -1,18 +1,18 @@
|
|
1
1
|
class ErrorHandlerChain {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
const handler = this.handlers[this.index];
|
13
|
-
this.index++;
|
14
|
-
return await handler.handle(error, chain);
|
2
|
+
handlers;
|
3
|
+
index;
|
4
|
+
constructor(handlers) {
|
5
|
+
this.handlers = handlers ? handlers : [];
|
6
|
+
this.index = 0;
|
7
|
+
}
|
8
|
+
async handle(error, chain) {
|
9
|
+
if (this.index == this.handlers.length) {
|
10
|
+
throw error;
|
15
11
|
}
|
12
|
+
const handler = this.handlers[this.index];
|
13
|
+
this.index++;
|
14
|
+
return await handler.handle(error, chain);
|
15
|
+
}
|
16
16
|
}
|
17
17
|
|
18
18
|
export { ErrorHandlerChain as default };
|
@@ -1,18 +1,18 @@
|
|
1
1
|
class RequestFilterChain {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
const filter = this.filters[this.index];
|
13
|
-
this.index++;
|
14
|
-
filter.doFilter(request, chain);
|
2
|
+
filters;
|
3
|
+
index;
|
4
|
+
constructor(filters) {
|
5
|
+
this.filters = filters ? filters : [];
|
6
|
+
this.index = 0;
|
7
|
+
}
|
8
|
+
doFilter(request, chain) {
|
9
|
+
if (this.index == this.filters.length) {
|
10
|
+
return;
|
15
11
|
}
|
12
|
+
const filter = this.filters[this.index];
|
13
|
+
this.index++;
|
14
|
+
filter.doFilter(request, chain);
|
15
|
+
}
|
16
16
|
}
|
17
17
|
|
18
18
|
export { RequestFilterChain as default };
|
@@ -1,18 +1,18 @@
|
|
1
1
|
class ResponseParserChain {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
const parser = this.parsers[this.index];
|
13
|
-
this.index++;
|
14
|
-
return parser.parse(response, chain);
|
2
|
+
parsers;
|
3
|
+
index;
|
4
|
+
constructor(parsers) {
|
5
|
+
this.parsers = parsers ? parsers : [];
|
6
|
+
this.index = 0;
|
7
|
+
}
|
8
|
+
doParse(response, chain) {
|
9
|
+
if (this.index == this.parsers.length) {
|
10
|
+
return response;
|
15
11
|
}
|
12
|
+
const parser = this.parsers[this.index];
|
13
|
+
this.index++;
|
14
|
+
return parser.parse(response, chain);
|
15
|
+
}
|
16
16
|
}
|
17
17
|
|
18
18
|
export { ResponseParserChain as default };
|
@@ -1,60 +1,52 @@
|
|
1
1
|
import dayjs from 'dayjs';
|
2
2
|
|
3
3
|
class DateSerializer {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
}
|
23
|
-
else {
|
24
|
-
result[key] = value;
|
25
|
-
}
|
26
|
-
});
|
27
|
-
return result;
|
4
|
+
format;
|
5
|
+
constructor(format = 'YYYY-MM-DD HH:mm:ss.SSS') {
|
6
|
+
this.format = format;
|
7
|
+
}
|
8
|
+
serialize(data) {
|
9
|
+
const format = this.format;
|
10
|
+
function objTransfer(data) {
|
11
|
+
const result = {};
|
12
|
+
Object.keys(data).forEach(key => {
|
13
|
+
const value = data[key];
|
14
|
+
if (value instanceof Date || dayjs.isDayjs(value)) {
|
15
|
+
result[key] = dayjs(value).format(format);
|
16
|
+
} else if (value && value instanceof Object && !Array.isArray(value)) {
|
17
|
+
result[key] = objTransfer(value);
|
18
|
+
} else if (value && Array.isArray(value)) {
|
19
|
+
result[key] = arrayTransfer(value);
|
20
|
+
} else {
|
21
|
+
result[key] = value;
|
28
22
|
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
}
|
43
|
-
});
|
23
|
+
});
|
24
|
+
return result;
|
25
|
+
}
|
26
|
+
function arrayTransfer(data) {
|
27
|
+
return data.map(value => {
|
28
|
+
if (value instanceof Date || dayjs.isDayjs(value)) {
|
29
|
+
return dayjs(value).format(format);
|
30
|
+
} else if (value && value instanceof Object && !Array.isArray(value)) {
|
31
|
+
return objTransfer(value);
|
32
|
+
} else if (value && Array.isArray(value)) {
|
33
|
+
return arrayTransfer(value);
|
34
|
+
} else {
|
35
|
+
return value;
|
44
36
|
}
|
45
|
-
|
46
|
-
const value = data[key];
|
47
|
-
if (value instanceof Date || dayjs.isDayjs(value)) {
|
48
|
-
data[key] = dayjs(value).format(this.format);
|
49
|
-
}
|
50
|
-
else if (value && typeof value == 'object' && !Array.isArray(value)) {
|
51
|
-
data[key] = objTransfer(value);
|
52
|
-
}
|
53
|
-
else if (value && Array.isArray(value)) {
|
54
|
-
data[key] = arrayTransfer(value);
|
55
|
-
}
|
56
|
-
});
|
37
|
+
});
|
57
38
|
}
|
39
|
+
Object.keys(data).forEach(key => {
|
40
|
+
const value = data[key];
|
41
|
+
if (value instanceof Date || dayjs.isDayjs(value)) {
|
42
|
+
data[key] = dayjs(value).format(this.format);
|
43
|
+
} else if (value && typeof value == 'object' && !Array.isArray(value)) {
|
44
|
+
data[key] = objTransfer(value);
|
45
|
+
} else if (value && Array.isArray(value)) {
|
46
|
+
data[key] = arrayTransfer(value);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
58
50
|
}
|
59
51
|
|
60
52
|
export { DateSerializer as default };
|