fan-standard-comp 4.1.2 → 4.1.3
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/fan-standard-comp.min.js +1 -1
- package/es/FormComp/FieldComponent/ExtensionField.d.ts +2 -2
- package/es/FormComp/FieldComponent/ExtensionField.js +1 -1
- package/es/StandardFilter/index.js +32 -22
- package/es/StandardForm/index.js +3 -1
- package/es/StandardTable/index.d.ts +2 -26
- package/es/StandardTable/index.js +57 -3
- package/es/StandardTable/types.d.ts +33 -0
- package/es/StandardTable/types.js +1 -0
- package/es/StandardTablePro/index.d.ts +11 -3
- package/es/StandardTablePro/index.js +61 -84
- package/es/StandardTablePro/types.d.ts +0 -0
- package/es/StandardTablePro/types.js +0 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -0
- package/es/types.d.ts +1 -0
- package/es/types.js +1 -0
- package/es/utils/ValueFormat.d.ts +1 -1
- package/es/utils/ValueFormat.js +41 -27
- package/es/utils/urlUtils.d.ts +6 -0
- package/es/utils/urlUtils.js +26 -0
- package/lib/FormComp/FieldComponent/ExtensionField.d.ts +2 -2
- package/lib/FormComp/FieldComponent/ExtensionField.js +1 -1
- package/lib/StandardFilter/index.js +32 -22
- package/lib/StandardForm/index.js +3 -1
- package/lib/StandardTable/index.d.ts +2 -26
- package/lib/StandardTable/index.js +57 -3
- package/lib/StandardTable/types.d.ts +33 -0
- package/lib/StandardTable/types.js +5 -0
- package/lib/StandardTablePro/index.d.ts +11 -3
- package/lib/StandardTablePro/index.js +59 -82
- package/lib/StandardTablePro/types.d.ts +0 -0
- package/lib/StandardTablePro/types.js +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +20 -0
- package/lib/types.d.ts +1 -0
- package/lib/types.js +16 -0
- package/lib/utils/ValueFormat.d.ts +1 -1
- package/lib/utils/ValueFormat.js +41 -29
- package/lib/utils/urlUtils.d.ts +6 -0
- package/lib/utils/urlUtils.js +27 -3
- package/package.json +2 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>>;
|
|
3
|
+
export default _default;
|
|
@@ -15,4 +15,4 @@ var ExtensionField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
15
15
|
var MatchTypeComponent = (MatchType === null || MatchType === void 0 ? void 0 : MatchType.component) || null;
|
|
16
16
|
return typeof MatchTypeComponent === 'function' ? /*#__PURE__*/React.createElement(MatchTypeComponent, fieldProps) : MatchTypeComponent;
|
|
17
17
|
});
|
|
18
|
-
export default ExtensionField;
|
|
18
|
+
export default /*#__PURE__*/React.memo(ExtensionField);
|
|
@@ -20,6 +20,7 @@ import ButtonGroup from "../ButtonGroup/";
|
|
|
20
20
|
import { general } from "../data/";
|
|
21
21
|
import "./style/index.less";
|
|
22
22
|
import { FanContext } from "../ConfigContext";
|
|
23
|
+
import dayjs from "dayjs";
|
|
23
24
|
import useStyle from "./style/FilterStyle";
|
|
24
25
|
import SpecIcon from "../SpecIcon";
|
|
25
26
|
var FormItem = Form.Item;
|
|
@@ -68,7 +69,11 @@ var StandardFilter = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
68
69
|
var filterFormRef = useRef();
|
|
69
70
|
// ref 的转发
|
|
70
71
|
useImperativeHandle(ref, function () {
|
|
71
|
-
return filterFormRef === null || filterFormRef === void 0 ? void 0 : filterFormRef.current
|
|
72
|
+
return _objectSpread(_objectSpread({}, filterFormRef === null || filterFormRef === void 0 ? void 0 : filterFormRef.current), {}, {
|
|
73
|
+
onSubmit: function onSubmit(values) {
|
|
74
|
+
return handleSearch(values);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
72
77
|
});
|
|
73
78
|
var _useState = useState([]),
|
|
74
79
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -230,6 +235,7 @@ var StandardFilter = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
230
235
|
|
|
231
236
|
// 更新表单控件值,用于外部获取当前表单实例(force是否强制清空表单)
|
|
232
237
|
var updateFormFields = function updateFormFields(newVal, force) {
|
|
238
|
+
// console.log('更新表单控件值,用于外部获取当前表单实例(force是否强制清空表单)')
|
|
233
239
|
var resetValues = {};
|
|
234
240
|
if (force) {
|
|
235
241
|
// this.filterFormRef.current.resetFields()
|
|
@@ -239,27 +245,30 @@ var StandardFilter = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
239
245
|
resetValues[item] = undefined;
|
|
240
246
|
});
|
|
241
247
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
248
|
+
var dateFieldTypes = ['datePicker', 'dateTimePicker', 'rangePicker', 'rangeTimePicker', 'timePicker', 'timePickerRange'];
|
|
249
|
+
var filterDateFields = formItemGroup.filter(function (fItem) {
|
|
250
|
+
return dateFieldTypes.includes(fItem.type);
|
|
251
|
+
});
|
|
252
|
+
// 如果配置了dateFormatter='string',则将默认对其他进行格式转换
|
|
253
|
+
if (dateFormatter === 'string') {
|
|
254
|
+
// 需要将字符串转换成日期格式
|
|
255
|
+
filterDateFields.forEach(function (dItem) {
|
|
256
|
+
if (newVal[dItem.filedName]) {
|
|
257
|
+
if (typeof newVal[dItem.filedName] === 'string') {
|
|
258
|
+
// console.log('将字符串转换成dayjs')
|
|
259
|
+
newVal[dItem.filedName] = dayjs(newVal[dItem.filedName]);
|
|
260
|
+
} else if (Array.isArray(newVal[dItem.filedName])) {
|
|
261
|
+
// console.log('将数组转换成dayjs数组')
|
|
262
|
+
newVal[dItem.filedName] = newVal[dItem.filedName].map(function (valItem) {
|
|
263
|
+
return typeof valItem === 'string' ? dayjs(valItem) : valItem;
|
|
264
|
+
});
|
|
265
|
+
} else {
|
|
266
|
+
// console.log('其他情况', newVal[dItem.filedName] instanceof Date)
|
|
267
|
+
// console.log('其他情况,当它是日期格式,则不进行转换')
|
|
260
268
|
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
263
272
|
filterFormRef.current.setFieldsValue(_objectSpread(_objectSpread({}, resetValues), newVal || {})); // 直接清空表单的赋值
|
|
264
273
|
forceUpdateForm();
|
|
265
274
|
};
|
|
@@ -276,7 +285,8 @@ var StandardFilter = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
276
285
|
if (Object.prototype.hasOwnProperty.call(values, false)) {
|
|
277
286
|
delete values.false; // 自定义结构会莫名的出来一个false字段
|
|
278
287
|
}
|
|
279
|
-
var resultValues =
|
|
288
|
+
var resultValues = UtilValueFormat(values, reFormItemGroup, dateFormatter);
|
|
289
|
+
// reFormItemGroup里面有 transform,则筛选转换
|
|
280
290
|
// console.log('格式化前数据', values)
|
|
281
291
|
// console.log('格式化后数据', resultValues)
|
|
282
292
|
if (onFilterSearch) {
|
package/es/StandardForm/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import "./style/index.less";
|
|
|
23
23
|
import ActionList from "./ActionList";
|
|
24
24
|
import useStyle from "./style/index";
|
|
25
25
|
import { FanContext } from "../ConfigContext";
|
|
26
|
+
import { UtilValueFormat } from "../utils";
|
|
26
27
|
var StandardForm = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
27
28
|
var InitFanContext = useContext(FanContext);
|
|
28
29
|
var providerConfig = InitFanContext['StandardForm'] || {}; // 使用上下文(全局配置)设置扩展的配置项
|
|
@@ -98,7 +99,8 @@ var StandardForm = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
98
99
|
getFormFields && getFormFields(initForm && initForm.getFieldsValue() || {}, initForm);
|
|
99
100
|
};
|
|
100
101
|
var onFormFinish = function onFormFinish(values) {
|
|
101
|
-
|
|
102
|
+
var resultValues = UtilValueFormat(values, formItemGroup);
|
|
103
|
+
if (onSubmit) onSubmit(_objectSpread({}, resultValues));
|
|
102
104
|
};
|
|
103
105
|
var onFormFinishFailed = function onFormFinishFailed(_ref) {
|
|
104
106
|
var values = _ref.values,
|
|
@@ -1,29 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import './style/index.less';
|
|
3
|
-
|
|
4
|
-
list?: object[];
|
|
5
|
-
pagination?: any;
|
|
6
|
-
}
|
|
7
|
-
export interface StandardTableProps {
|
|
8
|
-
columns?: any[];
|
|
9
|
-
data: StandardTableDataProps;
|
|
10
|
-
rowKey?: string;
|
|
11
|
-
onChange?: (pageConfig?: any) => void;
|
|
12
|
-
hideOrderNumber?: boolean;
|
|
13
|
-
emptyText?: string;
|
|
14
|
-
codes?: object[];
|
|
15
|
-
permissionCodes?: string[];
|
|
16
|
-
className?: string;
|
|
17
|
-
rowSelection?: any;
|
|
18
|
-
orderNumber?: object;
|
|
19
|
-
columnsConfig?: object;
|
|
20
|
-
buttonGroup?: any[];
|
|
21
|
-
title?: React.ReactNode | string;
|
|
22
|
-
min?: number;
|
|
23
|
-
buttonGroupConfig?: any;
|
|
24
|
-
batchButtonGroup?: any[];
|
|
25
|
-
buttonGroupPlacement?: string | 'left' | 'right' | 'bottomLeft' | 'bottomRight';
|
|
26
|
-
[k: string]: any;
|
|
27
|
-
}
|
|
3
|
+
import type { StandardTableProps } from './types';
|
|
28
4
|
declare const StandardTable: FC<StandardTableProps>;
|
|
29
5
|
export default StandardTable;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
var _excluded = ["data", "rowKey", "rowSelection", "columns", "hideOrderNumber", "orderNumber", "className", "emptyText", "codes", "permissionCodes", "columnsConfig", "title", "buttonGroup", "buttonGroupConfig", "min", "batchButtonGroup", "buttonGroupPlacement"];
|
|
2
|
+
var _excluded = ["data", "rowKey", "rowSelection", "columns", "hideOrderNumber", "orderNumber", "className", "emptyText", "codes", "permissionCodes", "columnsConfig", "title", "buttonGroup", "buttonGroupConfig", "min", "batchButtonGroup", "buttonGroupPlacement", "sortOrders"];
|
|
3
3
|
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); }
|
|
4
4
|
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; }
|
|
5
5
|
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; }
|
|
@@ -54,6 +54,7 @@ var StandardTable = function StandardTable(props) {
|
|
|
54
54
|
batchButtonGroup = _providerConfig$props.batchButtonGroup,
|
|
55
55
|
_providerConfig$props5 = _providerConfig$props.buttonGroupPlacement,
|
|
56
56
|
buttonGroupPlacement = _providerConfig$props5 === void 0 ? 'right' : _providerConfig$props5,
|
|
57
|
+
sortOrders = _providerConfig$props.sortOrders,
|
|
57
58
|
rest = _objectWithoutProperties(_providerConfig$props, _excluded);
|
|
58
59
|
// 加上类型修复 TS:2322 报警
|
|
59
60
|
var resetColumns = [_objectSpread(_objectSpread({
|
|
@@ -77,7 +78,8 @@ var StandardTable = function StandardTable(props) {
|
|
|
77
78
|
pageSizeOptions: ['5', '10', '15', '20', '30', '50'],
|
|
78
79
|
showTotal: function showTotal(total, range) {
|
|
79
80
|
return "".concat(range[0], "-").concat(range[1], "\u6761 \u5171").concat(total, "\u6761");
|
|
80
|
-
}
|
|
81
|
+
},
|
|
82
|
+
pageSize: (pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || (pagination === null || pagination === void 0 ? void 0 : pagination.size)
|
|
81
83
|
}, pagination);
|
|
82
84
|
if (columns) {
|
|
83
85
|
var recombinationColumns = columns.map(function (colItem) {
|
|
@@ -135,10 +137,27 @@ var StandardTable = function StandardTable(props) {
|
|
|
135
137
|
colItem.render = function (text, record, rowIndex) {
|
|
136
138
|
return text || text === 0 ? text : '-';
|
|
137
139
|
};
|
|
140
|
+
if (sortOrders && (sortOrders.hasOwnProperty(colItem.key) || sortOrders.hasOwnProperty(colItem.dataIndex))) {
|
|
141
|
+
colItem.sortOrder = (sortOrders === null || sortOrders === void 0 ? void 0 : sortOrders[colItem.key]) || (sortOrders === null || sortOrders === void 0 ? void 0 : sortOrders[colItem.dataIndex]) || (sortOrders === null || sortOrders === void 0 ? void 0 : sortOrders[colItem.key]) || null;
|
|
142
|
+
colItem.sortOrderExtra = true;
|
|
143
|
+
} else {
|
|
144
|
+
if (colItem.sortOrderExtra) {
|
|
145
|
+
delete colItem.sortOrder;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
138
148
|
// return Object.assign({ ellipsis: undefined, render: undefined }, { ...otherColumns, ...colItem }); // ellipsis要配置在render之前
|
|
139
149
|
return _objectSpread(_objectSpread({}, otherColumn), colItem);
|
|
140
150
|
}
|
|
151
|
+
if (sortOrders && (sortOrders.hasOwnProperty(colItem.key) || sortOrders.hasOwnProperty(colItem.dataIndex))) {
|
|
152
|
+
colItem.sortOrder = (sortOrders === null || sortOrders === void 0 ? void 0 : sortOrders[colItem.key]) || (sortOrders === null || sortOrders === void 0 ? void 0 : sortOrders[colItem.dataIndex]) || (sortOrders === null || sortOrders === void 0 ? void 0 : sortOrders[colItem.key]) || null;
|
|
153
|
+
colItem.sortOrderExtra = true;
|
|
154
|
+
} else {
|
|
155
|
+
if (colItem.sortOrderExtra) {
|
|
156
|
+
delete colItem.sortOrder;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
141
159
|
// return Object.assign({ ellipsis: undefined, render: undefined }, { ...otherColumns, ...colItem }) // ellipsis要配置在render之前
|
|
160
|
+
// return { ...otherColumn, ...colItem }
|
|
142
161
|
return _objectSpread(_objectSpread({}, otherColumn), colItem);
|
|
143
162
|
});
|
|
144
163
|
resetColumns = hideOrderNumber ? recombinationColumns : resetColumns.concat(recombinationColumns);
|
|
@@ -184,6 +203,41 @@ var StandardTable = function StandardTable(props) {
|
|
|
184
203
|
filterReset: '重置',
|
|
185
204
|
emptyText: emptyText || '暂无数据'
|
|
186
205
|
}
|
|
187
|
-
}, rest
|
|
206
|
+
}, rest, {
|
|
207
|
+
// @ts-ignore
|
|
208
|
+
onChange: function onChange(pagination, filters, sorter, extra) {
|
|
209
|
+
var _rest$onChange;
|
|
210
|
+
var sorterParams = {}; // 取当前列表中有配置排序条件
|
|
211
|
+
// (columns || []).forEach((cItem: any) => {
|
|
212
|
+
// if (cItem.hasOwnProperty('sorter') && cItem.type !== 'action') {
|
|
213
|
+
// // 加这个赋值处理是为了避免sorter为空时,原url已经加上了排序值,但是未清空
|
|
214
|
+
// sorterParams[`${sortPrefixToUrl}${cItem?.key || cItem?.dataIndex}`] = undefined
|
|
215
|
+
// }
|
|
216
|
+
// })
|
|
217
|
+
var sorters = [];
|
|
218
|
+
if (Array.isArray(sorter)) {
|
|
219
|
+
// 多个条件
|
|
220
|
+
sorters = sorter.map(function (item) {
|
|
221
|
+
return _objectSpread({}, item);
|
|
222
|
+
});
|
|
223
|
+
} else if (JSON.stringify(sorter) !== '{}') {
|
|
224
|
+
// 单个条件
|
|
225
|
+
sorters.push(_objectSpread({}, sorter));
|
|
226
|
+
}
|
|
227
|
+
// 取当前字段的排序值
|
|
228
|
+
// let orders: any = {};
|
|
229
|
+
(sorters || []).forEach(function (item) {
|
|
230
|
+
sorterParams["".concat(item === null || item === void 0 ? void 0 : item.columnKey)] = item === null || item === void 0 ? void 0 : item.order;
|
|
231
|
+
// sorterParams[`${sortPrefixToUrl}${item?.columnKey}`] = item?.order
|
|
232
|
+
});
|
|
233
|
+
rest === null || rest === void 0 || (_rest$onChange = rest.onChange) === null || _rest$onChange === void 0 || _rest$onChange.call(rest, _objectSpread(_objectSpread({}, pagination), {}, {
|
|
234
|
+
size: pagination.pageSize,
|
|
235
|
+
// orders, // 对象
|
|
236
|
+
sorters: sorters,
|
|
237
|
+
// 数组
|
|
238
|
+
sorterParams: sorterParams // 对象
|
|
239
|
+
}), filters, sorter, extra);
|
|
240
|
+
}
|
|
241
|
+
}))));
|
|
188
242
|
};
|
|
189
243
|
export default StandardTable;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { ButtonGroupOptionsProps } from "../ButtonGroup";
|
|
3
|
+
export interface StandardTableDataProps {
|
|
4
|
+
list?: object[];
|
|
5
|
+
pagination?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface ExButtonGroupProps {
|
|
8
|
+
buttonGroup?: ButtonGroupOptionsProps[];
|
|
9
|
+
batchButtonGroup?: ButtonGroupOptionsProps[];
|
|
10
|
+
[k: string]: any;
|
|
11
|
+
}
|
|
12
|
+
export interface StandardTableProps {
|
|
13
|
+
columns?: any[];
|
|
14
|
+
data: StandardTableDataProps;
|
|
15
|
+
rowKey?: string;
|
|
16
|
+
onChange?: (pageConfig?: any) => void;
|
|
17
|
+
hideOrderNumber?: boolean;
|
|
18
|
+
emptyText?: string;
|
|
19
|
+
codes?: object[];
|
|
20
|
+
permissionCodes?: string[];
|
|
21
|
+
className?: string;
|
|
22
|
+
rowSelection?: any;
|
|
23
|
+
orderNumber?: object;
|
|
24
|
+
columnsConfig?: object;
|
|
25
|
+
buttonGroup?: any[];
|
|
26
|
+
title?: React.ReactNode | string;
|
|
27
|
+
min?: number;
|
|
28
|
+
buttonGroupConfig?: any;
|
|
29
|
+
batchButtonGroup?: any[];
|
|
30
|
+
buttonGroupPlacement?: string | 'left' | 'right' | 'bottomLeft' | 'bottomRight';
|
|
31
|
+
sortOrders?: object;
|
|
32
|
+
[k: string]: any;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StandardTableProps } from '../StandardTable';
|
|
2
|
+
import type { StandardTableProps } from '../StandardTable/types';
|
|
3
3
|
interface StandardTableProType extends StandardTableProps {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
proClassname?: string;
|
|
5
|
+
filter?: any;
|
|
6
|
+
formConfig?: any;
|
|
7
|
+
onChange?: (pageParams?: any) => void;
|
|
8
|
+
onSubmit?: (searchParams?: any) => void;
|
|
9
|
+
onReset?: () => void;
|
|
10
|
+
params?: any;
|
|
6
11
|
[k: string]: any;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* 复合表格:筛选+表格列表
|
|
15
|
+
* */
|
|
8
16
|
declare const StandardTablePro: React.ForwardRefExoticComponent<React.RefAttributes<StandardTableProType>>;
|
|
9
17
|
export default StandardTablePro;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
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); }
|
|
2
|
-
var _excluded = ["proClassname", "
|
|
2
|
+
var _excluded = ["proClassname", "filter", "formConfig", "codes", "permissionCodes", "onSubmit", "onReset", "onChange", "children", "className", "columns", "params"];
|
|
3
3
|
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); }
|
|
4
4
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
5
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -14,26 +14,32 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
14
14
|
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); }
|
|
15
15
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
16
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
-
import React, { useContext, useImperativeHandle, forwardRef, useState } from 'react';
|
|
18
|
-
// import { FanContext } from "fan-standard-comp";
|
|
17
|
+
import React, { useContext, useImperativeHandle, forwardRef, useState, useMemo } from 'react';
|
|
18
|
+
// import { FanContext, StandardFilter, StandardTable } from "fan-standard-comp";
|
|
19
19
|
import { FanContext } from "../ConfigContext";
|
|
20
|
-
import useStyle from "./style/index";
|
|
21
|
-
import StandardTable from "../StandardTable";
|
|
22
20
|
import StandardFilter from "../StandardFilter";
|
|
23
|
-
import
|
|
21
|
+
import StandardTable from "../StandardTable";
|
|
22
|
+
import useStyle from "./style/index";
|
|
24
23
|
import classNames from "classnames";
|
|
24
|
+
/**
|
|
25
|
+
* 复合表格:筛选+表格列表
|
|
26
|
+
* */
|
|
25
27
|
var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
28
|
var InitFanContext = useContext(FanContext);
|
|
27
29
|
var providerConfig = InitFanContext['StandardTablePro'] || {}; // 使用上下文(全局配置)设置扩展的配置项
|
|
28
30
|
var _providerConfig$props = _objectSpread(_objectSpread({}, providerConfig), props),
|
|
29
31
|
proClassname = _providerConfig$props.proClassname,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
filter = _providerConfig$props.filter,
|
|
33
|
+
formConfig = _providerConfig$props.formConfig,
|
|
32
34
|
codes = _providerConfig$props.codes,
|
|
33
35
|
permissionCodes = _providerConfig$props.permissionCodes,
|
|
34
|
-
|
|
36
|
+
onSubmit = _providerConfig$props.onSubmit,
|
|
37
|
+
onReset = _providerConfig$props.onReset,
|
|
38
|
+
_onChange = _providerConfig$props.onChange,
|
|
35
39
|
children = _providerConfig$props.children,
|
|
36
40
|
className = _providerConfig$props.className,
|
|
41
|
+
columns = _providerConfig$props.columns,
|
|
42
|
+
params = _providerConfig$props.params,
|
|
37
43
|
others = _objectWithoutProperties(_providerConfig$props, _excluded);
|
|
38
44
|
var commonConfig = {
|
|
39
45
|
codes: codes,
|
|
@@ -45,101 +51,72 @@ var StandardTablePro = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
45
51
|
wrapSSR = _useStyle2[0],
|
|
46
52
|
hashId = _useStyle2[1];
|
|
47
53
|
var handleChange = function handleChange(targetKey, data, defaultParam) {
|
|
48
|
-
|
|
54
|
+
if (targetKey === 'filterSearch') {
|
|
55
|
+
onSubmit === null || onSubmit === void 0 || onSubmit(data);
|
|
56
|
+
}
|
|
57
|
+
if (targetKey === 'filterReset') {
|
|
58
|
+
onReset === null || onReset === void 0 || onReset();
|
|
59
|
+
}
|
|
60
|
+
// if (targetKey === 'tableChange') {
|
|
61
|
+
// onChange && onChange(data, defaultParam)
|
|
62
|
+
// }
|
|
49
63
|
};
|
|
64
|
+
var formItemGroup = useMemo(function () {
|
|
65
|
+
var itemGroupFromColumns = (columns || []).filter(function (item) {
|
|
66
|
+
return item.formItem && JSON.stringify(item.formItem) !== '{}';
|
|
67
|
+
}).map(function (fItem) {
|
|
68
|
+
return _objectSpread({
|
|
69
|
+
label: fItem === null || fItem === void 0 ? void 0 : fItem.title,
|
|
70
|
+
fieldName: (fItem === null || fItem === void 0 ? void 0 : fItem.key) || (fItem === null || fItem === void 0 ? void 0 : fItem.dataIndex)
|
|
71
|
+
}, fItem.formItem);
|
|
72
|
+
});
|
|
73
|
+
return ((filter === null || filter === void 0 ? void 0 : filter.formItemGroup) || []).concat(itemGroupFromColumns);
|
|
74
|
+
}, [columns, filter === null || filter === void 0 ? void 0 : filter.formItemGroup]);
|
|
75
|
+
|
|
76
|
+
// const [filterFields, setFilterFormFields] = useState({})
|
|
50
77
|
var _useState = useState({}),
|
|
51
78
|
_useState2 = _slicedToArray(_useState, 2),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
|
-
filterFormInstance = _useState4[0],
|
|
57
|
-
setFilterFormInstance = _useState4[1];
|
|
58
|
-
var _useState5 = useState({}),
|
|
59
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
60
|
-
modalFormFields = _useState6[0],
|
|
61
|
-
setModalFormFields = _useState6[1];
|
|
62
|
-
var _useState7 = useState(),
|
|
63
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
64
|
-
modalFormInstance = _useState8[0],
|
|
65
|
-
setModalFormInstance = _useState8[1];
|
|
66
|
-
var _useState9 = useState(false),
|
|
67
|
-
_useState10 = _slicedToArray(_useState9, 2),
|
|
68
|
-
modalVisible = _useState10[0],
|
|
69
|
-
setModalVisible = _useState10[1];
|
|
70
|
-
|
|
79
|
+
filterInstance = _useState2[0],
|
|
80
|
+
setFilterFormInstance = _useState2[1];
|
|
81
|
+
// const [filterValues, setFilterValues] = useState<any>({})
|
|
71
82
|
// ref 的转发
|
|
72
83
|
useImperativeHandle(ref, function () {
|
|
73
|
-
return
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
modalFormInstance: modalFormInstance
|
|
84
|
+
return {
|
|
85
|
+
// ...filter,
|
|
86
|
+
// filterFields, // 值不会更新,不传给ref
|
|
87
|
+
filterInstance: filterInstance === null || filterInstance === void 0 ? void 0 : filterInstance.current
|
|
78
88
|
// dataSource: resDataSource,
|
|
79
89
|
// setDataSource: setResDataSource,
|
|
80
90
|
// reload: (filter) => loadData('refresh', {}, filter) // 更新列表
|
|
81
|
-
}
|
|
82
|
-
});
|
|
91
|
+
};
|
|
92
|
+
}, [filterInstance]);
|
|
93
|
+
// sortOrder: sortedInfo.columnKey === 'name' ? sortedInfo.order : null,
|
|
94
|
+
// columns 里面需要把sort添加上去
|
|
83
95
|
return wrapSSR( /*#__PURE__*/React.createElement("div", {
|
|
84
96
|
className: classNames(componentName, proClassname, hashId)
|
|
85
|
-
}, /*#__PURE__*/React.createElement(StandardFilter, _extends({}, commonConfig,
|
|
97
|
+
}, /*#__PURE__*/React.createElement(StandardFilter, _extends({}, commonConfig, filter, {
|
|
98
|
+
// initialValue={filterValues}
|
|
99
|
+
formItemGroup: formItemGroup,
|
|
86
100
|
getFormFields: function getFormFields(fieldValues, form) {
|
|
87
|
-
|
|
101
|
+
var _filter$getFormFields;
|
|
102
|
+
// setFilterFormFields(fieldValues) // 获取表单内部控件值
|
|
88
103
|
setFilterFormInstance(form); // 获取表单实例
|
|
104
|
+
filter === null || filter === void 0 || (_filter$getFormFields = filter.getFormFields) === null || _filter$getFormFields === void 0 || _filter$getFormFields.call(filter, fieldValues, form);
|
|
89
105
|
},
|
|
90
106
|
onFilterSearch: function onFilterSearch(values) {
|
|
91
107
|
return handleChange('filterSearch', values);
|
|
92
108
|
},
|
|
93
|
-
onFilterReset: function onFilterReset(
|
|
94
|
-
return handleChange('filterReset'
|
|
109
|
+
onFilterReset: function onFilterReset() {
|
|
110
|
+
return handleChange('filterReset');
|
|
95
111
|
},
|
|
96
|
-
className: classNames('spec-standard-table-pro-filter',
|
|
97
|
-
})), /*#__PURE__*/React.createElement(StandardModal, _extends({}, commonConfig, modalForm, {
|
|
98
|
-
getFormFields: function getFormFields(fields, form) {
|
|
99
|
-
setModalFormFields(fields);
|
|
100
|
-
setModalFormInstance(form);
|
|
101
|
-
},
|
|
102
|
-
className: classNames('spec-standard-table-pro-modal', modalForm === null || modalForm === void 0 ? void 0 : modalForm.className)
|
|
112
|
+
className: classNames('spec-standard-table-pro-filter', filter === null || filter === void 0 ? void 0 : filter.className)
|
|
103
113
|
})), /*#__PURE__*/React.createElement(StandardTable, _extends({}, commonConfig, others, {
|
|
114
|
+
columns: columns
|
|
104
115
|
// @ts-ignore
|
|
116
|
+
,
|
|
105
117
|
onChange: function onChange(pagination, filters, sorter, extra) {
|
|
106
|
-
|
|
107
|
-
//
|
|
108
|
-
// loadData('table', {
|
|
109
|
-
// page: pagination.current,
|
|
110
|
-
// size: pagination.pageSize
|
|
111
|
-
// }, filters, sorter)
|
|
112
|
-
|
|
113
|
-
console.log('pagination', pagination);
|
|
114
|
-
console.log('filters', filters);
|
|
115
|
-
console.log('sorter', sorter);
|
|
116
|
-
console.log('extra', extra);
|
|
117
|
-
var orders = [];
|
|
118
|
-
if (Array.isArray(sorter)) {
|
|
119
|
-
// 多个条件
|
|
120
|
-
orders = sorter.map(function (item) {
|
|
121
|
-
return {
|
|
122
|
-
column: item.columnKey,
|
|
123
|
-
asc: item.order === 'ascend'
|
|
124
|
-
};
|
|
125
|
-
});
|
|
126
|
-
} else {
|
|
127
|
-
// 单个条件
|
|
128
|
-
orders.push({
|
|
129
|
-
column: sorter.columnKey,
|
|
130
|
-
asc: sorter.order === 'ascend'
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
console.log('orders', orders);
|
|
134
|
-
handleChange('tableChange', {
|
|
135
|
-
page: pagination.current,
|
|
136
|
-
size: pagination.pageSize
|
|
137
|
-
}, {
|
|
138
|
-
pagination: pagination,
|
|
139
|
-
filters: filters,
|
|
140
|
-
sorter: sorter,
|
|
141
|
-
extra: extra
|
|
142
|
-
});
|
|
118
|
+
_onChange && _onChange(pagination, filters, sorter, extra);
|
|
119
|
+
// handleChange('tableChange', { pagination, filters, sorter, extra, action: extra.action })
|
|
143
120
|
},
|
|
144
121
|
className: classNames('spec-standard-table-pro-table', className)
|
|
145
122
|
})), children));
|
|
File without changes
|
|
File without changes
|
package/es/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { default as SplitterLayout } from './StandardContent/SplitterLayout';
|
|
|
8
8
|
export { default as RefactorTree } from './RefactorTree';
|
|
9
9
|
export { default as StandardPanel } from './StandardPanel';
|
|
10
10
|
export { default as StandardTable } from './StandardTable';
|
|
11
|
+
export { default as StandardTablePro } from './StandardTablePro';
|
|
11
12
|
export { default as StandardForm } from './StandardForm';
|
|
12
13
|
export { default as StepForm } from './StandardForm/StepForm';
|
|
13
14
|
export { default as TabForm } from './StandardForm/TabForm';
|
|
@@ -25,5 +26,6 @@ export * from './components';
|
|
|
25
26
|
export * from './utils';
|
|
26
27
|
export * from './data';
|
|
27
28
|
export * from './ConfigContext';
|
|
29
|
+
export * from './types';
|
|
28
30
|
export { default as ImageGallery } from './ImageGallery/index';
|
|
29
31
|
export { default as ImagePreview } from './ImageGallery/ImagePreview';
|
package/es/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export { default as RefactorTree } from "./RefactorTree";
|
|
|
13
13
|
// // 通用组件
|
|
14
14
|
export { default as StandardPanel } from "./StandardPanel";
|
|
15
15
|
export { default as StandardTable } from "./StandardTable";
|
|
16
|
+
export { default as StandardTablePro } from "./StandardTablePro";
|
|
16
17
|
export { default as StandardForm } from "./StandardForm";
|
|
17
18
|
export { default as StepForm } from "./StandardForm/StepForm";
|
|
18
19
|
export { default as TabForm } from "./StandardForm/TabForm";
|
|
@@ -38,6 +39,8 @@ export * from "./utils";
|
|
|
38
39
|
export * from "./data";
|
|
39
40
|
// 上下文
|
|
40
41
|
export * from "./ConfigContext";
|
|
42
|
+
// 类型
|
|
43
|
+
export * from "./types";
|
|
41
44
|
|
|
42
45
|
// 图集
|
|
43
46
|
export { default as ImageGallery } from "./ImageGallery/index";
|
package/es/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './StandardTable/types';
|
package/es/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./StandardTable/types";
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const UtilValueFormat: (fieldsValue: any, formItemGroup: any) => any;
|
|
1
|
+
export declare const UtilValueFormat: (fieldsValue: any, formItemGroup: any, dateFormatter?: string) => any;
|
|
2
2
|
export declare const dateOrTimeStringToDayjs: () => void;
|
|
3
3
|
export declare const isDate: (value: any) => boolean;
|