index.tsx
2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React, { useState } from 'react';
import { Form, message, Card, Button, Row, Col, Input } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import * as api from '../../api';
import AuthTableList from './components/AuthTableList';
import { history } from 'umi';
import RenderSelectGoos from './components/RenderSelectGoos';
const formItemLayout =
{
labelCol: { span: 4 },
wrapperCol: { span: 20 },
};
interface Props {
match?: any
}
export default function Index(props: Props) {
const { match } = props;
const { id, name } = match.params;
const [form] = Form.useForm();
const [confirmloading, setConfirmloading] = useState(false);
function onSave(feildValue: any) {
const params = {
standardIds: id ? [id] : feildValue.standardIds.map((i: { id: any; }) => i.id),
shopAuthPostList: feildValue.shopAuthPostList.map(i => ({
shopIds: i.shopIds.map((shop: { value: any; }) => shop.value),
postList: i.postList.map((post: { value: any; label: any; }) => ({ postId: post.value, postName: post.label })),
periodDto: { maxNum: i.maxNum, periodType: i.periodType, period: i.period }
})),
};
setConfirmloading(true);
api.saveGoodsDimension(params).then(res => {
message.success('保存成功');
history.goBack();
}).catch(e => {
message.error(e.message);
}).finally(() => {
setConfirmloading(false);
});
}
return (
<PageHeaderWrapper
title="按物品维度授权"
content={<a onClick={(e) => { e.preventDefault(); history.go(-1); }}>返回资产列表</a>}
>
<Card>
<Form form={form} {...formItemLayout} onFinish={onSave}>
{!name ? (
<Form.Item label="选择物品" name="standardIds" rules={[{ required: true, message: '请选择' }]}>
<RenderSelectGoos />
</Form.Item>
) : (
// <Form.Item label="物品名称">
// <Input bordered={false} value={name} />
// </Form.Item>
null
)}
<Form.Item label="按门店授权" name="shopAuthPostList" rules={[{ required: true, message: '添加授权信息' }]}>
<AuthTableList />
</Form.Item>
</Form>
<Row gutter={16} justify="center">
<Col span={4} style={{ textAlign: 'center' }}>
<Button size="middle" type="default" onClick={() => history.go(-1)}>返回</Button>
</Col>
<Col span={4} style={{ textAlign: 'center' }}>
<Button size="middle" type="primary" loading={confirmloading} onClick={() => form.submit()}>提交</Button>
</Col>
</Row>
</Card>
</PageHeaderWrapper>
);
}