@fle-ui/plus-table 1.0.5 → 1.0.15
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/README.md +18 -18
- package/es/FormSearch/FormRender.d.ts +31 -0
- package/es/FormSearch/FormRender.js +208 -0
- package/es/FormSearch/index.d.ts +44 -0
- package/es/FormSearch/index.js +187 -0
- package/es/FormSearch/index.less +57 -0
- package/es/components/icon/index.d.ts +3 -0
- package/es/components/icon/index.js +7 -0
- package/es/index.d.ts +44 -0
- package/es/index.js +450 -0
- package/es/index.less +107 -0
- package/es/utils/api.d.ts +9 -0
- package/es/utils/api.js +9 -0
- package/es/utils/common.d.ts +26 -0
- package/es/utils/common.js +31 -0
- package/es/utils/options.d.ts +25 -0
- package/es/utils/options.js +95 -0
- package/es/utils/request.d.ts +26 -0
- package/es/utils/request.js +176 -0
- package/es/utils/serviceEnv.d.ts +6 -0
- package/es/utils/serviceEnv.js +12 -0
- package/lib/FormSearch/FormRender.d.ts +31 -0
- package/lib/FormSearch/FormRender.js +214 -0
- package/lib/FormSearch/index.d.ts +44 -0
- package/lib/FormSearch/index.js +194 -0
- package/lib/FormSearch/index.less +57 -0
- package/lib/components/icon/index.d.ts +3 -0
- package/lib/components/icon/index.js +13 -0
- package/lib/index.d.ts +44 -0
- package/lib/index.js +450 -0
- package/lib/index.less +107 -0
- package/lib/utils/api.d.ts +9 -0
- package/lib/utils/api.js +15 -0
- package/lib/utils/common.d.ts +26 -0
- package/lib/utils/common.js +38 -0
- package/lib/utils/options.d.ts +25 -0
- package/lib/utils/options.js +101 -0
- package/lib/utils/request.d.ts +26 -0
- package/lib/utils/request.js +180 -0
- package/lib/utils/serviceEnv.d.ts +6 -0
- package/lib/utils/serviceEnv.js +18 -0
- package/package.json +7 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const tabs: {
|
|
2
|
+
label: string;
|
|
3
|
+
key: string;
|
|
4
|
+
}[];
|
|
5
|
+
export declare const tabsSearchParamsMap: any;
|
|
6
|
+
export declare const priceRangeForOnce: {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const priceRangeForPurchase: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}[];
|
|
14
|
+
export declare const profitRangeForOnce: {
|
|
15
|
+
label: string;
|
|
16
|
+
value: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare const profitRangeForPurchase: {
|
|
19
|
+
label: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}[];
|
|
22
|
+
export declare const sortOptions: {
|
|
23
|
+
label: string;
|
|
24
|
+
value: string;
|
|
25
|
+
}[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export var tabs = [{
|
|
2
|
+
label: '京东商品',
|
|
3
|
+
key: 'jd'
|
|
4
|
+
}, {
|
|
5
|
+
label: '精选商品',
|
|
6
|
+
key: 'jx'
|
|
7
|
+
}, {
|
|
8
|
+
label: '自有商品',
|
|
9
|
+
key: 'zy'
|
|
10
|
+
}, {
|
|
11
|
+
label: '鲜花蛋糕',
|
|
12
|
+
key: 'xhdg'
|
|
13
|
+
}, {
|
|
14
|
+
label: '猫超商品',
|
|
15
|
+
key: 'mc'
|
|
16
|
+
}];
|
|
17
|
+
export var tabsSearchParamsMap = {
|
|
18
|
+
jd: {
|
|
19
|
+
thirdType: 10,
|
|
20
|
+
isSelf: 0
|
|
21
|
+
},
|
|
22
|
+
jx: {
|
|
23
|
+
thirdType: 0,
|
|
24
|
+
isSelf: 0
|
|
25
|
+
},
|
|
26
|
+
zy: {
|
|
27
|
+
isSelf: 1
|
|
28
|
+
},
|
|
29
|
+
xhdg: {
|
|
30
|
+
thirdType: 40,
|
|
31
|
+
isSelf: 0
|
|
32
|
+
},
|
|
33
|
+
mc: {
|
|
34
|
+
thirdType: 50,
|
|
35
|
+
isSelf: 0
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
// 一件代发价格筛选配置 - 非营销云
|
|
39
|
+
export var priceRangeForOnce = [{
|
|
40
|
+
label: '市场价',
|
|
41
|
+
value: 'onceMarketPrice'
|
|
42
|
+
}, {
|
|
43
|
+
label: '代发价',
|
|
44
|
+
value: 'onceSalePrice'
|
|
45
|
+
}, {
|
|
46
|
+
label: '销售价',
|
|
47
|
+
value: 'onceSitePrice'
|
|
48
|
+
}];
|
|
49
|
+
// 集采价格筛选配置 - 营销云
|
|
50
|
+
export var priceRangeForPurchase = [{
|
|
51
|
+
label: '集采市场价',
|
|
52
|
+
value: 'purchaseMarketPrice'
|
|
53
|
+
}, {
|
|
54
|
+
label: '代发市场价',
|
|
55
|
+
value: 'onceMarketPrice'
|
|
56
|
+
}, {
|
|
57
|
+
label: '集采价',
|
|
58
|
+
value: 'purchaseSalePrice'
|
|
59
|
+
}, {
|
|
60
|
+
label: '代发价',
|
|
61
|
+
value: 'onceSalePrice'
|
|
62
|
+
}, {
|
|
63
|
+
label: '集采销售价',
|
|
64
|
+
value: 'purchaseSitePrice'
|
|
65
|
+
}, {
|
|
66
|
+
label: '代发销售价',
|
|
67
|
+
value: 'onceSitePrice'
|
|
68
|
+
}];
|
|
69
|
+
// 一件代发利润率筛选配置 - 非营销云
|
|
70
|
+
export var profitRangeForOnce = [{
|
|
71
|
+
label: '利润率',
|
|
72
|
+
value: 'onceSiteProfit'
|
|
73
|
+
}];
|
|
74
|
+
// 集采利润率筛选配置 - 营销云
|
|
75
|
+
export var profitRangeForPurchase = [{
|
|
76
|
+
label: '集采利润率',
|
|
77
|
+
value: 'purchaseSiteProfit'
|
|
78
|
+
}, {
|
|
79
|
+
label: '代发利润率',
|
|
80
|
+
value: 'onceSiteProfit'
|
|
81
|
+
}];
|
|
82
|
+
// 排序规则
|
|
83
|
+
export var sortOptions = [{
|
|
84
|
+
label: '推荐',
|
|
85
|
+
value: 'pool_saas_search_site_profit_max' // 销售利润率(站点利润率)
|
|
86
|
+
}, {
|
|
87
|
+
label: '上架时间',
|
|
88
|
+
value: 'pool_saas_putaway_time'
|
|
89
|
+
}, {
|
|
90
|
+
label: '会员价',
|
|
91
|
+
value: 'search_sale_price_max'
|
|
92
|
+
}, {
|
|
93
|
+
label: '销售价',
|
|
94
|
+
value: 'pool_saas_search_site_price_max'
|
|
95
|
+
}];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
interface RequestConfig extends AxiosRequestConfig {
|
|
3
|
+
notice?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare module 'axios' {
|
|
6
|
+
interface AxiosInstance {
|
|
7
|
+
(config: RequestConfig): Promise<any>;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
interface AxiosConfig {
|
|
11
|
+
baseUrl?: string;
|
|
12
|
+
timeout?: number;
|
|
13
|
+
tokenKey?: string;
|
|
14
|
+
token?: string | undefined;
|
|
15
|
+
loginErrUrl?: string;
|
|
16
|
+
loginErrFn?: Function | undefined;
|
|
17
|
+
noNotificationCodes?: Array<string | number>;
|
|
18
|
+
errUrlFn?: Function | undefined;
|
|
19
|
+
formDataUrls?: Array<string>;
|
|
20
|
+
exceptionErrFn?: {
|
|
21
|
+
notification?: Function | undefined;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare const Request: (configParams: AxiosConfig) => import("axios").AxiosInstance;
|
|
25
|
+
export declare const request: import("axios").AxiosInstance;
|
|
26
|
+
export default Request;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import "antd/es/modal/style";
|
|
2
|
+
import _Modal from "antd/es/modal";
|
|
3
|
+
import "antd/es/notification/style";
|
|
4
|
+
import _notification from "antd/es/notification";
|
|
5
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
import Cookies from 'js-cookie';
|
|
12
|
+
import axios from 'axios';
|
|
13
|
+
import { getAePrefix, getAppInfo } from '@fle-tools/env';
|
|
14
|
+
var DATA_CODE = new Map([['SUCCESS', '2000'], ['LOGIN_ERROR', '100003']]);
|
|
15
|
+
// 登录失效
|
|
16
|
+
var CancelToken = axios.CancelToken;
|
|
17
|
+
var source = CancelToken.source();
|
|
18
|
+
var pending = [];
|
|
19
|
+
// 移除重复请求
|
|
20
|
+
var removePending = function removePending(config) {
|
|
21
|
+
for (var key in pending) {
|
|
22
|
+
var item = +key;
|
|
23
|
+
var list = pending[key];
|
|
24
|
+
// 当前请求在数组中存在时执行函数体
|
|
25
|
+
if (list.url === config.url && list.method === config.method && JSON.stringify(list.params) === JSON.stringify(config.params) && JSON.stringify(list.data) === JSON.stringify(config.data)) {
|
|
26
|
+
// 执行取消操作
|
|
27
|
+
list.cancel('操作太频繁,请稍后再试');
|
|
28
|
+
// 从数组中移除记录
|
|
29
|
+
pending.splice(item, 1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
// 默认配置
|
|
34
|
+
var initAxiosConfig = {
|
|
35
|
+
baseUrl: undefined,
|
|
36
|
+
timeout: 10000,
|
|
37
|
+
tokenKey: 'token',
|
|
38
|
+
token: undefined,
|
|
39
|
+
loginErrUrl: undefined,
|
|
40
|
+
loginErrFn: undefined,
|
|
41
|
+
noNotificationCodes: [],
|
|
42
|
+
errUrlFn: undefined,
|
|
43
|
+
formDataUrls: [] // 需要用formData提交的接口列表
|
|
44
|
+
};
|
|
45
|
+
var Request = function Request(configParams) {
|
|
46
|
+
configParams = _objectSpread(_objectSpread({}, initAxiosConfig), configParams);
|
|
47
|
+
// console.log(configParams, 'config')
|
|
48
|
+
var service = axios.create({
|
|
49
|
+
baseURL: configParams.baseUrl,
|
|
50
|
+
timeout: configParams.timeout
|
|
51
|
+
});
|
|
52
|
+
service.interceptors.request.use(function (config) {
|
|
53
|
+
var _configParams$formDat;
|
|
54
|
+
removePending(config);
|
|
55
|
+
config.headers['authority_token'] = configParams.token || Cookies.get(configParams.tokenKey);
|
|
56
|
+
config.url = "".concat(config.url);
|
|
57
|
+
if ((_configParams$formDat = configParams.formDataUrls) === null || _configParams$formDat === void 0 ? void 0 : _configParams$formDat.includes(config.url)) {
|
|
58
|
+
config.headers['Content-Type'] = 'multipart/form-data';
|
|
59
|
+
config.headers['Accept'] = '*/*';
|
|
60
|
+
}
|
|
61
|
+
return _objectSpread(_objectSpread({}, config), {}, {
|
|
62
|
+
cancelToken: source.token
|
|
63
|
+
});
|
|
64
|
+
}, function (err) {
|
|
65
|
+
var _configParams$excepti;
|
|
66
|
+
if ((_configParams$excepti = configParams.exceptionErrFn) === null || _configParams$excepti === void 0 ? void 0 : _configParams$excepti.notification) {
|
|
67
|
+
var _configParams$excepti2;
|
|
68
|
+
(_configParams$excepti2 = configParams.exceptionErrFn) === null || _configParams$excepti2 === void 0 ? void 0 : _configParams$excepti2.notification('提示', err.toString());
|
|
69
|
+
} else {
|
|
70
|
+
_notification.error({
|
|
71
|
+
message: '提示',
|
|
72
|
+
description: err.toString()
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return Promise.reject(_objectSpread(_objectSpread({}, err), {}, {
|
|
76
|
+
data: null
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
service.interceptors.response.use(function (res) {
|
|
80
|
+
var status = res.status,
|
|
81
|
+
data = res.data,
|
|
82
|
+
statusText = res.statusText,
|
|
83
|
+
config = res.config;
|
|
84
|
+
removePending(config);
|
|
85
|
+
return new Promise(function (resolve, reject) {
|
|
86
|
+
if (status < 200 || status > 300) {
|
|
87
|
+
var _configParams$excepti3;
|
|
88
|
+
if ((_configParams$excepti3 = configParams.exceptionErrFn) === null || _configParams$excepti3 === void 0 ? void 0 : _configParams$excepti3.notification) {
|
|
89
|
+
var _configParams$excepti4;
|
|
90
|
+
(_configParams$excepti4 = configParams.exceptionErrFn) === null || _configParams$excepti4 === void 0 ? void 0 : _configParams$excepti4.notification("\u8BF7\u6C42\u9519\u8BEF: ".concat(status), statusText);
|
|
91
|
+
} else {
|
|
92
|
+
_notification.error({
|
|
93
|
+
message: "\u8BF7\u6C42\u9519\u8BEF: ".concat(status),
|
|
94
|
+
description: statusText
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
reject(data);
|
|
98
|
+
} else if (!data.success) {
|
|
99
|
+
if (data.code === DATA_CODE.get('LOGIN_ERROR')) {
|
|
100
|
+
// 登录失效后,取消后续的http请求
|
|
101
|
+
source.cancel('登录失效');
|
|
102
|
+
if (configParams.loginErrFn) {
|
|
103
|
+
configParams.loginErrFn();
|
|
104
|
+
} else if (configParams.loginErrUrl) {
|
|
105
|
+
_Modal.warning({
|
|
106
|
+
title: '登录失效',
|
|
107
|
+
content: '点击确定重新登录',
|
|
108
|
+
okText: '确定',
|
|
109
|
+
onOk: function onOk() {
|
|
110
|
+
var _getAppInfo;
|
|
111
|
+
window.location.href = configParams.loginErrUrl || ((_getAppInfo = getAppInfo()) === null || _getAppInfo === void 0 ? void 0 : _getAppInfo.__fle_loginErrUrl__);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
var _configParams$noNotif;
|
|
117
|
+
if (!((_configParams$noNotif = configParams.noNotificationCodes) === null || _configParams$noNotif === void 0 ? void 0 : _configParams$noNotif.includes(data.code))) {
|
|
118
|
+
var _configParams$excepti5;
|
|
119
|
+
if ((_configParams$excepti5 = configParams.exceptionErrFn) === null || _configParams$excepti5 === void 0 ? void 0 : _configParams$excepti5.notification) {
|
|
120
|
+
var _configParams$excepti6;
|
|
121
|
+
(_configParams$excepti6 = configParams.exceptionErrFn) === null || _configParams$excepti6 === void 0 ? void 0 : _configParams$excepti6.notification('提示', data.message);
|
|
122
|
+
} else {
|
|
123
|
+
_notification.error({
|
|
124
|
+
message: '提示',
|
|
125
|
+
description: data.message
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
reject(data);
|
|
131
|
+
} else {
|
|
132
|
+
resolve(data);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}, function (err) {
|
|
136
|
+
var _err$message;
|
|
137
|
+
if (err.message === 'Request failed with status code 404') {
|
|
138
|
+
if (configParams.errUrlFn) {
|
|
139
|
+
configParams.errUrlFn();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (err.message === '登录失效') {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if ((_err$message = err.message) === null || _err$message === void 0 ? void 0 : _err$message.includes('timeout')) {
|
|
147
|
+
var _configParams$excepti7;
|
|
148
|
+
if ((_configParams$excepti7 = configParams.exceptionErrFn) === null || _configParams$excepti7 === void 0 ? void 0 : _configParams$excepti7.notification) {
|
|
149
|
+
var _configParams$excepti8;
|
|
150
|
+
(_configParams$excepti8 = configParams.exceptionErrFn) === null || _configParams$excepti8 === void 0 ? void 0 : _configParams$excepti8.notification('提示', '请求超时~');
|
|
151
|
+
} else {
|
|
152
|
+
_notification.error({
|
|
153
|
+
message: '提示',
|
|
154
|
+
description: '请求超时~'
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
var _configParams$excepti9;
|
|
159
|
+
if ((_configParams$excepti9 = configParams.exceptionErrFn) === null || _configParams$excepti9 === void 0 ? void 0 : _configParams$excepti9.notification) {
|
|
160
|
+
var _configParams$excepti10;
|
|
161
|
+
(_configParams$excepti10 = configParams.exceptionErrFn) === null || _configParams$excepti10 === void 0 ? void 0 : _configParams$excepti10.notification('提示', err.toString());
|
|
162
|
+
} else {
|
|
163
|
+
_notification.error({
|
|
164
|
+
message: '提示',
|
|
165
|
+
description: err.toString()
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return Promise.reject(err);
|
|
170
|
+
});
|
|
171
|
+
return service;
|
|
172
|
+
};
|
|
173
|
+
export var request = Request({
|
|
174
|
+
baseUrl: getAePrefix()
|
|
175
|
+
});
|
|
176
|
+
export default Request;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var baseURLMap = {
|
|
2
|
+
dev: 'https://dev-gateway.fxqifu.net/pangu',
|
|
3
|
+
test: 'https://qa-gateway.fxqifu.net/pangu',
|
|
4
|
+
qa: 'https://qa-gateway.fxqifu.net/pangu',
|
|
5
|
+
prod: 'https://gateway.fxqifu.net/pangu'
|
|
6
|
+
};
|
|
7
|
+
export var getApiHost = function getApiHost(env) {
|
|
8
|
+
return baseURLMap[env];
|
|
9
|
+
};
|
|
10
|
+
export var getApiUrl = function getApiUrl(env, url) {
|
|
11
|
+
return baseURLMap[env] + url;
|
|
12
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BaseQueryFilterProps, ProFormInstance, ProFormProps } from '@ant-design/pro-form';
|
|
2
|
+
import type { ProSchemaComponentTypes } from '@ant-design/pro-utils';
|
|
3
|
+
import type { FormItemProps } from 'antd';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import type { ActionType, ProColumns, ProTableProps } from '@ant-design/pro-components';
|
|
6
|
+
export type SearchConfig = BaseQueryFilterProps & {
|
|
7
|
+
filterType?: 'query' | 'light';
|
|
8
|
+
};
|
|
9
|
+
export type TableFormItem<T, U = any> = {
|
|
10
|
+
onSubmit?: (value: T, firstLoad: boolean) => void;
|
|
11
|
+
onReset?: (value: T) => void;
|
|
12
|
+
form?: Omit<ProFormProps, 'form'>;
|
|
13
|
+
type?: ProSchemaComponentTypes;
|
|
14
|
+
dateFormatter?: ProTableProps<T, U, any>['dateFormatter'];
|
|
15
|
+
search?: false | SearchConfig;
|
|
16
|
+
columns: ProColumns<U, any>[];
|
|
17
|
+
formRef: React.MutableRefObject<ProFormInstance | undefined>;
|
|
18
|
+
submitButtonLoading?: boolean;
|
|
19
|
+
manualRequest?: boolean;
|
|
20
|
+
bordered?: boolean;
|
|
21
|
+
action: React.MutableRefObject<ActionType | undefined>;
|
|
22
|
+
ghost?: boolean;
|
|
23
|
+
} & Omit<FormItemProps, 'children' | 'onReset'>;
|
|
24
|
+
/**
|
|
25
|
+
* 这里会把 列配置转化为 form 表单
|
|
26
|
+
*
|
|
27
|
+
* @param param0
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
declare const FormRender: <T, U = any>({ onSubmit, formRef, dateFormatter, type, columns, action, ghost, manualRequest, onReset, submitButtonLoading, search: searchConfig, form: formConfig, bordered, }: TableFormItem<T, U>) => React.JSX.Element;
|
|
31
|
+
export default FormRender;
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _proForm = require("@ant-design/pro-form");
|
|
8
|
+
var _proProvider = require("@ant-design/pro-provider");
|
|
9
|
+
var _antd = require("antd");
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _omit = _interopRequireDefault(require("omit.js"));
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
18
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
19
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
20
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
21
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
22
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
23
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
25
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
+
function toLowerLine(str) {
|
|
27
|
+
var temp = str.replace(/[A-Z]/g, function (match) {
|
|
28
|
+
return "-".concat(match.toLowerCase());
|
|
29
|
+
});
|
|
30
|
+
if (temp.startsWith('-')) {
|
|
31
|
+
// 如果首字母是大写,执行replace时会多一个_,这里需要去掉
|
|
32
|
+
temp = temp.slice(1);
|
|
33
|
+
}
|
|
34
|
+
return temp;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 获取当前选择的 Form Layout 配置
|
|
38
|
+
*
|
|
39
|
+
* @param isForm
|
|
40
|
+
* @param searchConfig
|
|
41
|
+
* @returns LightFilter | QueryFilter | ProForm
|
|
42
|
+
*/
|
|
43
|
+
var getFormCompetent = function getFormCompetent(isForm, searchConfig) {
|
|
44
|
+
if (!isForm && searchConfig !== false) {
|
|
45
|
+
if ((searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.filterType) === 'light') {
|
|
46
|
+
return 'LightFilter';
|
|
47
|
+
}
|
|
48
|
+
return 'QueryFilter';
|
|
49
|
+
}
|
|
50
|
+
return 'Form';
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 获取需要传给相应表单的props
|
|
54
|
+
*
|
|
55
|
+
* @param searchConfig
|
|
56
|
+
* @param name
|
|
57
|
+
*/
|
|
58
|
+
var getFromProps = function getFromProps(isForm, searchConfig, name) {
|
|
59
|
+
if (!isForm && name === 'LightFilter') {
|
|
60
|
+
// 传给 lightFilter 的问题
|
|
61
|
+
return (0, _omit.default)(_objectSpread({}, searchConfig), ['labelWidth', 'defaultCollapsed', 'filterType']);
|
|
62
|
+
}
|
|
63
|
+
if (!isForm) {
|
|
64
|
+
// 传给 QueryFilter 的配置
|
|
65
|
+
return (0, _omit.default)(_objectSpread({
|
|
66
|
+
labelWidth: searchConfig ? searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.labelWidth : undefined,
|
|
67
|
+
defaultCollapsed: true
|
|
68
|
+
}, searchConfig), ['filterType']);
|
|
69
|
+
}
|
|
70
|
+
return {};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* 从formConfig中获取传给相应表单的配置
|
|
74
|
+
*
|
|
75
|
+
* @param isForm
|
|
76
|
+
* @param formConfig
|
|
77
|
+
*/
|
|
78
|
+
var getFormConfigs = function getFormConfigs(isForm, formConfig) {
|
|
79
|
+
if (isForm) {
|
|
80
|
+
// 传给Form的配置
|
|
81
|
+
return (0, _omit.default)(formConfig, ['ignoreRules']);
|
|
82
|
+
}
|
|
83
|
+
// 传给Filter的配置
|
|
84
|
+
return _objectSpread({
|
|
85
|
+
ignoreRules: true
|
|
86
|
+
}, formConfig);
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* 这里会把 列配置转化为 form 表单
|
|
90
|
+
*
|
|
91
|
+
* @param param0
|
|
92
|
+
* @returns
|
|
93
|
+
*/
|
|
94
|
+
var FormRender = function FormRender(_ref) {
|
|
95
|
+
var onSubmit = _ref.onSubmit,
|
|
96
|
+
formRef = _ref.formRef,
|
|
97
|
+
_ref$dateFormatter = _ref.dateFormatter,
|
|
98
|
+
dateFormatter = _ref$dateFormatter === void 0 ? 'string' : _ref$dateFormatter,
|
|
99
|
+
type = _ref.type,
|
|
100
|
+
columns = _ref.columns,
|
|
101
|
+
action = _ref.action,
|
|
102
|
+
ghost = _ref.ghost,
|
|
103
|
+
manualRequest = _ref.manualRequest,
|
|
104
|
+
_onReset = _ref.onReset,
|
|
105
|
+
submitButtonLoading = _ref.submitButtonLoading,
|
|
106
|
+
searchConfig = _ref.search,
|
|
107
|
+
formConfig = _ref.form,
|
|
108
|
+
bordered = _ref.bordered;
|
|
109
|
+
var _useContext = (0, _react.useContext)(_proProvider.ProProvider),
|
|
110
|
+
hashId = _useContext.hashId;
|
|
111
|
+
var isForm = type === 'form';
|
|
112
|
+
/** 提交表单,根据两种模式不同,方法不相同 */
|
|
113
|
+
var submit = /*#__PURE__*/function () {
|
|
114
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(values, firstLoad) {
|
|
115
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
116
|
+
while (1) switch (_context.prev = _context.next) {
|
|
117
|
+
case 0:
|
|
118
|
+
if (onSubmit) {
|
|
119
|
+
onSubmit(values, firstLoad);
|
|
120
|
+
}
|
|
121
|
+
case 1:
|
|
122
|
+
case "end":
|
|
123
|
+
return _context.stop();
|
|
124
|
+
}
|
|
125
|
+
}, _callee);
|
|
126
|
+
}));
|
|
127
|
+
return function submit(_x, _x2) {
|
|
128
|
+
return _ref2.apply(this, arguments);
|
|
129
|
+
};
|
|
130
|
+
}();
|
|
131
|
+
var _useContext2 = (0, _react.useContext)(_antd.ConfigProvider.ConfigContext),
|
|
132
|
+
getPrefixCls = _useContext2.getPrefixCls;
|
|
133
|
+
var columnsList = (0, _react.useMemo)(function () {
|
|
134
|
+
return columns.filter(function (item) {
|
|
135
|
+
if (item === _antd.Table.EXPAND_COLUMN || item === _antd.Table.SELECTION_COLUMN) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
if ((item.hideInSearch || item.search === false) && type !== 'form') {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (type === 'form' && item.hideInForm) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}).map(function (item) {
|
|
146
|
+
var _item$dataIndex;
|
|
147
|
+
var finalValueType = !item.valueType || ['textarea', 'jsonCode', 'code'].includes(item === null || item === void 0 ? void 0 : item.valueType) && type === 'table' ? 'text' : item === null || item === void 0 ? void 0 : item.valueType;
|
|
148
|
+
var columnKey = (item === null || item === void 0 ? void 0 : item.key) || (item === null || item === void 0 ? void 0 : (_item$dataIndex = item.dataIndex) === null || _item$dataIndex === void 0 ? void 0 : _item$dataIndex.toString());
|
|
149
|
+
return _objectSpread(_objectSpread(_objectSpread({}, item), {}, {
|
|
150
|
+
width: undefined
|
|
151
|
+
}, item.search ? item.search : {}), {}, {
|
|
152
|
+
valueType: finalValueType,
|
|
153
|
+
proFieldProps: _objectSpread(_objectSpread({}, item.proFieldProps), {}, {
|
|
154
|
+
proFieldKey: columnKey ? "table-field-".concat(columnKey) : undefined
|
|
155
|
+
})
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
}, [columns, type]);
|
|
159
|
+
var className = getPrefixCls('pro-table-search');
|
|
160
|
+
var formClassName = getPrefixCls('pro-table-form');
|
|
161
|
+
var competentName = (0, _react.useMemo)(function () {
|
|
162
|
+
return getFormCompetent(isForm, searchConfig);
|
|
163
|
+
}, [searchConfig, isForm]);
|
|
164
|
+
// 传给每个表单的配置,理论上大家都需要
|
|
165
|
+
var loadingProps = (0, _react.useMemo)(function () {
|
|
166
|
+
return {
|
|
167
|
+
submitter: {
|
|
168
|
+
submitButtonProps: {
|
|
169
|
+
loading: submitButtonLoading
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}, [submitButtonLoading]);
|
|
174
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
175
|
+
className: (0, _classnames.default)(hashId, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, getPrefixCls('pro-card'), true), "".concat(getPrefixCls('pro-card'), "-border"), !!bordered), "".concat(getPrefixCls('pro-card'), "-bordered"), !!bordered), "".concat(getPrefixCls('pro-card'), "-ghost"), !!ghost), className, true), formClassName, isForm), getPrefixCls("pro-table-search-".concat(toLowerLine(competentName))), true), "".concat(className, "-ghost"), ghost), searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.className, searchConfig !== false && (searchConfig === null || searchConfig === void 0 ? void 0 : searchConfig.className)))
|
|
176
|
+
}, /*#__PURE__*/_react.default.createElement(_proForm.BetaSchemaForm, _extends({
|
|
177
|
+
layoutType: competentName,
|
|
178
|
+
columns: columnsList,
|
|
179
|
+
type: type
|
|
180
|
+
}, loadingProps, getFromProps(isForm, searchConfig, competentName), getFormConfigs(isForm, formConfig || {}), {
|
|
181
|
+
formRef: formRef,
|
|
182
|
+
action: action,
|
|
183
|
+
dateFormatter: dateFormatter,
|
|
184
|
+
onInit: function onInit(values, form) {
|
|
185
|
+
formRef.current = form;
|
|
186
|
+
// 触发一个 submit,之所以这里触发是为了保证 value 都被 format了
|
|
187
|
+
if (type !== 'form') {
|
|
188
|
+
var _action$current, _action$current2, _action$current2$setP;
|
|
189
|
+
// 修改 pageSize,变成从 url 中获取的
|
|
190
|
+
var pageInfo = (_action$current = action.current) === null || _action$current === void 0 ? void 0 : _action$current.pageInfo;
|
|
191
|
+
// 从 values 里获取是因为有时候要从 url中获取的 pageSize。
|
|
192
|
+
var _values$current = values.current,
|
|
193
|
+
current = _values$current === void 0 ? pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.current : _values$current,
|
|
194
|
+
_values$pageSize = values.pageSize,
|
|
195
|
+
pageSize = _values$pageSize === void 0 ? pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.pageSize : _values$pageSize;
|
|
196
|
+
(_action$current2 = action.current) === null || _action$current2 === void 0 ? void 0 : (_action$current2$setP = _action$current2.setPageInfo) === null || _action$current2$setP === void 0 ? void 0 : _action$current2$setP.call(_action$current2, _objectSpread(_objectSpread({}, pageInfo), {}, {
|
|
197
|
+
current: parseInt(current, 10),
|
|
198
|
+
pageSize: parseInt(pageSize, 10)
|
|
199
|
+
}));
|
|
200
|
+
/** 如果是手动模式不需要提交 */
|
|
201
|
+
if (manualRequest) return;
|
|
202
|
+
submit(values, true);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
onReset: function onReset(values) {
|
|
206
|
+
_onReset === null || _onReset === void 0 ? void 0 : _onReset(values);
|
|
207
|
+
},
|
|
208
|
+
onFinish: function onFinish(values) {
|
|
209
|
+
submit(values, false);
|
|
210
|
+
},
|
|
211
|
+
initialValues: formConfig === null || formConfig === void 0 ? void 0 : formConfig.initialValues
|
|
212
|
+
})));
|
|
213
|
+
};
|
|
214
|
+
var _default = exports.default = FormRender;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TablePaginationConfig } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { ActionType, ProTableProps } from '@ant-design/pro-components';
|
|
4
|
+
export type Bordered = boolean | {
|
|
5
|
+
search?: boolean;
|
|
6
|
+
table?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type BaseFormProps<T, U> = {
|
|
9
|
+
pagination?: TablePaginationConfig | false;
|
|
10
|
+
beforeSearchSubmit?: (params: Partial<U>) => any;
|
|
11
|
+
action: React.MutableRefObject<ActionType | undefined>;
|
|
12
|
+
onSubmit?: (params: U) => void;
|
|
13
|
+
onReset?: () => void;
|
|
14
|
+
loading: boolean;
|
|
15
|
+
onFormSearchSubmit: (params: U) => void;
|
|
16
|
+
columns: ProTableProps<T, U, any>['columns'];
|
|
17
|
+
dateFormatter: ProTableProps<T, U, any>['dateFormatter'];
|
|
18
|
+
formRef: ProTableProps<T, U, any>['formRef'];
|
|
19
|
+
type: ProTableProps<T, U, any>['type'];
|
|
20
|
+
cardBordered: ProTableProps<T, U, any>['cardBordered'];
|
|
21
|
+
form: ProTableProps<T, U, any>['form'];
|
|
22
|
+
search: ProTableProps<T, U, any>['search'];
|
|
23
|
+
manualRequest: ProTableProps<T, U, any>['manualRequest'];
|
|
24
|
+
changeValue: Function;
|
|
25
|
+
};
|
|
26
|
+
declare class FormSearch<T, U> extends React.Component<BaseFormProps<T, U> & {
|
|
27
|
+
ghost?: boolean;
|
|
28
|
+
}> {
|
|
29
|
+
/** 查询表单相关的配置 */
|
|
30
|
+
onSubmit: (value: U, firstLoad: boolean) => void;
|
|
31
|
+
onReset: (value: Partial<U>) => void;
|
|
32
|
+
/**
|
|
33
|
+
* 只 Diff 需要用的 props,能减少 5 次左右的render
|
|
34
|
+
*
|
|
35
|
+
* @param next
|
|
36
|
+
* @see 因为 hooks 每次的 setFormSearch 都是新的,所以每次都触发 render
|
|
37
|
+
* @see action 也是同样的原因
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
isEqual: (next: BaseFormProps<T, U>) => boolean;
|
|
41
|
+
shouldComponentUpdate: (next: BaseFormProps<T, U>) => boolean;
|
|
42
|
+
render: () => React.JSX.Element;
|
|
43
|
+
}
|
|
44
|
+
export default FormSearch;
|