diff --git a/src/views/orders/Follow.jsx b/src/views/orders/Follow.jsx index 41688fe..01ffb58 100644 --- a/src/views/orders/Follow.jsx +++ b/src/views/orders/Follow.jsx @@ -2,7 +2,7 @@ import useAuthStore from '@/stores/AuthStore' import { pick } from '@/utils/commons' import { UnorderedListOutlined, LeftOutlined } from '@ant-design/icons' import { Flex, Segmented, Tree, Typography, Layout, Splitter, Button, Tooltip, Badge } from 'antd' -import { useEffect, useMemo, useState } from 'react' +import { useEffect, useMemo, useState, useRef } from 'react' import EmailDetailInline from '../Conversations/Online/Components/EmailDetailInline' import OrderProfile from '@/components/OrderProfile' import Mailbox from './components/Mailbox' @@ -45,6 +45,8 @@ const deptMap = new Map([ function Follow() { const [collapsed, setCollapsed] = useState(true) + const mailboxTreeRef = useRef(null); + const [treeHeight, setTreeHeight] = useState(500); const [loginUser, isPermitted] = useAuthStore((state) => [state.loginUser, state.isPermitted]) const { accountList } = loginUser @@ -123,10 +125,27 @@ function Follow() { useEffect(() => { const first = currentMailboxDEI || accountDEI[0].value const opi = accountListDEIMapped[first].OPI_SN - setExpandTree(prev => [...[`${opi}-today`, `${opi}-todo`, `search-orders`, mailboxActiveNode.key, mailboxActiveNode?.VParent ]]) + setExpandTree([...[`${opi}-today`, `${opi}-todo`, `search-orders` ]]) return () => {} - }, [currentMailboxDEI, mailboxNestedDirsActive, mailboxActiveNode]) + }, [currentMailboxDEI ]) + + useEffect(() => { + if (mailboxActiveNode?.expand === true) { + setExpandTree([mailboxActiveNode.key]) + } + + return () => {} + }, [mailboxActiveNode]) + + useEffect(() => { + const targetRect = mailboxTreeRef.current?.getBoundingClientRect() + setTreeHeight(Math.floor(targetRect.height)) + + return () => {} + }, []) + + return ( <> @@ -134,13 +153,14 @@ function Follow() { -
+
{ const { coli_id, sourcetype, ...mailboxParams } = valuesToSub result = await getEmailDirAction({ ...mailboxParams, opi_sn: currentMailboxOPI }, false) updateCurrentMailboxNestedDirs(result[`${currentMailboxOPI}`]) - setMailboxActiveNode({key: -1, title: '1月', iconIndex: 1, _raw: { VKey: -1, COLI_SN: 0, IsTrue: 0 }}) + setMailboxActiveNode({expand:true, key: -1, title: '1月', iconIndex: 1, _raw: { VKey: -1, COLI_SN: 0, IsTrue: 0 }}) } else { const htOrderParams = pick(valuesToSub, ['coli_id', 'sourcetype']) result = await queryHTOrderListAction({ ...htOrderParams, opi_sn: currentMailboxOPI }) const addToTree = { + expand:true, key: 'search-orders', title: '查找订单', iconIndex: 'search',