|
@@ -1,6 +1,6 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
2
|
import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
3
|
|
-import { Form, Pagination, Card, Button, Icon, Tooltip, message, notification, Modal, Table, Select,Input, DatePicker,Row, Col } from 'antd';
|
|
3
|
+import { Form, Pagination, Card, Button, Icon, Tooltip, message, notification, Modal, Table, Select, Input, DatePicker, Row, Col } from 'antd';
|
4
|
4
|
import router from 'umi/router';
|
5
|
5
|
import moment from 'moment';
|
6
|
6
|
import className from 'classnames';
|
|
@@ -15,33 +15,33 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
|
15
|
15
|
|
16
|
16
|
function header(props) {
|
17
|
17
|
// 获取初始化数据
|
18
|
|
- const [ data, setData ] = useState({})
|
|
18
|
+ const [data, setData] = useState({})
|
19
|
19
|
|
20
|
20
|
useEffect(() => {
|
21
|
21
|
getList({ pageNum: 1, pageSize: 12 });
|
22
|
|
- },[])
|
|
22
|
+ }, [])
|
23
|
23
|
|
24
|
24
|
// 查询列表
|
25
|
25
|
const getList = (params) => {
|
26
|
26
|
request({ ...apis.sample.h5list, params: { ...params } }).then((data) => {
|
27
|
|
- console.log(data)
|
28
|
|
- setData(data)
|
|
27
|
+ console.log(data)
|
|
28
|
+ setData(data)
|
29
|
29
|
})
|
30
|
30
|
}
|
31
|
31
|
|
32
|
|
-
|
|
32
|
+
|
33
|
33
|
// 提交事件
|
34
|
34
|
const handleSubmit = (e, props) => {
|
35
|
35
|
e.preventDefault();
|
36
|
36
|
e.stopPropagation();
|
37
|
37
|
props.form.validateFields((err, values) => {
|
38
|
38
|
if (!err) {
|
39
|
|
- let {createDate, ...submitValue} = values
|
40
|
|
- if(null != createDate && createDate.length > 0){
|
|
39
|
+ let { createDate, ...submitValue } = values
|
|
40
|
+ if (null != createDate && createDate.length > 0) {
|
41
|
41
|
const [startCreateDate, endCreateDate] = createDate
|
42
|
42
|
submitValue.startCreateDate = moment(startCreateDate).format('YYYY-MM-DD');
|
43
|
43
|
submitValue.endCreateDate = moment(endCreateDate).format('YYYY-MM-DD');
|
44
|
|
- }else{
|
|
44
|
+ } else {
|
45
|
45
|
submitValue.startCreateDate = null
|
46
|
46
|
submitValue.endCreateDate = null
|
47
|
47
|
}
|
|
@@ -51,12 +51,12 @@ function header(props) {
|
51
|
51
|
}
|
52
|
52
|
|
53
|
53
|
const changePageNum = (pageNumber) => {
|
54
|
|
- let {createDate, ...submitValue} = props.form.getFieldsValue()
|
55
|
|
- if(null != createDate && createDate.length > 0){
|
|
54
|
+ let { createDate, ...submitValue } = props.form.getFieldsValue()
|
|
55
|
+ if (null != createDate && createDate.length > 0) {
|
56
|
56
|
const [startCreateDate, endCreateDate] = createDate
|
57
|
57
|
submitValue.startCreateDate = moment(startCreateDate).format('YYYY-MM-DD');
|
58
|
58
|
submitValue.endCreateDate = moment(endCreateDate).format('YYYY-MM-DD');
|
59
|
|
- }else{
|
|
59
|
+ } else {
|
60
|
60
|
submitValue.startCreateDate = null
|
61
|
61
|
submitValue.endCreateDate = null
|
62
|
62
|
}
|
|
@@ -74,15 +74,15 @@ function header(props) {
|
74
|
74
|
});
|
75
|
75
|
}
|
76
|
76
|
|
77
|
|
-
|
|
77
|
+
|
78
|
78
|
const changeNewsStatus = (row, newsId) => () => {
|
79
|
|
- const title = row.status === 0 ? '确定启用吗': '停用后,此账号将无法登录渠道代理商后台'
|
|
79
|
+ const title = row.status === 0 ? '确定启用吗' : '停用后,此账号将无法登录渠道代理商后台'
|
80
|
80
|
Modal.confirm({
|
81
|
81
|
title: title,
|
82
|
82
|
okText: '确认',
|
83
|
83
|
cancelText: '取消',
|
84
|
84
|
onOk() {
|
85
|
|
- if(row.status === 0){
|
|
85
|
+ if (row.status === 0) {
|
86
|
86
|
request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 1 } }).then((data) => {
|
87
|
87
|
message.info('操作成功!')
|
88
|
88
|
getList({ pageNum: 1, pageSize: 12 });
|
|
@@ -90,7 +90,7 @@ function header(props) {
|
90
|
90
|
console.log(err)
|
91
|
91
|
message.info(err.msg || err.message)
|
92
|
92
|
})
|
93
|
|
- }else{
|
|
93
|
+ } else {
|
94
|
94
|
request({ ...apis.channel.put, urlData: { id: newsId }, data: { ...row, status: 0 } }).then((data) => {
|
95
|
95
|
message.info('操作成功!')
|
96
|
96
|
getList({ pageNum: 1, pageSize: 12 });
|
|
@@ -99,11 +99,11 @@ function header(props) {
|
99
|
99
|
message.info(err.msg || err.message)
|
100
|
100
|
})
|
101
|
101
|
}
|
102
|
|
-
|
|
102
|
+
|
103
|
103
|
}
|
104
|
104
|
});
|
105
|
105
|
}
|
106
|
|
-
|
|
106
|
+
|
107
|
107
|
function handleReset() {
|
108
|
108
|
props.form.resetFields();
|
109
|
109
|
getList({ pageNum: 1, pageSize: 12 })
|
|
@@ -113,7 +113,7 @@ function header(props) {
|
113
|
113
|
return (
|
114
|
114
|
|
115
|
115
|
<>
|
116
|
|
- <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
|
116
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
117
|
117
|
<Form.Item>
|
118
|
118
|
{getFieldDecorator('sampleName')(
|
119
|
119
|
<Input
|
|
@@ -131,10 +131,10 @@ function header(props) {
|
131
|
131
|
)}
|
132
|
132
|
</Form.Item>
|
133
|
133
|
<Form.Item>
|
134
|
|
- <span style={{marginRight:'10px'}}>新增时间段:</span>
|
135
|
|
- {getFieldDecorator('createDate')(
|
136
|
|
- <RangePicker placeholder={['开始时间','结束时间']} />
|
137
|
|
- )}
|
|
134
|
+ <span style={{ marginRight: '10px' }}>新增时间段:</span>
|
|
135
|
+ {getFieldDecorator('createDate')(
|
|
136
|
+ <RangePicker placeholder={['开始时间', '结束时间']} />
|
|
137
|
+ )}
|
138
|
138
|
</Form.Item>
|
139
|
139
|
<Form.Item>
|
140
|
140
|
{getFieldDecorator('tag')(
|
|
@@ -149,21 +149,21 @@ function header(props) {
|
149
|
149
|
搜索
|
150
|
150
|
</Button>
|
151
|
151
|
<Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
152
|
|
- 重置
|
|
152
|
+ 重置
|
153
|
153
|
</Button>
|
154
|
154
|
</Form.Item>
|
155
|
155
|
</Form>
|
156
|
|
-
|
|
156
|
+
|
157
|
157
|
<Button type="danger" className={styles.addBtn} onClick={toEditH5()}>新增</Button>
|
158
|
|
- <Row>
|
159
|
|
- {(data.records || []).map(x => (
|
160
|
|
- <Col span={6}>
|
161
|
|
- <H5Card h5Data={x} onChange={handleReset}/>
|
162
|
|
- </Col>
|
163
|
|
- ))}
|
|
158
|
+ <Row>
|
|
159
|
+ {(data.records || []).map((x, index) => (
|
|
160
|
+ <Col key={index} span={6}>
|
|
161
|
+ <H5Card h5Data={x} onChange={handleReset} />
|
|
162
|
+ </Col>
|
|
163
|
+ ))}
|
164
|
164
|
</Row>
|
165
|
165
|
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
166
|
|
- <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
|
|
166
|
+ <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current} />
|
167
|
167
|
</div>
|
168
|
168
|
</>
|
169
|
169
|
)
|