Commit 7302113c9a30c4b2dd729b44babf1c0f9a6715e4

Authored by boyang
1 parent 386a5629

fix: 客户管理省市接口报错

src/pages/Client/Client/Components/ClientDrawer.tsx
@@ -213,20 +213,22 @@ export default ({ optType, record, onFinish }) => { @@ -213,20 +213,22 @@ export default ({ optType, record, onFinish }) => {
213 ]} 213 ]}
214 request={async () => { 214 request={async () => {
215 let cityOptions = []; 215 let cityOptions = [];
  216 + const idValue = form.getFieldValue('id');
  217 + console.log('Form ID Value:', idValue);
216 console.log(form.getFieldValue('id')); 218 console.log(form.getFieldValue('id'));
217 - if (form.getFieldValue('id')) { 219 + if (idValue) {
218 const resp = await postDistrictSelOrderProvince({ 220 const resp = await postDistrictSelOrderProvince({
219 - data: form.getFieldValue('id'), 221 + data: { id: idValue },
220 }); 222 });
221 if ( 223 if (
222 - resp.data.province !== null &&  
223 - resp.data.province !== undefined 224 + resp?.data?.province !== null &&
  225 + resp?.data?.province !== undefined
224 ) { 226 ) {
225 console.log('province is ok'); 227 console.log('province is ok');
226 let res = await postDistrictSelectByNameAndLevel({ 228 let res = await postDistrictSelectByNameAndLevel({
227 data: { district: resp.data.province, level: 1 }, 229 data: { district: resp.data.province, level: 1 },
228 }); 230 });
229 - if (res && res.data) { 231 + if (res && res?.data) {
230 cityOptions = res.data.map((item) => ({ 232 cityOptions = res.data.map((item) => ({
231 value: item.district, 233 value: item.district,
232 label: item.district, 234 label: item.district,
@@ -234,7 +236,7 @@ export default ({ optType, record, onFinish }) => { @@ -234,7 +236,7 @@ export default ({ optType, record, onFinish }) => {
234 } 236 }
235 } 237 }
236 } 238 }
237 - if (province !== '') { 239 + if (province) {
238 console.log(province); 240 console.log(province);
239 console.log('province is okk'); 241 console.log('province is okk');
240 let res = await postDistrictSelectByNameAndLevel({ 242 let res = await postDistrictSelectByNameAndLevel({
@@ -271,15 +273,16 @@ export default ({ optType, record, onFinish }) => { @@ -271,15 +273,16 @@ export default ({ optType, record, onFinish }) => {
271 ]} 273 ]}
272 request={async () => { 274 request={async () => {
273 let districtOptions = []; 275 let districtOptions = [];
274 - if (form.getFieldValue('id')) { 276 + const idValue = form.getFieldValue('id');
  277 + if (idValue) {
275 const resp = await postDistrictSelOrderProvince({ 278 const resp = await postDistrictSelOrderProvince({
276 - data: form.getFieldValue('id'), 279 + data: { id: idValue },
277 }); 280 });
278 - if (resp.data.city !== null && resp.data.city !== undefined) { 281 + if (resp?.data?.city !== null && resp.data.city !== undefined) {
279 let res = await postDistrictSelectByNameAndLevel({ 282 let res = await postDistrictSelectByNameAndLevel({
280 data: { district: resp.data.city, level: 2 }, 283 data: { district: resp.data.city, level: 2 },
281 }); 284 });
282 - if (res && res.data) { 285 + if (res && res?.data) {
283 districtOptions = res.data.map((item) => ({ 286 districtOptions = res.data.map((item) => ({
284 value: item.district, 287 value: item.district,
285 label: item.district, 288 label: item.district,
@@ -287,11 +290,11 @@ export default ({ optType, record, onFinish }) => { @@ -287,11 +290,11 @@ export default ({ optType, record, onFinish }) => {
287 } 290 }
288 } 291 }
289 } 292 }
290 - if (city !== '') { 293 + if (city) {
291 let res = await postDistrictSelectByNameAndLevel({ 294 let res = await postDistrictSelectByNameAndLevel({
292 data: { district: city, level: 2 }, 295 data: { district: city, level: 2 },
293 }); 296 });
294 - if (res && res.data) { 297 + if (res && res?.data) {
295 districtOptions = res.data.map((item) => ({ 298 districtOptions = res.data.map((item) => ({
296 value: item.district, 299 value: item.district,
297 label: item.district, 300 label: item.district,