|
@@ -6,6 +6,8 @@ import request from '../../../utils/request';
|
6
|
6
|
import apis from '../../../services/apis';
|
7
|
7
|
import Styles from './style.less';
|
8
|
8
|
import NewsTypeSelect from '../../../components/SelectButton/NewTypeSelect'
|
|
9
|
+import BuildSelect from '../../../components/SelectButton/BuildSelect'
|
|
10
|
+import SelectCity from '../../../components/SelectButton/CitySelect'
|
9
|
11
|
|
10
|
12
|
|
11
|
13
|
const { Option } = Select;
|
|
@@ -14,6 +16,64 @@ const { Meta } = Card;
|
14
|
16
|
|
15
|
17
|
const tempDate = [{ code: 's101' }]
|
16
|
18
|
|
|
19
|
+/**
|
|
20
|
+ *
|
|
21
|
+ *
|
|
22
|
+ * @param {*} props
|
|
23
|
+ * @returns
|
|
24
|
+ */
|
|
25
|
+function body(props) {
|
|
26
|
+ const { getFieldDecorator } = props.form
|
|
27
|
+
|
|
28
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
29
|
+ const [dataSource, setDataSource] = useState({ records: [] })
|
|
30
|
+
|
|
31
|
+ // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
32
|
+ useEffect(() => {
|
|
33
|
+ getList({ pageNum: 1, pageSize: 6 })
|
|
34
|
+ }, [])
|
|
35
|
+
|
|
36
|
+ function getList(params) {
|
|
37
|
+ // 网路请求
|
|
38
|
+ request({ ...apis.news.getList, params: { ...params } }).then(res => {
|
|
39
|
+ setDataSource(res)
|
|
40
|
+ }).catch(err => {
|
|
41
|
+ // eslint-disable-next-line no-unused-expressions
|
|
42
|
+ <Alert
|
|
43
|
+ style={{
|
|
44
|
+ marginBottom: 24,
|
|
45
|
+ }}
|
|
46
|
+ message={err}
|
|
47
|
+ type="error"
|
|
48
|
+ showIcon
|
|
49
|
+ />
|
|
50
|
+ })
|
|
51
|
+ }
|
|
52
|
+
|
|
53
|
+ // 提交事件
|
|
54
|
+ function handleSubmit(e) {
|
|
55
|
+ e.preventDefault();
|
|
56
|
+ props.form.validateFields((err, values) => {
|
|
57
|
+ if (!err) {
|
|
58
|
+ console.log('提交数据: ', values)
|
|
59
|
+ const { startDate } = values
|
|
60
|
+ getList({ pageNum: 1, pageSize: 6, ...values })
|
|
61
|
+ }
|
|
62
|
+ });
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ // 跳转到编辑资讯列表
|
|
66
|
+ const toEditList = (id) => () => {
|
|
67
|
+ router.push({
|
|
68
|
+ pathname: '/news/list/editNewsList',
|
|
69
|
+ query: {
|
|
70
|
+ id
|
|
71
|
+ },
|
|
72
|
+ });
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
17
|
77
|
/**
|
18
|
78
|
*卡片
|
19
|
79
|
*
|
|
@@ -28,17 +88,6 @@ function CartBody(props) {
|
28
|
88
|
});
|
29
|
89
|
}
|
30
|
90
|
|
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
|
91
|
//删除资讯
|
43
|
92
|
const changeNewsListStatus = (newsId) => () => {
|
44
|
93
|
Modal.confirm({
|
|
@@ -70,25 +119,45 @@ function CartBody(props) {
|
70
|
119
|
|
71
|
120
|
function cancelRelease (newsId, newsStatus, buildingId,newsTypeId) {
|
72
|
121
|
console.log("newsId" + newsId + "status" + newsStatus);
|
73
|
|
- Modal.confirm({
|
74
|
|
- title: '确认发布或取消该资讯?',
|
75
|
|
- okText: '确认',
|
76
|
|
- cancelText: '取消',
|
77
|
|
- onOk () {
|
78
|
|
- request({
|
79
|
|
- url: '/api/admin/taNews/' + newsId,
|
80
|
|
- method: 'PUT',
|
81
|
|
- data: { "newsStatus": newsStatus, "buildingId":buildingId, "newsTypeId":newsTypeId },
|
82
|
|
- }).then((data) => {
|
83
|
|
- message.info('操作成功!')
|
84
|
|
- getList({ pageNum: 1, pageSize: 10 });
|
85
|
|
- })
|
86
|
|
- },
|
87
|
|
- onCancel () {
|
88
|
|
- console.log('Cancel');
|
89
|
|
- },
|
90
|
|
- });
|
91
|
|
-
|
|
122
|
+ if (newsStatus === 1){
|
|
123
|
+ Modal.confirm({
|
|
124
|
+ title: '确认取消该资讯?',
|
|
125
|
+ okText: '确认',
|
|
126
|
+ cancelText: '取消',
|
|
127
|
+ onOk () {
|
|
128
|
+ request({
|
|
129
|
+ url: '/api/admin/taNews/' + newsId,
|
|
130
|
+ method: 'PUT',
|
|
131
|
+ data: { "newsStatus": newsStatus, "buildingId":buildingId, "newsTypeId":newsTypeId },
|
|
132
|
+ }).then((data) => {
|
|
133
|
+ message.info('操作成功!')
|
|
134
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
135
|
+ })
|
|
136
|
+ },
|
|
137
|
+ onCancel () {
|
|
138
|
+ console.log('Cancel');
|
|
139
|
+ },
|
|
140
|
+ });
|
|
141
|
+ }else if (newsStatus === 0){
|
|
142
|
+ Modal.confirm({
|
|
143
|
+ title: '确认发布该资讯?',
|
|
144
|
+ okText: '确认',
|
|
145
|
+ cancelText: '取消',
|
|
146
|
+ onOk () {
|
|
147
|
+ request({
|
|
148
|
+ url: '/api/admin/taNews/' + newsId,
|
|
149
|
+ method: 'PUT',
|
|
150
|
+ data: { "newsStatus": newsStatus, "buildingId":buildingId, "newsTypeId":newsTypeId },
|
|
151
|
+ }).then((data) => {
|
|
152
|
+ message.info('操作成功!')
|
|
153
|
+ getList({ pageNum: 1, pageSize: 10 });
|
|
154
|
+ })
|
|
155
|
+ },
|
|
156
|
+ onCancel () {
|
|
157
|
+ console.log('Cancel');
|
|
158
|
+ },
|
|
159
|
+ });
|
|
160
|
+ }
|
92
|
161
|
}
|
93
|
162
|
|
94
|
163
|
return (
|
|
@@ -153,63 +222,6 @@ function CartBody(props) {
|
153
|
222
|
)
|
154
|
223
|
}
|
155
|
224
|
|
156
|
|
-/**
|
157
|
|
- *
|
158
|
|
- *
|
159
|
|
- * @param {*} props
|
160
|
|
- * @returns
|
161
|
|
- */
|
162
|
|
-function body(props) {
|
163
|
|
- const { getFieldDecorator } = props.form
|
164
|
|
-
|
165
|
|
- // eslint-disable-next-line react-hooks/rules-of-hooks
|
166
|
|
- const [dataSource, setDataSource] = useState({ records: [] })
|
167
|
|
-
|
168
|
|
- // eslint-disable-next-line react-hooks/rules-of-hooks
|
169
|
|
- useEffect(() => {
|
170
|
|
- getList({ pageNum: 1, pageSize: 6 })
|
171
|
|
- }, [])
|
172
|
|
-
|
173
|
|
- function getList(params) {
|
174
|
|
- // 网路请求
|
175
|
|
- request({ ...apis.news.getList, params: { ...params } }).then(res => {
|
176
|
|
- setDataSource(res)
|
177
|
|
- }).catch(err => {
|
178
|
|
- // eslint-disable-next-line no-unused-expressions
|
179
|
|
- <Alert
|
180
|
|
- style={{
|
181
|
|
- marginBottom: 24,
|
182
|
|
- }}
|
183
|
|
- message={err}
|
184
|
|
- type="error"
|
185
|
|
- showIcon
|
186
|
|
- />
|
187
|
|
- })
|
188
|
|
- }
|
189
|
|
-
|
190
|
|
- // 提交事件
|
191
|
|
- function handleSubmit(e) {
|
192
|
|
- e.preventDefault();
|
193
|
|
- props.form.validateFields((err, values) => {
|
194
|
|
- if (!err) {
|
195
|
|
- // eslint-disable-next-line no-console
|
196
|
|
- console.log('提交数据: ', values)
|
197
|
|
- const { startDate } = values
|
198
|
|
- getList({ pageNum: 1, pageSize: 9, ...values })
|
199
|
|
- }
|
200
|
|
- });
|
201
|
|
- }
|
202
|
|
-
|
203
|
|
- // 跳转到编辑资讯列表
|
204
|
|
- const toEditList = (id) => () => {
|
205
|
|
- router.push({
|
206
|
|
- pathname: '/news/list/editNewsList',
|
207
|
|
- query: {
|
208
|
|
- id
|
209
|
|
- },
|
210
|
|
- });
|
211
|
|
- }
|
212
|
|
-
|
213
|
225
|
|
214
|
226
|
// Change 事件
|
215
|
227
|
function handleSelectChange(e) {
|
|
@@ -220,7 +232,7 @@ function body(props) {
|
220
|
232
|
// 分页
|
221
|
233
|
function onChange(pageNumber) {
|
222
|
234
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
223
|
|
- getList({ pageNum: pageNumber, pageSize: 9 })
|
|
235
|
+ getList({ pageNum: pageNumber, pageSize: 6 })
|
224
|
236
|
}
|
225
|
237
|
|
226
|
238
|
function getDate(value, dateString) {
|
|
@@ -233,17 +245,14 @@ function body(props) {
|
233
|
245
|
<Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
234
|
246
|
|
235
|
247
|
<Form.Item>
|
236
|
|
- {getFieldDecorator('city')(
|
237
|
|
- <Select style={{ width: '180px' }} placeholder="请选择城市" onChange={handleSelectChange}>
|
238
|
|
- </Select>,
|
|
248
|
+ {getFieldDecorator('cityId')(
|
|
249
|
+ <SelectCity />,
|
239
|
250
|
)}
|
240
|
251
|
</Form.Item>
|
241
|
|
-
|
242
|
252
|
<Form.Item>
|
243
|
|
- {getFieldDecorator('project')(
|
244
|
|
- <Select style={{ width: '180px' }} placeholder="请选择项目" onChange={handleSelectChange}>
|
245
|
|
- </Select>,
|
246
|
|
- )}
|
|
253
|
+ {getFieldDecorator('buildingId')(
|
|
254
|
+ <BuildSelect />,
|
|
255
|
+ )}
|
247
|
256
|
</Form.Item>
|
248
|
257
|
<Form.Item>
|
249
|
258
|
{getFieldDecorator('title')(
|
|
@@ -254,13 +263,13 @@ function body(props) {
|
254
|
263
|
)}
|
255
|
264
|
</Form.Item>
|
256
|
265
|
<Form.Item>
|
257
|
|
- {getFieldDecorator('buildingId')(
|
|
266
|
+ {getFieldDecorator('newsTypeId')(
|
258
|
267
|
<NewsTypeSelect />,
|
259
|
268
|
)}
|
260
|
269
|
</Form.Item>
|
261
|
270
|
<Form.Item>
|
262
|
271
|
{getFieldDecorator('newsStatus')(
|
263
|
|
- <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
|
|
272
|
+ <Select style={{ width: '180px' }} placeholder="状态">
|
264
|
273
|
<Option value="0">已发布</Option>
|
265
|
274
|
<Option value="1">未发布</Option>
|
266
|
275
|
</Select>,
|