Commit 26e3fcd1 authored by Bill's avatar Bill

Merge branch 'v2-220318' of http://10.0.0.22:3000/lingxi/lingxi-business-paltform into v2-220318

parents 15df527b 6498f9d5
......@@ -24,7 +24,7 @@ import asyncRoutes from '../router.config.json';
// import contracRoute from './contracRoute';
// export const routes = [CommodityRoute, MemberRoute, ShopRoute, ChannelRoute, TranactionRoute, AfterService, PayandSettleRoute, LogisticsRoute, AuthConfigRoute, HandlingRoute, BalaceRoute]
const isDev = false;
const isDev = true;
const homeRoute = {
path: `/memberCenter/home`,
name: 'home',
......
......@@ -3,7 +3,7 @@ import { Button, Form } from 'antd';
import PeripheralLayout from '@/pages/transaction/components/detailLayout';
import BasicLayout from './components/basicLayout';
import ContactLayout from './components/contactLayout';
import AddressLayout from './components/address';
import AddressLayout, { ADDED_DELIVERY, ADDED_DISPATCH } from './components/address';
const layout: any = {
colon: false,
......@@ -38,8 +38,8 @@ const PortalSystemAdded: React.FC<{}> = () => {
<Form {...layout} form={form}>
<BasicLayout />
<ContactLayout form={form} />
<AddressLayout id='address1' title='收货地址' />
<AddressLayout id='address2' title='发货(自提)地址' />
<AddressLayout id='address1' title='收货地址' type={ADDED_DELIVERY} />
<AddressLayout id='address2' title='发货(自提)地址' type={ADDED_DISPATCH} />
</Form>
}
/>
......
import React, { Fragment, useState } from 'react';
import CardLayout from '@/pages/transaction/components/card'
import { Button, Col, Radio, Row, Drawer } from 'antd';
import { Button, Col, Radio, Row, Drawer, Empty } from 'antd';
import style from './index.less';
import { DeleteOutlined, EditOutlined } from '@ant-design/icons';
import { DELIVERY_SCHEMA } from './schema/delivery';
......@@ -10,6 +10,7 @@ import { createFormActions, FormEffectHooks } from '@formily/antd';
import { getManageAreaByPcode, GetManageAreaByPcodeRequest, getManageCountryAreaGetTelCode } from '@/services/ManageV2Api';
import { useFetchAreaEnumLinkageEffect } from '@/components/AddressSelect';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { isEmpty } from 'lodash';
/** 收货地址 */
export const ADDED_DELIVERY = 1;
......@@ -31,28 +32,54 @@ const {
onFormInputChange$,
} = FormEffectHooks;
type addressList = {
/** 发货人名称 */
deliverName?: string,
/** 收货人名称 */
receiveName?: string,
/** 省编号 */
provinceCode?: string,
/** 省名称 */
provinceName?: string,
/** 市编号 */
cityCode?: string,
/** 市名称 */
cityName?: string,
/** 区编号 */
districtCode?: string,
/** 区名称 */
districtName?: string,
/** 街道编码 */
streetCode?: string,
/** 街道名称 */
streetName?: string,
/** 详细地址 */
address?: string,
/** 邮编 */
postalCode?: string,
/** 手机区号 */
areaCode?: string,
/** 手机号码 */
phone?: string,
/** 电话号码 */
tel?: string,
/** 是否默认0-否1-是 */
isDefault?: number,
}
const AddressLayout: React.FC<addressProps> = (props: addressProps) => {
const { id, title, type, yapi } = props;
const [visible, setVisible] = useState<boolean>(false);
const [selfInitValue, setSelfInitValue] = useState<any>({});
const renderFooter = () => {
return (
<div style={{ textAlign: 'right' }}>
<Button style={{ marginRight: 8 }}>
取消
</Button>
<Button type="primary">
保存
</Button>
</div>
)
}
const [addressList, setAddressList] = useState<addressList[]>([])
const handleAdded = () => {
setVisible(true)
}
console.log(typeof type, type)
const renderSelectOption = (key, ctx, params?: GetManageAreaByPcodeRequest) => {
getManageAreaByPcode({ ...params }).then(res => {
if (res.code === 1000) {
......@@ -78,6 +105,54 @@ const AddressLayout: React.FC<addressProps> = (props: addressProps) => {
return data
}
/** 新增地址 */
const handleSubmit = () => {
const newList = [...addressList]
addressSchemaAction.submit((value) => {
const provinceName = value?.provinceName ? value.provinceName : addressSchemaAction.getFieldState('provinceCode')['values'][1]['title'];
const cityName = value?.cityName ? value.cityName : addressSchemaAction.getFieldState('cityCode')['values'][1]['title'];
const districtName = value?.districtName ? value.districtName : addressSchemaAction.getFieldState('districtCode')['values'][1]['title'];
const streetName = value?.streetName ? value.streetName : value['streetCode'] ? addressSchemaAction.getFieldState('streetCode')['values'][1]['title'] : null;
const params = {
...value,
isDefault: Number(!!value.isDefault),
provinceName,
cityName,
districtName,
streetName
}
console.log(params, value)
setAddressList([...newList, params])
setVisible(false);
})
}
const renderFooter = () => {
return (
<div style={{ textAlign: 'right' }}>
<Button style={{ marginRight: 8 }}>
取消
</Button>
<Button type="primary" onClick={handleSubmit}>
保存
</Button>
</div>
)
}
/** 地址拼合 */
const handleMosaic = (
provinceName,
cityName,
districtName,
address,
streetName?,
) => {
const mosaic = (streetName ? provinceName + cityName + districtName + streetName + address : provinceName + cityName + districtName + address);
return mosaic
}
return (
<Fragment>
<CardLayout
......@@ -86,27 +161,34 @@ const AddressLayout: React.FC<addressProps> = (props: addressProps) => {
extra={<Button type='link' onClick={() => handleAdded()}>新增地址</Button>}
>
<div className={style.addressList}>
<Radio.Group style={{ display: 'block' }}>
<Row gutter={[48, 24]}>
<Col span={12}>
<div className={style.addressLayout}>
<Radio>
<div className={style.addressInfo}>
<div className={style.info}>
<div className={style.name}>蒯美政&nbsp;185 2929 6758</div>
<div className={style.default}>默认地址</div>
</div>
<div className={style.address}>广东省广州市海珠区新港东路1068号中洲中心北塔6楼</div>
{!isEmpty(addressList) ? (
<Radio.Group style={{ display: 'block' }}>
<Row gutter={[48, 24]}>
{addressList.map((item, index) => (
<Col span={12} key={index * 1}>
<div className={style.addressLayout}>
<Radio value={index * 1}>
<div className={style.addressInfo}>
<div className={style.info}>
<div className={style.name}>{type === ADDED_DELIVERY ? item.deliverName : item.receiveName}&nbsp;{item.phone}</div>
{item.isDefault && <div className={style.default}>默认地址</div>}
</div>
<div className={style.address}>{handleMosaic(item.provinceName, item.cityName, item.districtName, item.address, item.streetName)}</div>
</div>
<div className={style.addressOperate}>
<EditOutlined className={style.icon} />
<DeleteOutlined className={style.icon} />
</div>
</Radio>
</div>
<div className={style.addressOperate}>
<EditOutlined className={style.icon} />
<DeleteOutlined className={style.icon} />
</div>
</Radio>
</div>
</Col>
</Row>
</Radio.Group>
</Col>
))}
</Row>
</Radio.Group>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
)}
</div>
</CardLayout>
<Drawer
......
......@@ -11,11 +11,12 @@ export const DELIVERY_SCHEMA: ISchema = {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
inline: true,
labelCol: 24,
wrapperCol: 24,
labelAlign: 'left',
},
properties: {
receiverName: {
receiveName: {
type: 'string',
title: intl.formatMessage({ id: 'logistics.shouhuoren' }),
"x-rules": [
......
......@@ -16,7 +16,7 @@ export const DISPATCH_SCHEMA: ISchema = {
labelAlign: 'left',
},
properties: {
shipperName: {
deliverName: {
type: 'string',
title: intl.formatMessage({ id: 'logistics.fahuoren' }),
"x-rules": [
......
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