ls-pro-common 3.1.54 → 3.1.56
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/dist/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/es/components/InputTable.js +12 -4
- package/es/http/index.d.ts +2 -1
- package/es/http/index.js +6 -1
- package/es/utils/url.js +6 -3
- package/lib/components/InputTable.js +12 -4
- package/lib/http/index.d.ts +2 -1
- package/lib/http/index.js +6 -1
- package/lib/utils/url.js +6 -3
- package/package.json +1 -1
|
@@ -7,10 +7,10 @@ import _Popover from "antd/es/popover";
|
|
|
7
7
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
8
8
|
import "antd/es/button/style";
|
|
9
9
|
import _Button from "antd/es/button";
|
|
10
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
11
10
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
12
11
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
13
12
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
13
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
14
14
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
15
15
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
16
16
|
var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "labelWidth", "textField", "onSelectChange", "beforeLoad", "afterLoad", "isV2", "allowClear", "keepSelect", "fieldProps", "searchField", "fillMap", "loadOnShow", "triggerCheck", "getPopupContainer", "placement", "arrowPointAtCenter", "method", "changeOnSelect", "rowKey", "record", "id"],
|
|
@@ -42,6 +42,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
42
42
|
setText = _useState6[1];
|
|
43
43
|
var inputRef = useRef();
|
|
44
44
|
var initRows = useRef(null); //用于存储初始行数据
|
|
45
|
+
var firstMount = useRef(true);
|
|
45
46
|
var columns = prop.columns,
|
|
46
47
|
url = prop.url,
|
|
47
48
|
textName = prop.textName,
|
|
@@ -144,10 +145,12 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
144
145
|
if (!(formRef === null || formRef === void 0 ? void 0 : formRef.current) && record) return record;
|
|
145
146
|
if (rowKey) {
|
|
146
147
|
var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
|
|
147
|
-
if (
|
|
148
|
-
|
|
148
|
+
if (firstMount.current && record) {
|
|
149
|
+
firstMount.current = false;
|
|
150
|
+
return record;
|
|
151
|
+
}
|
|
152
|
+
return _objectSpread(_objectSpread({}, record || {}), (formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsValue) === null || _formRef$current$getF === void 0 ? void 0 : (_formRef$current$getF2 = _formRef$current$getF.call(_formRef$current)) === null || _formRef$current$getF2 === void 0 ? void 0 : _formRef$current$getF2[rowKey]) || {});
|
|
149
153
|
}
|
|
150
|
-
|
|
151
154
|
return formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2);
|
|
152
155
|
};
|
|
153
156
|
/**
|
|
@@ -158,6 +161,11 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
158
161
|
var setFormValue = function setFormValue(formValue) {
|
|
159
162
|
var _prop$onChange;
|
|
160
163
|
(_prop$onChange = prop.onChange) === null || _prop$onChange === void 0 ? void 0 : _prop$onChange.call(prop, formValue[name]);
|
|
164
|
+
for (var key in formValue) {
|
|
165
|
+
if (formValue[key] === null) {
|
|
166
|
+
formValue[key] = undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
161
169
|
if (rowKey) {
|
|
162
170
|
var _formRef$current3, _formRef$current3$set;
|
|
163
171
|
formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _defineProperty({}, rowKey, formValue));
|
package/es/http/index.d.ts
CHANGED
|
@@ -61,9 +61,10 @@ export interface UploadResult {
|
|
|
61
61
|
* @param labelName 对应后端接口的文件字段名,默认为 'file'
|
|
62
62
|
* @param needGateWay 是否需要网关,默认为 true,如果url里已包含网关,则不需要网关
|
|
63
63
|
* @param onProgress 进度回调函数,参数为 0-100 的进度百分比
|
|
64
|
+
* @param useDownloadDomain 是否使用下载域名来上传,默认为 false
|
|
64
65
|
* @returns 返回包含 promise 和 cancel 方法的对象
|
|
65
66
|
*/
|
|
66
|
-
export declare const httpUpload: (url: string, file: File, params?: Record<string, any>, labelName?: string, needGateWay?: boolean, onProgress?: UploadProgressCallback | undefined) => UploadResult;
|
|
67
|
+
export declare const httpUpload: (url: string, file: File, params?: Record<string, any>, labelName?: string, needGateWay?: boolean, onProgress?: UploadProgressCallback | undefined, useDownloadDomain?: boolean) => UploadResult;
|
|
67
68
|
/**
|
|
68
69
|
* 分批获取数据,当一次性取大于2000条,且是第一页时,分多次去取,避免一次性取太多数据导致后端工程压力过大
|
|
69
70
|
*
|
package/es/http/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
import { extend } from 'umi-request';
|
|
7
|
-
import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache, isDingtalk } from '../utils';
|
|
7
|
+
import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache, isDingtalk, urlDownloadDomain } from '../utils';
|
|
8
8
|
//默认超时时间为1分钟
|
|
9
9
|
var request = extend({
|
|
10
10
|
timeout: 60000
|
|
@@ -368,6 +368,7 @@ export function httpDelete(url, data) {
|
|
|
368
368
|
* @param labelName 对应后端接口的文件字段名,默认为 'file'
|
|
369
369
|
* @param needGateWay 是否需要网关,默认为 true,如果url里已包含网关,则不需要网关
|
|
370
370
|
* @param onProgress 进度回调函数,参数为 0-100 的进度百分比
|
|
371
|
+
* @param useDownloadDomain 是否使用下载域名来上传,默认为 false
|
|
371
372
|
* @returns 返回包含 promise 和 cancel 方法的对象
|
|
372
373
|
*/
|
|
373
374
|
export var httpUpload = function httpUpload(url, file) {
|
|
@@ -375,6 +376,7 @@ export var httpUpload = function httpUpload(url, file) {
|
|
|
375
376
|
var labelName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'file';
|
|
376
377
|
var needGateWay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
377
378
|
var onProgress = arguments.length > 5 ? arguments[5] : undefined;
|
|
379
|
+
var useDownloadDomain = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
378
380
|
var formData = new FormData();
|
|
379
381
|
// 处理附加参数,转换为FormData格式
|
|
380
382
|
Object.keys(params).forEach(function (key) {
|
|
@@ -394,6 +396,9 @@ export var httpUpload = function httpUpload(url, file) {
|
|
|
394
396
|
var _window$crypto$random2, _window$crypto2;
|
|
395
397
|
// 处理 URL(模拟拦截器的逻辑)
|
|
396
398
|
var requestUrl = finalUrl;
|
|
399
|
+
if (useDownloadDomain) {
|
|
400
|
+
requestUrl = urlDownloadDomain(requestUrl);
|
|
401
|
+
}
|
|
397
402
|
// 移除 noToken 参数
|
|
398
403
|
requestUrl = requestUrl.replace('&noToken=1', '').replace('noToken=1', '');
|
|
399
404
|
// 处理 resCode
|
package/es/utils/url.js
CHANGED
|
@@ -80,8 +80,11 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
80
80
|
var defaultGateway = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
81
81
|
url = url || '';
|
|
82
82
|
// 如果url带有名称,不需要设置网关
|
|
83
|
-
if (url.startsWith('http://') || url.startsWith('https://')
|
|
84
|
-
if (url.startsWith('
|
|
83
|
+
if (url.startsWith('http://') || url.startsWith('https://')) return url;
|
|
84
|
+
if (url.startsWith('//')) {
|
|
85
|
+
return location.protocol + url;
|
|
86
|
+
}
|
|
87
|
+
if (url.startsWith('/lesoon/') || url.startsWith('/petrel/') || url.startsWith('/lesoon-retail/') || url.startsWith('/scm-bms/') || url.startsWith('/porch/')) {
|
|
85
88
|
return location.origin + url;
|
|
86
89
|
}
|
|
87
90
|
// 读取项目的默认网关
|
|
@@ -105,7 +108,7 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
|
-
//
|
|
111
|
+
// 网关加上域名,避免多次设置,比如业务开发调用了一次,基础组件中又添加一次。
|
|
109
112
|
if (gateway && !gateway.startsWith('http')) {
|
|
110
113
|
gateway = location.origin + gateway;
|
|
111
114
|
}
|
|
@@ -7,10 +7,10 @@ import _Popover from "antd/es/popover";
|
|
|
7
7
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
8
8
|
import "antd/es/button/style";
|
|
9
9
|
import _Button from "antd/es/button";
|
|
10
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
11
10
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
12
11
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
13
12
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
13
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
14
14
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
15
15
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
16
16
|
var _excluded = ["columns", "url", "textName", "name", "tableConfig", "tableHeight", "tableWidth", "readonly", "multiple", "valueField", "labelWidth", "textField", "onSelectChange", "beforeLoad", "afterLoad", "isV2", "allowClear", "keepSelect", "fieldProps", "searchField", "fillMap", "loadOnShow", "triggerCheck", "getPopupContainer", "placement", "arrowPointAtCenter", "method", "changeOnSelect", "rowKey", "record", "id"],
|
|
@@ -42,6 +42,7 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
42
42
|
setText = _useState6[1];
|
|
43
43
|
var inputRef = useRef();
|
|
44
44
|
var initRows = useRef(null); //用于存储初始行数据
|
|
45
|
+
var firstMount = useRef(true);
|
|
45
46
|
var columns = prop.columns,
|
|
46
47
|
url = prop.url,
|
|
47
48
|
textName = prop.textName,
|
|
@@ -144,10 +145,12 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
144
145
|
if (!(formRef === null || formRef === void 0 ? void 0 : formRef.current) && record) return record;
|
|
145
146
|
if (rowKey) {
|
|
146
147
|
var _formRef$current, _formRef$current$getF, _formRef$current$getF2;
|
|
147
|
-
if (
|
|
148
|
-
|
|
148
|
+
if (firstMount.current && record) {
|
|
149
|
+
firstMount.current = false;
|
|
150
|
+
return record;
|
|
151
|
+
}
|
|
152
|
+
return _objectSpread(_objectSpread({}, record || {}), (formRef === null || formRef === void 0 ? void 0 : (_formRef$current = formRef.current) === null || _formRef$current === void 0 ? void 0 : (_formRef$current$getF = _formRef$current.getFieldsValue) === null || _formRef$current$getF === void 0 ? void 0 : (_formRef$current$getF2 = _formRef$current$getF.call(_formRef$current)) === null || _formRef$current$getF2 === void 0 ? void 0 : _formRef$current$getF2[rowKey]) || {});
|
|
149
153
|
}
|
|
150
|
-
|
|
151
154
|
return formRef === null || formRef === void 0 ? void 0 : (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : (_formRef$current2$get = _formRef$current2.getFieldsValue) === null || _formRef$current2$get === void 0 ? void 0 : _formRef$current2$get.call(_formRef$current2);
|
|
152
155
|
};
|
|
153
156
|
/**
|
|
@@ -158,6 +161,11 @@ var InputTable = /*#__PURE__*/React.forwardRef(function (prop, ref) {
|
|
|
158
161
|
var setFormValue = function setFormValue(formValue) {
|
|
159
162
|
var _prop$onChange;
|
|
160
163
|
(_prop$onChange = prop.onChange) === null || _prop$onChange === void 0 ? void 0 : _prop$onChange.call(prop, formValue[name]);
|
|
164
|
+
for (var key in formValue) {
|
|
165
|
+
if (formValue[key] === null) {
|
|
166
|
+
formValue[key] = undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
161
169
|
if (rowKey) {
|
|
162
170
|
var _formRef$current3, _formRef$current3$set;
|
|
163
171
|
formRef === null || formRef === void 0 ? void 0 : (_formRef$current3 = formRef.current) === null || _formRef$current3 === void 0 ? void 0 : (_formRef$current3$set = _formRef$current3.setFieldsValue) === null || _formRef$current3$set === void 0 ? void 0 : _formRef$current3$set.call(_formRef$current3, _defineProperty({}, rowKey, formValue));
|
package/lib/http/index.d.ts
CHANGED
|
@@ -61,9 +61,10 @@ export interface UploadResult {
|
|
|
61
61
|
* @param labelName 对应后端接口的文件字段名,默认为 'file'
|
|
62
62
|
* @param needGateWay 是否需要网关,默认为 true,如果url里已包含网关,则不需要网关
|
|
63
63
|
* @param onProgress 进度回调函数,参数为 0-100 的进度百分比
|
|
64
|
+
* @param useDownloadDomain 是否使用下载域名来上传,默认为 false
|
|
64
65
|
* @returns 返回包含 promise 和 cancel 方法的对象
|
|
65
66
|
*/
|
|
66
|
-
export declare const httpUpload: (url: string, file: File, params?: Record<string, any>, labelName?: string, needGateWay?: boolean, onProgress?: UploadProgressCallback | undefined) => UploadResult;
|
|
67
|
+
export declare const httpUpload: (url: string, file: File, params?: Record<string, any>, labelName?: string, needGateWay?: boolean, onProgress?: UploadProgressCallback | undefined, useDownloadDomain?: boolean) => UploadResult;
|
|
67
68
|
/**
|
|
68
69
|
* 分批获取数据,当一次性取大于2000条,且是第一页时,分多次去取,避免一次性取太多数据导致后端工程压力过大
|
|
69
70
|
*
|
package/lib/http/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
6
|
import { extend } from 'umi-request';
|
|
7
|
-
import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache, isDingtalk } from '../utils';
|
|
7
|
+
import { getCache, getUrlQuery, setUrlQuery, getCookie, getCacheSessionFirst, getResourceProps, showError, httpError, toGatewayUrl, reLogin, showLoading, exitLoading, getBrowserId, setCache, isDingtalk, urlDownloadDomain } from '../utils';
|
|
8
8
|
//默认超时时间为1分钟
|
|
9
9
|
var request = extend({
|
|
10
10
|
timeout: 60000
|
|
@@ -368,6 +368,7 @@ export function httpDelete(url, data) {
|
|
|
368
368
|
* @param labelName 对应后端接口的文件字段名,默认为 'file'
|
|
369
369
|
* @param needGateWay 是否需要网关,默认为 true,如果url里已包含网关,则不需要网关
|
|
370
370
|
* @param onProgress 进度回调函数,参数为 0-100 的进度百分比
|
|
371
|
+
* @param useDownloadDomain 是否使用下载域名来上传,默认为 false
|
|
371
372
|
* @returns 返回包含 promise 和 cancel 方法的对象
|
|
372
373
|
*/
|
|
373
374
|
export var httpUpload = function httpUpload(url, file) {
|
|
@@ -375,6 +376,7 @@ export var httpUpload = function httpUpload(url, file) {
|
|
|
375
376
|
var labelName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'file';
|
|
376
377
|
var needGateWay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
377
378
|
var onProgress = arguments.length > 5 ? arguments[5] : undefined;
|
|
379
|
+
var useDownloadDomain = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
378
380
|
var formData = new FormData();
|
|
379
381
|
// 处理附加参数,转换为FormData格式
|
|
380
382
|
Object.keys(params).forEach(function (key) {
|
|
@@ -394,6 +396,9 @@ export var httpUpload = function httpUpload(url, file) {
|
|
|
394
396
|
var _window$crypto$random2, _window$crypto2;
|
|
395
397
|
// 处理 URL(模拟拦截器的逻辑)
|
|
396
398
|
var requestUrl = finalUrl;
|
|
399
|
+
if (useDownloadDomain) {
|
|
400
|
+
requestUrl = urlDownloadDomain(requestUrl);
|
|
401
|
+
}
|
|
397
402
|
// 移除 noToken 参数
|
|
398
403
|
requestUrl = requestUrl.replace('&noToken=1', '').replace('noToken=1', '');
|
|
399
404
|
// 处理 resCode
|
package/lib/utils/url.js
CHANGED
|
@@ -80,8 +80,11 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
80
80
|
var defaultGateway = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
81
81
|
url = url || '';
|
|
82
82
|
// 如果url带有名称,不需要设置网关
|
|
83
|
-
if (url.startsWith('http://') || url.startsWith('https://')
|
|
84
|
-
if (url.startsWith('
|
|
83
|
+
if (url.startsWith('http://') || url.startsWith('https://')) return url;
|
|
84
|
+
if (url.startsWith('//')) {
|
|
85
|
+
return location.protocol + url;
|
|
86
|
+
}
|
|
87
|
+
if (url.startsWith('/lesoon/') || url.startsWith('/petrel/') || url.startsWith('/lesoon-retail/') || url.startsWith('/scm-bms/') || url.startsWith('/porch/')) {
|
|
85
88
|
return location.origin + url;
|
|
86
89
|
}
|
|
87
90
|
// 读取项目的默认网关
|
|
@@ -105,7 +108,7 @@ export var toGatewayUrl = function toGatewayUrl(url) {
|
|
|
105
108
|
}
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
|
-
//
|
|
111
|
+
// 网关加上域名,避免多次设置,比如业务开发调用了一次,基础组件中又添加一次。
|
|
109
112
|
if (gateway && !gateway.startsWith('http')) {
|
|
110
113
|
gateway = location.origin + gateway;
|
|
111
114
|
}
|