|
|
@@ -141,6 +141,12 @@ const sortField = (field: ProColumns[]) => {
|
|
|
|
|
|
// 场景二:高级模式
|
|
|
// 默认六组搜索条件。根据字段index排序
|
|
|
+// const nodeFor = <T extends Record<string, any>>(props: Props<T>, ref) => {
|
|
|
+// console.log(props,ref)
|
|
|
+// return (<></>)
|
|
|
+// }
|
|
|
+//
|
|
|
+// export const node = forwardRef(nodeFor) as <RecordType extends Record<string, any>>(props: Props<RecordType>, ref?: React.Ref<HTMLDivElement>) => React.ReactElement
|
|
|
|
|
|
const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
const { field, target, onSearch, defaultParam, enableSave = true, initParam, model } = props;
|
|
|
@@ -197,6 +203,9 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
f.setFieldState(typeFiled.query('.termType'), async (state) => {
|
|
|
state.value = 'eq';
|
|
|
});
|
|
|
+ f.setFieldState(typeFiled.query('.value'), async (state) => {
|
|
|
+ state.componentType = 'Input';
|
|
|
+ });
|
|
|
} else {
|
|
|
switch (_field?.valueType) {
|
|
|
case 'select':
|
|
|
@@ -213,6 +222,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
state.value = 'eq';
|
|
|
});
|
|
|
f.setFieldState(typeFiled.query('.value'), async (state) => {
|
|
|
+ console.log(state.value);
|
|
|
state.componentType = 'Select';
|
|
|
state.dataSource = __option;
|
|
|
});
|
|
|
@@ -257,6 +267,9 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
});
|
|
|
break;
|
|
|
default:
|
|
|
+ f.setFieldState(typeFiled.query('.termType'), async (state) => {
|
|
|
+ state.value = 'like';
|
|
|
+ });
|
|
|
f.setFieldState(typeFiled.query('.value'), async (state) => {
|
|
|
state.componentType = 'Input';
|
|
|
});
|
|
|
@@ -266,7 +279,9 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
});
|
|
|
onFieldValueChange('*.*.column', (field1, form1) => {
|
|
|
form1.setFieldState(field1.query('.value'), (state1) => {
|
|
|
- state1.value = undefined;
|
|
|
+ if (field1.modified) {
|
|
|
+ state1.value = undefined;
|
|
|
+ }
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
@@ -509,7 +524,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
};
|
|
|
|
|
|
const [url, setUrl] = useUrlState();
|
|
|
- const handleSearch = async () => {
|
|
|
+ const handleSearch = async (type: boolean = true) => {
|
|
|
const value = form.values;
|
|
|
const filterTerms = (data: Partial<Term>[] | undefined) =>
|
|
|
data && data.filter((item) => item.column != null).filter((item) => item.value !== undefined);
|
|
|
@@ -517,14 +532,16 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
_terms.terms1 = filterTerms(_terms.terms1);
|
|
|
_terms.terms2 = filterTerms(_terms.terms2);
|
|
|
const _temp = formatValue(_terms);
|
|
|
- setUrl({ q: JSON.stringify(value) });
|
|
|
+ if (type) {
|
|
|
+ setUrl({ q: JSON.stringify(value) });
|
|
|
+ }
|
|
|
onSearch({ terms: _temp });
|
|
|
};
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (url.q) {
|
|
|
form.setValues(JSON.parse(url.q));
|
|
|
- handleSearch();
|
|
|
+ handleSearch(false);
|
|
|
}
|
|
|
}, [url]);
|
|
|
|
|
|
@@ -564,15 +581,21 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
|
|
|
const SearchBtn = {
|
|
|
simple: (
|
|
|
- <Button icon={<SearchOutlined />} onClick={handleSearch} type="primary">
|
|
|
- 搜索
|
|
|
- </Button>
|
|
|
+ <>
|
|
|
+ {
|
|
|
+ // @ts-ignore
|
|
|
+ <Button icon={<SearchOutlined />} onClick={handleSearch} type="primary">
|
|
|
+ 搜索
|
|
|
+ </Button>
|
|
|
+ }
|
|
|
+ </>
|
|
|
),
|
|
|
advance: (
|
|
|
<Dropdown.Button
|
|
|
icon={<SearchOutlined />}
|
|
|
placement={'bottomLeft'}
|
|
|
destroyPopupOnHide
|
|
|
+ // @ts-ignore
|
|
|
onClick={handleSearch}
|
|
|
visible={logVisible}
|
|
|
onVisibleChange={async (visible) => {
|