|
@@ -0,0 +1,210 @@
|
|
1
|
+import React, { useState, useEffect } from 'react';
|
|
2
|
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert } from 'antd';
|
|
3
|
+import moment from 'moment';
|
|
4
|
+import request from '../../../utils/request';
|
|
5
|
+import apis from '../../../services/apis';
|
|
6
|
+import Styles from './style.less';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+const { Option } = Select;
|
|
10
|
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+const { Meta } = Card;
|
|
12
|
+
|
|
13
|
+const tempDate = [{ code: 's101' }]
|
|
14
|
+
|
|
15
|
+/**
|
|
16
|
+ *卡片
|
|
17
|
+ *
|
|
18
|
+ * @returns
|
|
19
|
+ */
|
|
20
|
+function CartBody(props) {
|
|
21
|
+ const { data } = props
|
|
22
|
+ console.log(props);
|
|
23
|
+ return (
|
|
24
|
+ <Card
|
|
25
|
+ hoverable
|
|
26
|
+ style={{ minWidth: '400px', borderRadius: '12px', margin: '10px', boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)' }}
|
|
27
|
+ cover={<img alt="example" src={ data.newsImg } style={{ borderRadius: '12px 12px 0 0', width: '100%', height: '14vw' }}></img>}
|
|
28
|
+ bodyStyle={{ padding: '10px 20px' }}
|
|
29
|
+ >
|
|
30
|
+ <p className={Styles.cardText}>
|
|
31
|
+ <span className={Styles.title}>资讯类型</span>
|
|
32
|
+ <span >:{ data.newsType.newsTypeName }</span>
|
|
33
|
+ <span className={Styles.ediText}>
|
|
34
|
+ 编辑
|
|
35
|
+ <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
|
|
36
|
+ </span>
|
|
37
|
+ </p>
|
|
38
|
+ <p className={Styles.cardText}>
|
|
39
|
+ <span className={Styles.title}>状态</span>
|
|
40
|
+ <span >:{ data.status == '0' ? "已发布" : "未发布" }</span>
|
|
41
|
+ </p>
|
|
42
|
+ <p className={Styles.cardItem}>
|
|
43
|
+ <span className={Styles.title}>阅读数量</span>
|
|
44
|
+ <span > :{ data.pvNum }</span>
|
|
45
|
+ </p>
|
|
46
|
+ <p className={Styles.cardItem}>
|
|
47
|
+ <span className={Styles.title}>转发数量</span>
|
|
48
|
+ <span className={ Styles.address }>:{ data.shareNum }</span>
|
|
49
|
+ </p>
|
|
50
|
+ <p className={Styles.cardItem}>
|
|
51
|
+ <span className={Styles.title}>点赞数量</span>
|
|
52
|
+ <span >:{ data.favorNum }</span>
|
|
53
|
+ </p>
|
|
54
|
+ <p className={Styles.cardItem}>
|
|
55
|
+ <span className={Styles.title}>收藏数量</span>
|
|
56
|
+ <span >:{ data.saveNum }</span>
|
|
57
|
+ </p>
|
|
58
|
+ <p className={Styles.cardItem}>
|
|
59
|
+ <span className={Styles.title}>录入时间</span>
|
|
60
|
+ <span >:{ data.createDate }</span>
|
|
61
|
+ </p>
|
|
62
|
+ <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
|
|
63
|
+ <span style={{ color: '#1990FF' }}>
|
|
64
|
+ 取消发布
|
|
65
|
+ <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
|
|
66
|
+ </span>
|
|
67
|
+ <span style={{
|
|
68
|
+ color: '#FF4A4A', position: 'absolute', right: '0',
|
|
69
|
+ }} >
|
|
70
|
+ 删除
|
|
71
|
+ <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
|
|
72
|
+ </span>
|
|
73
|
+ </p>
|
|
74
|
+ </Card>
|
|
75
|
+ )
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+/**
|
|
79
|
+ *
|
|
80
|
+ *
|
|
81
|
+ * @param {*} props
|
|
82
|
+ * @returns
|
|
83
|
+ */
|
|
84
|
+function body(props) {
|
|
85
|
+ const { getFieldDecorator } = props.form
|
|
86
|
+
|
|
87
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
88
|
+ const [dataSource, setDataSource] = useState({ records: [] })
|
|
89
|
+
|
|
90
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
91
|
+ useEffect(() => {
|
|
92
|
+ getList({ pageNum: 1, pageSize: 6 })
|
|
93
|
+ }, [])
|
|
94
|
+
|
|
95
|
+ function getList(params) {
|
|
96
|
+ // 网路请求
|
|
97
|
+ request({ ...apis.news.getList, params: { ...params } }).then(res => {
|
|
98
|
+ setDataSource(res)
|
|
99
|
+ }).catch(err => {
|
|
100
|
+ // eslint-disable-next-line no-unused-expressions
|
|
101
|
+ <Alert
|
|
102
|
+ style={{
|
|
103
|
+ marginBottom: 24,
|
|
104
|
+ }}
|
|
105
|
+ message={err}
|
|
106
|
+ type="error"
|
|
107
|
+ showIcon
|
|
108
|
+ />
|
|
109
|
+ })
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ // 提交事件
|
|
113
|
+ function handleSubmit(e) {
|
|
114
|
+ e.preventDefault();
|
|
115
|
+ props.form.validateFields((err, values) => {
|
|
116
|
+ if (!err) {
|
|
117
|
+ // eslint-disable-next-line no-console
|
|
118
|
+ console.log('提交数据: ', values)
|
|
119
|
+ const { startDate } = values
|
|
120
|
+ getList({ pageNum: 1, pageSize: 9, ...values })
|
|
121
|
+ }
|
|
122
|
+ });
|
|
123
|
+ }
|
|
124
|
+
|
|
125
|
+ // Change 事件
|
|
126
|
+ function handleSelectChange(e) {
|
|
127
|
+ // eslint-disable-next-line no-console
|
|
128
|
+ console.log(e)
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ // 分页
|
|
132
|
+ function onChange(pageNumber) {
|
|
133
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
134
|
+ getList({ pageNum: pageNumber, pageSize: 9 })
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ function getDate(value, dateString) {
|
|
138
|
+ // moment(value).format('YYYY-MM-DD HH:mm:ss')
|
|
139
|
+ console.log(value, dateString)
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ return (
|
|
143
|
+ <>
|
|
144
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
|
145
|
+
|
|
146
|
+ <Form.Item>
|
|
147
|
+ {getFieldDecorator('city')(
|
|
148
|
+ <Select style={{ width: '180px' }} placeholder="请选择城市" onChange={handleSelectChange}>
|
|
149
|
+ </Select>,
|
|
150
|
+ )}
|
|
151
|
+ </Form.Item>
|
|
152
|
+
|
|
153
|
+ <Form.Item>
|
|
154
|
+ {getFieldDecorator('project')(
|
|
155
|
+ <Select style={{ width: '180px' }} placeholder="请选择项目" onChange={handleSelectChange}>
|
|
156
|
+ </Select>,
|
|
157
|
+ )}
|
|
158
|
+ </Form.Item>
|
|
159
|
+ <Form.Item>
|
|
160
|
+ {getFieldDecorator('title')(
|
|
161
|
+ <Input
|
|
162
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
163
|
+ placeholder="请输入标题"
|
|
164
|
+ />,
|
|
165
|
+ )}
|
|
166
|
+ </Form.Item>
|
|
167
|
+ <Form.Item>
|
|
168
|
+ {getFieldDecorator('type')(
|
|
169
|
+ <Select style={{ width: '180px' }} placeholder="咨询类型" onChange={handleSelectChange}>
|
|
170
|
+ </Select>,
|
|
171
|
+ )}
|
|
172
|
+ </Form.Item>
|
|
173
|
+ <Form.Item>
|
|
174
|
+ {getFieldDecorator('newsStatus')(
|
|
175
|
+ <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
|
|
176
|
+ <Option value="1">已发布</Option>
|
|
177
|
+ <Option value="0">未发布</Option>
|
|
178
|
+ </Select>,
|
|
179
|
+ )}
|
|
180
|
+ </Form.Item>
|
|
181
|
+ <Form.Item>
|
|
182
|
+ <Button type="primary" htmlType="submit" className={Styles.SubmitButton}>
|
|
183
|
+ 搜索
|
|
184
|
+ </Button>
|
|
185
|
+ </Form.Item>
|
|
186
|
+ </Form>
|
|
187
|
+ <Button type="primary" className={Styles.addButton}>
|
|
188
|
+ 新增
|
|
189
|
+ </Button>
|
|
190
|
+
|
|
191
|
+ {/* 卡片内容,显示楼盘项目 */}
|
|
192
|
+ <Row style={{ padding: ' 0 10px' }}>
|
|
193
|
+ {
|
|
194
|
+ dataSource.records.map((item, index) => (
|
|
195
|
+ <Col span={8}>
|
|
196
|
+ <CartBody data={item} key={item.buildingId}/>
|
|
197
|
+ </Col>
|
|
198
|
+ ))
|
|
199
|
+ }
|
|
200
|
+ </Row>
|
|
201
|
+ {/* 分页 */}
|
|
202
|
+ <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
203
|
+ <Pagination showQuickJumper defaultCurrent={1} total={dataSource.total} onChange={onChange} />
|
|
204
|
+ </div>
|
|
205
|
+ </>
|
|
206
|
+ );
|
|
207
|
+}
|
|
208
|
+const WrappedBody = Form.create({ name: 'body' })(body);
|
|
209
|
+
|
|
210
|
+export default WrappedBody
|