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