@
wxsm @
rover5056 推倒重来不是个事儿,但是涉及时间、成本和风险,我觉得要慎重衡量,我贴一段代码,你们可以参考一下:
···
import React from 'react'
import {Modal, Form} from 'components'
import {
Input,
Radio,
InputNumber,
DatePicker,
Table,
Popover,
Cascader
} from 'antd'
import {Operation} from 'components'
import moment from 'moment'
const RadioButton = Radio.Button;
const RadioGroup = Radio.Group;
import {china_area_data} from 'utils'
const modal = ({
onOk,
onAudit,
payload = {}
}) => {
const {type, data} = payload
const handleAudit = (key, event, record) => {
let values = {
uid: payload.uid,
isAgree: key === 'agree',
comment: '',
aid:
record.id }
onAudit(values)
}
const columns = [
{
title: '审核名称',
dataIndex: 'name'
}, {
title: '审核类型',
width: 100,
dataIndex: 'auditTypeEnum',
render: text => ['实名审核', '快递协议审核', '提现审核', '分仓任务审核'][text]
}, {
title: '审核内容',
width: 220,
dataIndex: 'content',
render: text =>< Popover content = {
text
} > <a href='#' style={{
maxWidth: '200px',
display: 'inline-block',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis'
}}>{text}</a>
</Popover>
}, {
title: '更新时间',
width: 140,
dataIndex: 'lastUpdateTime'
}, {
title: '审核',
width: 120,
render: (text, record) =>< Operation options = {
[
{
name: '同意',
key: 'agree'
}, {
name: '拒绝',
key: 'refuse',
confirm: <Input placeholder='理由'/>
}
]
}
onClick = {
(key, event) => handleAudit(key, event, record)
} />
}
]
const handleOk = (close, form) => {
form.validateFields((err, values) => {
if (!err) {
values.birth = values.birth
? values.birth.format('YYYY-MM-DD')
: undefined
if (values.area.length == 3) {
values.province = values.area[0],
values.city = values.area[1],
values.zone = values.area[2]
delete values.area
} else if (values.area.length == 2) {
values.province = ''
values.city = values.area[0]
values.zone = values.area[1]
delete values.area
}
for (let key in values) {
if (values[key] === undefined || values[key] === null) {
delete values[key]
}
}
onOk(values, type)
close()
}
})
}
return (<Modal id='modal' title={{
audit: '审核',
update: '更新'
}[type]} onOk={handleOk} width={type == 'audit'
? 800
: 416}>
{
type == 'update'
? (<Form labelCol={4}>
<InputNumber name='id' initialValue={
data.id} hidden="hidden"/>
<Input name='name' initialValue={
data.name} label='昵称' placeholder='昵称'/>
<Input name='shopName' initialValue={data.shopName} label='店铺名称' placeholder='店铺名称'/>
<Cascader name='area' initialValue={[data.province, data.city, data.zone]} options={china_area_data} placeholder="地址" label='地址' type='array'/>
<Input name='address' initialValue={data.address} label='详细地址' placeholder='详细地址'/>
<DatePicker name='birth' initialValue={data.birth && moment(data.birth)} type='object' label='生日' placeholder='生日' style={{
width: '100%'
}}/>
<RadioGroup name='sexEnum' label='性别' initialValue={data.sexEnum} type='number' prefixCls='ant-radio-group'>
<RadioButton value={1}>男</RadioButton>
<RadioButton value={2}>女</RadioButton>
</RadioGroup>
</Form>)
: ''
}{
type == 'audit'
? <Table columns={columns} dataSource={data} size="middle" pagination={false} scroll={{
y: 440
}} rowKey={record =>
record.id}/>
: ''
}
</Modal>)
}
export default Modal.connect('modal')(modal)
···