接口调试

This commit is contained in:
huyunkun 2026-05-28 20:24:23 +08:00
parent 76d12d5284
commit 2e06fd2af5
1 changed files with 125 additions and 27 deletions

View File

@ -9,9 +9,13 @@ import {
UNIT_OR_ORG_TYPE_MAP,
UNIT_OR_ORG_TYPE_OPTIONS,
GENDER_MAP,
GENDER_OPTIONS,
POLITICAL_STATUS_MAP,
POLITICAL_STATUS_OPTIONS,
EDUCATION_LEVEL_MAP,
EDUCATION_LEVEL_OPTIONS,
REGION_OR_UNIT_MAP,
REGION_OR_UNIT_OPTIONS,
PERSONAL_MEMBER_TYPE_MAP,
PERSONAL_MEMBER_TYPE_OPTIONS,
} from '../../api/member'
@ -105,11 +109,18 @@ function adaptPersonalMember(item) {
function MemberList() {
const [activeTab, setActiveTab] = useState(MEMBER_CATEGORY.UNIT)
const [filters, setFilters] = useState({
const initialFilters = {
name: '',
unitOrOrgType: undefined,
memberType: undefined,
})
gender: undefined,
politicalStatus: undefined,
educationLevel: undefined,
title: '',
regionOrUnit: undefined,
specialCommitteeMemberType: '',
}
const [filters, setFilters] = useState(initialFilters)
const [appliedFilters, setAppliedFilters] = useState({})
const [pagination, setPagination] = useState({ current: 1, pageSize: 10 })
const [loading, setLoading] = useState(false)
@ -130,6 +141,24 @@ function MemberList() {
}
if (appliedFilters.name) params.name = appliedFilters.name
//
if (activeTab === MEMBER_CATEGORY.UNIT) {
if (appliedFilters.unitOrOrgType) params.unitOrOrgType = appliedFilters.unitOrOrgType
}
//
if (activeTab === MEMBER_CATEGORY.PERSONAL) {
if (appliedFilters.gender) params.gender = appliedFilters.gender
if (appliedFilters.politicalStatus) params.politicalStatus = appliedFilters.politicalStatus
if (appliedFilters.memberType) params.memberType = appliedFilters.memberType
if (appliedFilters.educationLevel) params.educationLevel = appliedFilters.educationLevel
if (appliedFilters.title) params.title = appliedFilters.title
if (appliedFilters.regionOrUnit) params.regionOrUnit = appliedFilters.regionOrUnit
if (appliedFilters.specialCommitteeMemberType) {
params.specialCommitteeMemberType = appliedFilters.specialCommitteeMemberType
}
}
const fetcher =
activeTab === MEMBER_CATEGORY.UNIT
? fetchUnitOrOrgMemberPage
@ -145,14 +174,6 @@ function MemberList() {
? records.map(adaptUnitOrOrgMember)
: records.map(adaptPersonalMember)
//
if (activeTab === MEMBER_CATEGORY.UNIT && appliedFilters.unitOrOrgType) {
list = list.filter((it) => it.unitOrOrgType === appliedFilters.unitOrOrgType)
}
if (activeTab === MEMBER_CATEGORY.PERSONAL && appliedFilters.memberType) {
list = list.filter((it) => it.memberType === appliedFilters.memberType)
}
setTableData(list)
setTotal(totalCount)
} catch (err) {
@ -176,14 +197,13 @@ function MemberList() {
setPagination((prev) => ({ ...prev, current: 1 }))
}
const handleReset = () => {
const empty = { name: '', unitOrOrgType: undefined, memberType: undefined }
setFilters(empty)
setAppliedFilters(empty)
setFilters(initialFilters)
setAppliedFilters(initialFilters)
setPagination((prev) => ({ ...prev, current: 1 }))
}
const handleTabChange = (key) => {
setActiveTab(key)
setFilters({ name: '', unitOrOrgType: undefined, memberType: undefined })
setFilters(initialFilters)
setAppliedFilters({})
setPagination({ current: 1, pageSize: 10 })
}
@ -402,19 +422,97 @@ function MemberList() {
</Select>
</Form.Item>
) : (
<Form.Item label="会员类型" style={{ marginBottom: 16 }}>
<Select
placeholder="请选择"
value={filters.memberType}
onChange={(value) => handleFilterChange('memberType', value)}
allowClear
style={{ width: 240, borderRadius: 6 }}
>
{PERSONAL_MEMBER_TYPE_OPTIONS.map((t) => (
<Option key={t.value} value={t.value}>{t.label}</Option>
))}
</Select>
</Form.Item>
<>
<Form.Item label="会员类型" style={{ marginBottom: 16 }}>
<Select
placeholder="请选择"
value={filters.memberType}
onChange={(value) => handleFilterChange('memberType', value)}
allowClear
style={{ width: 240, borderRadius: 6 }}
>
{PERSONAL_MEMBER_TYPE_OPTIONS.map((t) => (
<Option key={t.value} value={t.value}>{t.label}</Option>
))}
</Select>
</Form.Item>
<Form.Item label="性别" style={{ marginBottom: 16 }}>
<Select
placeholder="请选择"
value={filters.gender}
onChange={(value) => handleFilterChange('gender', value)}
allowClear
style={{ width: 140, borderRadius: 6 }}
>
{GENDER_OPTIONS.map((t) => (
<Option key={t.value} value={t.value}>{t.label}</Option>
))}
</Select>
</Form.Item>
<Form.Item label="政治面貌" style={{ marginBottom: 16 }}>
<Select
placeholder="请选择"
value={filters.politicalStatus}
onChange={(value) => handleFilterChange('politicalStatus', value)}
allowClear
showSearch
optionFilterProp="children"
style={{ width: 180, borderRadius: 6 }}
>
{POLITICAL_STATUS_OPTIONS.map((t) => (
<Option key={t.value} value={t.value}>{t.label}</Option>
))}
</Select>
</Form.Item>
<Form.Item label="学历" style={{ marginBottom: 16 }}>
<Select
placeholder="请选择"
value={filters.educationLevel}
onChange={(value) => handleFilterChange('educationLevel', value)}
allowClear
style={{ width: 160, borderRadius: 6 }}
>
{EDUCATION_LEVEL_OPTIONS.map((t) => (
<Option key={t.value} value={t.value}>{t.label}</Option>
))}
</Select>
</Form.Item>
<Form.Item label="职称" style={{ marginBottom: 16 }}>
<Input
placeholder="请输入职称关键字"
value={filters.title}
onChange={(e) => handleFilterChange('title', e.target.value)}
onPressEnter={handleSearch}
allowClear
style={{ width: 180, borderRadius: 6 }}
/>
</Form.Item>
<Form.Item label="所属单位/地区" style={{ marginBottom: 16 }}>
<Select
placeholder="请选择"
value={filters.regionOrUnit}
onChange={(value) => handleFilterChange('regionOrUnit', value)}
allowClear
showSearch
optionFilterProp="children"
style={{ width: 220, borderRadius: 6 }}
>
{REGION_OR_UNIT_OPTIONS.map((t) => (
<Option key={t.value} value={t.value}>{t.label}</Option>
))}
</Select>
</Form.Item>
<Form.Item label="专科分会委员" style={{ marginBottom: 16 }}>
<Input
placeholder="如:儿科分会"
value={filters.specialCommitteeMemberType}
onChange={(e) => handleFilterChange('specialCommitteeMemberType', e.target.value)}
onPressEnter={handleSearch}
allowClear
style={{ width: 180, borderRadius: 6 }}
/>
</Form.Item>
</>
)}
<Form.Item style={{ marginBottom: 16 }}>
<Space>