From 7433111bcb4eab5dfd1ab4bd1f8d514805443901 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 28 Oct 2025 16:25:25 +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=E4=B8=9A=E5=8A=A1=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=8C=85=E5=90=AB=E6=97=B6,=20=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/SearchForm.jsx | 14 ++++++++------ src/views/products/Manage.jsx | 5 +++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/SearchForm.jsx b/src/components/SearchForm.jsx index e8516d8..9aedd7b 100644 --- a/src/components/SearchForm.jsx +++ b/src/components/SearchForm.jsx @@ -24,11 +24,13 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f const [isPermitted, {travelAgencyName: myAgencyName, travelAgencyId: myAgencyId}] = useAuthStore((state) => [state.isPermitted, state.currentUser]) const [form] = Form.useForm(); + // 默认包含供应商字段, 默认当前登录; const showVendorSwitcher = isPermitted(PERM_AGENCY_ALL); + const hasAgencyField = (props.fieldsConfig?.shows || []).includes('agency'); const defaultShowFields = ['agency']; - const defaultFieldsProps = { agency: { col: 24, hidden: !showVendorSwitcher }, }; - const defaultFieldsComProps = { agency: { mode: null, allowClear: false }, }; - const defaultInitialValue = { agency: { key: myAgencyId, value: myAgencyId, label: myAgencyName }}; + const agencyFieldsProps = hasAgencyField ? {} : { agency: { col: 24, hidden: !showVendorSwitcher }, }; + const agencyFieldsComProps = hasAgencyField ? {} : { agency: { mode: null, allowClear: false }, }; + const agencyInitialValue = hasAgencyField ? {} : { agency: { key: myAgencyId, value: myAgencyId, label: myAgencyName }}; const { sort, hides, shows, fieldProps, fieldComProps } = { sort: "", @@ -36,10 +38,10 @@ const SearchForm = ({ initialValue, onSubmit, onReset, onMounted, confirmText, f hides: [], ...props.fieldsConfig, shows: [...defaultShowFields, ...(props.fieldsConfig?.shows || [])], - fieldProps: { ...defaultFieldsProps, ...(props.fieldsConfig?.fieldProps || {}) }, - fieldComProps: { ...defaultFieldsComProps, ...(props.fieldsConfig?.fieldComProps || {}) }, + fieldProps: { ...agencyFieldsProps, ...(props.fieldsConfig?.fieldProps || {}) }, + fieldComProps: { ...agencyFieldsComProps, ...(props.fieldsConfig?.fieldComProps || {}) }, }; - const readValues = { ...defaultInitialValue, ...initialValue, ...formValues }; + const readValues = { ...agencyInitialValue, ...initialValue, ...formValues }; const formValuesMapper = values => { const destinationObject = { diff --git a/src/views/products/Manage.jsx b/src/views/products/Manage.jsx index dfac973..23c622f 100644 --- a/src/views/products/Manage.jsx +++ b/src/views/products/Manage.jsx @@ -100,13 +100,14 @@ function Index() {