|
@@ -8,6 +8,7 @@ import List from '../components/List'
|
8
|
8
|
const getNewsList = fetchList(apis.propNews.getNewsList)
|
9
|
9
|
const updateNews = fetch(apis.propNews.updateNews)
|
10
|
10
|
const deleteNews = fetch(apis.propNews.deleteNews)
|
|
11
|
+const getTypeList = fetch(apis.propNews.newsType.list)
|
11
|
12
|
|
12
|
13
|
const Condition = props => {
|
13
|
14
|
return (
|
|
@@ -19,6 +20,17 @@ const Condition = props => {
|
19
|
20
|
|
20
|
21
|
return (
|
21
|
22
|
<>
|
|
23
|
+ <Form.Item label="分类">
|
|
24
|
+ {
|
|
25
|
+ getFieldDecorator('newsTypeId')(
|
|
26
|
+ <Select style={{width: '160px'}} placeholder="请选择分类">
|
|
27
|
+ {
|
|
28
|
+ (props.typeList || []).map(x => <Select.Option key={x.newsTypeId} value={x.newsTypeId}>{x.newsTypeName}</Select.Option>)
|
|
29
|
+ }
|
|
30
|
+ </Select>
|
|
31
|
+ )
|
|
32
|
+ }
|
|
33
|
+ </Form.Item>
|
22
|
34
|
<Form.Item label="标题">
|
23
|
35
|
{
|
24
|
36
|
getFieldDecorator('newsName')(<Input placeholder="标题" />)
|
|
@@ -41,6 +53,7 @@ export default props => {
|
41
|
53
|
const [listData, setListData] = useState([])
|
42
|
54
|
const [pagination, setPagination] = useState({})
|
43
|
55
|
const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10 })
|
|
56
|
+ const [typeList, setTypeList] = useState([])
|
44
|
57
|
|
45
|
58
|
const handleSearch = vals => {
|
46
|
59
|
setQueryParams({
|
|
@@ -82,6 +95,8 @@ export default props => {
|
82
|
95
|
})
|
83
|
96
|
}
|
84
|
97
|
|
|
98
|
+ const getNewsTypeName = newsTypeId => ((typeList || []).filter(x => x.newsTypeId === newsTypeId)[0] || {}).newsTypeName || ''
|
|
99
|
+
|
85
|
100
|
useEffect(() => {
|
86
|
101
|
setLoading(true)
|
87
|
102
|
getNewsList(queryParams).then(res => {
|
|
@@ -92,9 +107,13 @@ export default props => {
|
92
|
107
|
}).catch(() => setLoading(false))
|
93
|
108
|
}, [queryParams])
|
94
|
109
|
|
|
110
|
+ useEffect(() => {
|
|
111
|
+ getTypeList({pageSize: 999}).then(res => setTypeList(res.records))
|
|
112
|
+ }, [])
|
|
113
|
+
|
95
|
114
|
return (
|
96
|
115
|
<div>
|
97
|
|
- <Condition onSearch={handleSearch} onReset={handleSearch} />
|
|
116
|
+ <Condition onSearch={handleSearch} typeList={typeList} onReset={handleSearch} />
|
98
|
117
|
<div style={{ margin: '24px 0' }}>
|
99
|
118
|
<NavLink to={`/property/news/edit`}>
|
100
|
119
|
<Button type="primary">添加</Button>
|
|
@@ -102,6 +121,12 @@ export default props => {
|
102
|
121
|
</div>
|
103
|
122
|
<List dataSource={listData} loading={loading} pagination={pagination} onPageChange={handlePageChange} rowKey="newsId">
|
104
|
123
|
<Table.Column title="#ID" dataIndex="newsId" key="newsId" />
|
|
124
|
+ <Table.Column
|
|
125
|
+ title="分类"
|
|
126
|
+ dataIndex="newsTypeId"
|
|
127
|
+ key="newsTypeId"
|
|
128
|
+ render={x => getNewsTypeName(x)}
|
|
129
|
+ />
|
105
|
130
|
<Table.Column
|
106
|
131
|
title="标题"
|
107
|
132
|
dataIndex="newsName"
|