@cloudbase/weda-ui 3.22.5 → 3.23.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/configs/components/wd-table.d.ts +1 -0
- package/dist/configs/components/wd-table.js +14 -1
- package/dist/configs/index.d.ts +2 -0
- package/dist/style/index.css +27 -0
- package/dist/style/index.scss +1 -1
- package/dist/style/weda-ui.min.css +2 -2
- package/dist/web/components/form/select/index.js +14 -25
- package/dist/web/components/form-input-hooks/index.d.ts +0 -1
- package/dist/web/components/form-input-hooks/index.js +6 -13
- package/dist/web/components/wd-form/contexts/form-field-context.d.ts +6 -2
- package/dist/web/components/wd-form/contexts/form-field-context.js +18 -2
- package/dist/web/components/wd-form/contexts/form-field-obj-context.d.ts +2 -2
- package/dist/web/components/wd-form/contexts/form-field-obj-context.js +2 -2
- package/dist/web/components/wd-form/hoc/form-container-decorator.d.ts +11 -0
- package/dist/web/components/wd-form/hoc/form-container-decorator.js +61 -0
- package/dist/web/components/wd-form/index.d.ts +4 -49
- package/dist/web/components/wd-form/index.js +53 -70
- package/dist/web/components/wd-form-obj/base-form-obj.d.ts +5 -1
- package/dist/web/components/wd-form-obj/base-form-obj.js +19 -38
- package/dist/web/components/wd-input/wd-input.d.ts +2 -0
- package/dist/web/components/wd-input/wd-input.js +70 -18
- package/dist/web/components/wd-table/components/FieldRender/index.d.ts +9 -1
- package/dist/web/components/wd-table/components/FieldRender/index.js +33 -4
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.d.ts +3 -1
- package/dist/web/components/wd-table/components/FilterFieldsPanel/Fields.js +7 -3
- package/dist/web/components/wd-table/components/FilterFieldsPanel/FilterFieldItem.js +4 -1
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.d.ts +6 -15
- package/dist/web/components/wd-table/components/FilterFieldsPanel/filterFieldsGenerate.js +47 -16
- package/dist/web/components/wd-table/components/FilterFieldsPanel/index.js +15 -5
- package/dist/web/components/wd-table/utils/index.d.ts +5 -2
- package/dist/web/components/wd-table/utils/index.js +12 -1
- package/dist/web/components/wd-table/wd-table.d.ts +5 -19
- package/dist/web/components/wd-table/wd-table.js +22 -2
- package/dist/web/utils/hooks/useFormLegacy.js +5 -12
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/* eslint max-lines: [error, 500] */
|
|
3
3
|
import { forwardRef, useImperativeHandle, useEffect, useMemo, useRef, useState, useCallback } from 'react';
|
|
4
|
+
import { Tag } from 'tea-component';
|
|
4
5
|
import { WdFormItem, WdInputGroup } from '../wd-form-item';
|
|
5
6
|
import { useFormInputTrait } from '../form-input-hooks';
|
|
6
7
|
import WdIcon from '../wd-icon';
|
|
@@ -14,16 +15,46 @@ import isEqual from 'lodash.isequal';
|
|
|
14
15
|
import { X_RUNTIME_DEFAULT } from '../../../configs/type-utils/x-runtime-default';
|
|
15
16
|
import { usePlatform } from '../../utils/platform';
|
|
16
17
|
const inputTypes = { idcard: 'text', digit: 'number' };
|
|
18
|
+
const InputComponent = forwardRef(function InputComponent({ isTagInput, contentCls, ...props }, ref) {
|
|
19
|
+
var _a;
|
|
20
|
+
const tagInputValue = isTagInput ? (_a = [].concat(props.tagInputValue)) === null || _a === void 0 ? void 0 : _a.filter((i) => !!i) : [];
|
|
21
|
+
const [inputValue, setInputValue] = useState('');
|
|
22
|
+
const onChange = (e) => {
|
|
23
|
+
setInputValue(e.target.value);
|
|
24
|
+
};
|
|
25
|
+
const onKeyDown = (e) => {
|
|
26
|
+
if (e.key === 'enter' || e.keyCode === KEY_DOWN_CODE) {
|
|
27
|
+
props.onChange([...tagInputValue, e.target.value]);
|
|
28
|
+
setInputValue('');
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
useImperativeHandle(ref, () => ({
|
|
32
|
+
clearInput: () => setInputValue(''),
|
|
33
|
+
}), []);
|
|
34
|
+
return isTagInput ? (_jsx("div", { className: contentCls, onFocus: props.onFocus, onBlur: props.onBlur, children: _jsxs(Tag.Group, { children: [tagInputValue === null || tagInputValue === void 0 ? void 0 : tagInputValue.map((value, index) => (_jsx(Tag, { onClose: () => {
|
|
35
|
+
const newValue = tagInputValue.filter((tag, valueIndex) => valueIndex !== index);
|
|
36
|
+
props.onChange(newValue);
|
|
37
|
+
}, children: value }, index))), _jsx("input", { disabled: props.disabled, value: inputValue, onChange: onChange, onKeyDown: onKeyDown, placeholder: "\u56DE\u8F66\u952E\u6DFB\u52A0", onBlur: (e) => {
|
|
38
|
+
var _a;
|
|
39
|
+
if ((_a = e.target.value) === null || _a === void 0 ? void 0 : _a.trim()) {
|
|
40
|
+
props.onChange([...tagInputValue, e.target.value]);
|
|
41
|
+
}
|
|
42
|
+
setInputValue('');
|
|
43
|
+
} })] }) })) : (_jsx("div", { className: contentCls, children: _jsx("input", { ...props }) }));
|
|
44
|
+
});
|
|
17
45
|
/**
|
|
18
46
|
* 标准化:单行输入组件
|
|
19
47
|
*/
|
|
48
|
+
// eslint-disable-next-line complexity
|
|
20
49
|
export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
21
|
-
const { name, password = X_RUNTIME_DEFAULT.password, type = X_RUNTIME_DEFAULT.type, placeholder, focus: _focus = X_RUNTIME_DEFAULT.focus, maxLength = X_RUNTIME_DEFAULT.maxLength, clearable = X_RUNTIME_DEFAULT.clearable, events, isUnionValue = X_RUNTIME_DEFAULT.isUnionValue, prefixType, prefixIcon, prefixSrc = X_RUNTIME_DEFAULT.prefixSrc, suffixType, suffixIcon, suffixSrc = X_RUNTIME_DEFAULT.suffixSrc, classRoot = 'input', wrapClassName = '', counterVisible = X_RUNTIME_DEFAULT.counterVisible, label, required = X_RUNTIME_DEFAULT.required, inputPattern, template, isConvert = true, } = props;
|
|
50
|
+
const { name, password = X_RUNTIME_DEFAULT.password, type = X_RUNTIME_DEFAULT.type, placeholder, focus: _focus = X_RUNTIME_DEFAULT.focus, maxLength = X_RUNTIME_DEFAULT.maxLength, clearable = X_RUNTIME_DEFAULT.clearable, events, isUnionValue = X_RUNTIME_DEFAULT.isUnionValue, prefixType, prefixIcon, prefixSrc = X_RUNTIME_DEFAULT.prefixSrc, suffixType, suffixIcon, suffixSrc = X_RUNTIME_DEFAULT.suffixSrc, classRoot = 'input', wrapClassName = '', counterVisible = X_RUNTIME_DEFAULT.counterVisible, label, required = X_RUNTIME_DEFAULT.required, inputPattern, template, isConvert = true, isTagInput = false, } = props;
|
|
22
51
|
const zhRef = useRef(false); // 判断是否输入中文
|
|
23
52
|
const { before, after, inputValue } = useStringProp(props);
|
|
24
53
|
const [innerHandle, setInnerHandle] = useState({}); // hook里挂出的属性
|
|
25
54
|
const [currentInputValue, setCurrentInputValue] = useSyncValue(inputValue); // 监听inputValue
|
|
26
|
-
const
|
|
55
|
+
const initTagInputValue = useMemo(() => { var _a, _b; return (_b = (_a = [].concat(props.inputValue)) === null || _a === void 0 ? void 0 : _a.filter((i) => !!i)) !== null && _b !== void 0 ? _b : []; }, [props.inputValue]);
|
|
56
|
+
const [tagInputValue, setTagInputValue] = useSyncValue(initTagInputValue);
|
|
57
|
+
const formValue = useMemo(() => (isTagInput ? props.inputValue : converValueFix(inputValue, before, after, type, isUnionValue, isConvert)), [isTagInput, props.inputValue, inputValue, before, after, type, isUnionValue, isConvert]);
|
|
27
58
|
const rules = useRules(props); // 含前后缀和必填时,仅对输入框校验
|
|
28
59
|
const traitProps = {
|
|
29
60
|
...props,
|
|
@@ -34,6 +65,7 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
|
34
65
|
};
|
|
35
66
|
const { value, // 代表组件值,含前后缀
|
|
36
67
|
onChange: _onChange, disabled, readOnly, validateErrorMsg, validateState, visible, } = useFormInputTrait(traitProps);
|
|
68
|
+
const tagInputRef = useRef(null);
|
|
37
69
|
const wrapRef = useRef(null);
|
|
38
70
|
const valueRef = useRef(null);
|
|
39
71
|
const size = useSize(props);
|
|
@@ -43,7 +75,8 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
|
43
75
|
const inputId = useMemo(() => getUuid(), []);
|
|
44
76
|
const [focus, setFocus] = useSyncValue(_focus);
|
|
45
77
|
const inputType = password ? 'password' : inputTypes[type] || type;
|
|
46
|
-
const
|
|
78
|
+
const hasValue = isTagInput ? (tagInputValue === null || tagInputValue === void 0 ? void 0 : tagInputValue.length) > 0 : (currentInputValue === null || currentInputValue === void 0 ? void 0 : currentInputValue.length) > 0;
|
|
79
|
+
const hasClearIcon = clearable && focus && !disabled && hasValue;
|
|
47
80
|
const counter = typeof currentInputValue === 'string' ? currentInputValue.length : 0;
|
|
48
81
|
const root = `${classPrefix}-${classRoot}`;
|
|
49
82
|
const inputWrap = `${classPrefix}-form-input-wrap`;
|
|
@@ -59,6 +92,7 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
|
59
92
|
[`${inputWrap}--no-radius-left`]: before,
|
|
60
93
|
[`${inputWrap}--no-radius-right`]: after,
|
|
61
94
|
[`${inputWrap}--no-radius`]: before && after,
|
|
95
|
+
[`${classPrefix}-form-tag-input-wrap`]: isTagInput,
|
|
62
96
|
});
|
|
63
97
|
const countCls = `${classPrefix}-input__limit-number`;
|
|
64
98
|
const platform = usePlatform();
|
|
@@ -69,8 +103,9 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
|
69
103
|
return; // 监听非输入引起的value变化,比如调用 setValue, clearValue
|
|
70
104
|
const currentInputValue = converInputValue(value, before, after, isUnionValue);
|
|
71
105
|
setCurrentInputValue(currentInputValue);
|
|
106
|
+
setTagInputValue(value);
|
|
72
107
|
valueRef.current = value;
|
|
73
|
-
}, [value, before, after, isUnionValue, setCurrentInputValue]);
|
|
108
|
+
}, [value, before, after, isUnionValue, setCurrentInputValue, setTagInputValue]);
|
|
74
109
|
const changeForm = useCallback((val) => {
|
|
75
110
|
valueRef.current = val;
|
|
76
111
|
_onChange(val);
|
|
@@ -80,42 +115,59 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
|
80
115
|
return converValueFix(val, before, after, type, isUnionValue, isConvert);
|
|
81
116
|
};
|
|
82
117
|
const onChange = (e) => {
|
|
83
|
-
var _a;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
118
|
+
var _a, _b, _c;
|
|
119
|
+
let text = (_a = e === null || e === void 0 ? void 0 : e.target) === null || _a === void 0 ? void 0 : _a.value;
|
|
120
|
+
if (isTagInput) {
|
|
121
|
+
text = Array.isArray(e) ? e : [].concat(text);
|
|
122
|
+
setTagInputValue(text);
|
|
123
|
+
changeForm(text);
|
|
124
|
+
(_b = events.change) === null || _b === void 0 ? void 0 : _b.call(events, { value: text }, { originEvent: e });
|
|
88
125
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
(
|
|
126
|
+
else {
|
|
127
|
+
text = typeof e === 'string' ? e : text;
|
|
128
|
+
const reg = new RegExp(inputPattern);
|
|
129
|
+
// 只针对非标签输入框做校验
|
|
130
|
+
if (inputPattern && !reg.test(text)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
setCurrentInputValue(text);
|
|
134
|
+
if (!zhRef.current) {
|
|
135
|
+
const newValue = converValueFixWrap(text);
|
|
136
|
+
changeForm(newValue);
|
|
137
|
+
(_c = events.change) === null || _c === void 0 ? void 0 : _c.call(events, { value: newValue }, { originEvent: e });
|
|
138
|
+
}
|
|
94
139
|
}
|
|
95
140
|
};
|
|
96
141
|
const onClear = (e) => {
|
|
97
142
|
var _a, _b;
|
|
98
143
|
setCurrentInputValue('');
|
|
144
|
+
setTagInputValue(null);
|
|
99
145
|
const newValue = converValueFixWrap('');
|
|
100
146
|
changeForm(newValue);
|
|
101
147
|
(_a = events.change) === null || _a === void 0 ? void 0 : _a.call(events, { value: newValue }, { originEvent: e });
|
|
102
148
|
(_b = events.clear) === null || _b === void 0 ? void 0 : _b.call(events, { originValue: value }, { originEvent: e });
|
|
103
149
|
e.preventDefault();
|
|
150
|
+
if (tagInputRef.current && isTagInput) {
|
|
151
|
+
tagInputRef.current.clearInput();
|
|
152
|
+
}
|
|
104
153
|
};
|
|
105
154
|
const onKeyDown = (e) => {
|
|
155
|
+
var _a;
|
|
106
156
|
if (e.key === 'enter' || e.keyCode === KEY_DOWN_CODE) {
|
|
107
|
-
events.confirm({ value: converValueFixWrap(e.target.value) }, { originEvent: e });
|
|
157
|
+
(_a = events === null || events === void 0 ? void 0 : events.confirm) === null || _a === void 0 ? void 0 : _a.call(events, { value: converValueFixWrap(e.target.value) }, { originEvent: e });
|
|
108
158
|
}
|
|
109
159
|
if (inputType === 'number' && e.key === 'e') {
|
|
110
160
|
e.preventDefault();
|
|
111
161
|
}
|
|
112
162
|
};
|
|
113
163
|
const onFocus = (e) => {
|
|
114
|
-
(events === null || events === void 0 ? void 0 : events.focus) &&
|
|
164
|
+
(events === null || events === void 0 ? void 0 : events.focus) &&
|
|
165
|
+
events.focus({ value: isTagInput ? tagInputValue : converValueFixWrap(e.target.value) }, { originEvent: e });
|
|
115
166
|
setFocus(true);
|
|
116
167
|
};
|
|
117
168
|
const onBlur = (e) => {
|
|
118
|
-
(events === null || events === void 0 ? void 0 : events.blur) &&
|
|
169
|
+
(events === null || events === void 0 ? void 0 : events.blur) &&
|
|
170
|
+
events.blur({ value: isTagInput ? tagInputValue : converValueFixWrap(e.target.value) }, { originEvent: e });
|
|
119
171
|
setFocus(false);
|
|
120
172
|
};
|
|
121
173
|
const handleZhStart = () => {
|
|
@@ -172,5 +224,5 @@ export const WdInput = forwardRef(function WdInput(props, ref) {
|
|
|
172
224
|
return null;
|
|
173
225
|
return (_jsx(WdFormItem, { ...formItemProps, children: _jsxs(_Fragment, { children: [_jsx(WdInputGroup, { ...inputGroupProps, children: _jsxs("div", { className: `${cls} ${template === 'greySearchBox' ? 'wd-input-input-search template search-box color-grey is-pc-bordered' : ''} ${template === 'whiteSearchBox'
|
|
174
226
|
? 'wd-input-input-search template search-box color-white is-pc-bordered'
|
|
175
|
-
: ''} ${isH5 ? 'is-h5-borderless' : ''}`, ref: wrapRef, onFocus: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('is-focused'); }, onBlur: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('is-focused'); }, children: [prefixType && (_jsx("div", { className: prefixCls, onClick: () => inputAdornmentClick('prefix'), children: _jsx(WdIcon, { size: iconSize, name: prefixIcon, type: prefixType, src: prefixSrc, className: prefixIconCls }) })), _jsx(
|
|
227
|
+
: ''} ${isH5 ? 'is-h5-borderless' : ''}`, ref: wrapRef, onFocus: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.add('is-focused'); }, onBlur: () => { var _a, _b; return (_b = (_a = wrapRef.current) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.remove('is-focused'); }, children: [prefixType && (_jsx("div", { className: prefixCls, onClick: () => inputAdornmentClick('prefix'), children: _jsx(WdIcon, { size: iconSize, name: prefixIcon, type: prefixType, src: prefixSrc, className: prefixIconCls }) })), _jsx(InputComponent, { ref: tagInputRef, contentCls: contentCls, isTagInput: isTagInput, id: inputId, className: inputCls, type: currentInputType, placeholder: placeholder, value: currentInputValue !== null && currentInputValue !== void 0 ? currentInputValue : '', tagInputValue: tagInputValue !== null && tagInputValue !== void 0 ? tagInputValue : [], disabled: disabled, name: name, autoFocus: focus, autoComplete: "off", maxLength: maxLength, onChange: onChange, onFocus: onFocus, onBlur: onBlur, onKeyDown: onKeyDown, onCompositionStart: handleZhStart, onCompositionEnd: handleZhEnd, ...startWithOnProps }), hasClearIcon && (_jsx("div", { className: suffixCls, children: _jsx(WdIcon, { size: iconSize, className: `${classPrefix}-icon__trigger`, name: "td:close-circle-filled", onMouseDown: onClear }) })), !hasClearIcon && suffixType && (_jsx("div", { className: suffixCls, onClick: () => inputAdornmentClick('suffix'), children: _jsx(WdIcon, { size: iconSize, name: suffixIcon, type: suffixType, src: suffixSrc, className: suffixIconCls }) })), counterVisible && (_jsxs("span", { className: countCls, children: [counter, "/", maxLength] }))] }) }), password && passwordIconRender()] }) }));
|
|
176
228
|
});
|
|
@@ -102,7 +102,14 @@ export declare const formatDataToXlsx: (datas: any, fields: any, enumOptions?: {
|
|
|
102
102
|
*/
|
|
103
103
|
export declare const getSearchAttributes: (fields: any) => any;
|
|
104
104
|
export declare const getFieldValue: (name: any, _record: any, relatedFieldName?: any, isManyField?: any) => any;
|
|
105
|
-
|
|
105
|
+
interface SlotRenderProps {
|
|
106
|
+
recordIndex?: number | string;
|
|
107
|
+
record?: any;
|
|
108
|
+
rowKey?: string;
|
|
109
|
+
column?: any;
|
|
110
|
+
columnIndex?: number | string;
|
|
111
|
+
}
|
|
112
|
+
export declare const slotRender: (Slot: any, props?: SlotRenderProps) => any;
|
|
106
113
|
/**
|
|
107
114
|
* 根据列管理,过滤表格列信息
|
|
108
115
|
* columns: { key, header, width, align, render,fixed }[] Tea Table 的列
|
|
@@ -150,3 +157,4 @@ export declare const getTableColumns: ({ fields, columnSets, slots, fixedFront,
|
|
|
150
157
|
showRelationWithTag?: boolean;
|
|
151
158
|
}) => any;
|
|
152
159
|
export declare const mapColumKey: (columnSets: any) => any;
|
|
160
|
+
export {};
|
|
@@ -25,6 +25,8 @@ import { textToString } from '../../../../utils/platform';
|
|
|
25
25
|
import { getWhereParam, getSortColumns } from '../../utils';
|
|
26
26
|
import lodashGet from 'lodash.get';
|
|
27
27
|
import { convertMoment } from '../../../../utils/moment';
|
|
28
|
+
import { FormFieldObjProvider, useFormFieldObj } from '../../../wd-form/contexts/form-field-obj-context';
|
|
29
|
+
import { useFormField } from '../../../wd-form/contexts/form-field-context';
|
|
28
30
|
const MODAL_SIZE = '80%';
|
|
29
31
|
// 文字提示框包裹组件
|
|
30
32
|
export const TextWrap = React.memo(function TextWrapComp(props) {
|
|
@@ -726,10 +728,35 @@ export const getFieldValue = (name, _record, relatedFieldName, isManyField) => {
|
|
|
726
728
|
}
|
|
727
729
|
return record === null || record === void 0 ? void 0 : record[name];
|
|
728
730
|
};
|
|
729
|
-
|
|
731
|
+
const FunctionSlotRenderer = ({ Slot, ...props }) => {
|
|
732
|
+
var _a;
|
|
733
|
+
const formField = useFormField();
|
|
734
|
+
const { formFieldsValue = [], getFieldValue } = formField || {};
|
|
735
|
+
const formFieldObjsContext = useFormFieldObj();
|
|
736
|
+
const parentNamePath = (formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.isChildField) ? formFieldObjsContext === null || formFieldObjsContext === void 0 ? void 0 : formFieldObjsContext.namePath : [];
|
|
737
|
+
const recordIndex = props.recordIndex;
|
|
738
|
+
const namePath = useMemo(() => [...parentNamePath, recordIndex], [parentNamePath, recordIndex]);
|
|
739
|
+
const _formFieldValues = useMemo(() => {
|
|
740
|
+
try {
|
|
741
|
+
return (parentNamePath === null || parentNamePath === void 0 ? void 0 : parentNamePath.length) && getFieldValue ? getFieldValue === null || getFieldValue === void 0 ? void 0 : getFieldValue({ namePath: parentNamePath }) : formFieldsValue;
|
|
742
|
+
}
|
|
743
|
+
catch (error) {
|
|
744
|
+
errorHandler({
|
|
745
|
+
code: 'FormFieldValuesError',
|
|
746
|
+
error,
|
|
747
|
+
});
|
|
748
|
+
return [];
|
|
749
|
+
}
|
|
750
|
+
}, [parentNamePath, formFieldsValue, getFieldValue]);
|
|
751
|
+
const providerProps = useMemo(() => ({
|
|
752
|
+
namePath,
|
|
753
|
+
isChildField: true,
|
|
754
|
+
}), [namePath]);
|
|
755
|
+
return (_jsx(FormFieldObjProvider, { ...providerProps, children: _jsx(Slot, { ...props, value: _formFieldValues, rowValue: (_a = _formFieldValues === null || _formFieldValues === void 0 ? void 0 : _formFieldValues[recordIndex]) !== null && _a !== void 0 ? _a : {} }) }));
|
|
756
|
+
};
|
|
757
|
+
export const slotRender = (Slot, props = { recordIndex: 0 }) => {
|
|
730
758
|
if (typeof Slot === 'function') {
|
|
731
|
-
|
|
732
|
-
return _jsx(Slot, { ...props });
|
|
759
|
+
return _jsx(FunctionSlotRenderer, { Slot: Slot, ...props });
|
|
733
760
|
}
|
|
734
761
|
return Slot !== null && Slot !== void 0 ? Slot : null;
|
|
735
762
|
};
|
|
@@ -828,7 +855,9 @@ export const filterCustomColumns = ({ columns, columnSets, slots, fields, isH5,
|
|
|
828
855
|
if (genre === 'slot') {
|
|
829
856
|
// 拿到列对应的插槽
|
|
830
857
|
const slot = slots[`${TABLE_SLOT_PREFIX}${(item2 === null || item2 === void 0 ? void 0 : item2.slotKey) || key}`];
|
|
831
|
-
customColumn.render = (record, rowKey, recordIndex, column, columnIndex) =>
|
|
858
|
+
customColumn.render = (record, rowKey, recordIndex, column, columnIndex) => {
|
|
859
|
+
return (_jsx(TableSlotCell, { record: record, rowKey: rowKey, recordIndex: recordIndex, column: column, columnIndex: columnIndex, slot: slot }));
|
|
860
|
+
};
|
|
832
861
|
}
|
|
833
862
|
return customColumn;
|
|
834
863
|
});
|
|
@@ -13,10 +13,12 @@ export declare const TimePickerField: ({ disabled, isRange, updateValue, value }
|
|
|
13
13
|
updateValue: any;
|
|
14
14
|
value: any;
|
|
15
15
|
}) => JSX.Element;
|
|
16
|
-
export declare const
|
|
16
|
+
export declare const arrayInputType: string[];
|
|
17
|
+
export declare const InputField: ({ disabled, value, updateValue, fieldCalculation }: {
|
|
17
18
|
disabled?: boolean;
|
|
18
19
|
value: any;
|
|
19
20
|
updateValue: any;
|
|
21
|
+
fieldCalculation: any;
|
|
20
22
|
}) => JSX.Element;
|
|
21
23
|
export declare const MultipleNumber: ({ disabled, value, updateValue }: {
|
|
22
24
|
disabled?: boolean;
|
|
@@ -6,11 +6,11 @@ import { SelectSearch } from './SelectSearch';
|
|
|
6
6
|
import { WdDate, WdDateRange, WdTime, WdInput, WdSelectMultiple, WdSelect } from '../../../../components';
|
|
7
7
|
export { SelectSearch };
|
|
8
8
|
// 时间日期
|
|
9
|
-
export const DatePickerField = ({ disabled = false, showTime = false, isRange, updateValue, value }) => isRange ? (_jsx(Tooltip, { title: value && `${value[0]}~${value[1]}`, children: _jsx(WdDateRange, { status: disabled ? 'disabled' : 'edit', value: value ? [moment(value[0]), moment(value[1])] : null, mode: showTime ? 'datetime' : '
|
|
9
|
+
export const DatePickerField = ({ disabled = false, showTime = false, isRange, updateValue, value }) => isRange ? (_jsx(Tooltip, { title: value && `${value[0]}~${value[1]}`, children: _jsx(WdDateRange, { status: disabled ? 'disabled' : 'edit', value: value ? [moment(value[0]), moment(value[1])] : null, mode: showTime ? 'datetime' : 'day', "$widget": { closest: () => { } }, events: {
|
|
10
10
|
change: ({ value }) => {
|
|
11
11
|
updateValue({ value });
|
|
12
12
|
},
|
|
13
|
-
}, labelVisible: false, startPlaceholder: "\u5F00\u59CB\u65F6\u95F4", endPlaceholder: "\u7ED3\u675F\u65F6\u95F4", suffixIcon: "td:calendar", suffixType: "inner" }) })) : (_jsx(Tooltip, { title: value, children: _jsx(WdDate, { status: disabled ? 'disabled' : 'edit', clearable: true, value: value ? moment(value) : null, mode: showTime ? 'datetime' : '
|
|
13
|
+
}, labelVisible: false, startPlaceholder: "\u5F00\u59CB\u65F6\u95F4", endPlaceholder: "\u7ED3\u675F\u65F6\u95F4", suffixIcon: "td:calendar", suffixType: "inner" }) })) : (_jsx(Tooltip, { title: value, children: _jsx(WdDate, { status: disabled ? 'disabled' : 'edit', clearable: true, value: value ? moment(value) : null, mode: showTime ? 'datetime' : 'day', events: {
|
|
14
14
|
change: ({ value }) => {
|
|
15
15
|
updateValue({ value });
|
|
16
16
|
},
|
|
@@ -27,7 +27,11 @@ export const TimePickerField = ({ disabled = false, isRange, updateValue, value
|
|
|
27
27
|
},
|
|
28
28
|
}, "$widget": { closest: () => { } }, suffixIcon: "pending", suffixType: "inner" }));
|
|
29
29
|
// 文本输入框
|
|
30
|
-
export const
|
|
30
|
+
export const arrayInputType = ['in', 'nin', 'search_ci', 'nsearch_ci'];
|
|
31
|
+
export const InputField = ({ disabled = false, value, updateValue, fieldCalculation }) => {
|
|
32
|
+
const isTagInput = arrayInputType.includes(fieldCalculation === null || fieldCalculation === void 0 ? void 0 : fieldCalculation.value);
|
|
33
|
+
return (_jsx(WdInput, { clearable: true, isTagInput: isTagInput, status: disabled ? 'disabled' : 'edit', size: "full", inputValue: value, "$widget": { closest: () => { } }, events: { change: updateValue }, labelVisible: false, placeholder: "\u8BF7\u8F93\u5165" }));
|
|
34
|
+
};
|
|
31
35
|
// 数字范围输入
|
|
32
36
|
export const MultipleNumber = ({ disabled = false, value, updateValue }) => {
|
|
33
37
|
const val1 = value ? value[0] : '';
|
|
@@ -57,6 +57,7 @@ export const FilterFieldItem = ({ supportManyRelated, updateFilterData, ...filte
|
|
|
57
57
|
if (!supportManyRelated && NEW_RELATION_FORMATS.includes(filterType)) {
|
|
58
58
|
return (_jsx(InputAdornment, { label: label, before: null, children: _jsx(Input, { size: "full", disabled: true, defaultValue: '该类型暂不支持表格筛选器' }) }));
|
|
59
59
|
}
|
|
60
|
+
// eslint-disable-next-line complexity
|
|
60
61
|
const renderFieldItem = () => {
|
|
61
62
|
switch (filterType) {
|
|
62
63
|
case 'datetime':
|
|
@@ -66,7 +67,7 @@ export const FilterFieldItem = ({ supportManyRelated, updateFilterData, ...filte
|
|
|
66
67
|
case 'time':
|
|
67
68
|
return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig, isDate: true }), children: _jsx(TimePickerField, { disabled: disabled, value: value, isRange: isRange, updateValue: updateFilterConfig }) }));
|
|
68
69
|
case 'string':
|
|
69
|
-
return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(InputField, { updateValue: updateFilterConfig, value: value, disabled: disabled }) }));
|
|
70
|
+
return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(InputField, { updateValue: updateFilterConfig, value: value, disabled: disabled, fieldCalculation: fieldCalculation }) }));
|
|
70
71
|
case 'number':
|
|
71
72
|
return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(NumberField, { updateValue: updateFilterConfig, value: value, isRange: isRange, disabled: disabled }) }));
|
|
72
73
|
case 'boolean':
|
|
@@ -93,6 +94,8 @@ export const FilterFieldItem = ({ supportManyRelated, updateFilterData, ...filte
|
|
|
93
94
|
return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(SelectSearch, { format: filterType, childDbName: filterFieldItemConfig.childDbName, value: value, updateValue: updateFilterConfig, disabled: disabled, primaryColumn: filterFieldItemConfig.primaryColumn, name: filterFieldItemConfig.name, multiple: true }) }));
|
|
94
95
|
case 'x-area-code':
|
|
95
96
|
return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(SelectSearch, { format: filterType, childDbName: filterFieldItemConfig.childDbName, value: value, updateValue: updateFilterConfig, disabled: disabled, primaryColumn: filterFieldItemConfig.primaryColumn, name: filterFieldItemConfig.name, regionType: filterFieldItemConfig.regionType }) }));
|
|
97
|
+
case 'array':
|
|
98
|
+
return (_jsx(InputAdornment, { label: label, before: _jsx(CalculationSelect, { fieldCalculationOption: fieldCalculationOption, arg: fieldCalculation, cb: updateFilterConfig }), children: _jsx(InputField, { updateValue: updateFilterConfig, value: value, disabled: disabled, fieldCalculation: fieldCalculation }) }));
|
|
96
99
|
default:
|
|
97
100
|
return (_jsx(InputAdornment, { label: label, before: null, children: _jsx(Input, { size: "full", disabled: true, defaultValue: '该类型暂不支持表格筛选器' }) }));
|
|
98
101
|
}
|
|
@@ -8,26 +8,17 @@ export declare const fieldCalculations: {
|
|
|
8
8
|
text: string;
|
|
9
9
|
value: string;
|
|
10
10
|
}[];
|
|
11
|
-
|
|
11
|
+
array: {
|
|
12
|
+
value: string;
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
singleSelect: {
|
|
12
16
|
text: string;
|
|
13
17
|
value: string;
|
|
14
18
|
}[];
|
|
15
|
-
|
|
19
|
+
multipleSelect: {
|
|
16
20
|
text: string;
|
|
17
21
|
value: string;
|
|
18
22
|
}[];
|
|
19
23
|
};
|
|
20
|
-
/**
|
|
21
|
-
* 生成筛选配置
|
|
22
|
-
* 1、过滤不支持搜索的字段
|
|
23
|
-
* 2、生成配置
|
|
24
|
-
* 3、枚举/数字需要特殊处理(即format,用于处理查询数据转换)
|
|
25
|
-
* { filterType: 'datetime' | 'date' | 'time' | 'string' |'number' | 'x-enumObj' , isRange: boolean }
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* field?.type === 'array' && field?.format === '' 非关联关系 数组类型 不支持搜索
|
|
29
|
-
* field?.type === 'object' && field?.format === '' 非关联关系 对象类型 不支持搜索
|
|
30
|
-
* field?.name === '_departmentList' && field?.format === '' 所属部门 系统字段 不支持搜索
|
|
31
|
-
* ['x-markdown', 'x-location', 'x-music', 'x-json', 'x-video', 'x-file', 'x-image', 'x-rtf', 'function'] 不支持搜索
|
|
32
|
-
*/
|
|
33
24
|
export declare const filterFieldsGenerate: (fields: any) => any;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
|
+
import { getUuid } from '../../../../utils/tool';
|
|
2
3
|
const NEW_SINGLE_RELATION_FORMATS = ['many-one', 'one-one', 'one-one-r'];
|
|
3
4
|
const NEW_MULTIPLE_RELATION_FORMATS = ['many-many', 'one-many'];
|
|
4
5
|
export const NEW_RELATION_FORMATS = ['many-one', 'one-one', 'one-one-r', 'many-many', 'one-many'];
|
|
@@ -24,15 +25,19 @@ export const fieldCalculations = {
|
|
|
24
25
|
// { text: '为空', value: '$empty' },
|
|
25
26
|
// { text: '不为空', value: '$nempty' },
|
|
26
27
|
],
|
|
27
|
-
|
|
28
|
+
array: [
|
|
29
|
+
{ value: 'in', text: '包含其一' },
|
|
30
|
+
{ value: 'nin', text: '不包含' },
|
|
31
|
+
],
|
|
32
|
+
singleSelect: [
|
|
28
33
|
{ text: '等于', value: 'eq' },
|
|
29
34
|
{ text: '不等于', value: 'neq' },
|
|
30
35
|
// { text: '为空', value: '$empty' },
|
|
31
36
|
// { text: '不为空', value: '$nempty' },
|
|
32
37
|
],
|
|
33
|
-
|
|
34
|
-
{ text: '
|
|
35
|
-
{ text: '
|
|
38
|
+
multipleSelect: [
|
|
39
|
+
{ text: '包含其一', value: 'in' },
|
|
40
|
+
{ text: '不包含', value: 'nin' },
|
|
36
41
|
// { text: '为空', value: '$empty' },
|
|
37
42
|
// { text: '不为空', value: '$nempty' },
|
|
38
43
|
],
|
|
@@ -45,21 +50,39 @@ export const fieldCalculations = {
|
|
|
45
50
|
* { filterType: 'datetime' | 'date' | 'time' | 'string' |'number' | 'x-enumObj' , isRange: boolean }
|
|
46
51
|
*
|
|
47
52
|
*
|
|
53
|
+
* field?.type === 'array' && field?.items?.type === 'string'&& !['x-markdown','x-location','x-music','x-json','x-video','x-file','x-image','x-rtf','function'].includes(this?.items?.format)) 文本数组支持查询
|
|
48
54
|
* field?.type === 'array' && field?.format === '' 非关联关系 数组类型 不支持搜索
|
|
49
55
|
* field?.type === 'object' && field?.format === '' 非关联关系 对象类型 不支持搜索
|
|
50
56
|
* field?.name === '_departmentList' && field?.format === '' 所属部门 系统字段 不支持搜索
|
|
51
57
|
* ['x-markdown', 'x-location', 'x-music', 'x-json', 'x-video', 'x-file', 'x-image', 'x-rtf', 'function'] 不支持搜索
|
|
52
58
|
*/
|
|
59
|
+
const unsupportedSearchFieldsFormats = [
|
|
60
|
+
'x-markdown',
|
|
61
|
+
'x-location',
|
|
62
|
+
'x-music',
|
|
63
|
+
'x-json',
|
|
64
|
+
'x-video',
|
|
65
|
+
'x-file',
|
|
66
|
+
'x-image',
|
|
67
|
+
'x-rtf',
|
|
68
|
+
'function',
|
|
69
|
+
];
|
|
53
70
|
export const filterFieldsGenerate = (fields) => {
|
|
54
71
|
var _a;
|
|
55
72
|
return (_a = fields === null || fields === void 0 ? void 0 : fields.filter((field) => {
|
|
73
|
+
var _a, _b;
|
|
56
74
|
// 不支持搜索的类型
|
|
57
75
|
if (!field)
|
|
58
76
|
return false;
|
|
77
|
+
if ((field === null || field === void 0 ? void 0 : field.type) === 'array' &&
|
|
78
|
+
((_a = field === null || field === void 0 ? void 0 : field.items) === null || _a === void 0 ? void 0 : _a.type) === 'string' &&
|
|
79
|
+
!unsupportedSearchFieldsFormats.includes((_b = field === null || field === void 0 ? void 0 : field.items) === null || _b === void 0 ? void 0 : _b.format)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
59
82
|
if (((field === null || field === void 0 ? void 0 : field.type) === 'array' && (field === null || field === void 0 ? void 0 : field.format) === '') ||
|
|
60
83
|
((field === null || field === void 0 ? void 0 : field.type) === 'object' && (field === null || field === void 0 ? void 0 : field.format) === '') ||
|
|
61
84
|
((field === null || field === void 0 ? void 0 : field.name) === '_departmentList' && (field === null || field === void 0 ? void 0 : field.format) === '') ||
|
|
62
|
-
|
|
85
|
+
unsupportedSearchFieldsFormats.includes(field === null || field === void 0 ? void 0 : field.format)) {
|
|
63
86
|
return false;
|
|
64
87
|
}
|
|
65
88
|
return true;
|
|
@@ -70,7 +93,7 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
70
93
|
? { type: i.type, value: fieldCalculations[i.type][0].value }
|
|
71
94
|
: {};
|
|
72
95
|
const filterFieldItemConfig = {
|
|
73
|
-
id:
|
|
96
|
+
id: getUuid(),
|
|
74
97
|
name: i.name,
|
|
75
98
|
value: '',
|
|
76
99
|
isRange: typeof i.isRange === 'boolean' ? i.isRange : true,
|
|
@@ -86,17 +109,17 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
86
109
|
filterFieldItemConfig.isRange = false;
|
|
87
110
|
}
|
|
88
111
|
}
|
|
89
|
-
if (i.type === 'boolean') {
|
|
112
|
+
else if (i.type === 'boolean') {
|
|
90
113
|
filterFieldItemConfig.filterType = i.type;
|
|
91
114
|
filterFieldItemConfig.options = [
|
|
92
115
|
{ value: true, text: '是', label: '是' },
|
|
93
116
|
{ value: false, text: '否', label: '否' },
|
|
94
117
|
{ value: null, text: '空', label: '空' },
|
|
95
118
|
];
|
|
96
|
-
filterFieldItemConfig.fieldCalculation.type = '
|
|
119
|
+
filterFieldItemConfig.fieldCalculation.type = 'multipleSelect';
|
|
97
120
|
filterFieldItemConfig.fieldCalculation.value = 'in';
|
|
98
121
|
}
|
|
99
|
-
if ((_a = i['x-enumObj']) === null || _a === void 0 ? void 0 : _a.length) {
|
|
122
|
+
else if ((_a = i['x-enumObj']) === null || _a === void 0 ? void 0 : _a.length) {
|
|
100
123
|
filterFieldItemConfig.filterType = 'x-enumObj';
|
|
101
124
|
filterFieldItemConfig.options = i['x-enumObj'].map((enumItem) => ({
|
|
102
125
|
value: enumItem === null || enumItem === void 0 ? void 0 : enumItem.value,
|
|
@@ -105,34 +128,42 @@ export const filterFieldsGenerate = (fields) => {
|
|
|
105
128
|
}));
|
|
106
129
|
filterFieldItemConfig.options.push({ value: null, text: '空', label: '空' });
|
|
107
130
|
}
|
|
108
|
-
if (i.format === 'x-enum') {
|
|
131
|
+
else if (i.format === 'x-enum') {
|
|
109
132
|
filterFieldItemConfig.fieldCalculation.value = 'eq';
|
|
110
133
|
filterFieldItemConfig.filterType = i.format;
|
|
111
134
|
filterFieldItemConfig.xMultiSelect = i['x-multi-select'];
|
|
112
135
|
filterFieldItemConfig.xOptionName = i['x-option-name'];
|
|
113
|
-
filterFieldItemConfig.fieldCalculation.type = filterFieldItemConfig.xMultiSelect
|
|
136
|
+
filterFieldItemConfig.fieldCalculation.type = filterFieldItemConfig.xMultiSelect
|
|
137
|
+
? 'multipleSelect'
|
|
138
|
+
: 'singleSelect';
|
|
114
139
|
filterFieldItemConfig.fieldCalculation.value = filterFieldItemConfig.xMultiSelect ? 'in' : 'eq';
|
|
115
140
|
}
|
|
116
|
-
if (NEW_SINGLE_RELATION_FORMATS.includes(i.format) ||
|
|
141
|
+
else if (NEW_SINGLE_RELATION_FORMATS.includes(i.format) ||
|
|
142
|
+
i.format === 'father-son' ||
|
|
143
|
+
i.format === 'related') {
|
|
117
144
|
filterFieldItemConfig.filterType = i.format;
|
|
118
145
|
filterFieldItemConfig.childDbName = (_b = i['x-parent']) === null || _b === void 0 ? void 0 : _b.parentDataSourceName;
|
|
119
146
|
filterFieldItemConfig.primaryColumn = (_d = (_c = i === null || i === void 0 ? void 0 : i.parentDatasource) === null || _c === void 0 ? void 0 : _c.schema) === null || _d === void 0 ? void 0 : _d['x-primary-column'];
|
|
120
|
-
filterFieldItemConfig.fieldCalculation.type = '
|
|
147
|
+
filterFieldItemConfig.fieldCalculation.type = 'singleSelect';
|
|
121
148
|
filterFieldItemConfig.fieldCalculation.value = 'eq';
|
|
122
149
|
}
|
|
123
|
-
if (NEW_MULTIPLE_RELATION_FORMATS.includes(i.format)) {
|
|
150
|
+
else if (NEW_MULTIPLE_RELATION_FORMATS.includes(i.format)) {
|
|
124
151
|
filterFieldItemConfig.filterType = i.format;
|
|
125
152
|
filterFieldItemConfig.childDbName = (_e = i['x-parent']) === null || _e === void 0 ? void 0 : _e.parentDataSourceName;
|
|
126
153
|
filterFieldItemConfig.primaryColumn = (_g = (_f = i === null || i === void 0 ? void 0 : i.parentDatasource) === null || _f === void 0 ? void 0 : _f.schema) === null || _g === void 0 ? void 0 : _g['x-primary-column'];
|
|
127
|
-
filterFieldItemConfig.fieldCalculation.type = '
|
|
154
|
+
filterFieldItemConfig.fieldCalculation.type = 'multipleSelect';
|
|
128
155
|
filterFieldItemConfig.fieldCalculation.value = 'in';
|
|
129
156
|
}
|
|
130
|
-
if (i.format === 'x-area-code') {
|
|
157
|
+
else if (i.format === 'x-area-code') {
|
|
131
158
|
filterFieldItemConfig.filterType = i.format;
|
|
132
159
|
filterFieldItemConfig.regionType = i['x-area-code-type'];
|
|
133
160
|
filterFieldItemConfig.fieldCalculation.type = 'string';
|
|
134
161
|
filterFieldItemConfig.fieldCalculation.value = 'search_ci';
|
|
135
162
|
}
|
|
163
|
+
else if (i.type === 'array') {
|
|
164
|
+
filterFieldItemConfig.fieldCalculation.type = 'array';
|
|
165
|
+
filterFieldItemConfig.fieldCalculation.value = 'in';
|
|
166
|
+
}
|
|
136
167
|
const fieldCalculationOption = fieldCalculations[filterFieldItemConfig.fieldCalculation.type];
|
|
137
168
|
filterFieldItemConfig.fieldCalculationOption = fieldCalculationOption;
|
|
138
169
|
// 用户自定义配置
|
|
@@ -5,6 +5,7 @@ import { dateCalculation } from '../../../../utils/date';
|
|
|
5
5
|
import isObjectEqual from '../../../../utils/isObjectEqual';
|
|
6
6
|
import { useConfig } from '../../../../utils/config-context';
|
|
7
7
|
import { FilterFieldItem } from './FilterFieldItem';
|
|
8
|
+
import { arrayInputType } from './Fields';
|
|
8
9
|
import { filterFieldsGenerate } from './filterFieldsGenerate';
|
|
9
10
|
import { WdButton } from '../../../wd-button';
|
|
10
11
|
import { usePlatform } from '../../../../utils/platform';
|
|
@@ -89,7 +90,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
89
90
|
});
|
|
90
91
|
// 值筛选条件
|
|
91
92
|
filterValues.forEach((i) => {
|
|
92
|
-
var _a, _b;
|
|
93
|
+
var _a, _b, _c;
|
|
93
94
|
switch (i.fieldCalculation.value) {
|
|
94
95
|
case 'scope':
|
|
95
96
|
if (i.filterType === 'number') {
|
|
@@ -142,10 +143,19 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
142
143
|
default: {
|
|
143
144
|
const searchItem = {
|
|
144
145
|
key: i.name,
|
|
145
|
-
val: i.
|
|
146
|
+
val: i.value,
|
|
146
147
|
rel: i.fieldCalculation.value,
|
|
147
148
|
};
|
|
148
|
-
if (i.filterType === '
|
|
149
|
+
if (i.filterType === 'string') {
|
|
150
|
+
if (arrayInputType.includes(i.fieldCalculation.value) && ((_b = searchItem === null || searchItem === void 0 ? void 0 : searchItem.val) === null || _b === void 0 ? void 0 : _b.length)) {
|
|
151
|
+
searchValues.push(searchItem);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
searchItem.val = (_c = i.value) === null || _c === void 0 ? void 0 : _c.trim();
|
|
155
|
+
searchValues.push(searchItem);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else if (i.filterType === 'number') {
|
|
149
159
|
searchItem.val = Number(i.value);
|
|
150
160
|
searchValues.push(searchItem);
|
|
151
161
|
}
|
|
@@ -183,7 +193,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
183
193
|
};
|
|
184
194
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
185
195
|
useSetWidgetApi(() => ({ resetFilter }), [initFilterData], ref);
|
|
186
|
-
return (_jsxs(ConfigProvider, { classPrefix: "wedatea2td", children: [_jsx(Drawer, { className: `${classPrefix}-table-mobile-filter-drawer ${classPrefix}-table-wrap-filter ${classPrefix}-h5-table-wrap-filter`, title: "\u7B5B\u9009\u5668", visible: isH5 && openMobileFilter, onClose: () => {
|
|
196
|
+
return (_jsxs(ConfigProvider, { classPrefix: "wedatea2td", children: [isH5 && (_jsx(Drawer, { className: `${classPrefix}-table-mobile-filter-drawer ${classPrefix}-table-wrap-filter ${classPrefix}-h5-table-wrap-filter`, title: "\u7B5B\u9009\u5668", visible: isH5 && openMobileFilter, onClose: () => {
|
|
187
197
|
setOpenMobileFilter(false);
|
|
188
198
|
}, children: _jsxs("div", { children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__body`, children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i) => (_jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields, supportManyRelated: supportManyRelated }, i.id))) }), _jsx("div", { className: `${classPrefix}-table-wrap-filter__footer`, children: _jsxs("div", { className: `${classPrefix}-table-wrap-filter__btn`, children: [_jsx("div", { className: `${classPrefix}-table-wrap-filter__btn-item`, children: _jsx(WdButton, { theme: "primary", variant: "outline", size: "lg", text: "\u91CD\u7F6E", events: {
|
|
189
199
|
tap: resetFilter,
|
|
@@ -192,7 +202,7 @@ export const FilterFieldsPanel = forwardRef(function Comp(props, ref) {
|
|
|
192
202
|
searchHandle();
|
|
193
203
|
setOpenMobileFilter(false);
|
|
194
204
|
},
|
|
195
|
-
} }) })] }) })] }) }), !isH5 && !!filterData.length && (_jsx("form", { className: `${classPrefix}-table-wrap-filter`, onSubmit: onFormSubmit, children: _jsxs(Row, { gap: 20, verticalAlign: '
|
|
205
|
+
} }) })] }) })] }) })), !isH5 && !!filterData.length && (_jsx("form", { className: `${classPrefix}-table-wrap-filter`, onSubmit: onFormSubmit, "data-testid": "filter-form", children: _jsxs(Row, { gap: 20, verticalAlign: 'top', style: { justifyContent: 'space-between' }, children: [_jsx(_Fragment, { children: filterData === null || filterData === void 0 ? void 0 : filterData.map((i, index) => (_jsx(Col, { span: 6, style: {
|
|
196
206
|
display: `${index > num && collapse ? 'none' : 'block'}`,
|
|
197
207
|
}, children: _jsx(FilterFieldItem, { ...i, updateFilterData: updateFilterData, fields: filterFields, supportManyRelated: supportManyRelated }) }, i.id))) }), _jsx(Col, { span: 24, style: { flex: '1', textAlign: 'right' }, children: _jsxs("div", { className: `${classPrefix}-space`, children: [_jsx("div", { className: `${classPrefix}-space-item`, children: _jsx(WdButton, { size: "md", theme: "secondary", text: "\u91CD\u7F6E", events: {
|
|
198
208
|
tap: resetFilter,
|
|
@@ -13,11 +13,14 @@ export declare const getFilter: ({ wList, searchValues, searchConfig, conditionC
|
|
|
13
13
|
relateWhere: {};
|
|
14
14
|
};
|
|
15
15
|
export declare const getSearchValues: (searchValues?: any[]) => {
|
|
16
|
-
commonSearchValue: {
|
|
16
|
+
commonSearchValue: ({
|
|
17
|
+
$or: any;
|
|
18
|
+
} | {
|
|
17
19
|
[x: number]: {
|
|
18
20
|
[x: string]: any;
|
|
19
21
|
};
|
|
20
|
-
|
|
22
|
+
$or?: undefined;
|
|
23
|
+
})[];
|
|
21
24
|
relatedSearchValues: any;
|
|
22
25
|
};
|
|
23
26
|
export declare const orderByFieldKey: (key: any, columns: any) => any;
|
|
@@ -182,7 +182,18 @@ export const getSearchValues = (searchValues = []) => {
|
|
|
182
182
|
// 普通字段的直接条件
|
|
183
183
|
const commonSearchValue = searchValuesList
|
|
184
184
|
.filter((i) => !NEW_RELATION_FORMATS.includes(i.format))
|
|
185
|
-
.map((item) =>
|
|
185
|
+
.map((item) => {
|
|
186
|
+
if (item.format === 'string' && ['search_ci', 'nsearch_ci'].includes(item.rel)) {
|
|
187
|
+
const itemVal = Array.isArray(item.val) ? item.val : [item.val];
|
|
188
|
+
if (!itemVal.length) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
const searchCondition = itemVal === null || itemVal === void 0 ? void 0 : itemVal.map((n) => ({ [item.key]: { [`$${item.rel}`]: n } }));
|
|
192
|
+
return { $or: searchCondition };
|
|
193
|
+
}
|
|
194
|
+
return { [item.key]: { [`$${item.rel}`]: item.val } };
|
|
195
|
+
})
|
|
196
|
+
.filter(Boolean);
|
|
186
197
|
return {
|
|
187
198
|
commonSearchValue,
|
|
188
199
|
relatedSearchValues,
|