From 7f0845a111d211c67b16af41926ce0b091e95122 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 28 Oct 2025 11:27:12 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E9=80=89=E6=8B=A9=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=20=E7=BB=84=E4=BB=B6:=20=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SearchForm.jsx | 9 ++++++--- src/components/VendorSelector.jsx | 15 +++++++++++---- src/stores/Auth.js | 3 ++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/components/SearchForm.jsx b/src/components/SearchForm.jsx index bbeb8f4..a5dfeff 100644 --- a/src/components/SearchForm.jsx +++ b/src/components/SearchForm.jsx @@ -21,11 +21,14 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f const presets = useDatePresets(); const [formValues, setFormValues] = useFormStore(state => [state.formValues, state.setFormValues]); const [formValuesToSub, setFormValuesToSub] = useFormStore(state => [state.formValuesToSub, state.setFormValuesToSub]); - const isPermitted = useAuthStore((state) => state.isPermitted) + const [isPermitted, {travelAgencyName: myAgencyName, travelAgencyId: myAgencyId}] = useAuthStore((state) => [state.isPermitted, state.currentUser]) const [form] = Form.useForm(); + const defaultShowFields = isPermitted(PERM_AGENCY_ALL) ? ['agency'] : []; const defaultFieldsProps = isPermitted(PERM_AGENCY_ALL) ? { agency: { col: 24 }, } : {}; - const defaultFieldsComProps = isPermitted(PERM_AGENCY_ALL) ? { agency: { mode: null }, } : {}; + const defaultFieldsComProps = isPermitted(PERM_AGENCY_ALL) ? { agency: { mode: null, allowClear: false }, } : {}; + const defaultInitialValue = isPermitted(PERM_AGENCY_ALL) ? { agency: { key: myAgencyId, value: myAgencyId, label: myAgencyName }} : {}; + const { sort, hides, shows, fieldProps, fieldComProps } = { sort: "", // initialValue: '', @@ -35,7 +38,7 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f fieldProps: { ...defaultFieldsProps, ...(props.fieldsConfig?.fieldProps || {}) }, fieldComProps: { ...defaultFieldsComProps, ...(props.fieldsConfig?.fieldComProps || {}) }, }; - const readValues = { ...initialValue, ...formValues }; + const readValues = { ...defaultInitialValue, ...initialValue, ...formValues }; const formValuesMapper = values => { const destinationObject = { diff --git a/src/components/VendorSelector.jsx b/src/components/VendorSelector.jsx index bb3915a..3aaaba9 100644 --- a/src/components/VendorSelector.jsx +++ b/src/components/VendorSelector.jsx @@ -5,20 +5,27 @@ import { fetchJSON } from '@/utils/request'; import { HT_HOST } from '@/config'; import { useTranslation } from 'react-i18next'; import useFormStore from "@/stores/Form"; +import { usingStorage } from "@/hooks/usingStorage"; +import useAuthStore from '@/stores/Auth' -//供应商列表 -export const fetchVendorList = async (q) => { +/** + * 供应商列表 + * @deprecated + */ +const fetchVendorList = async (q) => { const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/VendorList`, { q }); return errcode !== 0 ? [] : result; }; const VendorSelector = ({ ...props }) => { + const { travelAgencyId: myAgencyId } = usingStorage(); + const [{ travelAgencyName: myAgencyName }] = useAuthStore((state) => [state.currentUser]); const { t } = useTranslation(); const [{ vendorList }, setCache] = useFormStore(state => [state.cache, state.setCache]); return ( <> - { fetchOptions={fetchVendorList} map={{ travel_agency_name: 'label', travel_agency_id: 'value' }} onFetch={(v) => setCache({ vendorList: v })} - defaultOptions={vendorList} + defaultOptions={vendorList?.length ? vendorList : [{ label: myAgencyName, value: myAgencyId, key: myAgencyId }]} /> ); diff --git a/src/stores/Auth.js b/src/stores/Auth.js index f38ec96..e129387 100644 --- a/src/stores/Auth.js +++ b/src/stores/Auth.js @@ -80,7 +80,8 @@ const useAuthStore = create(devtools((set, get) => ({ realname: isEmpty(userJson.real_name) ? userJson.LoginName : userJson.real_name, rolesName: userJson.roles_name, emailAddress: userJson.LMI_listmail, - travelAgencyName: isEmpty(userJson.VName) ? userJson.LMI_VEI_SN : userJson.VName + travelAgencyName: isEmpty(userJson.VName) ? userJson.LMI_VEI_SN : userJson.VName, + travelAgencyId: userJson.LMI_VEI_SN } }))