@zat-design/sisyphus-react 3.6.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.css +10 -0
- package/dist/less.esm.css +10 -0
- package/es/ProEditTable/utils/config.js +6 -2
- package/es/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/es/ProForm/components/combination/ProNumberRange/index.js +4 -1
- package/es/ProForm/components/render/Render.js +1 -1
- package/es/ProForm/components/render/RenderFields.js +0 -6
- package/es/ProForm/index.js +7 -4
- package/es/ProForm/propsType.d.ts +4 -0
- package/es/ProForm/utils/index.d.ts +1 -1
- package/es/ProForm/utils/index.js +5 -2
- package/es/ProForm/utils/useForm.d.ts +7 -1
- package/es/ProForm/utils/useForm.js +59 -6
- package/es/ProTooltip/index.js +14 -14
- package/es/ProTooltip/style/index.less +8 -0
- package/es/ProTreeModal/components/List.js +108 -17
- package/es/ProTreeModal/components/Tree.js +4 -2
- package/es/ProTreeModal/index.js +25 -20
- package/es/ProTreeModal/style/index.less +6 -0
- package/lib/ProEditTable/utils/config.js +6 -2
- package/lib/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/lib/ProForm/components/combination/ProNumberRange/index.js +4 -1
- package/lib/ProForm/components/render/Render.js +1 -1
- package/lib/ProForm/components/render/RenderFields.js +0 -6
- package/lib/ProForm/index.js +7 -4
- package/lib/ProForm/propsType.d.ts +4 -0
- package/lib/ProForm/utils/index.d.ts +1 -1
- package/lib/ProForm/utils/index.js +5 -2
- package/lib/ProForm/utils/useForm.d.ts +7 -1
- package/lib/ProForm/utils/useForm.js +59 -6
- package/lib/ProTooltip/index.js +14 -14
- package/lib/ProTooltip/style/index.less +8 -0
- package/lib/ProTreeModal/components/List.js +106 -15
- package/lib/ProTreeModal/components/Tree.js +4 -2
- package/lib/ProTreeModal/index.js +24 -19
- package/lib/ProTreeModal/style/index.less +6 -0
- package/package.json +1 -1
|
@@ -210,9 +210,13 @@ var actions = exports.actions = {
|
|
|
210
210
|
top: insertType === 'before' ? -10000 : 10000,
|
|
211
211
|
behavior: 'smooth'
|
|
212
212
|
});
|
|
213
|
-
|
|
213
|
+
if (!virtualKey) {
|
|
214
|
+
_context2.next = 15;
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
_context2.next = 15;
|
|
214
218
|
return form.validateFields([name]);
|
|
215
|
-
case
|
|
219
|
+
case 15:
|
|
216
220
|
case "end":
|
|
217
221
|
return _context2.stop();
|
|
218
222
|
}
|
|
@@ -706,7 +706,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
|
|
|
706
706
|
} : queryBean;
|
|
707
707
|
var nextParams = transformParams ? transformParams(params) : params;
|
|
708
708
|
run(nextParams);
|
|
709
|
-
},
|
|
709
|
+
}, 1000),
|
|
710
710
|
style: {
|
|
711
711
|
width: isView || disabled ? '100%' : 'calc(100% - 30px)'
|
|
712
712
|
}
|
|
@@ -133,7 +133,10 @@ var ProNumberRange = function ProNumberRange(props) {
|
|
|
133
133
|
case 'amount':
|
|
134
134
|
valueProps = {
|
|
135
135
|
formatter: function formatter(value) {
|
|
136
|
-
return
|
|
136
|
+
return typeof value === 'number' || value ? Number(value).toLocaleString('zh-CN', {
|
|
137
|
+
minimumFractionDigits: precision !== null && precision !== void 0 ? precision : null,
|
|
138
|
+
maximumFractionDigits: precision !== null && precision !== void 0 ? precision : 9
|
|
139
|
+
}) : value;
|
|
137
140
|
},
|
|
138
141
|
parser: function parser(value) {
|
|
139
142
|
return value.replace(/\$\s?|(,*)/g, '');
|
|
@@ -381,7 +381,7 @@ var Render = function Render(props) {
|
|
|
381
381
|
if (originComponent) {
|
|
382
382
|
delete childProps.otherProps;
|
|
383
383
|
}
|
|
384
|
-
var child = /*#__PURE__*/_react.default.isValidElement(AutoComponent) ? ( /*#__PURE__*/_react.default.cloneElement(AutoComponent, childProps)) : (0, _jsxRuntime.jsx)(AutoComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(lastComponentProps, lastComponentPropsFilter)), {}, {
|
|
384
|
+
var child = /*#__PURE__*/_react.default.isValidElement(AutoComponent) ? ( /*#__PURE__*/_react.default.cloneElement(AutoComponent, childProps)) : (0, _jsxRuntime.jsx)(AutoComponent, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _lodash.omit)(lastComponentProps, [].concat(lastComponentPropsFilter, ['debounceWait']))), {}, {
|
|
385
385
|
otherProps: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, otherProps), {}, {
|
|
386
386
|
show: show,
|
|
387
387
|
disabled: lastDisabled,
|
|
@@ -194,12 +194,6 @@ var RenderFields = function RenderFields(props) {
|
|
|
194
194
|
globalControl: globalControl,
|
|
195
195
|
formDisabled: formDisabled
|
|
196
196
|
};
|
|
197
|
-
if (outerClearNotShow !== false && show === false && (column === null || column === void 0 ? void 0 : column.name) && form.getFieldValue(column === null || column === void 0 ? void 0 : column.name)) {
|
|
198
|
-
setTimeout(function () {
|
|
199
|
-
form.resetFields([column === null || column === void 0 ? void 0 : column.name]);
|
|
200
|
-
}, 200);
|
|
201
|
-
return null;
|
|
202
|
-
}
|
|
203
197
|
return (0, _jsxRuntime.jsx)(_useFieldProps.FieldProvider, {
|
|
204
198
|
value: otherProps,
|
|
205
199
|
children: (0, _jsxRuntime.jsx)(_Render.default, {
|
package/lib/ProForm/index.js
CHANGED
|
@@ -24,7 +24,7 @@ var _index = require("./utils/index");
|
|
|
24
24
|
var _useForm3 = require("./utils/useForm");
|
|
25
25
|
var _useFieldProps = require("./utils/useFieldProps");
|
|
26
26
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
27
|
-
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalDiffTip", "formKey", "globalControl", "scrollToError"];
|
|
27
|
+
var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalDiffTip", "formKey", "globalControl", "scrollToError", "optimize"];
|
|
28
28
|
var ProForm = function ProForm(props, ref) {
|
|
29
29
|
var _forms$formKey, _localStorage, _ref;
|
|
30
30
|
var _props$mode = props.mode,
|
|
@@ -68,6 +68,8 @@ var ProForm = function ProForm(props, ref) {
|
|
|
68
68
|
globalControl = props.globalControl,
|
|
69
69
|
_props$scrollToError = props.scrollToError,
|
|
70
70
|
scrollToError = _props$scrollToError === void 0 ? true : _props$scrollToError,
|
|
71
|
+
_props$optimize = props.optimize,
|
|
72
|
+
optimize = _props$optimize === void 0 ? false : _props$optimize,
|
|
71
73
|
otherProps = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
72
74
|
var _useProConfig = (0, _ProConfigProvider.useProConfig)(),
|
|
73
75
|
state = _useProConfig.state,
|
|
@@ -75,7 +77,8 @@ var ProForm = function ProForm(props, ref) {
|
|
|
75
77
|
var config = state.ProForm,
|
|
76
78
|
forms = state.forms;
|
|
77
79
|
var _useForm = (0, _useForm3.useForm)((_forms$formKey = forms[formKey]) !== null && _forms$formKey !== void 0 ? _forms$formKey : originForm, {
|
|
78
|
-
scrollToError: scrollToError
|
|
80
|
+
scrollToError: scrollToError,
|
|
81
|
+
optimize: optimize
|
|
79
82
|
}),
|
|
80
83
|
_useForm2 = (0, _slicedToArray2.default)(_useForm, 1),
|
|
81
84
|
form = _useForm2[0];
|
|
@@ -168,7 +171,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
168
171
|
// 暂时通过'-'区分组合组件字段和普通字段
|
|
169
172
|
var keys = Object.keys(changedValue);
|
|
170
173
|
if (!keys.length) {
|
|
171
|
-
onValuesChange((0, _index.filterInternalFields)(changedValue), form.getFieldsValue());
|
|
174
|
+
onValuesChange((0, _index.filterInternalFields)(changedValue, optimize), form.getFieldsValue());
|
|
172
175
|
} else {
|
|
173
176
|
var values = keys.map(function (key) {
|
|
174
177
|
if (key.includes('-')) {
|
|
@@ -180,7 +183,7 @@ var ProForm = function ProForm(props, ref) {
|
|
|
180
183
|
}
|
|
181
184
|
return {};
|
|
182
185
|
});
|
|
183
|
-
onValuesChange((0, _index.filterInternalFields)(_lodash.merge.apply(void 0, [changedValue].concat((0, _toConsumableArray2.default)(values)))), form.getFieldsValue());
|
|
186
|
+
onValuesChange((0, _index.filterInternalFields)(_lodash.merge.apply(void 0, [changedValue].concat((0, _toConsumableArray2.default)(values))), optimize), form.getFieldsValue());
|
|
184
187
|
}
|
|
185
188
|
};
|
|
186
189
|
// 包装一层兼容 names 改变
|
|
@@ -76,6 +76,10 @@ export interface ProFormProps<Values = any> extends FormProps<Values> {
|
|
|
76
76
|
required?: boolean | boolean[];
|
|
77
77
|
originalDiffTip?: boolean;
|
|
78
78
|
scrollToError?: boolean;
|
|
79
|
+
/** 性能模式,谨慎使用,默认不开启
|
|
80
|
+
* 1. 开启不过滤names的中间态值
|
|
81
|
+
*/
|
|
82
|
+
optimize?: boolean;
|
|
79
83
|
}
|
|
80
84
|
export interface Transform<T = any> {
|
|
81
85
|
normalize?: (value: StoreValue, prevValue: StoreValue, allValues: Store) => StoreValue;
|
|
@@ -28,7 +28,7 @@ export declare const isUpperCase: (type: string, upperCase: boolean) => any;
|
|
|
28
28
|
export declare const weedOutProps: (data: Record<string, any>, keys: string[]) => {}[];
|
|
29
29
|
export declare const diffField: (prevValues: any, curValues: any, names: NamePath[]) => boolean;
|
|
30
30
|
export declare const splitNameStr: (name: string) => string[][];
|
|
31
|
-
export declare const filterInternalFields: (values: any) => any;
|
|
31
|
+
export declare const filterInternalFields: (values: any, optimize?: boolean) => any;
|
|
32
32
|
export declare const getAllNamePath: (object: Record<string, any>, currentPath?: InternalNamePath) => InternalNamePath[];
|
|
33
33
|
export declare const isNullValue: (value: any) => boolean;
|
|
34
34
|
/**
|
|
@@ -22,8 +22,8 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
22
22
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
23
23
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
24
24
|
var _react = _interopRequireWildcard(require("react"));
|
|
25
|
-
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
26
25
|
var _moment = _interopRequireDefault(require("moment"));
|
|
26
|
+
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
27
27
|
var getLayout = exports.getLayout = function getLayout(params) {
|
|
28
28
|
var _params$span = params.span,
|
|
29
29
|
span = _params$span === void 0 ? 8 : _params$span,
|
|
@@ -139,7 +139,10 @@ var splitNameStr = exports.splitNameStr = function splitNameStr(name) {
|
|
|
139
139
|
});
|
|
140
140
|
};
|
|
141
141
|
// 过滤掉字段名中包含 '-' 的字段
|
|
142
|
-
var filterInternalFields = exports.filterInternalFields = function filterInternalFields(values) {
|
|
142
|
+
var filterInternalFields = exports.filterInternalFields = function filterInternalFields(values, optimize) {
|
|
143
|
+
if (optimize) {
|
|
144
|
+
return values;
|
|
145
|
+
}
|
|
143
146
|
var nextValues = values;
|
|
144
147
|
// fix: braft-editor对象不可遍历 Moment不过滤
|
|
145
148
|
if ((values === null || values === void 0 ? void 0 : values._immutable) || _moment.default.isMoment(values)) {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { FormInstance } from 'antd';
|
|
2
|
+
import { NamePath } from 'antd/es/form/interface';
|
|
3
|
+
import { ValuedNotifyInfo } from 'rc-field-form/es/interface';
|
|
2
4
|
type ModifiedFormInstance<T> = FormInstance<T> & {
|
|
3
5
|
isModified?: boolean;
|
|
6
|
+
/** 默认清空设置值的报错状态 */
|
|
7
|
+
setFieldValue: (name: NamePath, value: any, info?: ValuedNotifyInfo) => void;
|
|
8
|
+
_init?: boolean;
|
|
4
9
|
};
|
|
5
10
|
interface FormInstanceOption {
|
|
6
11
|
scrollToError?: boolean;
|
|
12
|
+
optimize?: boolean;
|
|
7
13
|
}
|
|
8
|
-
export declare const useForm: <T>(originForm
|
|
14
|
+
export declare const useForm: <T>(originForm?: FormInstanceOption | ModifiedFormInstance<T>, options?: FormInstanceOption) => [ModifiedFormInstance<T>];
|
|
9
15
|
export {};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.useForm = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
8
9
|
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/regeneratorRuntime"));
|
|
9
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
@@ -13,22 +14,32 @@ var _antd = require("antd");
|
|
|
13
14
|
var _index = require("./index");
|
|
14
15
|
var _tools = require("../../ProEditTable/utils/tools");
|
|
15
16
|
var useForm = exports.useForm = function useForm(originForm, options) {
|
|
16
|
-
|
|
17
|
+
// 如果没有form实例可以直接把options放在第一个参数位置
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
var _originForm = (originForm === null || originForm === void 0 ? void 0 : originForm._init) ? originForm : undefined;
|
|
20
|
+
var _options =
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
options || originForm && !(originForm === null || originForm === void 0 ? void 0 : originForm._init) ? originForm : undefined;
|
|
23
|
+
var _ref = _options || {},
|
|
17
24
|
_ref$scrollToError = _ref.scrollToError,
|
|
18
|
-
scrollToError = _ref$scrollToError === void 0 ? true : _ref$scrollToError
|
|
19
|
-
|
|
25
|
+
scrollToError = _ref$scrollToError === void 0 ? true : _ref$scrollToError,
|
|
26
|
+
optimize = _ref.optimize;
|
|
27
|
+
var _Form$useForm = _antd.Form.useForm(_originForm),
|
|
20
28
|
_Form$useForm2 = (0, _slicedToArray2.default)(_Form$useForm, 1),
|
|
21
29
|
form = _Form$useForm2[0];
|
|
22
30
|
var getFieldsValue = form.getFieldsValue,
|
|
23
31
|
validateFields = form.validateFields,
|
|
24
|
-
isModified = form.isModified
|
|
32
|
+
isModified = form.isModified,
|
|
33
|
+
setFields = form.setFields,
|
|
34
|
+
getFieldsError = form.getFieldsError,
|
|
35
|
+
setFieldsValue = form.setFieldsValue;
|
|
25
36
|
if (isModified) return [form];
|
|
26
37
|
// @ts-ignore
|
|
27
38
|
var _getFieldsValue = function _getFieldsValue(nameList, filterFunc) {
|
|
28
39
|
// 全部查询
|
|
29
40
|
if (nameList !== true) {
|
|
30
41
|
var values = getFieldsValue(nameList || true, filterFunc);
|
|
31
|
-
return (0, _index.filterInternalFields)(values);
|
|
42
|
+
return (0, _index.filterInternalFields)(values, optimize);
|
|
32
43
|
}
|
|
33
44
|
return getFieldsValue(nameList, filterFunc);
|
|
34
45
|
};
|
|
@@ -76,7 +87,7 @@ var useForm = exports.useForm = function useForm(originForm, options) {
|
|
|
76
87
|
// delete rest[0].recursive;
|
|
77
88
|
_context.next = 11;
|
|
78
89
|
return validateFields.apply(void 0, [validateNames].concat(rest)).then(function (values) {
|
|
79
|
-
return (0, _index.filterInternalFields)(values);
|
|
90
|
+
return (0, _index.filterInternalFields)(values, optimize);
|
|
80
91
|
});
|
|
81
92
|
case 11:
|
|
82
93
|
return _context.abrupt("return", _context.sent);
|
|
@@ -108,6 +119,48 @@ var useForm = exports.useForm = function useForm(originForm, options) {
|
|
|
108
119
|
return _ref2.apply(this, arguments);
|
|
109
120
|
};
|
|
110
121
|
}();
|
|
122
|
+
var _setFieldValue = function _setFieldValue(name, value, info) {
|
|
123
|
+
if (info) {
|
|
124
|
+
setFields([(0, _objectSpread2.default)({
|
|
125
|
+
name: name,
|
|
126
|
+
value: value
|
|
127
|
+
}, info)]);
|
|
128
|
+
} else {
|
|
129
|
+
setFields([{
|
|
130
|
+
name: name,
|
|
131
|
+
value: value,
|
|
132
|
+
errors: [],
|
|
133
|
+
warnings: []
|
|
134
|
+
}]);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var _setFieldsValue = function _setFieldsValue(values) {
|
|
138
|
+
var errors = getFieldsError();
|
|
139
|
+
var errorNames = errors.reduce(function (acc, entry) {
|
|
140
|
+
if (entry.errors.length > 0) {
|
|
141
|
+
acc.push(entry.name[0]);
|
|
142
|
+
}
|
|
143
|
+
return acc;
|
|
144
|
+
}, []) || [];
|
|
145
|
+
if (errorNames.length) {
|
|
146
|
+
errorNames.forEach(function (errorName) {
|
|
147
|
+
// 只处理names的报错
|
|
148
|
+
if (errorName.includes('-')) {
|
|
149
|
+
setFields([{
|
|
150
|
+
name: errorName,
|
|
151
|
+
errors: [],
|
|
152
|
+
warnings: []
|
|
153
|
+
}]);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
setFieldsValue(values);
|
|
157
|
+
} else {
|
|
158
|
+
setFieldsValue(values);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
form.getFieldsValue = _getFieldsValue;
|
|
162
|
+
form.setFieldValue = _setFieldValue;
|
|
163
|
+
form.setFieldsValue = _setFieldsValue;
|
|
111
164
|
form.getFieldsValue = _getFieldsValue;
|
|
112
165
|
form.validateFields = _validateFields;
|
|
113
166
|
form.isModified = true;
|
package/lib/ProTooltip/index.js
CHANGED
|
@@ -73,12 +73,12 @@ var ProTooltip = function ProTooltip(props) {
|
|
|
73
73
|
} : {};
|
|
74
74
|
var AutoMixinSingle = function AutoMixinSingle() {
|
|
75
75
|
return isShowToolTip && line === 1 ? (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
76
|
-
title: text
|
|
77
|
-
}, restProps), {}, {
|
|
78
|
-
overlayStyle: overlayStyle,
|
|
76
|
+
title: text,
|
|
79
77
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
80
78
|
return triggerNode.parentNode;
|
|
81
|
-
}
|
|
79
|
+
}
|
|
80
|
+
}, restProps), {}, {
|
|
81
|
+
overlayStyle: overlayStyle,
|
|
82
82
|
children: (0, _jsxRuntime.jsx)("div", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, specialProps), {}, {
|
|
83
83
|
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, multiStyle), {}, {
|
|
84
84
|
width: localWidth,
|
|
@@ -108,12 +108,12 @@ var ProTooltip = function ProTooltip(props) {
|
|
|
108
108
|
};
|
|
109
109
|
var AutoMixinMulti = function AutoMixinMulti() {
|
|
110
110
|
return isShowToolTip && line > 1 ? (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
111
|
-
title: text
|
|
112
|
-
}, restProps), {}, {
|
|
113
|
-
overlayStyle: overlayStyle,
|
|
111
|
+
title: text,
|
|
114
112
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
115
113
|
return triggerNode.parentNode;
|
|
116
|
-
}
|
|
114
|
+
}
|
|
115
|
+
}, restProps), {}, {
|
|
116
|
+
overlayStyle: overlayStyle,
|
|
117
117
|
children: (0, _jsxRuntime.jsx)("div", (0, _objectSpread2.default)((0, _objectSpread2.default)({}, specialProps), {}, {
|
|
118
118
|
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, multiStyle), {}, {
|
|
119
119
|
width: localWidth,
|
|
@@ -259,11 +259,11 @@ var ProTooltip = function ProTooltip(props) {
|
|
|
259
259
|
width: localWidth
|
|
260
260
|
}),
|
|
261
261
|
children: isResponsiveWidth && isShowToolTip ? (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
262
|
-
title: text
|
|
263
|
-
}, restProps), {}, {
|
|
262
|
+
title: text,
|
|
264
263
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
265
264
|
return triggerNode.parentNode;
|
|
266
|
-
}
|
|
265
|
+
}
|
|
266
|
+
}, restProps), {}, {
|
|
267
267
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
268
268
|
className: isMultiLine ? 'multiLine' : 'singleLine',
|
|
269
269
|
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, multiStyle), {}, {
|
|
@@ -280,11 +280,11 @@ var ProTooltip = function ProTooltip(props) {
|
|
|
280
280
|
ref: childRef,
|
|
281
281
|
children: content
|
|
282
282
|
}) : mode === 'default' ? (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
|
283
|
-
title: text
|
|
284
|
-
}, restProps), {}, {
|
|
283
|
+
title: text,
|
|
285
284
|
getPopupContainer: function getPopupContainer(triggerNode) {
|
|
286
285
|
return triggerNode.parentNode;
|
|
287
|
-
}
|
|
286
|
+
}
|
|
287
|
+
}, restProps), {}, {
|
|
288
288
|
children: (0, _jsxRuntime.jsx)("div", {
|
|
289
289
|
className: isMultiLine ? 'multiLine' : 'singleLine',
|
|
290
290
|
style: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, multiStyle), {}, {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
@root-entry-name: 'default';
|
|
2
2
|
@import (reference) '~antd/es/style/themes/index.less';
|
|
3
3
|
|
|
4
|
+
.@{ant-prefix}-table-cell-fix-right {
|
|
5
|
+
z-index: 999 !important;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.@{ant-prefix}-table-cell-fix-left {
|
|
9
|
+
z-index: 999 !important;
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
.pro-tooltip {
|
|
5
13
|
cursor: pointer;
|
|
6
14
|
|
|
@@ -35,8 +35,14 @@ function List(props, ref) {
|
|
|
35
35
|
handleFilterClose = props.handleFilterClose,
|
|
36
36
|
optionRender = props.optionRender,
|
|
37
37
|
handleDragEndChange = props.handleDragEndChange;
|
|
38
|
+
var containerRef = (0, _react.useRef)(null);
|
|
39
|
+
var wrapperRef = (0, _react.useRef)(null);
|
|
40
|
+
var originalList = (0, _react.useMemo)(function () {
|
|
41
|
+
return treeData;
|
|
42
|
+
}, [treeData]);
|
|
38
43
|
var fieldNameLabel = fieldNames.label;
|
|
39
44
|
var fieldNameValue = fieldNames.value;
|
|
45
|
+
var isCASCADER = modeType === _.CASCADER;
|
|
40
46
|
var _useSetState = (0, _ahooks.useSetState)({
|
|
41
47
|
checkedList: []
|
|
42
48
|
}),
|
|
@@ -104,6 +110,33 @@ function List(props, ref) {
|
|
|
104
110
|
}));
|
|
105
111
|
}
|
|
106
112
|
};
|
|
113
|
+
function getLineHeight(string, width) {
|
|
114
|
+
// 创建临时元素
|
|
115
|
+
var temp = document.createElement('div');
|
|
116
|
+
temp.style.position = 'absolute';
|
|
117
|
+
temp.style.visibility = 'hidden';
|
|
118
|
+
temp.style.right = '-10000px';
|
|
119
|
+
temp.style.width = "".concat(width, "px"); // 设置宽度
|
|
120
|
+
temp.style.whiteSpace = 'normal'; // 保持换行
|
|
121
|
+
temp.innerHTML = string.replace(/\n/g, '<br>'); // 替换换行符
|
|
122
|
+
document.body.appendChild(temp); // 添加到DOM中以获取计算后的高度
|
|
123
|
+
// 清理
|
|
124
|
+
var len = Math.floor(temp.getBoundingClientRect().height / 20);
|
|
125
|
+
document.body.removeChild(temp);
|
|
126
|
+
return len * 20;
|
|
127
|
+
}
|
|
128
|
+
var _useVirtualList = (0, _ahooks.useVirtualList)(originalList, {
|
|
129
|
+
containerTarget: containerRef,
|
|
130
|
+
wrapperTarget: wrapperRef,
|
|
131
|
+
itemHeight: function itemHeight(index, item) {
|
|
132
|
+
var title = showCodeName ? "".concat(item[fieldNameValue], "-").concat(isCASCADER ? item === null || item === void 0 ? void 0 : item.title : item[fieldNameLabel]) : "".concat(isCASCADER ? item === null || item === void 0 ? void 0 : item.title : item[fieldNameLabel]);
|
|
133
|
+
return Math.floor(getLineHeight(title, 406)) + 12;
|
|
134
|
+
}
|
|
135
|
+
}),
|
|
136
|
+
_useVirtualList2 = (0, _slicedToArray2.default)(_useVirtualList, 1),
|
|
137
|
+
list = _useVirtualList2[0];
|
|
138
|
+
// 是否为多列模式
|
|
139
|
+
var isRowCols = mode === 'render' && span && span !== 24;
|
|
107
140
|
// 开启 draggable 拖拽模式
|
|
108
141
|
if (draggable) {
|
|
109
142
|
return (0, _jsxRuntime.jsx)("div", {
|
|
@@ -131,9 +164,56 @@ function List(props, ref) {
|
|
|
131
164
|
})
|
|
132
165
|
});
|
|
133
166
|
}
|
|
134
|
-
var isCASCADER = modeType === _.CASCADER;
|
|
135
167
|
// 编辑状态
|
|
136
|
-
if (
|
|
168
|
+
if (!isRowCols) {
|
|
169
|
+
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
170
|
+
children: (0, _jsxRuntime.jsx)(_antd.Checkbox.Group, {
|
|
171
|
+
disabled: disabled,
|
|
172
|
+
style: {
|
|
173
|
+
width: '100%'
|
|
174
|
+
},
|
|
175
|
+
value: checkedValues,
|
|
176
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
177
|
+
ref: containerRef,
|
|
178
|
+
style: {
|
|
179
|
+
height: '432px',
|
|
180
|
+
overflow: 'auto',
|
|
181
|
+
width: '100%'
|
|
182
|
+
},
|
|
183
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
184
|
+
ref: wrapperRef,
|
|
185
|
+
children: (0, _jsxRuntime.jsx)(_antd.Row, {
|
|
186
|
+
children: list.map(function (_item) {
|
|
187
|
+
var item = _item.data;
|
|
188
|
+
var title = showCodeName ? "".concat(item[fieldNameValue], "-").concat(isCASCADER ? item === null || item === void 0 ? void 0 : item.title : item[fieldNameLabel]) : "".concat(isCASCADER ? item === null || item === void 0 ? void 0 : item.title : item[fieldNameLabel]);
|
|
189
|
+
var content = optionRender ? optionRender(item, searchStr) : (0, _jsxRuntime.jsx)(_SearchTitle.default, {
|
|
190
|
+
label: title,
|
|
191
|
+
searchStr: searchStr
|
|
192
|
+
});
|
|
193
|
+
return (0, _jsxRuntime.jsx)(_antd.Col, {
|
|
194
|
+
span: span || 24,
|
|
195
|
+
className: !span || span === 24 ? 'pro-tree-modal-checkbox-content' : '',
|
|
196
|
+
style: {
|
|
197
|
+
marginBottom: span ? 16 : 12
|
|
198
|
+
},
|
|
199
|
+
children: (0, _jsxRuntime.jsx)(_antd.Checkbox, {
|
|
200
|
+
onChange: function onChange(e) {
|
|
201
|
+
return handleOnChange(e, item[fieldNameValue]);
|
|
202
|
+
},
|
|
203
|
+
value: item[fieldNameValue],
|
|
204
|
+
disabled: item.disabled,
|
|
205
|
+
children: content
|
|
206
|
+
})
|
|
207
|
+
}, item[fieldNameValue]);
|
|
208
|
+
})
|
|
209
|
+
})
|
|
210
|
+
})
|
|
211
|
+
})
|
|
212
|
+
})
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
// 编辑状态
|
|
216
|
+
if (isRowCols) {
|
|
137
217
|
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
138
218
|
children: (0, _jsxRuntime.jsx)(_antd.Checkbox.Group, {
|
|
139
219
|
disabled: disabled,
|
|
@@ -170,19 +250,30 @@ function List(props, ref) {
|
|
|
170
250
|
}
|
|
171
251
|
// 预览状态
|
|
172
252
|
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
173
|
-
children:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
253
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
254
|
+
ref: containerRef,
|
|
255
|
+
style: {
|
|
256
|
+
height: '432px',
|
|
257
|
+
overflow: 'auto'
|
|
258
|
+
},
|
|
259
|
+
children: (0, _jsxRuntime.jsx)("div", {
|
|
260
|
+
ref: wrapperRef,
|
|
261
|
+
children: list.map(function (_item) {
|
|
262
|
+
var item = _item.data;
|
|
263
|
+
var title = showCodeName ? "".concat(item[fieldNameValue], "-").concat(item[fieldNameLabel]) : item[fieldNameLabel];
|
|
264
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
265
|
+
className: "pro-tree-modal-checkbox-content",
|
|
266
|
+
children: [(0, _jsxRuntime.jsx)("div", {
|
|
267
|
+
className: "pro-tree-modal-checkbox-content-look",
|
|
268
|
+
children: optionRender ? optionRender(item, searchStr) : title
|
|
269
|
+
}), disabled ? null : (0, _jsxRuntime.jsx)(_CloseIcon.default, {
|
|
270
|
+
onClick: function onClick() {
|
|
271
|
+
return handleFilterClose(item[fieldNameValue]);
|
|
272
|
+
}
|
|
273
|
+
})]
|
|
274
|
+
}, item[fieldNames.value]);
|
|
275
|
+
})
|
|
276
|
+
})
|
|
186
277
|
})
|
|
187
278
|
});
|
|
188
279
|
}
|
|
@@ -197,7 +197,8 @@ function List(props, ref) {
|
|
|
197
197
|
selectable: false,
|
|
198
198
|
onCheck: onCheck,
|
|
199
199
|
checkedKeys: checkedValues,
|
|
200
|
-
checkStrictly: checkStrictly
|
|
200
|
+
checkStrictly: checkStrictly,
|
|
201
|
+
height: 432
|
|
201
202
|
})
|
|
202
203
|
});
|
|
203
204
|
}
|
|
@@ -219,7 +220,8 @@ function List(props, ref) {
|
|
|
219
220
|
autoExpandParent: true,
|
|
220
221
|
selectable: false,
|
|
221
222
|
treeData: treeViewData,
|
|
222
|
-
blockNode: true
|
|
223
|
+
blockNode: true,
|
|
224
|
+
height: 432
|
|
223
225
|
})
|
|
224
226
|
});
|
|
225
227
|
}
|
|
@@ -27,7 +27,7 @@ require("./style/index.less");
|
|
|
27
27
|
* @Author: za-xuwenli xuwenli@zhongan.io
|
|
28
28
|
* @Date: 2024-06-04 10:01:18
|
|
29
29
|
* @LastEditors: za-xuwenli xuwenli@zhongan.io
|
|
30
|
-
* @LastEditTime: 2024-06-
|
|
30
|
+
* @LastEditTime: 2024-06-25 17:56:33
|
|
31
31
|
* @FilePath: /za-material-warehouse/src/ProTreeModal/index.tsx
|
|
32
32
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
33
33
|
*/
|
|
@@ -477,23 +477,26 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
477
477
|
checkAll: false
|
|
478
478
|
});
|
|
479
479
|
};
|
|
480
|
-
var
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
480
|
+
var _useDebounceFn = (0, _ahooks.useDebounceFn)(function (str) {
|
|
481
|
+
if (modeType === LIST || modeType === CASCADER) {
|
|
482
|
+
var isCASCADER = modeType === CASCADER;
|
|
483
|
+
var data = state.flatTreeData.filter(function (item) {
|
|
484
|
+
var title = isCASCADER ? item === null || item === void 0 ? void 0 : item.title : item[fieldNameLabel];
|
|
485
|
+
return title.includes(str);
|
|
486
|
+
});
|
|
487
|
+
setState({
|
|
488
|
+
treeData: !str ? state.originalTreeData : data
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
}, {
|
|
492
|
+
wait: 300
|
|
493
|
+
}),
|
|
494
|
+
onSearch = _useDebounceFn.run;
|
|
495
|
+
var handleSetSearchStr = function handleSetSearchStr(str) {
|
|
496
|
+
setState({
|
|
497
|
+
searchStr: str
|
|
498
|
+
});
|
|
499
|
+
onSearch(str);
|
|
497
500
|
};
|
|
498
501
|
/**
|
|
499
502
|
* 指定模式下的操作
|
|
@@ -746,7 +749,9 @@ var ProTreeModal = function ProTreeModal(props) {
|
|
|
746
749
|
value: state.searchStr,
|
|
747
750
|
placeholder: placeholder || (_locale.default === null || _locale.default === void 0 ? void 0 : (_locale$ProTreeModal10 = _locale.default.ProTreeModal) === null || _locale$ProTreeModal10 === void 0 ? void 0 : _locale$ProTreeModal10.input),
|
|
748
751
|
className: "pro-tree-modal-search",
|
|
749
|
-
onChange:
|
|
752
|
+
onChange: function onChange(e) {
|
|
753
|
+
return handleSetSearchStr(e.target.value);
|
|
754
|
+
},
|
|
750
755
|
prefix: (0, _jsxRuntime.jsx)(_reactSvg.ReactSVG, {
|
|
751
756
|
className: "viewSvg",
|
|
752
757
|
src: _inputSearch.default
|