Commit 2108287b authored by XieZhiXiong's avatar XieZhiXiong

fix: 初始隐藏地址选择

parent 9cfa93d3
/*
* @Author: XieZhiXiong
* @Date: 2021-01-06 11:36:34
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-21 14:18:19
* @Description:
*/
import { FormEffectHooks, useValueLinkageEffect } from '@formily/antd'
export const useLinkComponentProps = (scope) => {
......
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-11-06 09:54:04
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-21 13:39:26
* @LastEditTime: 2021-01-21 14:36:00
* @Description: 换货收货地址
*/
import React from 'react';
......@@ -137,7 +137,7 @@ const ExchangeAddressInfo: React.FC<ExchangeAddressInfo> = ({
// 联动配送方式
onFieldValueChange$('deliveryType').subscribe(fieldState => {
const { name, value } = fieldState;
const { value } = fieldState;
switch (value) {
// 物流
......@@ -145,7 +145,6 @@ const ExchangeAddressInfo: React.FC<ExchangeAddressInfo> = ({
if (isEdit) {
linkage.show('shippingAddress');
linkage.hide('pickupAddress');
linkage.value('shippingAddress', undefined);
} else {
linkage.hide('*(shippingAddress,pickupAddress)');
linkage.show('shippingAddressShow');
......@@ -157,7 +156,6 @@ const ExchangeAddressInfo: React.FC<ExchangeAddressInfo> = ({
if (isEdit) {
linkage.hide('shippingAddress');
linkage.show('pickupAddress');
linkage.value('pickupAddress', undefined);
} else {
setFieldState('shippingAddressShow', fieldState => {
fieldState.title = '换货自提地址'
......@@ -170,7 +168,6 @@ const ExchangeAddressInfo: React.FC<ExchangeAddressInfo> = ({
// 无需物流
case 3: {
linkage.hide('*(shippingAddress,pickupAddress)');
linkage.value('*(shippingAddress,pickupAddress)', undefined);
break;
};
default:
......@@ -178,8 +175,15 @@ const ExchangeAddressInfo: React.FC<ExchangeAddressInfo> = ({
};
});
onFieldValueChange$('*(shippingAddress,pickupAddress)').subscribe(fieldState => {
const { name, value, originAsyncData = [] } = fieldState;
onFieldInputChange$('deliveryType').subscribe(fieldState => {
const { name, value } = fieldState;
if (value) {
linkage.value('*(shippingAddress,pickupAddress)', undefined);
}
});
onFieldInputChange$('*(shippingAddress,pickupAddress)').subscribe(fieldState => {
const { value, originAsyncData = [] } = fieldState;
const deliveryTypeValue = getFieldValue('deliveryType');
const fullData = originAsyncData.find(item => item.id === value);
......
......@@ -2,11 +2,11 @@
* @Author: XieZhiXiong
* @Date: 2020-11-09 15:56:35
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-01-21 13:40:28
* @LastEditTime: 2021-01-21 14:14:26
* @Description:
*/
import { ISchema } from '@formily/antd';
import { UPLOAD_TYPE, DELIVERY_TYPE_ENUM } from '@/constants';
import { DELIVERY_TYPE_ENUM } from '@/constants';
export const schema: ISchema = {
type: 'object',
......@@ -30,6 +30,12 @@ export const schema: ISchema = {
width: '80%',
},
},
'x-rules': [
{
required: true,
message: '请选择配送方式',
},
],
},
deliveryAddress: {
type: 'object',
......@@ -42,6 +48,7 @@ export const schema: ISchema = {
shippingAddress: {
type: 'string',
title: '换货发货地址',
visible: false,
enum: [],
'x-component-props': {
placeholder: '请选择',
......@@ -59,6 +66,7 @@ export const schema: ISchema = {
pickupAddress: {
type: 'string',
title: '换货自提地址',
visible: false,
enum: [],
'x-component-props': {
placeholder: '请选择',
......
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