Commit 4b2c926e authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 处理订单新增模块修改地址不选街道传参异常

parent ee4925a6
import React, { useMemo } from 'react'
import React, { useMemo, useRef } from 'react'
import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd'
import addressSchema from './schema'
......@@ -31,6 +31,7 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault
......@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName
const streetName = obj_streetCode ? obj_streetCode['title'] : value.streetName
const streetName = changDistrict.current ? (obj_streetCode ? obj_streetCode['title'] : obj_streetCode) : value.streetName
const streetCode = changDistrict.current ? (obj_streetCode ? obj_streetCode['value'] : obj_streetCode) : value.streetCode
const params = {
...value,
......@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
provinceName,
cityName,
districtName,
streetName
streetName,
streetCode
}
const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd
await fn(params)
......@@ -116,6 +119,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) {
changDistrict.current = true
ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value })
}
......
......@@ -31,6 +31,7 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault
......@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName
const streetName = obj_streetCode ? obj_streetCode['title'] : value.streetName
const streetName = changDistrict.current ? (obj_streetCode ? obj_streetCode['title'] : obj_streetCode) : value.streetName
const streetCode = changDistrict.current ? (obj_streetCode ? obj_streetCode['value'] : obj_streetCode) : value.streetCode
const params = {
...value,
......@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
provinceName,
cityName,
districtName,
streetName
streetName,
streetCode
}
const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd
......@@ -117,6 +120,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) {
changDistrict.current = true
ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value })
}
......
import React, { useMemo } from 'react'
import React, { useMemo, useRef } from 'react'
import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd'
import addressSchema from './schema'
......@@ -31,6 +31,7 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault
......@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName
const streetName = obj_streetCode ? obj_streetCode['title'] : value.streetName
const streetName = changDistrict.current ? (obj_streetCode ? obj_streetCode['title'] : obj_streetCode) : value.streetName
const streetCode = changDistrict.current ? (obj_streetCode ? obj_streetCode['value'] : obj_streetCode) : value.streetCode
const params = {
...value,
......@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
provinceName,
cityName,
districtName,
streetName
streetName,
streetCode
}
const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd
await fn(params)
......@@ -116,6 +119,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) {
changDistrict.current = true
ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value })
}
......
import React, { useMemo } from 'react'
import React, { useMemo, useRef } from 'react'
import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd'
import addressSchema from './schema'
......@@ -35,13 +35,16 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue, ctx } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault
}
const resetForm = () => {
addressSchemaAction.reset({validate: false})
}
const handleConfirm = () => {
if (mode === 'preview') {
props.currentRef.current.setVisible(false)
......@@ -59,7 +62,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName
const streetName = obj_streetCode ? obj_streetCode['title'] : value.streetName
const streetName = changDistrict.current ? (obj_streetCode ? obj_streetCode['title'] : obj_streetCode) : value.streetName
const streetCode = changDistrict.current ? (obj_streetCode ? obj_streetCode['value'] : obj_streetCode) : value.streetCode
const roleId = ctx.getFieldValue('buyerRoleId')
const memberId = ctx.getFieldValue('buyerMemberId')
......@@ -72,6 +76,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
cityName,
districtName,
streetName,
streetCode,
roleId,
memberId
}
......@@ -131,7 +136,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) {
console.log(value)
changDistrict.current = true
ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value })
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment