傅行帆 5 years ago
parent
commit
5f8b2130eb

+ 40
- 0
src/components/SelectButton/BuildSelect.jsx View File

1
+import React, { useState, useEffect } from 'react';
2
+import { Select } from 'antd';
3
+
4
+import request from '../../utils/request'
5
+
6
+const { Option } = Select;
7
+
8
+/**
9
+ *
10
+ *
11
+ * @param {*} props
12
+ * @returns
13
+ */
14
+const BuildingSelect = (props) => {
15
+  const [ data, setData ] = useState([])
16
+
17
+  useEffect(() => {
18
+    getCityList();
19
+  },[])
20
+
21
+  const getCityList = (e) => {
22
+    request({
23
+        url: '/api/admin/buildinglist/select',
24
+        method: 'GET',
25
+        params: {pageNum: 1,pageSize: 999},
26
+    }).then((data) => {
27
+        setData(data.records)
28
+    })
29
+  }
30
+
31
+  return (
32
+      <Select value={props.value} style={{ width: '180px' }} placeholder="请选择项目" onChange={props.onChange}>
33
+          {data.map(building => (
34
+            <Option key={building.buildingId}>{building.buildingName}</Option>
35
+          ))}
36
+      </Select>
37
+  )
38
+}
39
+export default BuildingSelect
40
+

+ 4
- 4
src/components/SelectButton/CitySelect.jsx View File

20
 
20
 
21
   const getCityList = (e) => {
21
   const getCityList = (e) => {
22
     request({
22
     request({
23
-        url: '/api/admin/buildinglist/select',
23
+        url: '/api/admin/tdCity',
24
         method: 'GET',
24
         method: 'GET',
25
-        params: {pageNum: 1,pageSize: 999},
25
+        params: {leveltype: 2, pageNum: 1,pageSize: 999},
26
     }).then((data) => {
26
     }).then((data) => {
27
-        setData(data.records)
27
+        setData(data)
28
     })
28
     })
29
   }
29
   }
30
 
30
 
31
   return (
31
   return (
32
       <Select value={props.value} style={{ width: '180px' }} placeholder="请选择城市" onChange={props.onChange}>
32
       <Select value={props.value} style={{ width: '180px' }} placeholder="请选择城市" onChange={props.onChange}>
33
           {data.map(city => (
33
           {data.map(city => (
34
-            <Option key={city.buildingId}>{city.buildingName}</Option>
34
+            <Option key={city.id}>{city.name}</Option>
35
           ))}
35
           ))}
36
       </Select>
36
       </Select>
37
   )
37
   )

+ 32
- 31
src/pages/activity/ActivityList.jsx View File

5
 import router from 'umi/router';
5
 import router from 'umi/router';
6
 import moment from 'moment';
6
 import moment from 'moment';
7
 import SelectCity from '../../components/SelectButton/CitySelect'
7
 import SelectCity from '../../components/SelectButton/CitySelect'
8
+import BuildSelect from '../../components/SelectButton/BuildSelect'
8
 
9
 
9
 import request from '../../utils/request'
10
 import request from '../../utils/request'
10
 
11
 
11
 const { Option } = Select;
12
 const { Option } = Select;
12
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
13
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
13
-// 提交事件
14
-function handleSubmit(e, props) {
15
-  e.preventDefault();
16
-  props.form.validateFields((err, values) => {
17
-    if (!err) {
18
-      console.log('提交数据: ', values)
19
-    }
20
-  });
21
-}
22
-// Change 事件
23
-function handleSelectChange(props) {
24
-  console.log(props)
25
-}
26
 
14
 
27
-// 分页
28
-function onChange(pageNumber) {
29
-  console.log('Page: ', pageNumber);
30
-}
31
 // 跳转到编辑商品
15
 // 跳转到编辑商品
32
 function toEditGoods() {
16
 function toEditGoods() {
33
   router.push({
17
   router.push({
187
     })
171
     })
188
 }
172
 }
189
 
173
 
174
+const changePageNum = (pageNumber) => {
175
+    getList({ pageNum: pageNumber, pageSize: 10 })
176
+}
177
+
178
+
179
+
190
 const header = (props) => {
180
 const header = (props) => {
191
   const [ data, setData ] = useState({})
181
   const [ data, setData ] = useState({})
192
 //   const [page, changePage] = useState({})
182
 //   const [page, changePage] = useState({})
193
 
183
 
194
   useEffect(() => {
184
   useEffect(() => {
195
-    getList();
185
+    getList({ pageNum: 1, pageSize: 10 });
196
   },[])
186
   },[])
197
 
187
 
198
   // 查询列表
188
   // 查询列表
199
-  const getList = (e) => {
189
+  const getList = (params) => {
200
     request({
190
     request({
201
         url: '/api/admin/iBuildingDynamicList',
191
         url: '/api/admin/iBuildingDynamicList',
202
         method: 'GET',
192
         method: 'GET',
203
-        params: {pageNum: 1,pageSize: 10},
193
+        params: { ...params },
204
     }).then((data) => {
194
     }).then((data) => {
205
         console.log(data)
195
         console.log(data)
206
         setData(data)
196
         setData(data)
207
     })
197
     })
208
   }
198
   }
209
 
199
 
200
+  // 提交事件
201
+const handleSubmit = (e, props) => {
202
+    e.preventDefault();
203
+    props.form.validateFields((err, values) => {
204
+      if (!err) {
205
+        console.log('提交数据: ', values)
206
+        getList({ pageNum: 1, pageSize: 10, ...values })
207
+      }
208
+    });
209
+  }
210
+
210
   const { getFieldDecorator } = props.form
211
   const { getFieldDecorator } = props.form
211
   return (
212
   return (
212
 
213
 
213
     <>
214
     <>
214
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
215
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
215
         <Form.Item>
216
         <Form.Item>
216
-          {getFieldDecorator('goodState')(
217
+          {getFieldDecorator('cityId')(
217
             <SelectCity />,
218
             <SelectCity />,
218
           )}
219
           )}
219
         </Form.Item>
220
         </Form.Item>
220
         <Form.Item>
221
         <Form.Item>
221
-          {getFieldDecorator('isMain')(
222
-            <Select style={{ width: '180px' }} placeholder="请选择项目" onChange={handleSelectChange}>
223
-              <Option value="1">首页推荐</Option>
224
-              <Option value="0">首页未推荐</Option>
225
-            </Select>,
222
+          {getFieldDecorator('buildingId')(
223
+            <BuildSelect />,
226
           )}
224
           )}
227
         </Form.Item>
225
         </Form.Item>
228
         <Form.Item>
226
         <Form.Item>
229
-          {getFieldDecorator('name')(
227
+          {getFieldDecorator('title')(
230
             <Input
228
             <Input
231
               prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
229
               prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
232
               placeholder="请输入标题"
230
               placeholder="请输入标题"
234
           )}
232
           )}
235
         </Form.Item>
233
         </Form.Item>
236
         <Form.Item>
234
         <Form.Item>
237
-          {getFieldDecorator('min')(
235
+          {getFieldDecorator('time')(
238
             <DatePicker />
236
             <DatePicker />
239
           )}
237
           )}
240
         </Form.Item>
238
         </Form.Item>
241
         <Form.Item>
239
         <Form.Item>
242
-          {getFieldDecorator('goodState')(
243
-            <Select style={{ width: '180px' }} placeholder="是否报名" onChange={handleSelectChange}>
240
+          {getFieldDecorator('isEnlist')(
241
+            <Select style={{ width: '180px' }} placeholder="是否报名">
244
               <Option value="1">已报名</Option>
242
               <Option value="1">已报名</Option>
245
               <Option value="0">未报名</Option>
243
               <Option value="0">未报名</Option>
246
             </Select>,
244
             </Select>,
253
         </Form.Item>
251
         </Form.Item>
254
       </Form>
252
       </Form>
255
       <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
253
       <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
256
-      <Table dataSource={data.list} columns={columns} />
254
+      <Table dataSource={data.list} columns={columns} pagination={false}/>
255
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
256
+        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} />
257
+      </div>
257
     </>
258
     </>
258
   )
259
   )
259
 }
260
 }