perf: 选择供应商 组件: 业务页面包含时, 覆盖默认设置

main
Lei OT 6 months ago
parent 48651edd74
commit 7433111bcb

@ -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 = {

@ -100,13 +100,14 @@ function Index() {
<Space direction='vertical' style={{ width: '100%' }}>
<SearchForm
fieldsConfig={{
shows: [ 'audit_state', 'dates', 'year'],
shows: ['agency', 'audit_state', 'dates', 'year'],
fieldProps: {
agency: { col: 4 },
dates: { label: t('products:CreateDate') },
keyword: { label: t('products:Title'), col: 4 },
year: { col: 4, rules: [{ required: true }] },
},
sort: { aaudit_state: 2, keyword: 100 },
sort: { agency: 1, audit_state: 2, keyword: 100 },
}}
initialValue={{
dates: [dayjs().subtract(2, 'M').startOf('M'), dayjs().endOf('M')],

Loading…
Cancel
Save