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() {