fan-standard-comp 4.0.2 → 4.0.4
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 +7 -0
- package/dist/fan-standard-comp.min.js +1 -1
- package/es/ButtonGroup/index.js +6 -16
- package/es/ButtonGroup/styles/index.js +12 -12
- package/es/FormComp/RenderItemGroup/index.js +65 -35
- package/es/StandardFilter/index.d.ts +1 -0
- package/es/StandardFilter/index.js +129 -32
- package/es/StandardModal/index.js +16 -15
- package/es/StandardTable/index.js +3 -3
- package/es/StandardTable/style/index.js +11 -13
- package/es/utils/filterPermission.d.ts +1 -1
- package/es/utils/filterPermission.js +4 -1
- package/lib/ButtonGroup/index.js +5 -15
- package/lib/ButtonGroup/styles/index.js +12 -12
- package/lib/FormComp/RenderItemGroup/index.js +64 -34
- package/lib/StandardFilter/index.d.ts +1 -0
- package/lib/StandardFilter/index.js +129 -32
- package/lib/StandardModal/index.js +16 -15
- package/lib/StandardTable/index.js +3 -3
- package/lib/StandardTable/style/index.js +11 -13
- package/lib/utils/filterPermission.d.ts +1 -1
- package/lib/utils/filterPermission.js +4 -1
- package/package.json +3 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const btnClickFunc: (fn: any, params?: {}) => any;
|
|
2
2
|
declare const btnIsDisabled: (isDisabled: any, params?: {}) => any;
|
|
3
3
|
declare const btnIsHide: (isHide: any, params?: {}) => any;
|
|
4
|
-
declare const removeNoPermission: (array: any, permissionCodes: any,
|
|
4
|
+
declare const removeNoPermission: (array: any, permissionCodes: any, codesList: any, params: any) => any[];
|
|
5
5
|
export { removeNoPermission, btnIsHide, btnIsDisabled, btnClickFunc };
|
|
@@ -6,6 +6,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
6
6
|
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); }
|
|
7
7
|
// @ts-nocheck
|
|
8
8
|
import _ from "lodash";
|
|
9
|
+
import { funcCode } from "../data/index";
|
|
9
10
|
// 按钮方法
|
|
10
11
|
var btnClickFunc = function btnClickFunc(fn) {
|
|
11
12
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -52,7 +53,9 @@ var btnIsHide = function btnIsHide(isHide) {
|
|
|
52
53
|
return isHide;
|
|
53
54
|
};
|
|
54
55
|
// 重新组合数据(排除不包含在permissionCodes内及isHide数据
|
|
55
|
-
var removeNoPermission = function removeNoPermission(array, permissionCodes,
|
|
56
|
+
var removeNoPermission = function removeNoPermission(array, permissionCodes, codesList, params) {
|
|
57
|
+
// 合并本地的codes
|
|
58
|
+
var codes = _.unionBy(codesList || [], funcCode.btnFuncCodes, 'code');
|
|
56
59
|
return Array.isArray(array) && array.filter(function (item) {
|
|
57
60
|
if (item.children) {
|
|
58
61
|
item.children = removeNoPermission(item.children, permissionCodes, codes, params);
|
package/lib/ButtonGroup/index.js
CHANGED
|
@@ -13,8 +13,6 @@ var _icons = require("@ant-design/icons");
|
|
|
13
13
|
var _filterPermission = require("../utils/filterPermission");
|
|
14
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
15
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
16
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
17
|
-
var _index = require("../data/index");
|
|
18
16
|
var _ConfigContext = require("../ConfigContext");
|
|
19
17
|
var _excluded = ["code", "fn", "exName", "name", "children", "icon"],
|
|
20
18
|
_excluded2 = ["exName", "name", "type", "icon", "ghost", "danger", "disabled", "loading", "fn", "code", "rowParams", "isHide"],
|
|
@@ -75,19 +73,11 @@ var ButtonGroup = function ButtonGroup(props) {
|
|
|
75
73
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
76
74
|
popRow = _useState4[0],
|
|
77
75
|
setPopRow = _useState4[1];
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// codes在方法内,再合并默认的权限配置
|
|
84
|
-
// 合并本地的codes
|
|
85
|
-
var codesConcat = _lodash.default.unionBy(codes || [], _index.funcCode.btnFuncCodes, 'code');
|
|
86
|
-
// 重组选项options集合数据,排除:无权限(有配置code,并且不包含permissionCodes内)的数据及,isHide 为true的数据
|
|
87
|
-
setResetList(_toConsumableArray((0, _filterPermission.removeNoPermission)(options, permissionCodes, codesConcat, rowParams)) || []);
|
|
88
|
-
return function () {
|
|
89
|
-
setResetList([]);
|
|
90
|
-
};
|
|
76
|
+
// const [resetList, setResetList] = useState<any[]>([])
|
|
77
|
+
var resetList = (0, _react.useMemo)(function () {
|
|
78
|
+
// // codes在方法内,再合并默认的权限配置
|
|
79
|
+
// // 重组选项options集合数据,排除:无权限(有配置code,并且不包含permissionCodes内)的数据及,isHide 为true的数据
|
|
80
|
+
return _toConsumableArray((0, _filterPermission.removeNoPermission)(options, permissionCodes, codes, rowParams)) || [];
|
|
91
81
|
}, [options, codes, permissionCodes]);
|
|
92
82
|
(0, _react.useEffect)(function () {
|
|
93
83
|
setPopVisibleIndex(-1);
|
|
@@ -30,18 +30,18 @@ var SpecButtonGroupTextStyle = function SpecButtonGroupTextStyle(prefixCls, toke
|
|
|
30
30
|
}
|
|
31
31
|
}, "& + ".concat(prefixCls, "-text"), {
|
|
32
32
|
position: 'relative',
|
|
33
|
-
marginLeft: token.paddingSM
|
|
34
|
-
'&:before': {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
33
|
+
marginLeft: token.paddingSM
|
|
34
|
+
// '&:before': {
|
|
35
|
+
// position: 'absolute',
|
|
36
|
+
// content: '""',
|
|
37
|
+
// top: '50%',
|
|
38
|
+
// left:` calc(-${token.paddingSM}px / 2)`,
|
|
39
|
+
// transform: 'translate(0, -50%)',
|
|
40
|
+
// display: 'inline-block',
|
|
41
|
+
// height: '.9em',
|
|
42
|
+
// verticalAlign: 'middle',
|
|
43
|
+
// borderLeft: `1px solid ${token.colorBorder}`
|
|
44
|
+
// }
|
|
45
45
|
}));
|
|
46
46
|
};
|
|
47
47
|
var SpecButtonGroupStyleFunc = function SpecButtonGroupStyleFunc(prefix) {
|
|
@@ -56,7 +56,53 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
56
56
|
// // @ts-ignore
|
|
57
57
|
// return general.modalSize[size].columnNumber || 1
|
|
58
58
|
// }, [size, columnCount])
|
|
59
|
-
|
|
59
|
+
/*
|
|
60
|
+
// 当前需要显示的前几条表单项
|
|
61
|
+
// const [showItemNumber, setShowItemNumber] = useState(0)
|
|
62
|
+
// 计算当前栅格数量,及对应的size
|
|
63
|
+
const columnNumberAndSize = useMemo(() => {
|
|
64
|
+
// 当前栅栅数量
|
|
65
|
+
let itemGroupSize = size || (layout === 'horizontal' ? 'xxlg' : 'md')
|
|
66
|
+
if (columnCount) {
|
|
67
|
+
// 有配置栅格数 1,2,3,4
|
|
68
|
+
switch (columnCount) {
|
|
69
|
+
case 1:
|
|
70
|
+
itemGroupSize = 'sm'
|
|
71
|
+
break;
|
|
72
|
+
case 2:
|
|
73
|
+
itemGroupSize = 'md'
|
|
74
|
+
break;
|
|
75
|
+
case 3:
|
|
76
|
+
itemGroupSize = 'lg'
|
|
77
|
+
break;
|
|
78
|
+
case 4:
|
|
79
|
+
itemGroupSize = 'xxlg'
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
// @ts-ignore
|
|
85
|
+
columnNumber: general.modalSize[itemGroupSize].columnNumber,
|
|
86
|
+
itemGroupSize, columnCount
|
|
87
|
+
}
|
|
88
|
+
}, [size, columnCount, layout])
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
setShowItemNumber(columnNumberAndSize.columnNumber - 1)
|
|
91
|
+
}, [columnNumberAndSize, size])
|
|
92
|
+
|
|
93
|
+
// 判断是否隐藏结构, display:'none'
|
|
94
|
+
const setItemHiddenNode = (item: any, index: number, collapsed: boolean, showItemNumber: number) => {
|
|
95
|
+
// updateFormFields() // TODO 放这执行会报错,但是不加的话,切换栅格变化会导致收缩状态下隐藏的表单项未更新
|
|
96
|
+
if (item.filedName === 'filterAction') {
|
|
97
|
+
return {
|
|
98
|
+
isHidden: false
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
// 栅格列为1时,显示1个表单项
|
|
103
|
+
isHidden: collapsed ? false : (showItemNumber === 0 ? index !== 0 : !(index < showItemNumber))
|
|
104
|
+
}
|
|
105
|
+
}*/
|
|
60
106
|
var setColSpan = function setColSpan(display, modalSize, columnCount) {
|
|
61
107
|
if (_typeof(display) === 'object' || display === 'block') {
|
|
62
108
|
// 栅格数量为:1
|
|
@@ -80,13 +126,13 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
80
126
|
return 12;
|
|
81
127
|
};
|
|
82
128
|
var updateFormFields = function updateFormFields() {
|
|
129
|
+
// console.log('用于触发更新表单实例赋值')
|
|
83
130
|
// if (newVal) form && form.setFieldsValue({ ...newVal })
|
|
84
131
|
if (doUpdateFormFields) doUpdateFormFields(); // 用于触发更新表单实例赋值
|
|
85
132
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
// }, [form])
|
|
133
|
+
(0, _react.useEffect)(function () {
|
|
134
|
+
updateFormFields();
|
|
135
|
+
}, [form]);
|
|
90
136
|
|
|
91
137
|
// 渲染隐藏指定控件
|
|
92
138
|
var itemIsHide = function itemIsHide(isHide, getFieldsValue, FormInstance) {
|
|
@@ -213,9 +259,18 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
213
259
|
customRender = item.customRender,
|
|
214
260
|
filedName = item.filedName; // 当前可传参的配置值
|
|
215
261
|
if (layout === "horizontal" || layout === "vertical") {
|
|
262
|
+
// if (collapseable && layout === "horizontal") {
|
|
263
|
+
// const { isHidden } = setItemHiddenNode(item, index, collapsed, showItemNumber)
|
|
264
|
+
// item.isHidden = isHidden
|
|
265
|
+
// item.style = { ...(item.style || {}), display: item.isHidden ? 'none' : 'block' }
|
|
266
|
+
// // if (index < showItemNumber) {
|
|
267
|
+
// // console.log('===>>>>当前显示【常规表单项】=>>', item.filedName, '序号', index, '可显示数量', showItemNumber, collapsed)
|
|
268
|
+
// // }
|
|
269
|
+
// }
|
|
216
270
|
return /*#__PURE__*/_react.default.createElement(_antd.Col, {
|
|
217
271
|
key: index,
|
|
218
|
-
span: item.colSpan || setColSpan(item.display, size, columnCount)
|
|
272
|
+
span: item.colSpan || setColSpan(item.display, size, columnCount),
|
|
273
|
+
style: item.style
|
|
219
274
|
}, /*#__PURE__*/_react.default.createElement(FormItem, _extends({
|
|
220
275
|
name: type !== 'custom' && filedName,
|
|
221
276
|
className: (0, _classnames.default)(fieldStatus === 'viewOnly' ? 'form-item-view-only' : '', 'spec-item-group-form-item'),
|
|
@@ -252,34 +307,7 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
252
307
|
type = item.type,
|
|
253
308
|
_item$display = item.display,
|
|
254
309
|
display = _item$display === void 0 ? 'side' : _item$display; // 当前可传参的配置值
|
|
255
|
-
|
|
256
310
|
var formLayout = calculateFormLayout(item);
|
|
257
|
-
// if (displayLayout) {
|
|
258
|
-
// // 如果未配置,则使用以下配置值
|
|
259
|
-
// formLayout = { ...displayLayout }
|
|
260
|
-
// }
|
|
261
|
-
// 优先级 displayLayout.side > displayLayout > general
|
|
262
|
-
// 优先级:若有displayLayout.block 则直接使用 general > displayLayout
|
|
263
|
-
// 还需要判断 layout为vertical还是horizontal
|
|
264
|
-
// @ts-ignore
|
|
265
|
-
// formLayout = displayLayout?.side || (displayLayout?.block ? general.modalSize[size].formLayout : ((!displayLayout || JSON.stringify(displayLayout) === '{}') ? general.modalSize[size].formLayout : displayLayout))
|
|
266
|
-
// if (item.hasOwnProperty('display')) {
|
|
267
|
-
// if (typeof display === 'string') {
|
|
268
|
-
// if (display === 'block') {
|
|
269
|
-
// // @ts-ignore
|
|
270
|
-
// formLayout = displayLayout?.block || general.modalSize[size].formBlockLayout
|
|
271
|
-
// } else {
|
|
272
|
-
// // 使用默认
|
|
273
|
-
// // formLayout = displayLayout?.side || (displayLayout?.block ? general.modalSize[size].formLayout : displayLayout) || general.modalSize[size].formLayout
|
|
274
|
-
// }
|
|
275
|
-
// } else {
|
|
276
|
-
// formLayout = item.display // 对象类型传值如: {labelCol: {span: 3},wrapperCol: {span: 8}} 优先级最高
|
|
277
|
-
// }
|
|
278
|
-
// }
|
|
279
|
-
// // 当布局为 'inline' 时,不配置栅格结构
|
|
280
|
-
// if (layout === 'inline') {
|
|
281
|
-
// formLayout = {}
|
|
282
|
-
// }
|
|
283
311
|
// title标题或html渲染
|
|
284
312
|
if (type === 'title' || type === 'html') {
|
|
285
313
|
return /*#__PURE__*/_react.default.createElement(FormItem, {
|
|
@@ -290,7 +318,8 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
290
318
|
var _item$protoConfig;
|
|
291
319
|
// isHide 返回为true则隐藏当前控件
|
|
292
320
|
return !itemIsHide(isHide, FormInstance.getFieldValue(), FormInstance) ? /*#__PURE__*/_react.default.createElement(_antd.Col, {
|
|
293
|
-
span: item.colSpan || 24
|
|
321
|
+
span: item.colSpan || 24,
|
|
322
|
+
style: item.style
|
|
294
323
|
}, type === 'title' ? /*#__PURE__*/_react.default.createElement("h3", _extends({}, item.protoConfig, {
|
|
295
324
|
className: "modalPanelTitle ".concat((item === null || item === void 0 || (_item$protoConfig = item.protoConfig) === null || _item$protoConfig === void 0 ? void 0 : _item$protoConfig.className) || '')
|
|
296
325
|
}), label) : label) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, null);
|
|
@@ -307,6 +336,7 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
307
336
|
return !itemIsHide(isHide, FormInstance.getFieldValue(), FormInstance) ? renderColFormItem(item, index, formLayout) : null;
|
|
308
337
|
});
|
|
309
338
|
}
|
|
339
|
+
// 常规表单项结构
|
|
310
340
|
return renderColFormItem(item, index, formLayout);
|
|
311
341
|
});
|
|
312
342
|
};
|
|
@@ -22,6 +22,7 @@ export interface StandardFilterProps {
|
|
|
22
22
|
colon?: boolean;
|
|
23
23
|
dateFormatter?: 'dayjs' | 'string';
|
|
24
24
|
itemGroupConfig?: object;
|
|
25
|
+
collapseable?: boolean;
|
|
25
26
|
[k: string]: any;
|
|
26
27
|
}
|
|
27
28
|
declare const StandardFilter: React.ForwardRefExoticComponent<Omit<StandardFilterProps, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -13,6 +13,7 @@ var _data = require("../data/");
|
|
|
13
13
|
require("./style/index.less");
|
|
14
14
|
var _ConfigContext = require("../ConfigContext");
|
|
15
15
|
var _FilterStyle = _interopRequireDefault(require("./style/FilterStyle"));
|
|
16
|
+
var _SpecIcon = _interopRequireDefault(require("../SpecIcon"));
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
18
|
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); }
|
|
18
19
|
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 && Object.prototype.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; }
|
|
@@ -31,6 +32,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
31
32
|
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); } // @ts-nocheck
|
|
32
33
|
var FormItem = _antd.Form.Item;
|
|
33
34
|
var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
35
|
+
var _filterFormRef$curren4;
|
|
34
36
|
var InitFanContext = (0, _react.useContext)(_ConfigContext.FanContext);
|
|
35
37
|
var providerConfig = InitFanContext['StandardFilter'] || {}; // 使用上下文(全局配置)设置扩展的配置项
|
|
36
38
|
var _providerConfig$props = _objectSpread(_objectSpread({}, providerConfig), props),
|
|
@@ -64,7 +66,9 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
64
66
|
filterBtnsStyle = _providerConfig$props.filterBtnsStyle,
|
|
65
67
|
_providerConfig$props7 = _providerConfig$props.colon,
|
|
66
68
|
colon = _providerConfig$props7 === void 0 ? true : _providerConfig$props7,
|
|
67
|
-
dateFormatter = _providerConfig$props.dateFormatter
|
|
69
|
+
dateFormatter = _providerConfig$props.dateFormatter,
|
|
70
|
+
_providerConfig$props8 = _providerConfig$props.collapseable,
|
|
71
|
+
collapseable = _providerConfig$props8 === void 0 ? false : _providerConfig$props8;
|
|
68
72
|
var filterFormRef = (0, _react.useRef)();
|
|
69
73
|
// ref 的转发
|
|
70
74
|
(0, _react.useImperativeHandle)(ref, function () {
|
|
@@ -78,7 +82,10 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
78
82
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
79
83
|
isHideCount = _useState4[0],
|
|
80
84
|
setIsHideCount = _useState4[1]; // 表单隐藏项数量值
|
|
81
|
-
|
|
85
|
+
var _useState5 = (0, _react.useState)(false),
|
|
86
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
87
|
+
collapsed = _useState6[0],
|
|
88
|
+
setCollapsed = _useState6[1];
|
|
82
89
|
var componentName = 'spec-standard-filter';
|
|
83
90
|
var _useStyle = (0, _FilterStyle.default)(componentName),
|
|
84
91
|
_useStyle2 = _slicedToArray(_useStyle, 2),
|
|
@@ -87,8 +94,9 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
87
94
|
var filterFormLayout = (0, _react.useMemo)(function () {
|
|
88
95
|
return formLayout || 'inline';
|
|
89
96
|
}, [formLayout]);
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
|
|
98
|
+
// 计算当前栅格数量,及对应的size
|
|
99
|
+
var columnNumberAndSize = (0, _react.useMemo)(function () {
|
|
92
100
|
// 当前栅栅数量
|
|
93
101
|
var itemGroupSize = (itemGroupConfig === null || itemGroupConfig === void 0 ? void 0 : itemGroupConfig.size) || (filterFormLayout === 'horizontal' ? 'xxlg' : 'md');
|
|
94
102
|
if (itemGroupConfig !== null && itemGroupConfig !== void 0 && itemGroupConfig.columnCount) {
|
|
@@ -108,8 +116,31 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
108
116
|
break;
|
|
109
117
|
}
|
|
110
118
|
}
|
|
119
|
+
return {
|
|
120
|
+
columnNumber: _data.general.modalSize[itemGroupSize].columnNumber,
|
|
121
|
+
itemGroupSize: itemGroupSize
|
|
122
|
+
};
|
|
123
|
+
}, [itemGroupConfig, filterFormLayout]);
|
|
124
|
+
|
|
125
|
+
// 计算表单隐藏项(开启展开与收缩)
|
|
126
|
+
var calculateHideCount = function calculateHideCount(filterFormRef, groups) {
|
|
127
|
+
var _filterFormRef$curren;
|
|
128
|
+
var formValues = filterFormRef === null || filterFormRef === void 0 || (_filterFormRef$curren = filterFormRef.current) === null || _filterFormRef$curren === void 0 ? void 0 : _filterFormRef$curren.getFieldValue();
|
|
129
|
+
setIsHideCount((groups || []).filter(function (item) {
|
|
130
|
+
return (item === null || item === void 0 ? void 0 : item.isHidden) || (item.hasOwnProperty('isHide') ? item.isHide(_objectSpread({}, formValues), filterFormRef) : false);
|
|
131
|
+
}).length);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// 配置筛选按钮(确认与取消)
|
|
135
|
+
var filterActionButtons = (0, _react.useMemo)(function () {
|
|
136
|
+
var itemGroupSize = columnNumberAndSize.itemGroupSize,
|
|
137
|
+
columnNumber = columnNumberAndSize.columnNumber;
|
|
111
138
|
// 计算扣除栅格列数是否还有多余的项,用来判断筛选按钮的版式(初始化的时候,可能会受默认值内配置的isHide影响导致计算错误;或自定义表单控件组栅格影响)
|
|
112
|
-
|
|
139
|
+
// if (collapseable) {
|
|
140
|
+
// columnNumber = collapsed ? columnNumber : (columnNumber === 1 ? columnNumber = 2 : columnNumber)
|
|
141
|
+
// }
|
|
142
|
+
var calculateTimes = (reFormItemGroup.length - isHideCount) % columnNumber;
|
|
143
|
+
// console.log('当前多余的数量', calculateTimes, '当前隐藏的控件数量isHideCount==>', isHideCount, itemGroupSize, 'columnNumber', columnNumber)
|
|
113
144
|
// xs:1列 sm:1列 【span:24】
|
|
114
145
|
// md:2列 【span:12】
|
|
115
146
|
// lg:3列 xlg:3列 【span:8】
|
|
@@ -119,10 +150,11 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
119
150
|
label: '',
|
|
120
151
|
type: 'custom',
|
|
121
152
|
// display: 'block',
|
|
153
|
+
filedName: 'filterAction',
|
|
122
154
|
display: {
|
|
123
155
|
wrapperCol: {
|
|
124
|
-
// 占用的格子数按对应size配置的formItem(md下额外再新增1)
|
|
125
|
-
span: _data.general.modalSize[itemGroupSize].formLayout.labelCol.span + _data.general.modalSize[itemGroupSize].formLayout.wrapperCol.span + (itemGroupSize === 'md' ? 1 : 0)
|
|
156
|
+
// 占用的格子数按对应size配置的formItem(md下额外再新增1, 忘了为什么额外加了,先去除.20240619)
|
|
157
|
+
span: _data.general.modalSize[itemGroupSize].formLayout.labelCol.span + _data.general.modalSize[itemGroupSize].formLayout.wrapperCol.span // + (itemGroupSize === 'md' ? 1 : 0)
|
|
126
158
|
}
|
|
127
159
|
},
|
|
128
160
|
protoFormItem: {
|
|
@@ -145,10 +177,23 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
145
177
|
},
|
|
146
178
|
onClick: handleReset,
|
|
147
179
|
ghost: true
|
|
148
|
-
}, cancelButtonProps), cancelText || '重置')
|
|
180
|
+
}, cancelButtonProps), cancelText || '重置'), filterFormLayout === 'horizontal' && collapseable && reFormItemGroup.length > columnNumberAndSize.columnNumber - 1 ? /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
181
|
+
type: 'link',
|
|
182
|
+
onClick: function onClick() {
|
|
183
|
+
return setCollapsed(!collapsed);
|
|
184
|
+
},
|
|
185
|
+
style: {
|
|
186
|
+
marginLeft: 8,
|
|
187
|
+
paddingInlineStart: 0,
|
|
188
|
+
paddingInlineEnd: 0
|
|
189
|
+
}
|
|
190
|
+
}, collapsed ? '收起' : '展开', /*#__PURE__*/_react.default.createElement(_SpecIcon.default, {
|
|
191
|
+
noPrefix: true,
|
|
192
|
+
name: collapsed ? 'speci-up' : 'speci-down'
|
|
193
|
+
})) : null);
|
|
149
194
|
}
|
|
150
195
|
})];
|
|
151
|
-
}, [confirmText, cancelText, filterFormLayout, reFormItemGroup, onFilterSearch, onFilterReset,
|
|
196
|
+
}, [confirmText, cancelText, filterFormLayout, reFormItemGroup, onFilterSearch, onFilterReset, columnNumberAndSize, filterFormRef, isHideCount, collapseable, collapsed]);
|
|
152
197
|
|
|
153
198
|
// 更新表单控件值,用于外部获取当前表单实例(force是否强制清空表单)
|
|
154
199
|
var updateFormFields = function updateFormFields(newVal, force) {
|
|
@@ -183,37 +228,29 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
183
228
|
})
|
|
184
229
|
} */
|
|
185
230
|
filterFormRef.current.setFieldsValue(_objectSpread(_objectSpread({}, resetValues), newVal || {})); // 直接清空表单的赋值
|
|
186
|
-
|
|
187
|
-
if (getFormFields) getFormFields(filterFormRef.current.getFieldsValue(), filterFormRef);
|
|
231
|
+
forceUpdateForm();
|
|
188
232
|
};
|
|
189
233
|
// 强制更新表单值,用于赋初始化实例值
|
|
190
234
|
var forceUpdateForm = (0, _react.useCallback)(function () {
|
|
191
235
|
var formValues = filterFormRef.current.getFieldsValue();
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (getFormFields) getFormFields(
|
|
197
|
-
}, [dateFormatter, formItemGroup]);
|
|
198
|
-
// 计算表单隐藏项
|
|
199
|
-
var updateCalculate = (0, _react.useCallback)(function (formValues) {
|
|
200
|
-
setIsHideCount(reFormItemGroup.filter(function (item) {
|
|
201
|
-
return item.hasOwnProperty('isHide') ? item.isHide(_objectSpread({}, formValues), filterFormRef) : false;
|
|
202
|
-
}).length);
|
|
236
|
+
if (Object.prototype.hasOwnProperty.call(formValues, false)) {
|
|
237
|
+
delete formValues.false; // 自定义结构会莫名的出来一个false字段
|
|
238
|
+
}
|
|
239
|
+
calculateHideCount(filterFormRef, reFormItemGroup); // 更新当前表单数量,排除被隐藏的值
|
|
240
|
+
if (getFormFields) getFormFields(formValues, filterFormRef);
|
|
203
241
|
}, [reFormItemGroup, filterFormRef]);
|
|
204
242
|
var handleSearch = function handleSearch(values) {
|
|
205
243
|
if (Object.prototype.hasOwnProperty.call(values, false)) {
|
|
206
|
-
delete values.false; //
|
|
244
|
+
delete values.false; // 自定义结构会莫名的出来一个false字段
|
|
207
245
|
}
|
|
208
|
-
var resultValues = dateFormatter === 'string' ? (0, _utils.UtilValueFormat)(values,
|
|
209
|
-
console.log('格式化前数据', values)
|
|
210
|
-
console.log('格式化后数据', resultValues)
|
|
246
|
+
var resultValues = dateFormatter === 'string' ? (0, _utils.UtilValueFormat)(values, reFormItemGroup) : values;
|
|
247
|
+
// console.log('格式化前数据', values)
|
|
248
|
+
// console.log('格式化后数据', resultValues)
|
|
211
249
|
if (onFilterSearch) {
|
|
212
250
|
onFilterSearch(_objectSpread({}, resultValues));
|
|
213
251
|
}
|
|
214
252
|
};
|
|
215
253
|
var handleReset = function handleReset() {
|
|
216
|
-
var _filterFormRef$curren;
|
|
217
254
|
// 使用此方法,表单校验无法清空掉
|
|
218
255
|
// const resetValues = this.filterFormRef.current.getFieldsValue()
|
|
219
256
|
// Object.keys(resetValues).forEach((item) => {
|
|
@@ -222,20 +259,78 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
222
259
|
// this.filterFormRef.current.setFieldsValue({ ...resetValues }) // 直接清空表单的赋值
|
|
223
260
|
filterFormRef.current.resetFields();
|
|
224
261
|
setReFormItemGroup(formItemGroup); // 重新渲染列表
|
|
225
|
-
|
|
262
|
+
calculateHideCount(filterFormRef, reFormItemGroup);
|
|
226
263
|
if (onFilterReset) {
|
|
227
264
|
var _filterFormRef$curren2;
|
|
228
265
|
onFilterReset(filterFormRef === null || filterFormRef === void 0 || (_filterFormRef$curren2 = filterFormRef.current) === null || _filterFormRef$curren2 === void 0 ? void 0 : _filterFormRef$curren2.getFieldsValue());
|
|
229
266
|
}
|
|
230
267
|
};
|
|
268
|
+
|
|
269
|
+
// 判断是否隐藏结构, display:'none'
|
|
270
|
+
var setItemHiddenNode = function setItemHiddenNode(item, index, collapsed, showItemNumber) {
|
|
271
|
+
// console.log('判断是否隐藏结构==>当前执行序号', index, showItemNumber)
|
|
272
|
+
if (item.filedName === 'filterAction') {
|
|
273
|
+
return {
|
|
274
|
+
isHidden: false
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
// 栅格列为1时,显示1个表单项
|
|
279
|
+
isHidden: collapsed ? false : showItemNumber === 0 ? index !== 0 : !(index < showItemNumber)
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
// 渲染隐藏指定控件
|
|
283
|
+
var itemIsHide = function itemIsHide(isHide, getFieldsValue, FormInstance) {
|
|
284
|
+
if (typeof isHide === 'function') {
|
|
285
|
+
return isHide(getFieldsValue, FormInstance, 'default');
|
|
286
|
+
}
|
|
287
|
+
return isHide || false;
|
|
288
|
+
};
|
|
289
|
+
var updateGroupByCollapsed = function updateGroupByCollapsed(groups, formValues) {
|
|
290
|
+
// console.log('判断当前是否需要按展开与收缩显示对应的表单项')
|
|
291
|
+
var showItemNumber = columnNumberAndSize.columnNumber - 1;
|
|
292
|
+
return new Promise(function (resolve, reject) {
|
|
293
|
+
if (Array.isArray(groups)) {
|
|
294
|
+
resolve(groups.map(function (item, index) {
|
|
295
|
+
if (collapseable && filterFormLayout === "horizontal") {
|
|
296
|
+
var _setItemHiddenNode = setItemHiddenNode(item, index, collapsed, showItemNumber),
|
|
297
|
+
isHidden = _setItemHiddenNode.isHidden;
|
|
298
|
+
item.isHidden = isHidden;
|
|
299
|
+
item.style = _objectSpread(_objectSpread({}, item.style || {}), {}, {
|
|
300
|
+
display: item.isHidden ? 'none' : 'block'
|
|
301
|
+
});
|
|
302
|
+
if (item.hasOwnProperty('isHide') && itemIsHide(item.isHide, formValues, filterFormRef)) {
|
|
303
|
+
showItemNumber++;
|
|
304
|
+
item.isHidden = true;
|
|
305
|
+
// console.log('当前是结构是隐藏未渲染,跳到下个序号', showItemNumber)
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return _objectSpread({}, item);
|
|
309
|
+
}));
|
|
310
|
+
} else {
|
|
311
|
+
resolve(groups);
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
(0, _react.useEffect)(function () {
|
|
316
|
+
// 初始化表单数据数据
|
|
317
|
+
if (collapseable && filterFormLayout === "horizontal") {
|
|
318
|
+
var _filterFormRef$curren3;
|
|
319
|
+
var formValues = filterFormRef === null || filterFormRef === void 0 || (_filterFormRef$curren3 = filterFormRef.current) === null || _filterFormRef$curren3 === void 0 ? void 0 : _filterFormRef$curren3.getFieldValue();
|
|
320
|
+
updateGroupByCollapsed(formItemGroup, formValues).then(function (groups) {
|
|
321
|
+
setReFormItemGroup(groups);
|
|
322
|
+
calculateHideCount(filterFormRef, groups);
|
|
323
|
+
});
|
|
324
|
+
} else {
|
|
325
|
+
setReFormItemGroup(formItemGroup);
|
|
326
|
+
}
|
|
327
|
+
}, [formItemGroup, collapseable, filterFormLayout, collapsed, columnNumberAndSize === null || columnNumberAndSize === void 0 ? void 0 : columnNumberAndSize.columnNumber, itemGroupConfig, filterFormRef, filterFormRef === null || filterFormRef === void 0 || (_filterFormRef$curren4 = filterFormRef.current) === null || _filterFormRef$curren4 === void 0 ? void 0 : _filterFormRef$curren4.getFieldValue()]);
|
|
231
328
|
(0, _react.useEffect)(function () {
|
|
232
329
|
if (initialValues && JSON.stringify(initialValues) !== '{}') {
|
|
233
330
|
updateFormFields(initialValues, true);
|
|
234
331
|
}
|
|
235
332
|
}, [initialValues]);
|
|
236
|
-
|
|
237
|
-
setReFormItemGroup(formItemGroup);
|
|
238
|
-
}, [formItemGroup]);
|
|
333
|
+
|
|
239
334
|
// / 表单列表组 formItemGroup 类型为数组或者React.Node
|
|
240
335
|
var renderFormItemGroup = function renderFormItemGroup() {
|
|
241
336
|
if (Array.isArray(reFormItemGroup)) {
|
|
@@ -245,7 +340,9 @@ var StandardFilter = /*#__PURE__*/_react.default.forwardRef(function (props, ref
|
|
|
245
340
|
size: filterFormLayout === 'horizontal' ? 'xxlg' : 'md' // size决定栅格排列数量(4列排版)
|
|
246
341
|
,
|
|
247
342
|
layout: filterFormLayout,
|
|
248
|
-
form: filterFormRef
|
|
343
|
+
form: filterFormRef,
|
|
344
|
+
collapseable: collapseable,
|
|
345
|
+
collapsed: collapsed
|
|
249
346
|
// displayLayout={{labelCol: { span: 8 }, wrapperCol: { span: 16 },}}
|
|
250
347
|
,
|
|
251
348
|
doUpdateFormFields: function doUpdateFormFields() {
|
|
@@ -82,20 +82,17 @@ var StandardModal = function StandardModal(props) {
|
|
|
82
82
|
var _Form$useForm = _antd.Form.useForm(),
|
|
83
83
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
84
84
|
modalForm = _Form$useForm2[0];
|
|
85
|
-
|
|
85
|
+
// const [modalFormRef, setModalFormRef] = useState<any>(); // <---- set the ref when Form Rendered(使用此方法会出现溢出事件)
|
|
86
|
+
var _useState = (0, _react.useState)(0),
|
|
86
87
|
_useState2 = _slicedToArray(_useState, 2),
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var _useState3 = (0, _react.useState)(0),
|
|
90
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
91
|
-
bodyMaxHeight = _useState4[0],
|
|
92
|
-
setBodyMaxHeight = _useState4[1];
|
|
88
|
+
bodyMaxHeight = _useState2[0],
|
|
89
|
+
setBodyMaxHeight = _useState2[1];
|
|
93
90
|
|
|
94
91
|
// setTabFormChild
|
|
95
|
-
var
|
|
96
|
-
|
|
97
|
-
formChild =
|
|
98
|
-
setFormChild =
|
|
92
|
+
var _useState3 = (0, _react.useState)(),
|
|
93
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
94
|
+
formChild = _useState4[0],
|
|
95
|
+
setFormChild = _useState4[1]; // <---- set the ref when Form Rendered
|
|
99
96
|
|
|
100
97
|
// 按钮栏是否有显示(默认显示)
|
|
101
98
|
var hasFooterBar = (0, _react.useMemo)(function () {
|
|
@@ -171,7 +168,7 @@ var StandardModal = function StandardModal(props) {
|
|
|
171
168
|
};
|
|
172
169
|
// fill Form when modal open 此处可解决获取 Form.useForm warning
|
|
173
170
|
(0, _react.useEffect)(function () {
|
|
174
|
-
if (visible &&
|
|
171
|
+
if (visible && modalForm) {
|
|
175
172
|
// <---- check ref before use the form instance
|
|
176
173
|
if (initialValues && _typeof(initialValues) === 'object') {
|
|
177
174
|
initialValues && modalForm.setFieldsValue(_objectSpread({}, initialValues));
|
|
@@ -181,7 +178,7 @@ var StandardModal = function StandardModal(props) {
|
|
|
181
178
|
// if (!visible && modalFormRef) {
|
|
182
179
|
// clearAllFieldsValue() // 清空表单传参数
|
|
183
180
|
// }
|
|
184
|
-
}, [
|
|
181
|
+
}, [modalForm, visible]);
|
|
185
182
|
(0, _react.useEffect)(function () {
|
|
186
183
|
if (visible) {
|
|
187
184
|
initBodyMaxHeight();
|
|
@@ -427,8 +424,12 @@ var StandardModal = function StandardModal(props) {
|
|
|
427
424
|
// 内容渲染
|
|
428
425
|
var renderChildrenNodes = function renderChildrenNodes() {
|
|
429
426
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children, (type === 'form' || type === 'gridForm') && /*#__PURE__*/_react.default.createElement(_antd.Form, {
|
|
430
|
-
layout: formLayout
|
|
431
|
-
ref
|
|
427
|
+
layout: formLayout
|
|
428
|
+
// ref={(formInstance)=> {
|
|
429
|
+
// // console.log('formInstance', formInstance)
|
|
430
|
+
// // setModalFormRef(formInstance)
|
|
431
|
+
// }}
|
|
432
|
+
,
|
|
432
433
|
form: modalForm,
|
|
433
434
|
onFinish: handleSubmit,
|
|
434
435
|
hideRequiredMark: fieldStatus === 'viewOnly' || hideRequiredMark
|
|
@@ -64,7 +64,7 @@ var StandardTable = function StandardTable(props) {
|
|
|
64
64
|
rest = _objectWithoutProperties(_providerConfig$props, _excluded);
|
|
65
65
|
// 加上类型修复 TS:2322 报警
|
|
66
66
|
var resetColumns = [_objectSpread(_objectSpread({
|
|
67
|
-
width:
|
|
67
|
+
width: 76,
|
|
68
68
|
align: 'center',
|
|
69
69
|
title: '序号',
|
|
70
70
|
key: 'orderNum',
|
|
@@ -92,7 +92,7 @@ var StandardTable = function StandardTable(props) {
|
|
|
92
92
|
otherColumn = columnsConfig.otherColumn;
|
|
93
93
|
if (colItem.type === 'action') {
|
|
94
94
|
var _colItem, _colItem2, _colItem3;
|
|
95
|
-
colItem.width = ((_colItem = colItem) === null || _colItem === void 0 ? void 0 : _colItem.width) || (action === null || action === void 0 ? void 0 : action.width) || (colItem.buttonGroup.length > 1 ?
|
|
95
|
+
colItem.width = ((_colItem = colItem) === null || _colItem === void 0 ? void 0 : _colItem.width) || (action === null || action === void 0 ? void 0 : action.width) || (colItem.buttonGroup.length > 1 ? 130 : 80);
|
|
96
96
|
colItem.align = ((_colItem2 = colItem) === null || _colItem2 === void 0 ? void 0 : _colItem2.align) || (action === null || action === void 0 ? void 0 : action.align) || 'center';
|
|
97
97
|
colItem.title = ((_colItem3 = colItem) === null || _colItem3 === void 0 ? void 0 : _colItem3.title) || (action === null || action === void 0 ? void 0 : action.title) || '操作';
|
|
98
98
|
colItem.key = 'control';
|
|
@@ -176,7 +176,7 @@ var StandardTable = function StandardTable(props) {
|
|
|
176
176
|
}, /*#__PURE__*/_react.default.createElement(_antd.Table, _extends({
|
|
177
177
|
rowKey: rowKey || 'id',
|
|
178
178
|
rowSelection: rowSelection ? _objectSpread({
|
|
179
|
-
columnWidth:
|
|
179
|
+
columnWidth: 56
|
|
180
180
|
}, rowSelection) : rowSelection,
|
|
181
181
|
dataSource: list,
|
|
182
182
|
pagination: !pagination ? false : paginationProps,
|