index.tsx
5.51 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import React, { useState, useEffect } from "react";
import { Button, Form, InputNumber, Space, Popconfirm, Spin, Divider, Radio, Row } from "antd";
// import SignupGifts from "./CouponGifts";
import SignupGifts from "./Coupons";
interface Props {
data: any;
mulLottery: boolean;
}
export default function Index({ data, mulLottery }: Props) {
// const { baseInfo, readOnly, getFlowConfig, getACarList } = useStore();
// const { activityNo, bizType, changeEnable } = baseInfo;
// const { data, errMsg, loading } = useInitial(getSignUpDetail, {}, { activityNo, change: changeEnable });
const [form] = Form.useForm();
const [saveLoading, setSaveLoading] = useState<boolean>(false);
useEffect(() => {
form.setFieldsValue({
...data,
// ladderReward: data.ladderReward != null ? Number(data.ladderReward) : 0,
// awardConfigs: data.awardConfigs ? data.awardConfigs : [{ sortOrder: 1, lotteryMinLimit: 1, awardWay: 1, gifts: [{ parcelType: 2, awardName: "报名有礼", winningNum: 100, giftItems: [] }] }]
});
}, [data]);
return (
<>
<Form form={form}>
{/* 优惠券部分 */}
<Divider orientation="left">赠送奖品详情</Divider>
{/* <Form.Item
style={{ width: "100%" }}
label="发券方式"
name="ladderReward"
rules={[{ required: true }]}
>
<Radio.Group>
<Radio value={0}>报名成功则送相同优惠券</Radio>
<Radio value={1}>按报名顺序不同赠送不同优惠券</Radio>
</Radio.Group>
</Form.Item> */}
<Form.Item
noStyle
shouldUpdate={(prevValues, currentValues) => prevValues.ladderReward !== currentValues.ladderReward}
>
{({ getFieldValue }) => {
return (
<Form.List name="awardConfigs">
{(fields, { add, remove }) => {
const _Limit = data.awardConfigs && data.awardConfigs[0].lotteryMaxLimit;
return (
<>
{fields.map(({ key, name, ...restField }, index) => {
return (
<Space
key={key}
style={{ display: "flex", marginBottom: 8 }}
direction="vertical"
>
<>
{!!_Limit && mulLottery && (
<>
<Divider>第{index + 1}轮</Divider>
<Space key={key} style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 8, height: 35 }} align="baseline">
<Row style={{ alignItems: 'baseline' }}>
<span><span style={{ color: 'red' }}>* </span>参与名额:</span>
<Form.Item
{...restField}
name={[name, 'lotteryMinLimit']}
>
<InputNumber placeholder="请输入" disabled precision={0} min={1} />
</Form.Item>
<span>~</span>
<Form.Item
{...restField}
name={[name, 'lotteryMaxLimit']}
>
<InputNumber disabled precision={0} min={0} />
</Form.Item>
<span>名</span>
</Row>
{/* {!editDisabled(index) && <MinusCircleOutlined onClick={() => remove(name)} style={{ color: 'red' }} />} */}
</Space>
</>
)}
<Form.Item
{...restField}
noStyle
shouldUpdate={(prevValues, currentValues) => prevValues.awardConfigs !== currentValues.awardConfigs}
>
{({ getFieldValue }) => {
let _awardWay = getFieldValue("awardConfigs")[index];
return (
<Form.Item name={[name, "gifts"]}>
<SignupGifts disabled awardWay={_awardWay.awardWay} />
</Form.Item>
);
}}
</Form.Item>
</>
</Space>
);
// )}
})}
{/* {!!_mulLottery && (
<Button
type="dashed"
onClick={() => addRewardTimes()}
block
icon={<PlusOutlined />}
disabled={readOnly && !changeEnable}
>
增加名额配置
</Button>
)} */}
</>
);
}}
</Form.List>
);
}}
</Form.Item>
</Form>
</>
);
}