From b255285476c1b5a98a9b3a3773b366cd8bc0aef4 Mon Sep 17 00:00:00 2001 From: zhangzhen <525765282@qq.com> Date: Tue, 19 Aug 2025 15:50:27 +0800 Subject: [PATCH] 首页搜索新增导航页搜索; --- src/components/Common/PersonCenter/MenuSearchPopovor.js | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 15 deletions(-) diff --git a/src/components/Common/PersonCenter/MenuSearchPopovor.js b/src/components/Common/PersonCenter/MenuSearchPopovor.js index 6934232..89040f5 100644 --- a/src/components/Common/PersonCenter/MenuSearchPopovor.js +++ b/src/components/Common/PersonCenter/MenuSearchPopovor.js @@ -16,14 +16,43 @@ const MenuSearchPopovor = props => { [] ); + const { modelCenter, kpiData } = app; + const popovorRef = useRef(null); - const handleTabClick = useCallback(e => { + const handleTabClick = useCallback(option => { + const { data, type } = option; + if (type === 1) { + const record = data; + const newsId = record.sId; + const newKey = new Date().getTime().toString(); + const route = record.sName; + const title = record.sMenuName; + const pane = { + title, route, formId: newsId, key: newKey, sModelsType: record.sModelType, fromKey: "1", sSrcModelsId: '1', + currentIndex: 0, + }; + onAddPane(pane); + return; + } else if (type === 2) { + const record = data; + const newsId = record.sResultModelId; + const newKey = new Date().getTime().toString(); + const route = record.sResultModelName; + const title = record.sResultModelMenuName; + const pane = { + title, route, formId: newsId, key: newKey, sModelsType: record.sResultModelType, fromKey: "1", + currentIndex: 0, + }; + onAddPane(pane); + return + } + const paneKey = new Date().getTime().toString(); - const formId = e.sId; - const route = e.sName; - const title = e.sMenuName; - const sModelsType = e.sModelType; - const { sProcName } = e; + const formId = data.sId; + const route = data.sName; + const title = data.sMenuName; + const sModelsType = data.sModelType; + const { sProcName } = data; for (const each of app.panes) { /* 解决导航栏打开页签,Modal不消失问题 */ each.notCurrentPane = true; @@ -139,10 +168,33 @@ const MenuSearchPopovor = props => { }); } - return [...commonlyUsedOption, ...options]; + const columnWorkMatters = commonFunc.showMessage(app.commonConst, 'columnWorkMatters'); + const columnContent = commonFunc.showMessage(app.commonConst, 'columnContent'); + const { model = {} } = kpiData || modelCenter || {}; + const modelOptions = [{ label: renderTitle('', columnWorkMatters), options: [] }, { label: renderTitle('', columnContent), options: [] }]; + Object.keys(model).filter((_, index) => index === 0).forEach(key => { + const value = model[key]; + value.forEach(item => { + const { sId, sMenuUnMemo, sResultModelId, sMenuWorkFruit } = item; + modelOptions[0].options.push({ + label: sMenuUnMemo, + value: sId, + data: item, + type: 1 + }); + modelOptions[1].options.push({ + label: sMenuWorkFruit, + value: `${sId},${sResultModelId}`, + data: item, + type: 2 + }); + }); + }); + + return [...commonlyUsedOption, ...options, ...modelOptions]; }, [menuPanel.panelMenus]); - const searchTitle = commonFunc.showMessage(app.commonConst, 'btnSearch') || '搜索122'; + const searchTitle = commonFunc.showMessage(app.commonConst, 'btnSearch') || '搜索'; return (
@@ -157,18 +209,23 @@ const MenuSearchPopovor = props => { }} filterOption={(inputValue, option) => { let result = false; - const { data } = option; + const { data, value } = option; if (commonUtils.isNotEmptyObject(data)) { - const { sMenuName, parentMenu, grandParentMenu } = data; + const { sMenuName, parentMenu = {}, grandParentMenu = {}, sMenuUnMemo, sMenuWorkFruit } = data; const { sMenuName: sMenuName1 } = parentMenu; const { sMenuName: sMenuName2 } = grandParentMenu; + const bMenuWorkFruit = value.includes(','); const result0 = - sMenuName.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; + sMenuName && sMenuName.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; const result1 = - sMenuName1.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; + sMenuName1 && sMenuName1.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; const result2 = - sMenuName2.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; - result = result0 || result1 || result2; + sMenuName2 && sMenuName2.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; + const result3 = + !bMenuWorkFruit && sMenuUnMemo && sMenuUnMemo.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; + const result4 = + bMenuWorkFruit && sMenuWorkFruit && sMenuWorkFruit.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1; + result = result0 || result1 || result2 || result3 || result4; } return result; }} @@ -176,7 +233,7 @@ const MenuSearchPopovor = props => { // popovorRef.current.animate([{ width: '250px' }, { width: 0 }], { // duration: 2000, iterations: 1 // }); - handleTabClick(option.data); + handleTabClick(option); onSetMenuSearchPopoverVisible(false); }} > -- libgit2 0.22.2