From b7af5b1cd3bcffadd6eefe18c29ff5ab9fa49ecb Mon Sep 17 00:00:00 2001 From: Lei OT Date: Fri, 8 Mar 2024 22:31:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BD=93=E9=AA=8C:=20?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E8=A1=A8=E5=8D=95=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/FormStore.js | 33 +++++++++++++++++++++------------ src/views/OrderFollow.jsx | 27 ++++++++++++++++----------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/src/stores/FormStore.js b/src/stores/FormStore.js index e303415..35e476b 100644 --- a/src/stores/FormStore.js +++ b/src/stores/FormStore.js @@ -1,16 +1,25 @@ import { create } from 'zustand'; -import { RealTimeAPI } from '@/lib/realTimeAPI'; -import { olog, isEmpty } from '@/utils/utils'; -import { receivedMsgTypeMapped, handleNotification } from '@/lib/msgUtils'; -import { fetchConversationsList, fetchTemplates, fetchMessages } from '@/actions/ConversationActions'; import { devtools } from 'zustand/middleware'; -import { WS_URL } from '@/config'; -export const useFormStore = create(devtools((set, get) => ({ - // 历史记录页面 - chatHistoryForm: {}, - setChatHistoryForm: (chatHistoryForm) => set({ chatHistoryForm, chatHistorySelectChat: {} }), - chatHistorySelectChat: {}, - setChatHistorySelectChat: (chatHistorySelectChat) => set({ chatHistorySelectChat }), -}))); +export const useFormStore = create( + devtools((set, get) => ({ + // 历史记录页面 + chatHistoryForm: {}, + setChatHistoryForm: (chatHistoryForm) => set({ chatHistoryForm, chatHistorySelectChat: {} }), + chatHistorySelectChat: {}, + setChatHistorySelectChat: (chatHistorySelectChat) => set({ chatHistorySelectChat }), + + // 订单跟踪页面 + orderFollowForm: { + type: 'today', + orderStatus: '新状态', + orderNumber: '订单号', + orderLabel: '订单标签', + startDate: '走团时间', + }, + setOrderFollowForm: (orderFollowForm) => set({ orderFollowForm }), + orderFollowAdvanceChecked: false, + setOrderFollowAdvanceChecked: (orderFollowAdvanceChecked) => set({ orderFollowAdvanceChecked }), + })) +); export default useFormStore; diff --git a/src/views/OrderFollow.jsx b/src/views/OrderFollow.jsx index 921f4a9..3e88b13 100644 --- a/src/views/OrderFollow.jsx +++ b/src/views/OrderFollow.jsx @@ -9,10 +9,13 @@ import { Conditional } from '@/components/Conditional' import useOrderStore from '@/stores/OrderStore' import useAuthStore from '@/stores/AuthStore' import { copy } from '@/utils/commons' +import useFormStore from '@/stores/FormStore'; +import { useShallow } from 'zustand/react/shallow'; const { RangePicker } = DatePicker -const AdvanceSearchForm = memo(function ({ onSubmit }) { +// eslint-disable-next-line react/display-name +const AdvanceSearchForm = memo(function ({ initialValues, onSubmit }) { const DATE_RANGE_PRESETS = [ { @@ -205,7 +208,7 @@ function OrderGroupTable({ formValues }) { const [loading, setLoading] = useState(false) const { orderList, fetchOrderList } = useOrderStore() const { loginUser } = useAuthStore() - + useEffect(() => { let canSearch = true @@ -301,7 +304,7 @@ function OrderGroupTable({ formValues }) { children: - } + } ) }) @@ -311,14 +314,16 @@ function OrderGroupTable({ formValues }) { function OrderFollow() { - const [advanceChecked, toggleAdvance] = useState(false) - const [formValues, setFormValues] = useState({ - type: 'today', - orderStatus: '新状态', - orderNumber: '订单号', - orderLabel: '订单标签', - startDate: '走团时间' - }) + // const [advanceChecked, toggleAdvance] = useState(false) + // const [formValues, setFormValues] = useState({ + // type: 'today', + // orderStatus: '新状态', + // orderNumber: '订单号', + // orderLabel: '订单标签', + // startDate: '走团时间' + // }) + const [formValues, setFormValues] = useFormStore(useShallow((state) => [state.orderFollowForm, state.setOrderFollowForm])); + const [advanceChecked, toggleAdvance] = useFormStore(useShallow((state) => [state.orderFollowAdvanceChecked, state.setOrderFollowAdvanceChecked])); const handleSubmit = useCallback((values) => { setFormValues({ ...values, type: 'advance' })