Commit 80687f0c authored by LeeJiancong's avatar LeeJiancong

对接完发货地址和收货地址

parent d74d2743
......@@ -2,7 +2,7 @@
* @Author: LeeJiancong
* @Date: 2020-07-15 10:31:55
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-27 17:01:52
* @LastEditTime: 2020-07-28 10:56:07
*/
import React, { Component, useState, useEffect } from 'react';
import ReactDOM from 'react-dom'
......@@ -23,6 +23,7 @@ import { Row, Col, Card, Button, Popconfirm, Select as ISelect, message } from '
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { MegaLayout, Input, Switch, Select, FormMegaLayout } from '@formily/antd-components'
import { PublicApi } from '@/services/api'
import { PATTERN_MAPS} from '@/constants/regExp'
import ReutrnEle from '@/components/ReturnEle'
import ChinaImg from '../../../../../mockStatic/china.png'
import gou from '../../../../../mockStatic/gou.png'
......@@ -58,25 +59,8 @@ const children: any = [];
for (let i = 10; i < 36; i++) {
children.push(<Option value={i} key={i.toString(36) + i}>{i.toString(36) + i}</Option>);
}
const dropdownRender = () => {
return (
<div>12</div>
)
}
// const CustomSelect = (props: any) => {
// return (
// <ISelect showArrow style={{ width: '100%' }} dropdownRender={dropdownRender}
// placeholder="Tags Mode" onChange={value => props.onChange(value)}>
// {/* {children} */}
// </ISelect>
// )
// }
// registerFormFields({ prefixSelect: connect()(CustomSelect) })
const diaLogForm: React.FC<ListProps> = (props) => {
const type: string = history.location.query.type
const [areaCode, setAreaCode] = useState<number>(null)
const [Options, setOptions] = useState([])
......@@ -108,14 +92,14 @@ const diaLogForm: React.FC<ListProps> = (props) => {
let type = history.location.query.type //'1' 发货 '2'收货
let value = { ...values }
value.isDefault = values.isDefault ? 1 : 0
value.provinceCode = value.provinceCode.split('-').length > 1 ? value.provinceCode.split('-')[0] : value.provinceCode
value.cityCode = value.cityCode.split('-').length > 1 ? value.cityCode.split('-')[0] : value.cityCode
value.districtCode = value.districtCode.split('-').length > 1 ? value.districtCode.split('-')[0] : value.districtCode
value.provinceName = provinceName
value.cityName = cityName
value.districtName = districtName
if (type == 1) {
if (id == 0) {
value.provinceCode = value.provinceCode.split('-').length > 1 ? value.provinceCode.split('-')[0] : value.provinceCode
value.cityCode = value.cityCode.split('-').length > 1 ? value.cityCode.split('-')[0] : value.cityCode
value.districtCode = value.districtCode.split('-').length > 1 ? value.districtCode.split('-')[0] : value.districtCode
value.provinceName = provinceName
value.cityName = cityName
value.districtName = districtName
PublicApi.postLogisticsShipperAddressAdd(value).then(res => {
if (res.code == 1000) {
}
......@@ -168,7 +152,7 @@ const diaLogForm: React.FC<ListProps> = (props) => {
{ label: <><img src={korenImg} key='4' style={{ width: _width, height: 17 }} /> +86</>, value: '4' },
{ label: <><img src={us} key='5' style={{ width: _width, height: 17 }} /> +86</>, value: '5' }
]
let _Options: any = []
let _Options: any = [],TelCodeList:any = []
List.forEach((item: any, index: number) => {
let tem = <><img src={item} key={'item' + index} style={{ width: _width, height: _height }} /> +86</>
_Options.push({ label: tem, value: (index + 1).toString() })
......@@ -184,29 +168,40 @@ const diaLogForm: React.FC<ListProps> = (props) => {
console.log(typeof(id))
let title = id === 0 ? '新建' : '编辑'
history.location.query.type == '1' ? setHeaderTitle(`${title}发货地址`) : setHeaderTitle(`${title}收货地址`)
setOptions(_Options)
PublicApi.getLogisticsShipperAddressGetTelCode().then(res => {})
PublicApi.getWarehouseAreaByPcodeAll({ pcode: '100000' }).then(res => {
let list = []
res.data.forEach((item: any, index: number) => {
list.push({ label: item.name, value: `${item.code}-${item.name}` })
// list.push({ label: item.name, value: item.code })
PublicApi.getLogisticsShipperAddressGetTelCode().then(res => {
res.data.forEach((item,index) => {
TelCodeList.push({ label: item, value: (index).toString() })
})
setProvinceList(list)
setOptions(TelCodeList)
})
const getAllCode = setTimeout(()=> {
PublicApi.getWarehouseAreaByPcodeAll({ pcode: '100000' }).then(res => {
let list = []
res.data.forEach((item: any, index: number) => {
list.push({ label: item.name, value: `${item.code}-${item.name}` })
// list.push({ label: item.name, value: item.code })
})
setProvinceList(list)
})
},1000)
if (id != 0 && history.location.query.type == '1') {
PublicApi.getLogisticsShipperAddressGet({ id: id.toString() }).then(res => {
if (res.code == 1000) {
let data = res.data
Object.keys(data).forEach(key => {
actions.setFieldState(key, state => {
state.value = data[key]
if (key == 'isDefault') {
state.value = data[key] === 0 ? false : true
}else if(key== 'provinceCode'){
state.value = `${data.provinceCode}-${data.provinceName}`
}else if(key == 'cityCode'){
state.value = `${data.cityCode}-${data.cityName}`
}else if(key == 'districtCode'){
state.value = `${data.districtCode}-${data.districtName}`
}else{
state.value = data[key]
}
// else if(key == 'areaCode'){
// setAreaCode(Number(data[key]))
// }
})
})
}
......@@ -223,6 +218,14 @@ const diaLogForm: React.FC<ListProps> = (props) => {
state.value = data[key]
if (key == 'isDefault') {
state.value = data[key] === 0 ? false : true
}else if(key== 'provinceCode'){
state.value = `${data.provinceCode}-${data.provinceName}`
}else if(key == 'cityCode'){
state.value = `${data.cityCode}-${data.cityName}`
}else if(key == 'districtCode'){
state.value = `${data.districtCode}-${data.districtName}`
}else{
state.value = data[key]
}
})
})
......@@ -234,8 +237,7 @@ const diaLogForm: React.FC<ListProps> = (props) => {
return () => {
clearTimeout(getAllCode)
}
}, [])
......@@ -401,20 +403,21 @@ const diaLogForm: React.FC<ListProps> = (props) => {
placeholder: '+86'
}}
/>
{/* <Field
name="phoneHead2"
x-component="prefixSelect"
/> */}
{/* <ISelect mode="tags" style={{ width: '100%' }} placeholder="Tags Mode" onChange={handleChangeSelect}>
{children}
</ISelect>, */}
<Field
x-mega-props={{ span: 5 }}
name="phone"
required
maxLength={11}
x-component="Input"
x-rules={{
pattern: PATTERN_MAPS.phone,
message:'请输入正确手机号',
// maximum={11}数值的意思
}}
x-component-props={{
placeholder: '输入你的手机号码'
placeholder: '输入你的手机号码',
}}
/>
</FormMegaLayout>
......
......@@ -2,23 +2,27 @@
* @Author: LeeJiancong
* @Date: 2020-07-14 15:07:34
* @LastEditors: LeeJiancong
* @LastEditTime: 2020-07-27 11:26:07
* @LastEditTime: 2020-07-27 20:28:06
*/
import React, { Component, ReactNode, useRef, useState } from 'react'
import { history } from 'umi'
import { Modal, Card, Button, Form, InputNumber, Radio, Popconfirm, Switch, Input,Tag } from 'antd';
import { Modal, Row, Col, Card, Button, Form, InputNumber, Radio, Tooltip, Popconfirm, Switch, Input,Select, Tag } from 'antd';
import {
PlayCircleOutlined,
PauseCircleOutlined,
PlusOutlined,
EyeOutlined,
UpOutlined,
DownOutlined,
PlusCircleOutlined
} from '@ant-design/icons';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { StandardTable } from 'god'
import { ColumnType } from 'antd/lib/table/interface'
import { ColumnType, TableRowSelection } from 'antd/lib/table/interface'
import { IFormFilter, IButtonFilter } from 'god/dist/src/standard-table/TableController'
import {PublicApi} from '@/services/api'
import { PublicApi } from '@/services/api'
import style from '../components/index.less'
let {Option} = Select
const data = [
{
key: '1',
......@@ -46,6 +50,49 @@ const data = [
interface Item {
key: string
}
const TimeList = [
{
label:'单据时间(全部)',value: ''
},
{
label:'今天',value:1
},
{
label:'一周内',value:2
},
{
label:'一个月内',value:3
},
{
label:'三个月内',value:4
},
{
label:'六个月内',value:5
},
{
label:'一年内',value: 6
},
{
label:'一年前',value: 7
}
]
const outSideStatusList = [
{
label:'外部状态(全部)',value: ''
},
{
label:'待提交',value: 1
},
{
label:'待确认',value: 2
},
{
label:'接受物流单',value: 3
},
{
label:'不接受物流单',value: 4
}
]
//父页面传递来的参数
export interface ListProps {
title?: React.ReactNode,
......@@ -107,7 +154,17 @@ const OrderList: React.FC<ListProps> = (props) => {
const ref = useRef({})
const [form] = Form.useForm();
const [table, setTable] = useState([])
const [selectTableRow, setSelectTableRow] = useState<any>([])
let [selectedTableRowKeys, setSelectedTableRowKeys] = useState<Array<number>>([])
const [editingKey, setEditingKey] = useState('');
let [isSearch, setIsSearch] = useState(false)
const [searchForm, setSearchForm] = useState({
searName: '',
buyer: '',//收货商
dateSelect: '',
outSideStatus: '',
TimeRange: ''
})
const edit = (record: Item) => {
setEditingKey(record.key);
form.setFieldsValue({ code: '', ...record });
......@@ -185,7 +242,7 @@ const OrderList: React.FC<ListProps> = (props) => {
render: (_: any, record: any) => {
return (
<>
{
record.status === 0 ?
<><Button type="link" onClick={() => edit(record)}>编辑</Button>
......@@ -205,20 +262,20 @@ const OrderList: React.FC<ListProps> = (props) => {
];
// 模拟请求
const fetchData = (params: any) => {
return new Promise((resolve, reject) => {
if(props.type === '1'){//发货
PublicApi.getLogisticsShipperAddressPage({ current: params.page, pageSize: params.rows }).then(res => {
resolve(res.data)
})
}else{
PublicApi.getLogisticsReceiverAddressPage({ current: params.page, pageSize: params.rows }).then(res => {
resolve(res.data)
})
}
})
const fetchData = (params: any) => {
return new Promise((resolve, reject) => {
if (props.type === '1') {//发货
PublicApi.getLogisticsShipperAddressPage({ current: params.page, pageSize: params.rows }).then(res => {
resolve(res.data)
})
} else {
PublicApi.getLogisticsReceiverAddressPage({ current: params.page, pageSize: params.rows }).then(res => {
resolve(res.data)
})
}
})
}
}
//生命周期
// useEffect(() => {
// effect
......@@ -248,9 +305,23 @@ const fetchData = (params: any) => {
console.log('cancel')
}
const handleModify = (record: object) => {
// 通过传入的params字符串判断是修改那种类型的数据
console.log('执行状态修改', record)
const rowSelection: TableRowSelection<any> = {
type: 'checkbox',
selectedRowKeys: selectedTableRowKeys,
onChange: (selectedRowKeys: any, selectedRows: any) => {
setSelectTableRow(selectedRows);
setSelectedTableRowKeys(selectedRowKeys);
console.log(selectedRowKeys, 'selected: ', selectedRows);
}
}
const handleSearch = () => {
}
const handleReset = () => {
for (let key in searchForm) {
searchForm[key] = ''
}
setSearchForm({ ...searchForm })
}
return (
......@@ -261,13 +332,104 @@ const fetchData = (params: any) => {
currentRef={ref}
fetchTableData={(params: any) => fetchData(params)}
rowClassName="editable-row"
formilyChilds={{
children: (
<>
<Button type="primary" icon={<PlusOutlined />} onClick={() => history.push(`/memberCenter/logisticsAbility/logistics/list/addressForm?addType=${props.type}`)}>新建</Button>
</>
)
}}
controlRender={
<>
<Row>
<Col span={8}>
<Button
type="primary"
onClick={() =>
history.push('')
}
>
<PlusOutlined />
新建
</Button>
</Col>
<Col span={10}
offset={6}
style={{textAlign:'right'}}
>
<Tooltip trigger={['focus']} placement='top'
title={props.type === '1' ? '输入物流单号、订单号进行搜索' : '输入物流单号、发货方进行搜索'}>
<Input.Search
style={{ width: '232px' }}
value={searchForm.searName}
placeholder='搜索'
onChange={(e) => setSearchForm({ ...searchForm, searName: e.target.value })}
onSearch={() => handleSearch}
/>
</Tooltip>
<Button className={style['filter-btn']} onClick={() => setIsSearch(isSearch = !isSearch)}>
高级筛选{isSearch ? <UpOutlined /> : <DownOutlined />}
</Button>
<Button className={style.selectBtn} onClick={() => handleReset()}>重置</Button>
<Row style={{ margin: '16px 0' }}>
{
isSearch &&
<Col
offset={2}
span={22}
>
{
props.type === '1' ?
<Select
className={style.select}
value={searchForm.buyer}
onChange={(val) => setSearchForm({ ...searchForm, buyer: val })}
>
<Option value=''>物流服务商(全部)</Option>
<Option value='1'>待审核</Option>
<Option value='2'>审核通过</Option>
<Option value='3'>审核不通过</Option>
</Select>
:
<Select
className={style.select}
value={searchForm.buyer}
onChange={(val) => setSearchForm({ ...searchForm, buyer: val })}
>
<Option value=''>发货方(全部)</Option>
<Option value='1'>待审核</Option>
<Option value='2'>审核通过</Option>
<Option value='3'>审核不通过</Option>
</Select>
}
<Select
className={style.select}
value={searchForm.TimeRange}
onChange={(val) => setSearchForm({ ...searchForm, TimeRange: val })}
>
{
TimeList.map((item) => {
return <Option value={item.value}>{item.label}</Option>
})
}
</Select>
<Select
className={style.select}
value={searchForm.outSideStatus}
onChange={(val) => setSearchForm({ ...searchForm, outSideStatus: val })}
>
{
outSideStatusList.map((item) => {
return <Option value={item.value}>{item.label}</Option>
})
}
</Select>
</Col>
}
</Row>
</Col>
</Row>
</>
}
/>
</Card>
</PageHeaderWrapper>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
* @param str:string 需要校验的字符串
* @param type:string 需要校验的类型
*/
export const checkRegExp = (str:string, type:string) => {
switch (type) {
case 'phone': //手机号码
return /^1[3|4|5|6|7|8|9][0-9]{9}$/.test(str);
case 'tel': //座机
return /^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(str);
case 'card': //身份证
return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(str);
case 'pwd': //密码以字母开头,长度在6~18之间,只能包含字母、数字和下划线
return /^[a-zA-Z]\w{5,17}$/.test(str)
case 'postal': //邮政编码
return /[1-9]\d{5}(?!\d)/.test(str);
case 'QQ': //QQ号
return /^[1-9][0-9]{4,9}$/.test(str);
case 'email': //邮箱
return /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(str);
case 'money': //金额(小数点2位)
return /^\d*(?:\.\d{0,2})?$/.test(str);
case 'URL': //网址
return /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(str)
case 'IP': //IP
return /((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(str);
case 'date': //日期时间
return /^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(str) || /^(\d{4})\-(\d{2})\-(\d{2})$/.test(str)
case 'number': //数字
return /^[0-9]$/.test(str);
case 'english': //英文
return /^[a-zA-Z]+$/.test(str);
case 'chinese': //中文
return /^[\\u4E00-\\u9FA5]+$/.test(str);
case 'lower': //小写
return /^[a-z]+$/.test(str);
case 'upper': //大写
return /^[A-Z]+$/.test(str);
case 'HTML': //HTML标记
return /<("[^"]*"|'[^']*'|[^'">])*>/.test(str);
default:
return true;
}
}
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