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 ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd' import { createFormActions } from '@formily/antd'
import addressSchema from './schema' import addressSchema from './schema'
...@@ -31,6 +31,7 @@ const fetchTelCode = async () => { ...@@ -31,6 +31,7 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => { const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue } = props const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue]) const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean // 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) { if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault selfInitValue.isDefault = !!selfInitValue.isDefault
...@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName 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 = { const params = {
...value, ...value,
...@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
provinceName, provinceName,
cityName, cityName,
districtName, districtName,
streetName streetName,
streetCode
} }
const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd
await fn(params) await fn(params)
...@@ -116,6 +119,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -116,6 +119,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇 // 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => { $('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) { if(value) {
changDistrict.current = true
ctx.setFieldValue('streetCode', null) ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value }) renderSelectOption('streetCode', ctx, { pcode: value })
} }
......
...@@ -31,6 +31,7 @@ const fetchTelCode = async () => { ...@@ -31,6 +31,7 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => { const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue } = props const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue]) const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean // 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) { if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault selfInitValue.isDefault = !!selfInitValue.isDefault
...@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName 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 = { const params = {
...value, ...value,
...@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
provinceName, provinceName,
cityName, cityName,
districtName, districtName,
streetName streetName,
streetCode
} }
const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd
...@@ -117,6 +120,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -117,6 +120,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇 // 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => { $('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) { if(value) {
changDistrict.current = true
ctx.setFieldValue('streetCode', null) ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value }) renderSelectOption('streetCode', ctx, { pcode: value })
} }
......
import React, { useMemo } from 'react' import React, { useMemo, useRef } from 'react'
import ModalForm from '@/components/ModalForm' import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd' import { createFormActions } from '@formily/antd'
import addressSchema from './schema' import addressSchema from './schema'
...@@ -31,6 +31,7 @@ const fetchTelCode = async () => { ...@@ -31,6 +31,7 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => { const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue } = props const { mode, formInitValue } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue]) const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean // 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) { if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault selfInitValue.isDefault = !!selfInitValue.isDefault
...@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -55,7 +56,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName 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 = { const params = {
...value, ...value,
...@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -63,7 +65,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
provinceName, provinceName,
cityName, cityName,
districtName, districtName,
streetName streetName,
streetCode
} }
const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd const fn = mode === 'edit' ? postLogisticsReceiverAddressUpdate : postLogisticsReceiverAddressAdd
await fn(params) await fn(params)
...@@ -116,6 +119,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -116,6 +119,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇 // 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => { $('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) { if(value) {
changDistrict.current = true
ctx.setFieldValue('streetCode', null) ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value }) renderSelectOption('streetCode', ctx, { pcode: value })
} }
......
import React, { useMemo } from 'react' import React, { useMemo, useRef } from 'react'
import ModalForm from '@/components/ModalForm' import ModalForm from '@/components/ModalForm'
import { createFormActions } from '@formily/antd' import { createFormActions } from '@formily/antd'
import addressSchema from './schema' import addressSchema from './schema'
...@@ -35,13 +35,16 @@ const fetchTelCode = async () => { ...@@ -35,13 +35,16 @@ const fetchTelCode = async () => {
const AddressModal:React.FC<AddressModalProps> = (props) => { const AddressModal:React.FC<AddressModalProps> = (props) => {
const { mode, formInitValue, ctx } = props const { mode, formInitValue, ctx } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue]) const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
const changDistrict = useRef<boolean>(false)
// 由于默认是number类型, 但switch组件只接收boolean // 由于默认是number类型, 但switch组件只接收boolean
if (selfInitValue) { if (selfInitValue) {
selfInitValue.isDefault = !!selfInitValue.isDefault selfInitValue.isDefault = !!selfInitValue.isDefault
} }
const resetForm = () => { const resetForm = () => {
addressSchemaAction.reset({validate: false}) addressSchemaAction.reset({validate: false})
} }
const handleConfirm = () => { const handleConfirm = () => {
if (mode === 'preview') { if (mode === 'preview') {
props.currentRef.current.setVisible(false) props.currentRef.current.setVisible(false)
...@@ -59,7 +62,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -59,7 +62,8 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName const provinceName = obj_provinceCode ? obj_provinceCode['title'] : value.provinceName
const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName const cityName = obj_cityCode ? obj_cityCode['title'] : value.cityName
const districtName = obj_districtCode ? obj_districtCode['title'] : value.districtName 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 roleId = ctx.getFieldValue('buyerRoleId')
const memberId = ctx.getFieldValue('buyerMemberId') const memberId = ctx.getFieldValue('buyerMemberId')
...@@ -72,6 +76,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -72,6 +76,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
cityName, cityName,
districtName, districtName,
streetName, streetName,
streetCode,
roleId, roleId,
memberId memberId
} }
...@@ -81,7 +86,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -81,7 +86,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
props.currentRef.current.setVisible(false) props.currentRef.current.setVisible(false)
props.reloadAddress && props.reloadAddress() props.reloadAddress && props.reloadAddress()
} else { } else {
message.error(getIntl().formatMessage({id: 'purchaseOrder.orderCollect.model.message2'})) message.error(getIntl().formatMessage({id: 'purchaseOrder.orderCollect.model.message2'}))
} }
} }
...@@ -131,7 +136,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => { ...@@ -131,7 +136,7 @@ const AddressModal:React.FC<AddressModalProps> = (props) => {
// 街道/乡/镇 // 街道/乡/镇
$('onFieldValueChange', 'districtCode').subscribe(({value}) => { $('onFieldValueChange', 'districtCode').subscribe(({value}) => {
if(value) { if(value) {
console.log(value) changDistrict.current = true
ctx.setFieldValue('streetCode', null) ctx.setFieldValue('streetCode', null)
renderSelectOption('streetCode', ctx, { pcode: value }) 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