|
@@ -5,83 +5,22 @@ import styles from '../../style/GoodsList.less';
|
5
|
5
|
import router from 'umi/router';
|
6
|
6
|
import BuildSelect from '../../../components/SelectButton/BuildSelect';
|
7
|
7
|
import AuthButton from '@/components/AuthButton';
|
8
|
|
-import apis from '../../../services/apis';
|
9
|
|
-import request from '../../../utils/request'
|
|
8
|
+// import apis from '../../../services/apis';
|
|
9
|
+import { fetchList, apis } from '../../../utils/request'
|
|
10
|
+import { withSearchList } from '@/layouts/SearchList'
|
10
|
11
|
|
11
|
12
|
const { Option } = Select;
|
|
13
|
+const SearchList = withSearchList()
|
|
14
|
+const getNewsTypeList = fetchList(apis.newsType.list)
|
12
|
15
|
|
13
|
|
-
|
14
|
|
-function header(props) {
|
15
|
|
- // 获取初始化数据
|
16
|
|
- const [ data, setData ] = useState({})
|
17
|
|
-
|
18
|
|
- useEffect(() => {
|
19
|
|
- getList({ pageNum: 1, pageSize: 10 });
|
20
|
|
- },[])
|
21
|
|
-
|
22
|
|
- // 查询列表
|
23
|
|
- const getList = (params) => {
|
24
|
|
- request({ ...apis.newsType.list, params: { ...params } }).then((data) => {
|
25
|
|
- console.log(data)
|
26
|
|
- setData(data)
|
27
|
|
- })
|
28
|
|
- }
|
29
|
|
-
|
30
|
|
-
|
31
|
|
- // 提交事件
|
32
|
|
- const handleSubmit = (e, props) => {
|
33
|
|
- e.preventDefault();
|
34
|
|
- props.form.validateFields((err, values) => {
|
35
|
|
- if (!err) {
|
36
|
|
- getList({ pageNum: 1, pageSize: 10, ...values })
|
37
|
|
- }
|
38
|
|
- });
|
39
|
|
- }
|
40
|
|
-
|
41
|
|
- const changePageNum = (pageNumber) => {
|
42
|
|
- props.form.validateFields((err, values) => {
|
43
|
|
- if (!err) {
|
44
|
|
- getList({ pageNum: pageNumber, pageSize: 10, ...values })
|
45
|
|
- }
|
46
|
|
- });
|
47
|
|
- }
|
48
|
|
-
|
49
|
|
-
|
50
|
|
- // 跳转到编辑资讯
|
51
|
|
- const toEditNews = (id) => () => {
|
52
|
|
- router.push({
|
53
|
|
- pathname: '/news/type/editNews',
|
54
|
|
- query: {
|
55
|
|
- id
|
56
|
|
- },
|
57
|
|
- });
|
58
|
|
- }
|
59
|
|
-
|
|
16
|
+export default function NewsType(props) {
|
|
17
|
+ const conditions = [
|
|
18
|
+ {
|
|
19
|
+ name: 'buildingId',
|
|
20
|
+ node: BuildSelect,
|
|
21
|
+ }
|
|
22
|
+ ]
|
60
|
23
|
|
61
|
|
- const changeNewsStatus = (row, newsId) => () => {
|
62
|
|
- Modal.confirm({
|
63
|
|
- title: '确认删除?',
|
64
|
|
- okText: '确认',
|
65
|
|
- cancelText: '取消',
|
66
|
|
- onOk() {
|
67
|
|
-
|
68
|
|
- request({ ...apis.newsType.put, urlData: { id: newsId }, data: { ...row, status: -1 } }).then((data) => {
|
69
|
|
- message.info('操作成功!')
|
70
|
|
- getList({ pageNum: 1, pageSize: 10 });
|
71
|
|
- }).catch((err) => {
|
72
|
|
- console.log(err)
|
73
|
|
- message.info(err.msg || err.message)
|
74
|
|
- })
|
75
|
|
-
|
76
|
|
- }
|
77
|
|
- });
|
78
|
|
- }
|
79
|
|
- /**
|
80
|
|
- *
|
81
|
|
- *
|
82
|
|
- * @param {*} props
|
83
|
|
- * @returns
|
84
|
|
- */
|
85
|
24
|
const columns = [
|
86
|
25
|
{
|
87
|
26
|
title: '类型图',
|
|
@@ -105,12 +44,12 @@ function header(props) {
|
105
|
44
|
render: (x, row) => (
|
106
|
45
|
<>
|
107
|
46
|
<AuthButton name="admin.taNewsType.id.delete" noRight={null}>
|
108
|
|
- <span style={{ color: '#EF273A', marginRight: '20px', cursor: 'pointer' }} onClick={changeNewsStatus(row, row.newsTypeId)}>
|
|
47
|
+ <span style={{ color: '#EF273A', marginRight: '20px', cursor: 'pointer' }}>
|
109
|
48
|
{row.status == 1 ? '删除' : '上架'}<Icon type="shopping-cart" className={styles.shoppingCart} />
|
110
|
49
|
</span>
|
111
|
50
|
</AuthButton>
|
112
|
51
|
<AuthButton name="admin.taNewsType.id.put" noRight={null}>
|
113
|
|
- <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditNews(row.newsTypeId)}>
|
|
52
|
+ <span style={{ color: '#FF925C', cursor: 'pointer' }}>
|
114
|
53
|
编辑<Icon type="form" className={styles.edit} />
|
115
|
54
|
</span>
|
116
|
55
|
</AuthButton>
|
|
@@ -118,42 +57,172 @@ function header(props) {
|
118
|
57
|
),
|
119
|
58
|
},
|
120
|
59
|
];
|
121
|
|
- function handleReset() {
|
122
|
|
- props.form.resetFields();
|
123
|
|
- getList({ pageNum: 1, pageSize: 10 })
|
124
|
|
- }
|
125
|
|
-
|
126
|
|
- const { getFieldDecorator } = props.form
|
127
|
|
- return (
|
|
60
|
+
|
128
|
61
|
|
129
|
|
- <>
|
130
|
|
- <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
131
|
|
- <Form.Item>
|
132
|
|
- {getFieldDecorator('buildingId')(
|
133
|
|
- <BuildSelect />,
|
134
|
|
- )}
|
135
|
|
- </Form.Item>
|
136
|
|
- <Form.Item>
|
137
|
|
- <AuthButton name="admin.taNewsType.search" noRight={null}>
|
138
|
|
- <Button type="primary" htmlType="submit" >
|
139
|
|
- 查询
|
140
|
|
- </Button>
|
141
|
|
- </AuthButton>
|
142
|
|
- <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
143
|
|
- 重置
|
144
|
|
- </Button>
|
145
|
|
- </Form.Item>
|
146
|
|
- </Form>
|
|
62
|
+ const renderActions = () => {
|
|
63
|
+ return (
|
147
|
64
|
<AuthButton name="admin.taNewsType.post" noRight={null}>
|
148
|
|
- <Button type="danger" className={styles.addBtn} onClick={toEditNews()}>新增</Button>
|
|
65
|
+ <Button type="danger" className={styles.addBtn}>新增</Button>
|
149
|
66
|
</AuthButton>
|
150
|
|
- <Table rowKey="newsType" dataSource={data.records} columns={columns} pagination={false} />
|
151
|
|
- <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
152
|
|
- <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
|
153
|
|
- </div>
|
154
|
|
- </>
|
|
67
|
+ );
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ return (
|
|
71
|
+ <SearchList
|
|
72
|
+ title="资讯类型"
|
|
73
|
+ actions={renderActions()}
|
|
74
|
+ service={getNewsTypeList}
|
|
75
|
+ search={{ fields: conditions }}
|
|
76
|
+ body={{ columns }}
|
|
77
|
+ pagination={{}}
|
|
78
|
+ />
|
155
|
79
|
)
|
156
|
80
|
}
|
157
|
|
-const WrappedHeader = Form.create({ name: 'header' })(header);
|
158
|
81
|
|
159
|
|
-export default WrappedHeader
|
|
82
|
+// function header(props) {
|
|
83
|
+// // 获取初始化数据
|
|
84
|
+// const [ data, setData ] = useState({})
|
|
85
|
+
|
|
86
|
+// useEffect(() => {
|
|
87
|
+// getList({ pageNum: 1, pageSize: 10 });
|
|
88
|
+// },[])
|
|
89
|
+
|
|
90
|
+// // 查询列表
|
|
91
|
+// const getList = (params) => {
|
|
92
|
+// request({ ...apis.newsType.list, params: { ...params } }).then((data) => {
|
|
93
|
+// console.log(data)
|
|
94
|
+// setData(data)
|
|
95
|
+// })
|
|
96
|
+// }
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+// // 提交事件
|
|
100
|
+// const handleSubmit = (e, props) => {
|
|
101
|
+// e.preventDefault();
|
|
102
|
+// props.form.validateFields((err, values) => {
|
|
103
|
+// if (!err) {
|
|
104
|
+// getList({ pageNum: 1, pageSize: 10, ...values })
|
|
105
|
+// }
|
|
106
|
+// });
|
|
107
|
+// }
|
|
108
|
+
|
|
109
|
+// const changePageNum = (pageNumber) => {
|
|
110
|
+// props.form.validateFields((err, values) => {
|
|
111
|
+// if (!err) {
|
|
112
|
+// getList({ pageNum: pageNumber, pageSize: 10, ...values })
|
|
113
|
+// }
|
|
114
|
+// });
|
|
115
|
+// }
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+// // 跳转到编辑资讯
|
|
119
|
+// const toEditNews = (id) => () => {
|
|
120
|
+// router.push({
|
|
121
|
+// pathname: '/news/type/editNews',
|
|
122
|
+// query: {
|
|
123
|
+// id
|
|
124
|
+// },
|
|
125
|
+// });
|
|
126
|
+// }
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+// const changeNewsStatus = (row, newsId) => () => {
|
|
130
|
+// Modal.confirm({
|
|
131
|
+// title: '确认删除?',
|
|
132
|
+// okText: '确认',
|
|
133
|
+// cancelText: '取消',
|
|
134
|
+// onOk() {
|
|
135
|
+
|
|
136
|
+// request({ ...apis.newsType.put, urlData: { id: newsId }, data: { ...row, status: -1 } }).then((data) => {
|
|
137
|
+// message.info('操作成功!')
|
|
138
|
+// getList({ pageNum: 1, pageSize: 10 });
|
|
139
|
+// }).catch((err) => {
|
|
140
|
+// console.log(err)
|
|
141
|
+// message.info(err.msg || err.message)
|
|
142
|
+// })
|
|
143
|
+
|
|
144
|
+// }
|
|
145
|
+// });
|
|
146
|
+// }
|
|
147
|
+// /**
|
|
148
|
+// *
|
|
149
|
+// *
|
|
150
|
+// * @param {*} props
|
|
151
|
+// * @returns
|
|
152
|
+// */
|
|
153
|
+// const columns = [
|
|
154
|
+// {
|
|
155
|
+// title: '类型图',
|
|
156
|
+// dataIndex: 'newsTypeImg',
|
|
157
|
+// key: 'newsTypeImg',
|
|
158
|
+// align: 'center',
|
|
159
|
+// render: (text, record) => <img src={record.newsTypeImg} style={{ width: '165px',height: '104px' }} className={styles.touxiang} />,
|
|
160
|
+// },
|
|
161
|
+// {
|
|
162
|
+// title: '名称',
|
|
163
|
+// dataIndex: 'newsTypeName',
|
|
164
|
+// key: 'newsTypeName',
|
|
165
|
+// align: 'center',
|
|
166
|
+
|
|
167
|
+// },
|
|
168
|
+// {
|
|
169
|
+// title: '操作',
|
|
170
|
+// dataIndex: 'handle',
|
|
171
|
+// key: 'handle',
|
|
172
|
+// align: 'center',
|
|
173
|
+// render: (x, row) => (
|
|
174
|
+// <>
|
|
175
|
+// <AuthButton name="admin.taNewsType.id.delete" noRight={null}>
|
|
176
|
+// <span style={{ color: '#EF273A', marginRight: '20px', cursor: 'pointer' }} onClick={changeNewsStatus(row, row.newsTypeId)}>
|
|
177
|
+// {row.status == 1 ? '删除' : '上架'}<Icon type="shopping-cart" className={styles.shoppingCart} />
|
|
178
|
+// </span>
|
|
179
|
+// </AuthButton>
|
|
180
|
+// <AuthButton name="admin.taNewsType.id.put" noRight={null}>
|
|
181
|
+// <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditNews(row.newsTypeId)}>
|
|
182
|
+// 编辑<Icon type="form" className={styles.edit} />
|
|
183
|
+// </span>
|
|
184
|
+// </AuthButton>
|
|
185
|
+// </>
|
|
186
|
+// ),
|
|
187
|
+// },
|
|
188
|
+// ];
|
|
189
|
+
|
|
190
|
+// function handleReset() {
|
|
191
|
+// props.form.resetFields();
|
|
192
|
+// getList({ pageNum: 1, pageSize: 10 })
|
|
193
|
+// }
|
|
194
|
+
|
|
195
|
+// const { getFieldDecorator } = props.form
|
|
196
|
+// return (
|
|
197
|
+
|
|
198
|
+// <>
|
|
199
|
+// <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
|
200
|
+// <Form.Item>
|
|
201
|
+// {getFieldDecorator('buildingId')(
|
|
202
|
+// <BuildSelect />,
|
|
203
|
+// )}
|
|
204
|
+// </Form.Item>
|
|
205
|
+// <Form.Item>
|
|
206
|
+// <AuthButton name="admin.taNewsType.search" noRight={null}>
|
|
207
|
+// <Button type="primary" htmlType="submit" >
|
|
208
|
+// 查询
|
|
209
|
+// </Button>
|
|
210
|
+// </AuthButton>
|
|
211
|
+// <Button style={{ marginLeft: 8 }} onClick={handleReset}>
|
|
212
|
+// 重置
|
|
213
|
+// </Button>
|
|
214
|
+// </Form.Item>
|
|
215
|
+// </Form>
|
|
216
|
+// <AuthButton name="admin.taNewsType.post" noRight={null}>
|
|
217
|
+// <Button type="danger" className={styles.addBtn} onClick={toEditNews()}>新增</Button>
|
|
218
|
+// </AuthButton>
|
|
219
|
+// <Table rowKey="newsType" dataSource={data.records} columns={columns} pagination={false} />
|
|
220
|
+// <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
221
|
+// <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
|
|
222
|
+// </div>
|
|
223
|
+// </>
|
|
224
|
+// )
|
|
225
|
+// }
|
|
226
|
+// const WrappedHeader = Form.create({ name: 'header' })(header);
|
|
227
|
+
|
|
228
|
+// export default WrappedHeader
|