feat: update

This commit is contained in:
chashaobao
2025-09-19 23:49:31 +08:00
parent 8e42fef4f7
commit 1d8a0d7a33
10 changed files with 164 additions and 81 deletions

View File

@ -5,34 +5,19 @@ import { isEqual } from 'lodash-es';
import { useCallback, useState } from 'react';
import PickerToolbar from '@/components/picker-toolbar';
import {
EmployType,
ALL_EMPLOY_TYPES,
FULL_PRICE_OPTIONS,
PART_PRICE_OPTIONS,
EMPLOY_TYPE_TITLE_MAP,
} from '@/constants/job';
import {
ALL_ANCHOR_READ_TYPES,
ALL_GENDER_TYPES,
ANCHOR_READ_TITLE_MAP,
AnchorReadType,
GENDER_TYPE_TITLE_MAP,
GenderType,
} from '@/constants/material';
import { FULL_PRICE_OPTIONS, PART_PRICE_OPTIONS } from '@/constants/job';
import { ALL_ANCHOR_READ_TYPES, ANCHOR_READ_TITLE_MAP, AnchorReadType } from '@/constants/material';
import { IAnchorFilters } from '@/types/material';
import { isUndefined } from '@/utils/common';
import './index.less';
type MoreFilter = Omit<IAnchorFilters, 'employType' | 'gender'>;
interface IProps {
value: IAnchorFilters;
onConfirm: (newValue: IAnchorFilters) => void;
value: MoreFilter;
onConfirm: (newValue: MoreFilter) => void;
}
const PREFIX = 'anchor-picker';
const getDefaultGender = (value: IAnchorFilters) => value.gender;
const getDefaultEmploy = (value: IAnchorFilters) => value.employType;
const getDefaultReadType = (value: IAnchorFilters) => value.readType;
const getDefaultCategory = (value: IAnchorFilters) => value.category || '';
const getSalaryValue = (value: IAnchorFilters, full: boolean) => {
@ -47,9 +32,7 @@ const getSalaryValue = (value: IAnchorFilters, full: boolean) => {
function AnchorPicker(props: IProps) {
const { value, onConfirm } = props;
const [gender, setGender] = useState<GenderType | undefined>(getDefaultGender(value));
const [readType, setReadType] = useState<AnchorReadType | undefined>(getDefaultReadType(value));
const [employType, setEmployType] = useState<EmployType | undefined>(getDefaultEmploy(value));
const [fullSalary, setFullSalary] = useState(getSalaryValue(value, true));
const [partSalary, setPartSalary] = useState(getSalaryValue(value, false));
const [category, setCategory] = useState(getDefaultCategory(value));
@ -59,9 +42,7 @@ function AnchorPicker(props: IProps) {
}, []);
const handleClickReset = useCallback(() => {
setGender(undefined);
setReadType(undefined);
setEmployType(undefined);
setFullSalary(null);
setPartSalary(null);
setCategory('');
@ -83,10 +64,6 @@ function AnchorPicker(props: IProps) {
const handleClickConfirm = useCallback(() => {
const filters: IAnchorFilters = {};
if (!isUndefined(gender)) {
filters.gender = gender === GenderType.All ? undefined : gender;
}
employType && (filters.employType = employType);
readType && (filters.readType = readType);
category && (filters.category = category);
if (fullSalary) {
@ -98,34 +75,10 @@ function AnchorPicker(props: IProps) {
filters.highPriceForPartyTime = partSalary.maxSalary;
}
onConfirm(filters);
}, [gender, employType, readType, category, fullSalary, partSalary, onConfirm]);
}, [readType, category, fullSalary, partSalary, onConfirm]);
return (
<div className={PREFIX}>
<div className={`${PREFIX}__title`}></div>
<div className={`${PREFIX}__container`}>
{ALL_GENDER_TYPES.map((type: GenderType) => (
<div
key={type}
onClick={() => setGender(type)}
className={classNames(`${PREFIX}__item`, { selected: type === gender })}
>
{GENDER_TYPE_TITLE_MAP[type]}
</div>
))}
</div>
<div className={`${PREFIX}__title`}>/</div>
<div className={`${PREFIX}__container`}>
{ALL_EMPLOY_TYPES.map(type => (
<div
key={type}
onClick={() => setEmployType(type)}
className={classNames(`${PREFIX}__item`, { selected: type === employType })}
>
{EMPLOY_TYPE_TITLE_MAP[type]}
</div>
))}
</div>
<div className={`${PREFIX}__title`}>/</div>
<div className={`${PREFIX}__container`}>
{ALL_ANCHOR_READ_TYPES.map(type => (

View File

@ -0,0 +1,13 @@
import Select, { ISelectProps } from '@/components/select';
import { GENDER_OPTIONS, GenderType } from '@/constants/material';
interface IProps extends Omit<ISelectProps<GenderType>, 'options'> {
value: GenderType;
}
function GenderSelect(props: IProps) {
const { value: selectValue, onSelect } = props;
return <Select options={GENDER_OPTIONS} title="性别" value={selectValue} onSelect={onSelect} />;
}
export default GenderSelect;

View File

@ -28,6 +28,7 @@
justify-content: space-between;
box-sizing: border-box;
padding: 0 24px;
flex: 0 0 96px;
&.selected {
color: @blHighlightColor;
@ -45,4 +46,4 @@
border-top-left-radius: 24px;
border-top-right-radius: 24px;
}
}
}

View File

@ -0,0 +1,13 @@
import Select, { ISelectProps } from '@/components/select';
import { JOB_TYPE_SELECT_OPTIONS_WITH_ALL, JobType } from '@/constants/job';
interface IProps extends Omit<ISelectProps<JobType>, 'options'> {
value: JobType;
}
function TopCategorySelect(props: IProps) {
const { value: selectValue, onSelect } = props;
return <Select options={JOB_TYPE_SELECT_OPTIONS_WITH_ALL} title="品类" value={selectValue} onSelect={onSelect} />;
}
export default TopCategorySelect;