|
|
@@ -399,7 +399,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
|
|
|
const handleForm = (_expand?: boolean) => {
|
|
|
const value = form.values;
|
|
|
- const __expand = _expand || expand;
|
|
|
+ const __expand = _expand !== undefined ? _expand : expand;
|
|
|
// 第一组条件值
|
|
|
const _terms1 = _.cloneDeep(value.terms1?.[0]);
|
|
|
const uiParam = uiParamRef.current;
|
|
|
@@ -416,11 +416,12 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
uiParam?.[1]?.terms?.[2] || defaultTerms(5),
|
|
|
];
|
|
|
} else {
|
|
|
- value.terms1 = _terms1 ? [_terms1] : [defaultTerms(0)];
|
|
|
+ value.terms1 = [uiParam?.[0]?.terms?.[0] || _terms1 || defaultTerms(0)];
|
|
|
value.terms2 = [];
|
|
|
}
|
|
|
setInitParams(value);
|
|
|
};
|
|
|
+
|
|
|
const handleExpand = () => {
|
|
|
handleForm();
|
|
|
setExpand(!expand);
|
|
|
@@ -451,7 +452,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
setLogVisible(false);
|
|
|
uiParamRef.current = ui2Server(log);
|
|
|
const _expand =
|
|
|
- (log.terms1 && log.terms1?.length > 1) || (log.terms2 && log.terms2?.length > 1);
|
|
|
+ !!(log.terms1 && log.terms1.length > 1) || !!(log.terms2 && log.terms2.length > 1);
|
|
|
if (_expand) {
|
|
|
setExpand(false);
|
|
|
}
|
|
|
@@ -532,6 +533,17 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
_terms.terms1 = filterTerms(_terms.terms1);
|
|
|
_terms.terms2 = filterTerms(_terms.terms2);
|
|
|
const _temp = formatValue(_terms);
|
|
|
+
|
|
|
+ if (
|
|
|
+ (_terms.terms1 && _terms.terms1.length > 1) ||
|
|
|
+ (_terms.terms2 && _terms.terms2.length > 1)
|
|
|
+ ) {
|
|
|
+ // 展开高级搜索
|
|
|
+ uiParamRef.current = ui2Server(value);
|
|
|
+ setExpand(false);
|
|
|
+ handleForm(true);
|
|
|
+ }
|
|
|
+
|
|
|
if (type) {
|
|
|
setUrl({ q: JSON.stringify(value) });
|
|
|
}
|
|
|
@@ -566,7 +578,8 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
setAliasVisible(!aliasVisible);
|
|
|
};
|
|
|
|
|
|
- const resetForm = async () => {
|
|
|
+ const resetForm = async (type: boolean) => {
|
|
|
+ console.log('resetForm', type);
|
|
|
const value = form.values;
|
|
|
if (!expand) {
|
|
|
value.terms1 = [defaultTerms(0), defaultTerms(1), defaultTerms(2)];
|
|
|
@@ -576,7 +589,7 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
value.terms2 = [];
|
|
|
}
|
|
|
setInitParams(value);
|
|
|
- await handleSearch();
|
|
|
+ await handleSearch(type);
|
|
|
};
|
|
|
|
|
|
const SearchBtn = {
|
|
|
@@ -584,7 +597,13 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
<>
|
|
|
{
|
|
|
// @ts-ignore
|
|
|
- <Button icon={<SearchOutlined />} onClick={handleSearch} type="primary">
|
|
|
+ <Button
|
|
|
+ icon={<SearchOutlined />}
|
|
|
+ onClick={() => {
|
|
|
+ handleSearch(false);
|
|
|
+ }}
|
|
|
+ type="primary"
|
|
|
+ >
|
|
|
搜索
|
|
|
</Button>
|
|
|
}
|
|
|
@@ -665,7 +684,13 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
|
|
|
<Space>
|
|
|
{enableSave ? SearchBtn.advance : SearchBtn.simple}
|
|
|
{enableSave && SaveBtn}
|
|
|
- <Button icon={<ReloadOutlined />} block onClick={resetForm}>
|
|
|
+ <Button
|
|
|
+ icon={<ReloadOutlined />}
|
|
|
+ block
|
|
|
+ onClick={() => {
|
|
|
+ resetForm(model !== 'simple');
|
|
|
+ }}
|
|
|
+ >
|
|
|
重置
|
|
|
</Button>
|
|
|
</Space>
|