From 7302113c9a30c4b2dd729b44babf1c0f9a6715e4 Mon Sep 17 00:00:00 2001 From: boyang <1920788179@qq.com> Date: Tue, 11 Feb 2025 14:16:56 +0800 Subject: [PATCH] fix: 客户管理省市接口报错 --- src/pages/Client/Client/Components/ClientDrawer.tsx | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/pages/Client/Client/Components/ClientDrawer.tsx b/src/pages/Client/Client/Components/ClientDrawer.tsx index 502eaa9..d9c3cf1 100644 --- a/src/pages/Client/Client/Components/ClientDrawer.tsx +++ b/src/pages/Client/Client/Components/ClientDrawer.tsx @@ -213,20 +213,22 @@ export default ({ optType, record, onFinish }) => { ]} request={async () => { let cityOptions = []; + const idValue = form.getFieldValue('id'); + console.log('Form ID Value:', idValue); console.log(form.getFieldValue('id')); - if (form.getFieldValue('id')) { + if (idValue) { const resp = await postDistrictSelOrderProvince({ - data: form.getFieldValue('id'), + data: { id: idValue }, }); if ( - resp.data.province !== null && - resp.data.province !== undefined + resp?.data?.province !== null && + resp?.data?.province !== undefined ) { console.log('province is ok'); let res = await postDistrictSelectByNameAndLevel({ data: { district: resp.data.province, level: 1 }, }); - if (res && res.data) { + if (res && res?.data) { cityOptions = res.data.map((item) => ({ value: item.district, label: item.district, @@ -234,7 +236,7 @@ export default ({ optType, record, onFinish }) => { } } } - if (province !== '') { + if (province) { console.log(province); console.log('province is okk'); let res = await postDistrictSelectByNameAndLevel({ @@ -271,15 +273,16 @@ export default ({ optType, record, onFinish }) => { ]} request={async () => { let districtOptions = []; - if (form.getFieldValue('id')) { + const idValue = form.getFieldValue('id'); + if (idValue) { const resp = await postDistrictSelOrderProvince({ - data: form.getFieldValue('id'), + data: { id: idValue }, }); - if (resp.data.city !== null && resp.data.city !== undefined) { + if (resp?.data?.city !== null && resp.data.city !== undefined) { let res = await postDistrictSelectByNameAndLevel({ data: { district: resp.data.city, level: 2 }, }); - if (res && res.data) { + if (res && res?.data) { districtOptions = res.data.map((item) => ({ value: item.district, label: item.district, @@ -287,11 +290,11 @@ export default ({ optType, record, onFinish }) => { } } } - if (city !== '') { + if (city) { let res = await postDistrictSelectByNameAndLevel({ data: { district: city, level: 2 }, }); - if (res && res.data) { + if (res && res?.data) { districtOptions = res.data.map((item) => ({ value: item.district, label: item.district, -- libgit2 0.23.3