From 5d0c11b00aa368d6d99c89a76d58e89b2166535b Mon Sep 17 00:00:00 2001 From: huyunkun <1391805182@qq.com> Date: Sun, 31 May 2026 10:33:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4mock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MemberFormModal/index.jsx | 69 ------------- src/data/mockData.js | 126 ----------------------- 2 files changed, 195 deletions(-) delete mode 100644 src/data/mockData.js diff --git a/src/components/MemberFormModal/index.jsx b/src/components/MemberFormModal/index.jsx index 08860fb..f39f7a9 100644 --- a/src/components/MemberFormModal/index.jsx +++ b/src/components/MemberFormModal/index.jsx @@ -43,56 +43,6 @@ const CITY_ASSOCIATION_OPTIONS = [ '温州市', '台州市', '丽水市', '金华市', '衢州市', ] -/** 随机后缀,避免重复提交冲突 */ -const rand = () => Math.floor(Math.random() * 10000) - -/** 个人会员 mock 预填数据 */ -const getPersonalMockData = () => { - const suffix = rand() - return { - memberCategory: 'personal', - name: `测试会员${suffix}`, - phone: `138${String(10000000 + suffix).slice(-8)}`, - password: 'Test@123456', - email: `member${suffix}@example.com`, - zipCode: '321000', - gender: 'MALE', - identityCard: '330702199001011234', - politicalStatus: 'CPC_MEMBER', - educationLevel: 'MASTER', - title: 'CHIEF_PHYSICIAN', - position: '科室负责人', - regionOrUnit: 'JINHUA_TCM_HOSPITAL', - unitName: '金华市中医医院', - unitAddress: '金华市婺城区中医药路88号', - memberType: 'SPECIAL_COMMITTEE_MEMBER', - specialCommitteeMemberType: '内科分会', - cityAssociation: '金华市', - registerTime: dayjs(), - } -} - -/** 单位/组织会员 mock 预填数据 */ -const getUnitMockData = () => { - const suffix = rand() - return { - memberCategory: 'unit', - name: `测试企业${suffix}有限公司`, - phone: '0579-88886666', - password: 'Test@123456', - unitOrOrgType: 'PUBLIC_INSTITUTION', - address: '金华市金东区发展路168号', - zipCode: '321000', - legalPersonName: '法人测试', - legalPersonPhone: `139${String(10000000 + suffix).slice(-8)}`, - legalPersonEmail: `legal${suffix}@example.com`, - referrerName: '推荐人测试', - referrerPhone: `137${String(10000000 + suffix).slice(-8)}`, - referrerEmail: `referrer${suffix}@example.com`, - registerTime: dayjs(), - } -} - function MemberFormModal({ open, onCancel, onOk }) { const [form] = Form.useForm() const memberCategory = Form.useWatch('memberCategory', form) @@ -103,28 +53,9 @@ function MemberFormModal({ open, onCancel, onOk }) { useEffect(() => { if (open) { form.resetFields() - // 默认以个人会员 mock 预填 - const mock = getPersonalMockData() - form.setFieldsValue(mock) - setPersonalMemberType(mock.memberType) } }, [open, form]) - // 会员类别切换时自动填充对应的 mock 数据 - useEffect(() => { - if (!open || !memberCategory) return - const current = form.getFieldsValue() - if (memberCategory === 'unit' && !current.unitOrOrgType) { - form.resetFields() - form.setFieldsValue(getUnitMockData()) - } else if (memberCategory === 'personal' && !current.gender) { - form.resetFields() - const mock = getPersonalMockData() - form.setFieldsValue(mock) - setPersonalMemberType(mock.memberType) - } - }, [memberCategory, open, form]) - const handleMemberTypeChange = (value) => { setPersonalMemberType(value) if (value !== PERSONAL_MEMBER_TYPE.SPECIAL_COMMITTEE_MEMBER) { diff --git a/src/data/mockData.js b/src/data/mockData.js deleted file mode 100644 index bf4c81c..0000000 --- a/src/data/mockData.js +++ /dev/null @@ -1,126 +0,0 @@ -export const memberTypes = [ - { label: '专科分会委员', value: 'special_committee' }, - { label: '普通会员', value: 'ordinary' }, - { label: '地区中医药学(协)会会长、秘书长', value: 'regional_president' }, -]; - -export const specialCommittees = [ - { label: '内科分会', value: 'internal_medicine' }, - { label: '外科分会', value: 'surgery' }, - { label: '儿科分会', value: 'pediatrics' }, - { label: '妇科分会', value: 'gynecology' }, - { label: '针灸分会', value: 'acupuncture' }, - { label: '推拿分会', value: 'massage' }, - { label: '中药分会', value: 'chinese_medicine' }, - { label: '骨伤分会', value: 'orthopedics' }, -]; - -export const regions = [ - { label: '杭州市', value: 'hangzhou' }, - { label: '宁波市', value: 'ningbo' }, - { label: '温州市', value: 'wenzhou' }, - { label: '嘉兴市', value: 'jiaxing' }, - { label: '湖州市', value: 'huzhou' }, - { label: '绍兴市', value: 'shaoxing' }, - { label: '金华市', value: 'jinhua' }, - { label: '衢州市', value: 'quzhou' }, - { label: '舟山市', value: 'zhoushan' }, - { label: '台州市', value: 'taizhou' }, - { label: '丽水市', value: 'lishui' }, -]; - -export const unitTypes = [ - { label: '公立医院', value: 'public_hospital' }, - { label: '民营医院', value: 'private_hospital' }, - { label: '社区卫生服务中心', value: 'community_health' }, - { label: '乡镇卫生院', value: 'township_clinic' }, - { label: '诊所', value: 'clinic' }, - { label: '医药企业', value: 'pharma_enterprise' }, - { label: '医学院校', value: 'medical_school' }, - { label: '科研机构', value: 'research_institution' }, - { label: '其他', value: 'other' }, -]; - -function generateMockData(count) { - const data = []; - const surnames = ['张', '王', '李', '刘', '陈', '杨', '黄', '赵', '吴', '周', '徐', '孙', '马', '朱', '胡', '林', '郭', '何', '高', '罗']; - const names = ['伟', '芳', '娜', '敏', '静', '丽', '强', '磊', '军', '洋', '勇', '艳', '杰', '涛', '明', '超', '秀英', '华', '鹏', '飞']; - const streets = ['中山路', '解放路', '人民路', '建设路', '和平路', '新华路', '青年路', '文化路', '工业路', '胜利路']; - - for (let i = 0; i < count; i++) { - const isPersonal = Math.random() > 0.3; - const surname = surnames[Math.floor(Math.random() * surnames.length)]; - const name = names[Math.floor(Math.random() * names.length)]; - const fullName = surname + name; - const phone = '1' + ['3', '5', '7', '8'][Math.floor(Math.random() * 4)] + String(Math.floor(Math.random() * 1000000000)).padStart(9, '0'); - const memberType = memberTypes[Math.floor(Math.random() * memberTypes.length)].value; - - const base = { - id: i + 1, - name: fullName, - phone, - memberType, - memberTypeLabel: memberTypes.find(t => t.value === memberType)?.label, - createTime: new Date(Date.now() - Math.floor(Math.random() * 365 * 24 * 60 * 60 * 1000)).toISOString().slice(0, 10), - }; - - if (isPersonal) { - const region = regions[Math.floor(Math.random() * regions.length)]; - const selectedCommittee = memberType === 'special_committee' - ? specialCommittees[Math.floor(Math.random() * specialCommittees.length)] - : null; - data.push({ - ...base, - memberCategory: 'personal', - memberCategoryLabel: '个人会员', - gender: Math.random() > 0.5 ? 'male' : 'female', - idCard: '3301' + String(Math.floor(Math.random() * 1000000000000)).padStart(12, '0'), - politicalStatus: ['中共党员', '中共预备党员', '共青团员', '民盟盟员', '民建会员', '民进会员', '农工党党员', '致公党党员', '九三学社社员', '无党派民主人士', '群众'][Math.floor(Math.random() * 11)], - education: ['中专', '大专', '本科', '硕士研究生', '博士研究生'][Math.floor(Math.random() * 5)], - title: ['医师', '主治医师', '副主任医师', '主任医师', '助理研究员', '副研究员', '研究员'][Math.floor(Math.random() * 7)], - position: ['科室主任', '科室副主任', '护士长', '普通医师', '科研人员', '教师'][Math.floor(Math.random() * 6)], - region: region.value, - regionLabel: region.label, - unitName: `金华市${region.label}中医院`, - unitAddress: `${region.label}${streets[Math.floor(Math.random() * streets.length)]}${Math.floor(Math.random() * 200) + 1}号`, - email: `${pinyin(fullName)}@example.com`, - zipCode: String(Math.floor(Math.random() * 900000) + 100000), - specialCommittee: selectedCommittee ? selectedCommittee.value : undefined, - specialCommitteeLabel: selectedCommittee ? selectedCommittee.label : undefined, - }); - } else { - const unitType = unitTypes[Math.floor(Math.random() * unitTypes.length)]; - data.push({ - ...base, - memberCategory: 'unit', - memberCategoryLabel: '单位会员', - unitType: unitType.value, - unitTypeLabel: unitType.label, - unitName: `${fullName}中医院`, - unitAddress: `金华市${streets[Math.floor(Math.random() * streets.length)]}${Math.floor(Math.random() * 200) + 1}号`, - zipCode: String(Math.floor(Math.random() * 900000) + 100000), - legalName: surname + names[Math.floor(Math.random() * names.length)], - legalPhone: '1' + ['3', '5', '7', '8'][Math.floor(Math.random() * 4)] + String(Math.floor(Math.random() * 1000000000)).padStart(9, '0'), - legalEmail: `legal${i}@example.com`, - referrer: Math.random() > 0.5 ? surname + names[Math.floor(Math.random() * names.length)] : undefined, - referrerPhone: Math.random() > 0.5 ? '1' + ['3', '5', '7', '8'][Math.floor(Math.random() * 4)] + String(Math.floor(Math.random() * 1000000000)).padStart(9, '0') : undefined, - referrerEmail: Math.random() > 0.5 ? `referrer${i}@example.com` : undefined, - unitIntro: `本单位成立于${2000 + Math.floor(Math.random() * 24)}年,是一家专注于中医药事业发展的${unitType.label},致力于传承和发扬中医药文化。`, - }); - } - } - return data; -} - -function pinyin(name) { - const map = { - '张': 'zhang', '王': 'wang', '李': 'li', '刘': 'liu', '陈': 'chen', - '杨': 'yang', '黄': 'huang', '赵': 'zhao', '吴': 'wu', '周': 'zhou', - '徐': 'xu', '孙': 'sun', '马': 'ma', '朱': 'zhu', '胡': 'hu', - '林': 'lin', '郭': 'guo', '何': 'he', '高': 'gao', '罗': 'luo', - }; - const first = map[name[0]] || 'user'; - return first + Math.floor(Math.random() * 1000); -} - -export const mockMembers = generateMockData(120);