Operation.tsx
3.87 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
126
127
128
129
130
import React from 'react';
import { Button, message, Modal, Dropdown, Menu } from 'antd';
import { history } from 'umi';
import { common } from '@/typing/common';
import * as API from '../api';
// import * as IF from '../interface.d';
const { confirm } = Modal;
interface Props extends common.ConnectProps {
record: MarketingManage.Item,
/** 刷新列表 */
onRefreshing: () => any,
}
export default function Oparetion(props: Props) {
const { record, onRefreshing } = props;
/** 1草稿2待审核3未通过4待发布5进行中6提前结束7正常结束) */
const status = record.status;
/** 提审 */
function commitAudit() {
confirm({
title: '您确定提交审核吗,提审后活动不可进行编辑?',
okText: "确定",
cancelText: "取消",
onOk: () => {
API.approveApi(record.activityNo).then(res => {
message.success("提审成功,请等待审核结果");
onRefreshing && onRefreshing();
}).catch((e: any) => {
message.error(e.message);
});
},
});
}
/** 查看/编辑 */
function viewDetail() {
history.push(`/mkt/manage/create/${record.activityNo}/${record.status}`);
}
/** 变更信息 */
function changeBaseInfo() {
history.push(`/mkt/manage/create/${record.activityNo}/${record.status}/change`);
}
/** 变更记录 */
function changeRecords() {
history.push(`/mkt/prize/record/changes/${record.activityNo}`);
}
/** 删除 */
function deleteItem(row: MarketingManage.Item) {
confirm({
title: `活动删除后不可恢复,是否删除【${record.activityName}】?`,
okText: '确定',
okType: 'danger',
cancelText: '取消',
onOk: () => {
API.deleteApi(row.activityNo).then(res => {
message.success("删除成功");
onRefreshing && onRefreshing();
}).catch(e => {
message.error(e.message);
});
},
});
}
/** 终止 */
function endActivity() {
confirm({
title: `活动结束后不可再次编辑或发布,是否终止${record.activityName}活动?`,
okText: '确定',
okType: 'danger',
cancelText: '取消',
onOk: () => {
API.finishApi(record.activityNo).then(res => {
message.success("已提交审批");
onRefreshing && onRefreshing();
}).catch(e => {
message.error(e.message, 5);
});
},
});
}
return (
<Dropdown.Button
type="primary"
size="small"
onClick={viewDetail}
overlay={() => {
let menus: any[] = [];
/* 草稿、审核失败 */
if ([1, 3].includes(status)) {
menus = [
<Button type="primary" ghost size="small" onClick={viewDetail}>编辑</Button>,
<Button type="primary" ghost size="small" onClick={commitAudit}>提审</Button>,
<Button danger ghost size="small" onClick={() => deleteItem(record)}>删除</Button>,
];
}
/* 待审核 */
// if ([2].includes(status)) {
// menus = [
// <Button type="primary" ghost size="small" onClick={commitAudit}>提审</Button>,
// ];
// }
/* 审核成功、待发布 ;未开始,进行中*/
if ([4, 5].includes(status) && record.changeStatus !== 2) {
menus = [
<Button type="primary" ghost size="small" onClick={changeBaseInfo}>变更信息</Button>,
<Button type="primary" ghost size="small" onClick={changeRecords}>变更记录</Button>,
// <Button danger ghost size="small" onClick={endActivity}>终止</Button>,
];
}
return (
<Menu>
{menus.map((item, i) => (
<Menu.Item key={`item_${i}`}>
{item}
</Menu.Item>
))}
</Menu>
);
}}
>
查看
</Dropdown.Button>
);
}