@zgfe/business-lib 1.1.76-bugfix.0 → 1.1.76-bugfix.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/es/addToPanel/index.js +5 -2
- package/es/utils/ajax.js +18 -29
- package/es/utils/util.d.ts +3 -0
- package/es/utils/util.js +7 -0
- package/package.json +2 -2
package/es/addToPanel/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import request from '../utils/ajax';
|
|
|
23
23
|
import Apis from '../constants/apis';
|
|
24
24
|
import BizGlobalDataContext from '../context';
|
|
25
25
|
import _ from 'lodash';
|
|
26
|
+
import { util } from '../utils';
|
|
26
27
|
export var classPrefix = 'biz-addtopanel';
|
|
27
28
|
var BizAddToPanel = function BizAddToPanel(props) {
|
|
28
29
|
var refForm = useRef();
|
|
@@ -119,8 +120,10 @@ var BizAddToPanel = function BizAddToPanel(props) {
|
|
|
119
120
|
}
|
|
120
121
|
request(url, {
|
|
121
122
|
method: 'post',
|
|
122
|
-
data: data,
|
|
123
|
-
|
|
123
|
+
data: util.transformRequest(data),
|
|
124
|
+
headers: {
|
|
125
|
+
'Content-Type': 'application/x-www-form-urlencoded'
|
|
126
|
+
}
|
|
124
127
|
}).then(function (res) {
|
|
125
128
|
setLoading(false);
|
|
126
129
|
var result = res;
|
package/es/utils/ajax.js
CHANGED
|
@@ -7,7 +7,6 @@ import { notification, message } from 'antd';
|
|
|
7
7
|
import { globalConfig } from '../config';
|
|
8
8
|
import { ResponseStatus } from './type';
|
|
9
9
|
import util from './util';
|
|
10
|
-
import _ from 'lodash';
|
|
11
10
|
var codeMessage = {
|
|
12
11
|
200: '服务器成功返回请求的数据。',
|
|
13
12
|
201: '新建或修改数据成功。',
|
|
@@ -108,27 +107,17 @@ function _request() {
|
|
|
108
107
|
while (1) switch (_context.prev = _context.next) {
|
|
109
108
|
case 0:
|
|
110
109
|
_context.prev = 0;
|
|
111
|
-
if (options === null || options === void 0 ? void 0 : options.isTransform) {
|
|
112
|
-
options.transformRequest = function (params) {
|
|
113
|
-
var arr = [];
|
|
114
|
-
for (var key in params) {
|
|
115
|
-
var value = _.isString(params[key]) ? params[key] : JSON.stringify(params[key]);
|
|
116
|
-
arr.push("".concat(key, "=").concat(encodeURIComponent(value)));
|
|
117
|
-
}
|
|
118
|
-
return arr.join('&');
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
110
|
if (!/{{\S*}}/.test(url)) {
|
|
122
|
-
_context.next =
|
|
111
|
+
_context.next = 8;
|
|
123
112
|
break;
|
|
124
113
|
}
|
|
125
114
|
if (!(!options || !options.params)) {
|
|
126
|
-
_context.next =
|
|
115
|
+
_context.next = 5;
|
|
127
116
|
break;
|
|
128
117
|
}
|
|
129
118
|
err = new Error("\u5E26\u53C2URL(".concat(url, ")\u8BF7\u6C42\u4E2D\uFF0C\u7F3A\u5C11params\u53C2\u6570"));
|
|
130
119
|
throw err;
|
|
131
|
-
case
|
|
120
|
+
case 5:
|
|
132
121
|
option = options;
|
|
133
122
|
list = url.match(/{{\S*?}}/g) || [];
|
|
134
123
|
list.forEach(function (param) {
|
|
@@ -136,7 +125,7 @@ function _request() {
|
|
|
136
125
|
url = url.replace(param, option.params[key]);
|
|
137
126
|
delete option.params[key];
|
|
138
127
|
});
|
|
139
|
-
case
|
|
128
|
+
case 8:
|
|
140
129
|
optionsWrapper = (options === null || options === void 0 ? void 0 : options.optionsWrapper) || ((_globalConfig$request = globalConfig.request) === null || _globalConfig$request === void 0 ? void 0 : _globalConfig$request.optionsWrapper);
|
|
141
130
|
responseWrapper = (options === null || options === void 0 ? void 0 : options.responseWrapper) || ((_globalConfig$request2 = globalConfig.request) === null || _globalConfig$request2 === void 0 ? void 0 : _globalConfig$request2.responseWrapper);
|
|
142
131
|
params = optionsWrapper ? optionsWrapper(url, options) : {
|
|
@@ -146,44 +135,44 @@ function _request() {
|
|
|
146
135
|
if (((_params$options = params.options) === null || _params$options === void 0 ? void 0 : _params$options.responseType) === 'blob') {
|
|
147
136
|
params.options.getResponse = true;
|
|
148
137
|
}
|
|
149
|
-
_context.next =
|
|
138
|
+
_context.next = 14;
|
|
150
139
|
return req(params.url, params.options);
|
|
151
|
-
case
|
|
140
|
+
case 14:
|
|
152
141
|
res = _context.sent;
|
|
153
142
|
if (res) {
|
|
154
|
-
_context.next =
|
|
143
|
+
_context.next = 17;
|
|
155
144
|
break;
|
|
156
145
|
}
|
|
157
146
|
throw new Error('Request Interruption');
|
|
158
|
-
case
|
|
147
|
+
case 17:
|
|
159
148
|
if (!(((_params$options2 = params.options) === null || _params$options2 === void 0 ? void 0 : _params$options2.responseType) === 'blob')) {
|
|
160
|
-
_context.next =
|
|
149
|
+
_context.next = 23;
|
|
161
150
|
break;
|
|
162
151
|
}
|
|
163
152
|
if (!util.isBlob(res.data)) {
|
|
164
|
-
_context.next =
|
|
153
|
+
_context.next = 22;
|
|
165
154
|
break;
|
|
166
155
|
}
|
|
167
156
|
return _context.abrupt("return", downloadFile(res, params.options.fileName));
|
|
168
|
-
case
|
|
157
|
+
case 22:
|
|
169
158
|
res = res.data;
|
|
170
|
-
case
|
|
159
|
+
case 23:
|
|
171
160
|
return _context.abrupt("return", responseWrapper ? responseWrapper(url, responseErrorHandler(url, res, options === null || options === void 0 ? void 0 : options.errorTitle, options === null || options === void 0 ? void 0 : options.notifyType)) : responseErrorHandler(url, res, options === null || options === void 0 ? void 0 : options.errorTitle, options === null || options === void 0 ? void 0 : options.notifyType));
|
|
172
|
-
case
|
|
173
|
-
_context.prev =
|
|
161
|
+
case 26:
|
|
162
|
+
_context.prev = 26;
|
|
174
163
|
_context.t0 = _context["catch"](0);
|
|
175
164
|
if (!(_context.t0.message === 'Request Interruption')) {
|
|
176
|
-
_context.next =
|
|
165
|
+
_context.next = 30;
|
|
177
166
|
break;
|
|
178
167
|
}
|
|
179
168
|
throw new Error('Request Interruption');
|
|
180
|
-
case
|
|
169
|
+
case 30:
|
|
181
170
|
return _context.abrupt("return", null);
|
|
182
|
-
case
|
|
171
|
+
case 31:
|
|
183
172
|
case "end":
|
|
184
173
|
return _context.stop();
|
|
185
174
|
}
|
|
186
|
-
}, _callee, null, [[0,
|
|
175
|
+
}, _callee, null, [[0, 26]]);
|
|
187
176
|
}));
|
|
188
177
|
return _request.apply(this, arguments);
|
|
189
178
|
}
|
package/es/utils/util.d.ts
CHANGED
|
@@ -30,5 +30,8 @@ declare let util: {
|
|
|
30
30
|
replaceStr: string;
|
|
31
31
|
}): string;
|
|
32
32
|
setHighLight(content: string, search: string | RegExp, wrapper: (text: string, key: string) => any): any[];
|
|
33
|
+
transformRequest(param: {
|
|
34
|
+
[prop: string]: any;
|
|
35
|
+
}): string;
|
|
33
36
|
};
|
|
34
37
|
export default util;
|
package/es/utils/util.js
CHANGED
|
@@ -157,6 +157,13 @@ var util = {
|
|
|
157
157
|
res.push(this.setHighLight(content.substring(beginIndex, content.length), search, wrapper));
|
|
158
158
|
}
|
|
159
159
|
return res;
|
|
160
|
+
},
|
|
161
|
+
transformRequest: function transformRequest(param) {
|
|
162
|
+
var arr = [];
|
|
163
|
+
for (var key in param) {
|
|
164
|
+
arr.push("".concat(key, "=").concat(encodeURIComponent(param[key])));
|
|
165
|
+
}
|
|
166
|
+
return arr.join('&');
|
|
160
167
|
}
|
|
161
168
|
};
|
|
162
169
|
export default util;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.1.76-bugfix.
|
|
3
|
+
"version": "1.1.76-bugfix.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "dumi dev",
|
|
6
6
|
"docs:build": "dumi build",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"react": "^16.12.0 || ^17.0.0",
|
|
59
59
|
"yorkie": "^2.0.0"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "b7c48a5d961652e1feea1ac6db73f51c91d7e5b5"
|
|
62
62
|
}
|