@kp-ui/lowcode 1.0.35 → 1.0.36
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/_virtual/virtual_svg-icons-register.js +2 -2
- package/package.json +27 -27
- package/render.js +4 -1
- package/src/api/useFilesystemApi/filesystem/index.js +2 -1
- package/src/components/CustomRender/components/AttachmentRender.vue.js +1 -1
- package/src/components/CustomRender/components/AttachmentRender.vue2.js +8 -5
- package/src/components/CustomRender/useCustomRender.js +12 -4
- package/src/components/code-editor/code-modal-editor.vue.js +2 -2
- package/src/components/form-designer/form-widget/container-widget/data-table-widget.vue.js +13 -63
- package/src/components/form-designer/form-widget/container-widget/data-table-widget.vue2.js +3 -1
- package/src/components/form-designer/setting-panel/form-setting.vue.js +19 -5
- package/src/components/form-designer/setting-panel/index.vue.js +4 -2
- package/src/components/form-designer/setting-panel/property-editor/container-data-table/data-table-tableColumns-editor.vue.js +20 -26
- package/src/components/form-designer/setting-panel/property-editor/diy-compontent-editor.vue.js +6 -0
- package/src/components/form-designer/toolbar-panel/index.vue.js +73 -34
- package/src/components/form-designer/widget-panel/advanced/diy-compontent.js +0 -1
- package/src/components/form-designer/widget-panel/advancedFieldsEnums.js +1 -2
- package/src/components/form-render/container-item/data-table-item.vue.js +14 -56
- package/src/components/http-editor/index.vue2.js +2 -1
- package/src/lang/zh-CN.js +1 -0
- package/src/mixins/useDataTableMixin.js +149 -27
- package/src/utils/request/fmtHttpParams.js +9 -9
- package/src/utils/request/handleAxiosError.js +31 -0
- package/src/utils/request/http.js +81 -0
- package/styles/style.css +1 -1
- package/types/src/components/CustomRender/components/AttachmentRender.d.ts.map +1 -1
- package/types/src/components/CustomRender/useCustomRender.d.ts.map +1 -1
- package/types/src/components/form-designer/setting-panel/index.d.ts.map +1 -1
- package/types/src/components/form-designer/toolbar-panel/index.d.ts.map +1 -1
- package/types/src/components/form-designer/widget-panel/advanced/diy-compontent.d.ts.map +1 -1
- package/types/src/components/form-designer/widget-panel/advancedFieldsEnums.d.ts +0 -8
- package/types/src/components/form-designer/widget-panel/advancedFieldsEnums.d.ts.map +1 -1
- package/types/src/components/form-render/index.d.ts +1 -0
- package/types/src/components/form-render/index.d.ts.map +1 -1
- package/types/src/utils/request/http.d.ts +3 -1
- package/types/src/utils/request/http.d.ts.map +1 -1
- package/src/components/form-designer/widget-panel/advanced/slot.js +0 -22
- package/types/src/components/lowcodeCompontent/index.d.ts +0 -6
- package/types/src/components/lowcodeCompontent/index.d.ts.map +0 -1
|
@@ -1,17 +1,81 @@
|
|
|
1
|
+
import { createVNode, Fragment, mergeProps, isVNode } from "vue";
|
|
1
2
|
import { omit, isArray, isEmpty } from "lodash-es";
|
|
2
3
|
import { fmtHttpParams } from "../utils/request/fmtHttpParams.js";
|
|
3
4
|
import { TpfConfirm } from "../hooks/TpfConfirm.js";
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import { Space, Button } from "ant-design-vue";
|
|
6
|
+
function _isSlot(s) {
|
|
7
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
8
|
+
}
|
|
6
9
|
const useDataTableMixin = {
|
|
7
10
|
data() {
|
|
8
11
|
return {
|
|
9
|
-
selectedRowInfo: {
|
|
12
|
+
selectedRowInfo: {
|
|
13
|
+
selectedRowKeys: [],
|
|
14
|
+
selectedRows: []
|
|
15
|
+
},
|
|
10
16
|
selectRow: {},
|
|
11
17
|
loading: false
|
|
12
18
|
};
|
|
13
19
|
},
|
|
14
20
|
computed: {
|
|
21
|
+
columns() {
|
|
22
|
+
var _a;
|
|
23
|
+
const leftFixedColumns = [];
|
|
24
|
+
const optins = ((_a = this.widget) == null ? void 0 : _a.options) ?? {};
|
|
25
|
+
if (optins.showIndex) {
|
|
26
|
+
leftFixedColumns.push({
|
|
27
|
+
title: "序号",
|
|
28
|
+
align: "left",
|
|
29
|
+
width: 90,
|
|
30
|
+
fixed: "left",
|
|
31
|
+
field: "dataIndex",
|
|
32
|
+
customRender: this.customRenderIndex
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const centerColumns = optins.tableColumns.filter((item) => item.show).map((item) => ({
|
|
36
|
+
...item,
|
|
37
|
+
...this.handleColumnItem(item)
|
|
38
|
+
}));
|
|
39
|
+
const rightFixedColumns = [];
|
|
40
|
+
if (optins.showButtonsColumn) {
|
|
41
|
+
const operationButtons = optins.operationButtons ?? [];
|
|
42
|
+
let showOperationButton = this.showOperationButton;
|
|
43
|
+
let disableOperationButton = this.disableOperationButton;
|
|
44
|
+
let handleOperationButtonClick = this.handleOperationButtonClick;
|
|
45
|
+
let getOperationButtonLabel = this.getOperationButtonLabel;
|
|
46
|
+
rightFixedColumns.push({
|
|
47
|
+
fixed: "right",
|
|
48
|
+
align: "center",
|
|
49
|
+
title: optins.buttonsColumnTitle,
|
|
50
|
+
width: optins.buttonsColumnWidth,
|
|
51
|
+
customRender(scope) {
|
|
52
|
+
let _slot2;
|
|
53
|
+
return createVNode(Space, null, _isSlot(_slot2 = operationButtons.map((item, index) => {
|
|
54
|
+
let _slot;
|
|
55
|
+
if (!showOperationButton(item, scope.index, scope.record)) {
|
|
56
|
+
return createVNode(Fragment, null, null);
|
|
57
|
+
}
|
|
58
|
+
return createVNode(Button, mergeProps({
|
|
59
|
+
"key": index
|
|
60
|
+
}, item, {
|
|
61
|
+
"disabled": disableOperationButton(item, scope.index, scope.record),
|
|
62
|
+
"onClick": () => handleOperationButtonClick(item.name, scope.index, scope.record, scope, item),
|
|
63
|
+
"class": ["data-table-" + item.name + "-button"]
|
|
64
|
+
}), _isSlot(_slot = getOperationButtonLabel(item, scope.index, scope.record)) ? _slot : {
|
|
65
|
+
default: () => [_slot]
|
|
66
|
+
});
|
|
67
|
+
})) ? _slot2 : {
|
|
68
|
+
default: () => [_slot2]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
let columns = [...leftFixedColumns, ...centerColumns, ...rightFixedColumns];
|
|
74
|
+
console.log({
|
|
75
|
+
columns
|
|
76
|
+
});
|
|
77
|
+
return columns;
|
|
78
|
+
},
|
|
15
79
|
tableHeight() {
|
|
16
80
|
return this.widget.options.tableHeight || void 0;
|
|
17
81
|
},
|
|
@@ -28,7 +92,9 @@ const useDataTableMixin = {
|
|
|
28
92
|
return this.widget.options.tableSize || "default";
|
|
29
93
|
},
|
|
30
94
|
fmtPagination() {
|
|
31
|
-
const {
|
|
95
|
+
const {
|
|
96
|
+
showPagination
|
|
97
|
+
} = this.widget.options;
|
|
32
98
|
if (!showPagination) return false;
|
|
33
99
|
return {
|
|
34
100
|
...this.widget.options.pagination,
|
|
@@ -38,7 +104,10 @@ const useDataTableMixin = {
|
|
|
38
104
|
},
|
|
39
105
|
methods: {
|
|
40
106
|
handleHidden() {
|
|
41
|
-
const {
|
|
107
|
+
const {
|
|
108
|
+
onHidden,
|
|
109
|
+
hidden
|
|
110
|
+
} = this.widget.options;
|
|
42
111
|
if (hidden) return true;
|
|
43
112
|
if (onHidden) {
|
|
44
113
|
const onHiddenFn = new Function(onHidden);
|
|
@@ -47,22 +116,31 @@ const useDataTableMixin = {
|
|
|
47
116
|
return false;
|
|
48
117
|
},
|
|
49
118
|
rowClassName(record) {
|
|
50
|
-
const {
|
|
119
|
+
const {
|
|
120
|
+
rowKey,
|
|
121
|
+
colorRow
|
|
122
|
+
} = this.widget.options;
|
|
51
123
|
if (!colorRow) return "";
|
|
52
124
|
return this.selectRow[rowKey] === record[rowKey] ? "colorRowClassName" : "";
|
|
53
125
|
},
|
|
54
126
|
handleResizeColumn(w, col) {
|
|
55
|
-
const {
|
|
127
|
+
const {
|
|
128
|
+
tableColumns
|
|
129
|
+
} = this.widget.options;
|
|
56
130
|
const newTableColumns = tableColumns.map((item) => {
|
|
57
131
|
if (item.dataIndex === col.dataIndex) {
|
|
58
132
|
item.width = w;
|
|
59
133
|
}
|
|
60
|
-
return {
|
|
134
|
+
return {
|
|
135
|
+
...item
|
|
136
|
+
};
|
|
61
137
|
});
|
|
62
138
|
this.setTableColumns(newTableColumns);
|
|
63
139
|
},
|
|
64
140
|
disabledClick() {
|
|
65
|
-
const {
|
|
141
|
+
const {
|
|
142
|
+
hasRowSelection
|
|
143
|
+
} = this.widget.options.rowSelection;
|
|
66
144
|
if (hasRowSelection) {
|
|
67
145
|
return isEmpty(this.selectedRowInfo.selectedRowKeys);
|
|
68
146
|
}
|
|
@@ -82,10 +160,14 @@ const useDataTableMixin = {
|
|
|
82
160
|
return;
|
|
83
161
|
},
|
|
84
162
|
async delSelectRow(delKeys) {
|
|
85
|
-
await TpfConfirm({
|
|
163
|
+
await TpfConfirm({
|
|
164
|
+
content: "确定删除选中的数据吗"
|
|
165
|
+
});
|
|
86
166
|
delKeys = delKeys || this.selectedRowInfo.selectedRowKeys;
|
|
87
167
|
if (!delKeys.length) return;
|
|
88
|
-
const {
|
|
168
|
+
const {
|
|
169
|
+
rowKey
|
|
170
|
+
} = this.widget.options;
|
|
89
171
|
const data = this.getDataSource();
|
|
90
172
|
const newList = data.filter((item) => !(delKeys == null ? void 0 : delKeys.includes(item[rowKey])));
|
|
91
173
|
this.setDataSource(newList);
|
|
@@ -110,7 +192,10 @@ const useDataTableMixin = {
|
|
|
110
192
|
}
|
|
111
193
|
},
|
|
112
194
|
setDataSource(list) {
|
|
113
|
-
this.selectedRowInfo = {
|
|
195
|
+
this.selectedRowInfo = {
|
|
196
|
+
selectedRowKeys: [],
|
|
197
|
+
selectedRows: []
|
|
198
|
+
};
|
|
114
199
|
this.selectRow = {};
|
|
115
200
|
const val = isArray(list) ? list : [list];
|
|
116
201
|
this.widget.options.dataSource = [...val];
|
|
@@ -139,8 +224,13 @@ const useDataTableMixin = {
|
|
|
139
224
|
}
|
|
140
225
|
},
|
|
141
226
|
handleCustomRow(record) {
|
|
142
|
-
const {
|
|
143
|
-
|
|
227
|
+
const {
|
|
228
|
+
customRow,
|
|
229
|
+
colorRow
|
|
230
|
+
} = this.widget.options;
|
|
231
|
+
const {
|
|
232
|
+
hasRowSelection
|
|
233
|
+
} = this.widget.options.rowSelection;
|
|
144
234
|
return {
|
|
145
235
|
onClick: (event) => {
|
|
146
236
|
if (colorRow) {
|
|
@@ -169,14 +259,27 @@ const useDataTableMixin = {
|
|
|
169
259
|
if (!customRenderFn) return item;
|
|
170
260
|
return {
|
|
171
261
|
...res,
|
|
172
|
-
customRender: (
|
|
173
|
-
|
|
174
|
-
|
|
262
|
+
customRender: ({
|
|
263
|
+
text,
|
|
264
|
+
record,
|
|
265
|
+
index,
|
|
266
|
+
column
|
|
267
|
+
}) => {
|
|
268
|
+
try {
|
|
269
|
+
const cusFunc = new Function("text", "record", "index", "column", customRenderFn);
|
|
270
|
+
return cusFunc.call(this, text, record, index, column);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
console.log({
|
|
273
|
+
error
|
|
274
|
+
});
|
|
275
|
+
}
|
|
175
276
|
}
|
|
176
277
|
};
|
|
177
278
|
},
|
|
178
279
|
getOperationButtonLabel(buttonConfig, rowIndex, row) {
|
|
179
|
-
const {
|
|
280
|
+
const {
|
|
281
|
+
onGetOperationButtonLabel
|
|
282
|
+
} = this.widget.options;
|
|
180
283
|
if (!!onGetOperationButtonLabel) {
|
|
181
284
|
const customFn = new Function("buttonConfig", "rowIndex", "row", onGetOperationButtonLabel);
|
|
182
285
|
return customFn.call(this, buttonConfig, rowIndex, row);
|
|
@@ -192,7 +295,9 @@ const useDataTableMixin = {
|
|
|
192
295
|
clcFn.call(this, row, rowIndex, scope.column, ob);
|
|
193
296
|
return;
|
|
194
297
|
}
|
|
195
|
-
const {
|
|
298
|
+
const {
|
|
299
|
+
onOperationButtonClick
|
|
300
|
+
} = this.widget.options;
|
|
196
301
|
if (!!onOperationButtonClick) {
|
|
197
302
|
const customFn = new Function("buttonName", "rowIndex", "row", onOperationButtonClick);
|
|
198
303
|
customFn.call(this, btnName, rowIndex, row);
|
|
@@ -204,7 +309,9 @@ const useDataTableMixin = {
|
|
|
204
309
|
}
|
|
205
310
|
},
|
|
206
311
|
showOperationButton(buttonConfig, rowIndex, row) {
|
|
207
|
-
const {
|
|
312
|
+
const {
|
|
313
|
+
onHideOperationButton
|
|
314
|
+
} = this.widget.options;
|
|
208
315
|
if (!!onHideOperationButton) {
|
|
209
316
|
const customFn = new Function("buttonConfig", "rowIndex", "row", onHideOperationButton);
|
|
210
317
|
return !!customFn.call(this, buttonConfig, rowIndex, row);
|
|
@@ -213,7 +320,9 @@ const useDataTableMixin = {
|
|
|
213
320
|
}
|
|
214
321
|
},
|
|
215
322
|
disableOperationButton(buttonConfig, rowIndex, row) {
|
|
216
|
-
const {
|
|
323
|
+
const {
|
|
324
|
+
onDisableOperationButton
|
|
325
|
+
} = this.widget.options;
|
|
217
326
|
if (!!onDisableOperationButton) {
|
|
218
327
|
const customFn = new Function("buttonConfig", "rowIndex", "row", onDisableOperationButton);
|
|
219
328
|
return customFn.call(this, buttonConfig, rowIndex, row);
|
|
@@ -221,12 +330,16 @@ const useDataTableMixin = {
|
|
|
221
330
|
return buttonConfig.disabled;
|
|
222
331
|
}
|
|
223
332
|
},
|
|
224
|
-
customRenderIndex({
|
|
333
|
+
customRenderIndex({
|
|
334
|
+
index
|
|
335
|
+
}) {
|
|
225
336
|
return index + 1;
|
|
226
337
|
},
|
|
227
338
|
handleCurrentPageChange(currentPage) {
|
|
228
339
|
this.currentPage = currentPage;
|
|
229
|
-
const {
|
|
340
|
+
const {
|
|
341
|
+
onCurrentPageChange
|
|
342
|
+
} = this.widget.options;
|
|
230
343
|
if (!!onCurrentPageChange) {
|
|
231
344
|
const customFn = new Function("pageSize", "currentPage", onCurrentPageChange);
|
|
232
345
|
customFn.call(this, this.pageSize, currentPage);
|
|
@@ -236,7 +349,9 @@ const useDataTableMixin = {
|
|
|
236
349
|
},
|
|
237
350
|
handlePageSizeChange(pageSize) {
|
|
238
351
|
this.pageSize = pageSize;
|
|
239
|
-
const {
|
|
352
|
+
const {
|
|
353
|
+
onPageSizeChange
|
|
354
|
+
} = this.widget.options;
|
|
240
355
|
if (!!onPageSizeChange) {
|
|
241
356
|
const customFn = new Function("pageSize", "currentPage", onPageSizeChange);
|
|
242
357
|
customFn.call(this, pageSize, this.currentPage);
|
|
@@ -244,13 +359,17 @@ const useDataTableMixin = {
|
|
|
244
359
|
this.dispatch("VFormRender", "dataTablePageSizeChange", [this, pageSize, this.currentPage]);
|
|
245
360
|
}
|
|
246
361
|
},
|
|
247
|
-
handleTablePageChange(pagination, filters, sorter, {
|
|
362
|
+
handleTablePageChange(pagination, filters, sorter, {
|
|
363
|
+
currentDataSource
|
|
364
|
+
}) {
|
|
248
365
|
const fn = this.widget.options.onTableChange;
|
|
249
366
|
this.widget.options.pagination.current = pagination.current;
|
|
250
367
|
this.widget.options.pagination.pageSize = pagination.pageSize;
|
|
251
368
|
if (fn) {
|
|
252
369
|
const changeFunc = new Function("pagination", "filters", "sorter", "currentDataSource", fn);
|
|
253
|
-
changeFunc.call(this, pagination, filters, sorter, {
|
|
370
|
+
changeFunc.call(this, pagination, filters, sorter, {
|
|
371
|
+
currentDataSource
|
|
372
|
+
});
|
|
254
373
|
}
|
|
255
374
|
this.loadDataTableDataSource();
|
|
256
375
|
},
|
|
@@ -262,7 +381,10 @@ const useDataTableMixin = {
|
|
|
262
381
|
return {
|
|
263
382
|
...omit(info, ["onChange"]),
|
|
264
383
|
onChange: (selectedRowKeys, selectedRows) => {
|
|
265
|
-
this.selectedRowInfo = {
|
|
384
|
+
this.selectedRowInfo = {
|
|
385
|
+
selectedRowKeys,
|
|
386
|
+
selectedRows
|
|
387
|
+
};
|
|
266
388
|
const rcFunc = new Function("selectedRowKeys", "selectedRows", info.onChange);
|
|
267
389
|
rcFunc.call(this, selectedRowKeys, selectedRows);
|
|
268
390
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLocat } from "@kp-ui/tool";
|
|
2
|
+
import http from "./http.js";
|
|
2
3
|
const replaceVars = (sendParams, paramsMap) => {
|
|
3
4
|
Object.entries(sendParams).forEach(([key, value]) => {
|
|
4
5
|
if (key) {
|
|
@@ -14,19 +15,18 @@ const replaceVars = (sendParams, paramsMap) => {
|
|
|
14
15
|
return sendParams;
|
|
15
16
|
};
|
|
16
17
|
async function fmtHttpParams(req, params = {}) {
|
|
17
|
-
const request = getHttp();
|
|
18
18
|
const { data, vfCtx, ...args } = params;
|
|
19
|
-
const { http, dataHandlerCode, dataReqHandlerCode } = req;
|
|
20
|
-
if (!http.url) return;
|
|
19
|
+
const { http: http$1, dataHandlerCode, dataReqHandlerCode } = req;
|
|
20
|
+
if (!http$1.url) return;
|
|
21
21
|
const paramsMap = { ...getLocat(), ...data, ...vfCtx, ...args };
|
|
22
|
-
const method = http.method || "get";
|
|
22
|
+
const method = http$1.method || "get";
|
|
23
23
|
let sendParams = {
|
|
24
|
-
params: http.method === "get" ? { ...http.params, ...data } : { ...http.params },
|
|
25
|
-
data: http.method === "post" ? { ...http.data, ...data } : { ...http.data }
|
|
24
|
+
params: http$1.method === "get" ? { ...http$1.params, ...data } : { ...http$1.params },
|
|
25
|
+
data: http$1.method === "post" ? { ...http$1.data, ...data } : { ...http$1.data }
|
|
26
26
|
};
|
|
27
27
|
sendParams = replaceVars(sendParams, paramsMap);
|
|
28
28
|
let p = {
|
|
29
|
-
...http,
|
|
29
|
+
...http$1,
|
|
30
30
|
method,
|
|
31
31
|
...sendParams
|
|
32
32
|
};
|
|
@@ -36,7 +36,7 @@ async function fmtHttpParams(req, params = {}) {
|
|
|
36
36
|
}
|
|
37
37
|
if (!p) return;
|
|
38
38
|
console.log("请求参数 ", p);
|
|
39
|
-
let dsResult = await
|
|
39
|
+
let dsResult = await http(p);
|
|
40
40
|
if (dataHandlerCode) {
|
|
41
41
|
const dhFn = new Function("data", dataHandlerCode);
|
|
42
42
|
dsResult = dhFn.call(this, dsResult);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { message } from "ant-design-vue";
|
|
2
|
+
const handleErrorStatus = {
|
|
3
|
+
401: (data) => {
|
|
4
|
+
message.error(data.statusText);
|
|
5
|
+
window.location.href.toString();
|
|
6
|
+
},
|
|
7
|
+
403: (data) => {
|
|
8
|
+
message.error(data.statusText);
|
|
9
|
+
},
|
|
10
|
+
404: (data) => {
|
|
11
|
+
message.error(data.statusText);
|
|
12
|
+
},
|
|
13
|
+
418: (data) => {
|
|
14
|
+
message.error(data.statusText);
|
|
15
|
+
},
|
|
16
|
+
429: (data) => {
|
|
17
|
+
message.error(data.statusText);
|
|
18
|
+
},
|
|
19
|
+
500: (data) => {
|
|
20
|
+
message.error("网络繁忙");
|
|
21
|
+
},
|
|
22
|
+
510: (data) => {
|
|
23
|
+
message.error(data.data.errorMessage || data.statusText);
|
|
24
|
+
},
|
|
25
|
+
599: (data) => {
|
|
26
|
+
message.error(data.data.errorMessage);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export {
|
|
30
|
+
handleErrorStatus
|
|
31
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { getUserInfo } from "@kp-ui/tool";
|
|
2
|
+
import { getHttp } from "@kp-ui/tool";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
import { message } from "ant-design-vue";
|
|
5
|
+
import { handleErrorStatus } from "./handleAxiosError.js";
|
|
6
|
+
const http = axios.create({
|
|
7
|
+
timeout: 6e5,
|
|
8
|
+
baseURL: void 0,
|
|
9
|
+
withCredentials: true,
|
|
10
|
+
// transformResponse: [
|
|
11
|
+
// function (data) {
|
|
12
|
+
// try {
|
|
13
|
+
// return JSONBig.parse(data);
|
|
14
|
+
// } catch (error) {
|
|
15
|
+
// console.log(error);
|
|
16
|
+
// return data;
|
|
17
|
+
// }
|
|
18
|
+
// }
|
|
19
|
+
// ],
|
|
20
|
+
validateStatus(status) {
|
|
21
|
+
return status <= 600;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
http.interceptors.request.use((config) => {
|
|
25
|
+
const { tokenId, tenantId, employeeId } = getUserInfo();
|
|
26
|
+
config.withCredentials = true;
|
|
27
|
+
if (!config.headers) {
|
|
28
|
+
config.headers = {};
|
|
29
|
+
}
|
|
30
|
+
config.headers["mes-user"] = "{}";
|
|
31
|
+
config.headers["imeclient-type"] = "PC";
|
|
32
|
+
config.headers["imeclient-source"] = "tmgc2";
|
|
33
|
+
config.headers["imeclient-version"] = "1.0";
|
|
34
|
+
config.headers["accept-language"] = "zh-CN";
|
|
35
|
+
if (tokenId) {
|
|
36
|
+
config.headers["Authorization"] = "Bearer " + tokenId;
|
|
37
|
+
}
|
|
38
|
+
if (tenantId) {
|
|
39
|
+
config.headers["imeclient-tenant-id"] = tenantId;
|
|
40
|
+
}
|
|
41
|
+
if (employeeId) {
|
|
42
|
+
config.headers["imeclient-employee-id"] = employeeId;
|
|
43
|
+
}
|
|
44
|
+
return config;
|
|
45
|
+
});
|
|
46
|
+
http.interceptors.response.use(
|
|
47
|
+
(data) => {
|
|
48
|
+
if ([200].includes(data.status)) {
|
|
49
|
+
const resData = data.data;
|
|
50
|
+
if (data.config.responseType === "blob") {
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
if (resData.success === true) {
|
|
54
|
+
return resData;
|
|
55
|
+
}
|
|
56
|
+
message.error(resData.errorMessage || "接口报错");
|
|
57
|
+
return Promise.reject(data);
|
|
58
|
+
} else {
|
|
59
|
+
if (handleErrorStatus[Number(data.status)]) {
|
|
60
|
+
handleErrorStatus[Number(data.status)](data);
|
|
61
|
+
} else {
|
|
62
|
+
message.error(data.statusText);
|
|
63
|
+
}
|
|
64
|
+
return Promise.reject(data);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
(error) => {
|
|
68
|
+
if (error.name === "CanceledError") {
|
|
69
|
+
return Promise.reject(error);
|
|
70
|
+
}
|
|
71
|
+
if (!error.response) {
|
|
72
|
+
return Promise.reject(error);
|
|
73
|
+
}
|
|
74
|
+
console.log(error);
|
|
75
|
+
return Promise.reject(error);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
export {
|
|
79
|
+
http as default,
|
|
80
|
+
getHttp
|
|
81
|
+
};
|