|
@@ -0,0 +1,176 @@
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
|
3
|
+import { Form, Pagination, Card, Button, Icon, Tooltip, message, notification, Modal, Table } from 'antd';
|
|
4
|
+import router from 'umi/router';
|
|
5
|
+import moment from 'moment';
|
|
6
|
+import className from 'classnames';
|
|
7
|
+import Cell from '../../../components/Cell';
|
|
8
|
+import styles from './style.less';
|
|
9
|
+import { fetch, apis } from '../../../utils/request';
|
|
10
|
+import request from '../../../utils/request';
|
|
11
|
+import AuthButton from '@/components/AuthButton';
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+function header(props) {
|
|
16
|
+ // 获取初始化数据
|
|
17
|
+ const [ data, setData ] = useState({})
|
|
18
|
+
|
|
19
|
+ useEffect(() => {
|
|
20
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
21
|
+ },[])
|
|
22
|
+
|
|
23
|
+ // 查询列表
|
|
24
|
+ const getList = (params) => {
|
|
25
|
+ request({ ...apis.channel.list, params: { ...params } }).then((data) => {
|
|
26
|
+ console.log(data)
|
|
27
|
+ setData(data)
|
|
28
|
+ })
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+ // 提交事件
|
|
33
|
+ const handleSubmit = (e, props) => {
|
|
34
|
+ e.preventDefault();
|
|
35
|
+ props.form.validateFields((err, values) => {
|
|
36
|
+ if (!err) {
|
|
37
|
+ getList({ pageNum: 1, pageSize: 10, ...values })
|
|
38
|
+ }
|
|
39
|
+ });
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ const changePageNum = (pageNumber) => {
|
|
43
|
+ getList({ pageNum: pageNumber, pageSize: 10 })
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+ // 跳转到编辑资讯
|
|
48
|
+ const toEditNews = (id) => () => {
|
|
49
|
+ router.push({
|
|
50
|
+ pathname: '/channel/edit',
|
|
51
|
+ query: {
|
|
52
|
+ id
|
|
53
|
+ },
|
|
54
|
+ });
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+ const changeNewsStatus = (row, newsId) => () => {
|
|
59
|
+ const title = row.status === 0 ? '确定启用吗': '停用后,此账号将无法登录渠道代理商后台'
|
|
60
|
+ Modal.confirm({
|
|
61
|
+ title: title,
|
|
62
|
+ okText: '确认',
|
|
63
|
+ cancelText: '取消',
|
|
64
|
+ onOk() {
|
|
65
|
+ if(row.status === 0){
|
|
66
|
+ request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 1 } }).then((data) => {
|
|
67
|
+ message.info('操作成功!')
|
|
68
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
69
|
+ }).catch((err) => {
|
|
70
|
+ console.log(err)
|
|
71
|
+ message.info(err.msg || err.message)
|
|
72
|
+ })
|
|
73
|
+ }else{
|
|
74
|
+ request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 0 } }).then((data) => {
|
|
75
|
+ message.info('操作成功!')
|
|
76
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
77
|
+ }).catch((err) => {
|
|
78
|
+ console.log(err)
|
|
79
|
+ message.info(err.msg || err.message)
|
|
80
|
+ })
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ }
|
|
84
|
+ });
|
|
85
|
+ }
|
|
86
|
+ /**
|
|
87
|
+ *
|
|
88
|
+ *
|
|
89
|
+ * @param {*} props
|
|
90
|
+ * @returns
|
|
91
|
+ */
|
|
92
|
+ const columns = [
|
|
93
|
+ {
|
|
94
|
+ title: '渠道代理',
|
|
95
|
+ dataIndex: 'channelProxyName',
|
|
96
|
+ key: 'channelProxyName',
|
|
97
|
+ align: 'center',
|
|
98
|
+ },
|
|
99
|
+ {
|
|
100
|
+ title: '账号名',
|
|
101
|
+ dataIndex: 'userName',
|
|
102
|
+ key: 'userName',
|
|
103
|
+ align: 'center',
|
|
104
|
+ render: (x, row) => <span>{row.userName === null || row.userName === '' ? row.channelTel : row.userName}</span>,
|
|
105
|
+ },
|
|
106
|
+ {
|
|
107
|
+ title: '小程序总数',
|
|
108
|
+ dataIndex: 'appMaxNum',
|
|
109
|
+ key: 'appMaxNum',
|
|
110
|
+ align: 'center',
|
|
111
|
+
|
|
112
|
+ },
|
|
113
|
+ {
|
|
114
|
+ title: '现有小程序',
|
|
115
|
+ dataIndex: 'appCurrentNum',
|
|
116
|
+ key: 'appCurrentNum',
|
|
117
|
+ align: 'center',
|
|
118
|
+ render: (appCurrentNum) => <span>{appCurrentNum === 0 || appCurrentNum == null ? 0 : appCurrentNum}</span>,
|
|
119
|
+ },
|
|
120
|
+ {
|
|
121
|
+ title: '服务到期时间',
|
|
122
|
+ dataIndex: 'expireDate',
|
|
123
|
+ key: 'expireDate',
|
|
124
|
+ align: 'center',
|
|
125
|
+ render: (x, row) => <><span>{`${moment(row.expireDate).format('YYYY-MM-DD')}`}</span></>,
|
|
126
|
+ },
|
|
127
|
+ {
|
|
128
|
+ title: '状态',
|
|
129
|
+ dataIndex: 'status',
|
|
130
|
+ key: 'status',
|
|
131
|
+ align: 'center',
|
|
132
|
+ render: (status) => <span>{status === 1 ? '启动' : '停用'}</span>,
|
|
133
|
+ },
|
|
134
|
+ {
|
|
135
|
+ title: '操作',
|
|
136
|
+ dataIndex: 'handle',
|
|
137
|
+ key: 'handle',
|
|
138
|
+ align: 'center',
|
|
139
|
+ render: (x, row) => (
|
|
140
|
+ <>
|
|
141
|
+ <AuthButton name="admin.taNewsType.id.delete" noRight={null}>
|
|
142
|
+ <span style={{ color: '#EF273A', marginRight: '20px', cursor: 'pointer' }} onClick={changeNewsStatus(row, row.channelId)}>
|
|
143
|
+ {row.status == 1 ? '停用' : '启用'}<Icon type="shopping-cart" className={styles.shoppingCart} />
|
|
144
|
+ </span>
|
|
145
|
+ </AuthButton>
|
|
146
|
+ <AuthButton name="admin.taNewsType.id.put" noRight={null}>
|
|
147
|
+ <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditNews(row.channelId)}>
|
|
148
|
+ 编辑<Icon type="form" className={styles.edit} />
|
|
149
|
+ </span>
|
|
150
|
+ </AuthButton>
|
|
151
|
+ </>
|
|
152
|
+ ),
|
|
153
|
+ },
|
|
154
|
+ ];
|
|
155
|
+ function handleReset() {
|
|
156
|
+ props.form.resetFields();
|
|
157
|
+ getList({ pageNum: 1, pageSize: 10 })
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ const { getFieldDecorator } = props.form
|
|
161
|
+ return (
|
|
162
|
+
|
|
163
|
+ <>
|
|
164
|
+ <AuthButton name="admin.taNewsType.post" noRight={null}>
|
|
165
|
+ <Button type="danger" className={styles.addBtn} onClick={toEditNews()}>新增</Button>
|
|
166
|
+ </AuthButton>
|
|
167
|
+ <Table rowKey="newsType" dataSource={data.records} columns={columns} pagination={false} />
|
|
168
|
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
169
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
|
|
170
|
+ </div>
|
|
171
|
+ </>
|
|
172
|
+ )
|
|
173
|
+}
|
|
174
|
+const WrappedHeader = Form.create({ name: 'header' })(header);
|
|
175
|
+
|
|
176
|
+export default WrappedHeader
|