|
@@ -0,0 +1,150 @@
|
|
1
|
+import { deleteBanner, getBannerList, updataBanner } from '@/services/api/rotationChart';
|
|
2
|
+import { queryTable } from '@/utils/request';
|
|
3
|
+import { PageContainer, ProTable } from '@ant-design/pro-components';
|
|
4
|
+import { history } from '@umijs/max';
|
|
5
|
+import { Button, message, Popconfirm } from 'antd';
|
|
6
|
+import { useRef, useState } from 'react';
|
|
7
|
+
|
|
8
|
+const List = (props) => {
|
|
9
|
+ console.log(props, '===');
|
|
10
|
+ const [showDetail, setShowDetail] = useState(false);
|
|
11
|
+ const [activeKey, setActiveKey] = useState('');
|
|
12
|
+ const actionRef = useRef();
|
|
13
|
+
|
|
14
|
+ const updata = (row) => {
|
|
15
|
+ if (row.id) {
|
|
16
|
+ updataBanner(row.id, { state: row.state === '1' ? '2' : '1' }).then((res) => {
|
|
17
|
+ message.success('修改成功');
|
|
18
|
+ actionRef.current.reload();
|
|
19
|
+ });
|
|
20
|
+ }
|
|
21
|
+ };
|
|
22
|
+
|
|
23
|
+ const handleDelete = (id) => {
|
|
24
|
+ if (id) {
|
|
25
|
+ deleteBanner(id).then((res) => {
|
|
26
|
+ message.success('删除成功');
|
|
27
|
+ actionRef.current.reload();
|
|
28
|
+ });
|
|
29
|
+ }
|
|
30
|
+ };
|
|
31
|
+
|
|
32
|
+ const columns = [
|
|
33
|
+ {
|
|
34
|
+ title: 'id',
|
|
35
|
+ dataIndex: 'id',
|
|
36
|
+ },
|
|
37
|
+ {
|
|
38
|
+ title: '监控',
|
|
39
|
+ dataIndex: 'title',
|
|
40
|
+ },
|
|
41
|
+ {
|
|
42
|
+ title: '封面图',
|
|
43
|
+ dataIndex: 'image',
|
|
44
|
+ render: t => !t || '-' === t ? t : <img src={t} style={{ width: '96px', borderRadius: '6px' }} />
|
|
45
|
+ },
|
|
46
|
+
|
|
47
|
+ {
|
|
48
|
+ title: '视频',
|
|
49
|
+ dataIndex: 'video',
|
|
50
|
+ render: () => '-',
|
|
51
|
+ },
|
|
52
|
+ {
|
|
53
|
+ title: '状态',
|
|
54
|
+ dataIndex: 'state',
|
|
55
|
+ valueEnum: {
|
|
56
|
+ 1: {
|
|
57
|
+ text: '上架',
|
|
58
|
+ status: 'Processing',
|
|
59
|
+ },
|
|
60
|
+ 2: {
|
|
61
|
+ text: '下架',
|
|
62
|
+ status: 'Error',
|
|
63
|
+ },
|
|
64
|
+ },
|
|
65
|
+ },
|
|
66
|
+ // {
|
|
67
|
+ // title: '描述',
|
|
68
|
+ // dataIndex: 'desc',
|
|
69
|
+ // },
|
|
70
|
+ {
|
|
71
|
+ title: '权重',
|
|
72
|
+ dataIndex: 'qz',
|
|
73
|
+ },
|
|
74
|
+ {
|
|
75
|
+ title: '操作',
|
|
76
|
+ valueType: 'option',
|
|
77
|
+ width: 200,
|
|
78
|
+ render: (_, record) => [
|
|
79
|
+ <Button
|
|
80
|
+ key={1}
|
|
81
|
+ style={{ padding: 0 }}
|
|
82
|
+ type="link"
|
|
83
|
+ onClick={() => {
|
|
84
|
+ updata(record);
|
|
85
|
+ }}
|
|
86
|
+ >
|
|
87
|
+ {record.state === '1' ? '下架' : '上架'}
|
|
88
|
+ </Button>,
|
|
89
|
+ <Button
|
|
90
|
+ key={2}
|
|
91
|
+ style={{ padding: 0 }}
|
|
92
|
+ type="link"
|
|
93
|
+ onClick={() => {
|
|
94
|
+ console.log(record, ']]');
|
|
95
|
+ history.push(`/rotationChart/add?id=${record.id}`);
|
|
96
|
+ }}
|
|
97
|
+ >
|
|
98
|
+ 编辑
|
|
99
|
+ </Button>,
|
|
100
|
+
|
|
101
|
+ <Popconfirm
|
|
102
|
+ key={3}
|
|
103
|
+ title="您是否确认删除 ?"
|
|
104
|
+ onConfirm={() => handleDelete(record.id)}
|
|
105
|
+ okText="确定"
|
|
106
|
+ cancelText="取消"
|
|
107
|
+ >
|
|
108
|
+ {/* manualPush */}
|
|
109
|
+ <Button style={{ padding: 0 }} type="link">
|
|
110
|
+ 删除
|
|
111
|
+ </Button>
|
|
112
|
+ </Popconfirm>,
|
|
113
|
+ ],
|
|
114
|
+ },
|
|
115
|
+ ];
|
|
116
|
+
|
|
117
|
+ return (
|
|
118
|
+ <PageContainer>
|
|
119
|
+ <ProTable
|
|
120
|
+ // headerTitle={'中高风险地区库'}
|
|
121
|
+ search={false}
|
|
122
|
+ actionRef={actionRef}
|
|
123
|
+ rowKey="id"
|
|
124
|
+ toolBarRender={() => [
|
|
125
|
+ <Button
|
|
126
|
+ key="2"
|
|
127
|
+ type="primary"
|
|
128
|
+ onClick={() => {
|
|
129
|
+ history.push('/rotationChart/add');
|
|
130
|
+ }}
|
|
131
|
+ >
|
|
132
|
+ 新增
|
|
133
|
+ </Button>,
|
|
134
|
+ // <EditForm
|
|
135
|
+ // key="2"
|
|
136
|
+ // type="add"
|
|
137
|
+ // butttomTitle="新增轮播图"
|
|
138
|
+ // onSuccess={() => actionRef.current.reload()}
|
|
139
|
+ // butttomProps={{}}
|
|
140
|
+ // />,
|
|
141
|
+ ]}
|
|
142
|
+ // search={false}
|
|
143
|
+ request={queryTable(getBannerList)}
|
|
144
|
+ columns={columns}
|
|
145
|
+ />
|
|
146
|
+ </PageContainer>
|
|
147
|
+ );
|
|
148
|
+};
|
|
149
|
+
|
|
150
|
+export default RotationChartList;
|