|
@@ -1,9 +1,11 @@
|
1
|
1
|
import React, { useState, useEffect } from 'react';
|
2
|
|
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert } from 'antd';
|
|
2
|
+import { Form, Icon, Input, Button, DatePicker, Select, Modal, message, Card, Row, Col, Pagination, Alert } from 'antd';
|
3
|
3
|
import moment from 'moment';
|
|
4
|
+import router from 'umi/router';
|
4
|
5
|
import request from '../../../utils/request';
|
5
|
6
|
import apis from '../../../services/apis';
|
6
|
7
|
import Styles from './style.less';
|
|
8
|
+import NewsTypeSelect from '../../../components/SelectButton/NewTypeSelect'
|
7
|
9
|
|
8
|
10
|
|
9
|
11
|
const { Option } = Select;
|
|
@@ -19,7 +21,53 @@ const tempDate = [{ code: 's101' }]
|
19
|
21
|
*/
|
20
|
22
|
function CartBody(props) {
|
21
|
23
|
const { data } = props
|
22
|
|
- console.log(props);
|
|
24
|
+
|
|
25
|
+ const cancelPage = () =>{
|
|
26
|
+ router.push({
|
|
27
|
+ pathname: '/news/list/NewsList',
|
|
28
|
+ });
|
|
29
|
+ }
|
|
30
|
+
|
|
31
|
+ // 查询列表
|
|
32
|
+ const getList = (params) => {
|
|
33
|
+ request({
|
|
34
|
+ url: '/api/admin/taNews',
|
|
35
|
+ method: 'GET',
|
|
36
|
+ params: { ...params },
|
|
37
|
+ }).then((data) => {
|
|
38
|
+ cancelPage();
|
|
39
|
+ })
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ //删除资讯
|
|
43
|
+ const changeNewsListStatus = (newsId) => () => {
|
|
44
|
+ Modal.confirm({
|
|
45
|
+ title: '确认删除该资讯?',
|
|
46
|
+ okText: '确认',
|
|
47
|
+ cancelText: '取消',
|
|
48
|
+ onOk() {
|
|
49
|
+ request({
|
|
50
|
+ url: '/api/admin/taNews/' + newsId,
|
|
51
|
+ method: 'DELETE',
|
|
52
|
+ // data: { ...row },
|
|
53
|
+ }).then((data) => {
|
|
54
|
+ message.info('操作成功!')
|
|
55
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
56
|
+ })
|
|
57
|
+ }
|
|
58
|
+ });
|
|
59
|
+ }
|
|
60
|
+
|
|
61
|
+ // 跳转到编辑资讯列表
|
|
62
|
+ const toEditList = (newsId) => () => {
|
|
63
|
+ router.push({
|
|
64
|
+ pathname: '/news/list/editNewsList',
|
|
65
|
+ query: {
|
|
66
|
+ newsId
|
|
67
|
+ },
|
|
68
|
+ });
|
|
69
|
+ }
|
|
70
|
+
|
23
|
71
|
return (
|
24
|
72
|
<Card
|
25
|
73
|
hoverable
|
|
@@ -30,14 +78,14 @@ function CartBody(props) {
|
30
|
78
|
<p className={Styles.cardText}>
|
31
|
79
|
<span className={Styles.title}>资讯类型</span>
|
32
|
80
|
<span >:{ data.newsType.newsTypeName }</span>
|
33
|
|
- <span className={Styles.ediText}>
|
|
81
|
+ <span className={Styles.ediText} onClick={toEditList(data.newsId)}>
|
34
|
82
|
编辑
|
35
|
83
|
<Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
|
36
|
84
|
</span>
|
37
|
85
|
</p>
|
38
|
86
|
<p className={Styles.cardText}>
|
39
|
87
|
<span className={Styles.title}>状态</span>
|
40
|
|
- <span >:{ data.status == 0 ? "已发布" : "未发布" }</span>
|
|
88
|
+ <span >:{ data.newsStatus == 0 ? "已发布" : "未发布" }</span>
|
41
|
89
|
</p>
|
42
|
90
|
<p className={Styles.cardItem}>
|
43
|
91
|
<span className={Styles.title}>阅读数量</span>
|
|
@@ -45,7 +93,7 @@ function CartBody(props) {
|
45
|
93
|
</p>
|
46
|
94
|
<p className={Styles.cardItem}>
|
47
|
95
|
<span className={Styles.title}>转发数量</span>
|
48
|
|
- <span className={ Styles.address }>:{ data.shareNum }</span>
|
|
96
|
+ <span>:{ data.shareNum }</span>
|
49
|
97
|
</p>
|
50
|
98
|
<p className={Styles.cardItem}>
|
51
|
99
|
<span className={Styles.title}>点赞数量</span>
|
|
@@ -66,7 +114,7 @@ function CartBody(props) {
|
66
|
114
|
</span>
|
67
|
115
|
<span style={{
|
68
|
116
|
color: '#FF4A4A', position: 'absolute', right: '0',
|
69
|
|
- }} >
|
|
117
|
+ }} onClick={changeNewsListStatus(data.newsId)}>
|
70
|
118
|
删除
|
71
|
119
|
<Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
|
72
|
120
|
</span>
|
|
@@ -122,6 +170,17 @@ function body(props) {
|
122
|
170
|
});
|
123
|
171
|
}
|
124
|
172
|
|
|
173
|
+ // 跳转到编辑资讯列表
|
|
174
|
+ const toEditList = (id) => () => {
|
|
175
|
+ router.push({
|
|
176
|
+ pathname: '/news/list/editNewsList',
|
|
177
|
+ query: {
|
|
178
|
+ id
|
|
179
|
+ },
|
|
180
|
+ });
|
|
181
|
+ }
|
|
182
|
+
|
|
183
|
+
|
125
|
184
|
// Change 事件
|
126
|
185
|
function handleSelectChange(e) {
|
127
|
186
|
// eslint-disable-next-line no-console
|
|
@@ -165,9 +224,8 @@ function body(props) {
|
165
|
224
|
)}
|
166
|
225
|
</Form.Item>
|
167
|
226
|
<Form.Item>
|
168
|
|
- {getFieldDecorator('type')(
|
169
|
|
- <Select style={{ width: '180px' }} placeholder="咨询类型" onChange={handleSelectChange}>
|
170
|
|
- </Select>,
|
|
227
|
+ {getFieldDecorator('buildingId')(
|
|
228
|
+ <NewsTypeSelect />,
|
171
|
229
|
)}
|
172
|
230
|
</Form.Item>
|
173
|
231
|
<Form.Item>
|
|
@@ -184,7 +242,7 @@ function body(props) {
|
184
|
242
|
</Button>
|
185
|
243
|
</Form.Item>
|
186
|
244
|
</Form>
|
187
|
|
- <Button type="primary" className={Styles.addButton}>
|
|
245
|
+ <Button type="primary" className={Styles.addButton} onClick={toEditList()}>
|
188
|
246
|
新增
|
189
|
247
|
</Button>
|
190
|
248
|
|