Browse Source

Merge branch 'master' of http://git.ycjcjy.com/zhiyuxing/estateagents-admin-manager

傅行帆 5 years ago
parent
commit
ab0f1e976a

+ 6
- 1
config/config.js View File

127
                   name: '项目类型',
127
                   name: '项目类型',
128
                   component: './building/type/index',
128
                   component: './building/type/index',
129
                 },
129
                 },
130
+                {
131
+                  path: '/building/type/edi',
132
+                  name: '',
133
+                  component: './building/type/edi',
134
+                },
130
               ],
135
               ],
131
             },
136
             },
132
             {
137
             {
281
   
286
   
282
   proxy: {
287
   proxy: {
283
     '/api/': {
288
     '/api/': {
284
-      target: 'http://192.168.0.84:8080/',
289
+      target: 'http://localhost:8080/',
285
       changeOrigin: true,
290
       changeOrigin: true,
286
       // pathRewrite: { '^/server': '' },
291
       // pathRewrite: { '^/server': '' },
287
     },
292
     },

+ 35
- 15
src/pages/building/list/index.jsx View File

1
 import React, { useState, useEffect } from 'react';
1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination } from 'antd';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert } from 'antd';
3
+import moment from 'moment';
3
 import request from '../../../utils/request';
4
 import request from '../../../utils/request';
4
 import apis from '../../../services/apis';
5
 import apis from '../../../services/apis';
5
 import Styles from './style.less';
6
 import Styles from './style.less';
23
           <Card
24
           <Card
24
             hoverable
25
             hoverable
25
             style={{ minWidth: '400px', borderRadius: '12px', margin: '10px', boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)' }}
26
             style={{ minWidth: '400px', borderRadius: '12px', margin: '10px', boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)' }}
26
-            cover={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" style={{ borderRadius: '12px 12px 0 0', width: '100%', height: '14vw' }}></img>}
27
+            cover={<img alt="example" src={ data.poster } style={{ borderRadius: '12px 12px 0 0', width: '100%', height: '14vw' }}></img>}
27
             bodyStyle={{ padding: '10px 20px' }}
28
             bodyStyle={{ padding: '10px 20px' }}
28
           >
29
           >
29
             <p className={Styles.cardText}>
30
             <p className={Styles.cardText}>
46
             </p>
47
             </p>
47
             <p className={Styles.cardItem}>
48
             <p className={Styles.cardItem}>
48
               <span className={Styles.title}>项目地址</span>
49
               <span className={Styles.title}>项目地址</span>
49
-              <span >:{ data.address }</span>
50
+              <span className={ Styles.address }>:{ data.address }</span>
50
             </p>
51
             </p>
51
             <p className={Styles.cardItem}>
52
             <p className={Styles.cardItem}>
52
               <span className={Styles.title}>发布状态</span>
53
               <span className={Styles.title}>发布状态</span>
54
             </p>
55
             </p>
55
             <p className={Styles.cardItem}>
56
             <p className={Styles.cardItem}>
56
               <span className={Styles.title}>录入时间</span>
57
               <span className={Styles.title}>录入时间</span>
57
-              <span >:2019-08-28 17</span>
58
+              <span >:{ data.createDate }</span>
58
             </p>
59
             </p>
59
             <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
60
             <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
60
               <span style={{ color: '#1990FF' }}>
61
               <span style={{ color: '#1990FF' }}>
82
   const { getFieldDecorator } = props.form
83
   const { getFieldDecorator } = props.form
83
 
84
 
84
   // eslint-disable-next-line react-hooks/rules-of-hooks
85
   // eslint-disable-next-line react-hooks/rules-of-hooks
85
-  const { dataSource, setDataSource } = useState(tempDate || [])
86
-  console.log(dataSource)
86
+  const [dataSource, setDataSource] = useState({ records: [] })
87
 
87
 
88
   // eslint-disable-next-line react-hooks/rules-of-hooks
88
   // eslint-disable-next-line react-hooks/rules-of-hooks
89
   useEffect(() => {
89
   useEffect(() => {
90
+    getList({ pageNum: 1, pageSize: 9 })
91
+  }, [])
92
+
93
+  function getList(params) {
90
     // 网路请求
94
     // 网路请求
91
-    request({ ...apis.building }).then(res => {
95
+    request({ ...apis.building.getList, params: { ...params } }).then(res => {
92
       setDataSource(res)
96
       setDataSource(res)
97
+    }).catch(err => {
98
+      // eslint-disable-next-line no-unused-expressions
99
+      <Alert
100
+        style={{
101
+          marginBottom: 24,
102
+        }}
103
+        message={err}
104
+        type="error"
105
+        showIcon
106
+      />
93
     })
107
     })
94
-  })
95
-
108
+  }
96
 
109
 
97
   // 提交事件
110
   // 提交事件
98
   function handleSubmit(e) {
111
   function handleSubmit(e) {
101
       if (!err) {
114
       if (!err) {
102
         // eslint-disable-next-line no-console
115
         // eslint-disable-next-line no-console
103
         console.log('提交数据: ', values)
116
         console.log('提交数据: ', values)
117
+        const { startDate } = values
118
+        getList({ pageNum: 1, pageSize: 9, ...values })
104
       }
119
       }
105
     });
120
     });
106
   }
121
   }
113
 
128
 
114
   // 分页
129
   // 分页
115
   function onChange(pageNumber) {
130
   function onChange(pageNumber) {
116
-    // eslint-disable-next-line no-console
117
-    console.log('Page: ', pageNumber);
131
+    // eslint-disable-next-line react-hooks/rules-of-hooks
132
+      getList({ pageNum: pageNumber, pageSize: 9 })
133
+  }
134
+
135
+  function getDate(value, dateString) {
136
+    // moment(value).format('YYYY-MM-DD HH:mm:ss')
137
+    console.log(value, dateString)
118
   }
138
   }
119
 
139
 
120
   return (
140
   return (
139
         </Form.Item>
159
         </Form.Item>
140
         <Form.Item>
160
         <Form.Item>
141
           {getFieldDecorator('startDate')(
161
           {getFieldDecorator('startDate')(
142
-            <DatePicker placeholder="开盘时间" />,
162
+            <DatePicker placeholder="开盘时间" format="YYYY-MM-DD" onChange={getDate} />,
143
           )}
163
           )}
144
         </Form.Item>
164
         </Form.Item>
145
         <Form.Item>
165
         <Form.Item>
187
       {/* 卡片内容,显示楼盘项目  */}
207
       {/* 卡片内容,显示楼盘项目  */}
188
       <Row style={{ padding: ' 0 10px' }}>
208
       <Row style={{ padding: ' 0 10px' }}>
189
         {
209
         {
190
-          dataSource.map((item, index) => (
210
+          dataSource.records.map((item, index) => (
191
               <Col span={8}>
211
               <Col span={8}>
192
-                <CartBody data={item} key={item.code}/>
212
+                <CartBody data={item} key={item.buildingId}/>
193
               </Col>
213
               </Col>
194
             ))
214
             ))
195
         }
215
         }
196
       </Row>
216
       </Row>
197
       {/* 分页 */}
217
       {/* 分页 */}
198
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
218
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
199
-        <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={onChange} />
219
+        <Pagination showQuickJumper defaultCurrent={1} total={dataSource.total} onChange={onChange} />
200
       </div>
220
       </div>
201
     </>
221
     </>
202
   );
222
   );

+ 54
- 0
src/pages/building/list/style.css View File

1
+.SubmitButton {
2
+  background: #3a91d5;
3
+  border-radius: 7px;
4
+  border: 0px;
5
+}
6
+.SelectFrom {
7
+  width: 180px;
8
+  background: #ffffff;
9
+  border-radius: 7px;
10
+  border: 1px solid #dbdbdb;
11
+}
12
+.addButton {
13
+  background: #50be00;
14
+  border-radius: 4px;
15
+  border: 0px;
16
+  margin: 10px 0px;
17
+}
18
+.cardText {
19
+  font-size: 18px;
20
+  color: #333;
21
+  line-height: 24px;
22
+  display: flex;
23
+  align-items: center;
24
+  position: relative;
25
+}
26
+.cardItem {
27
+  font-size: 18px;
28
+  font-weight: 400;
29
+  color: #666;
30
+  line-height: 24px;
31
+  display: flex;
32
+  align-items: center;
33
+}
34
+.ediText {
35
+  font-size: 18px;
36
+  color: #ff925c;
37
+  line-height: 24px;
38
+  position: absolute;
39
+  right: 0;
40
+}
41
+.title {
42
+  display: inline-block;
43
+  width: 84px;
44
+  justify-content: space-between;
45
+  text-align: justify;
46
+  text-align-last: justify;
47
+}
48
+.address {
49
+  width: 400px;
50
+  height: 24px;
51
+  text-overflow: ellipsis;
52
+  white-space: nowrap;
53
+  overflow: hidden;
54
+}

+ 10
- 1
src/pages/building/list/style.less View File

45
   justify-content: space-between;
45
   justify-content: space-between;
46
   text-align: justify;
46
   text-align: justify;
47
   text-align-last:justify
47
   text-align-last:justify
48
-}
48
+}
49
+
50
+.address { 
51
+  width: 400px;
52
+  height: 24px; 
53
+  text-overflow: ellipsis; 
54
+  white-space: nowrap;
55
+  overflow: hidden;
56
+}
57
+

+ 54
- 0
src/pages/building/list/style.wxss View File

1
+.SubmitButton {
2
+  background: #3a91d5;
3
+  border-radius: 7px;
4
+  border: 0px;
5
+}
6
+.SelectFrom {
7
+  width: 180px;
8
+  background: #ffffff;
9
+  border-radius: 7px;
10
+  border: 1px solid #dbdbdb;
11
+}
12
+.addButton {
13
+  background: #50be00;
14
+  border-radius: 4px;
15
+  border: 0px;
16
+  margin: 10px 0px;
17
+}
18
+.cardText {
19
+  font-size: 18px;
20
+  color: #333;
21
+  line-height: 24px;
22
+  display: flex;
23
+  align-items: center;
24
+  position: relative;
25
+}
26
+.cardItem {
27
+  font-size: 18px;
28
+  font-weight: 400;
29
+  color: #666;
30
+  line-height: 24px;
31
+  display: flex;
32
+  align-items: center;
33
+}
34
+.ediText {
35
+  font-size: 18px;
36
+  color: #ff925c;
37
+  line-height: 24px;
38
+  position: absolute;
39
+  right: 0;
40
+}
41
+.title {
42
+  display: inline-block;
43
+  width: 84px;
44
+  justify-content: space-between;
45
+  text-align: justify;
46
+  text-align-last: justify;
47
+}
48
+.address {
49
+  width: 400px;
50
+  height: 24px;
51
+  text-overflow: ellipsis;
52
+  white-space: nowrap;
53
+  overflow: hidden;
54
+}

+ 78
- 0
src/pages/building/type/edi.jsx View File

1
+import React from 'react';
2
+import { Input, Button, Row, Col, Form, Alert } from 'antd';
3
+import router from 'umi/router';
4
+import Styles from './style.less';
5
+import request from '../../../utils/request';
6
+import apis from '../../../services/apis';
7
+
8
+function body(props) {
9
+  const { getFieldDecorator } = props.form;
10
+
11
+  console.log('id: ', props.location.query.id)
12
+
13
+  function handleSubmit(e) {
14
+    e.preventDefault();
15
+    props.form.validateFields((err, values) => {
16
+      if (!err) {
17
+        // 提交数据
18
+        values.status = 1
19
+        values.createDate = new Date()
20
+        submitData(values)
21
+      }
22
+    });
23
+  }
24
+
25
+  function submitData(data) {
26
+    request({ ...apis.buildingType.add, data: { ...data } }).then(() => {
27
+      // eslint-disable-next-line no-unused-expressions
28
+      <Alert
29
+        style={{
30
+          marginBottom: 24,
31
+        }}
32
+        message="操作成功"
33
+        type="success"
34
+        showIcon
35
+      />
36
+      router.go(-1)
37
+    }).catch(err => {
38
+      // eslint-disable-next-line no-unused-expressions
39
+      <Alert
40
+        style={{
41
+          marginBottom: 24,
42
+        }}
43
+        message={ err }
44
+        type="err"
45
+        showIcon
46
+      />
47
+    })
48
+  }
49
+
50
+  return (
51
+    <>
52
+        <Form onSubmit={handleSubmit} style={{ width: '500px', margin: 'auto' }}>
53
+          <Form.Item>
54
+            {getFieldDecorator('buildingTypeName', {
55
+              rules: [{ required: true, message: '请输入名称' }],
56
+            })(
57
+              <Input
58
+                placeholder="名称"
59
+              />,
60
+            )}
61
+          </Form.Item>
62
+          <Form.Item style={{ display: 'flex', justifyContent: 'space-between' }}>
63
+            <Button type="primary" htmlType="submit" className={ Styles.addButton } style={{ margin: '0' }}>
64
+              确定
65
+            </Button>
66
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
67
+            <Button onClick={() => router.go(-1)}>
68
+              取消
69
+            </Button>
70
+          </Form.Item>
71
+        </Form>
72
+    </>
73
+  )
74
+}
75
+
76
+const WrappedBuidingTypeForm = Form.create({ name: 'body' })(body);
77
+
78
+export default WrappedBuidingTypeForm

+ 88
- 55
src/pages/building/type/index.jsx View File

1
-import React, { useState } from 'react';
2
-import { Button, Table, Pagination } from 'antd'
1
+import React, { useState, useEffect } from 'react';
2
+import { Button, Table, Pagination, Alert, Icon, Tag } from 'antd'
3
+import router from 'umi/router';
4
+import moment from 'moment';
3
 import Styles from './style.less'
5
 import Styles from './style.less'
6
+import request from '../../../utils/request';
7
+import apis from '../../../services/apis';
4
 
8
 
5
-const dataSource = [
6
-  {
7
-    key: '1',
8
-    name: '胡彦斌',
9
-    age: 32,
10
-    address: '西湖区湖底公园1号',
11
-  },
12
-  {
13
-    key: '2',
14
-    name: '胡彦祖',
15
-    age: 42,
16
-    address: '西湖区湖底公园1号',
17
-  },
18
-];
19
-
20
-const columns = [
21
-  {
22
-    title: '姓名',
23
-    dataIndex: 'name',
24
-    key: 'name',
25
-  },
26
-  {
27
-    title: '年龄',
28
-    dataIndex: 'age',
29
-    key: 'age',
30
-  },
31
-  {
32
-    title: '住址',
33
-    dataIndex: 'address',
34
-    key: 'address',
35
-  },
36
-];
9
+function body() {
10
+  // eslint-disable-next-line react-hooks/rules-of-hooks
11
+  const [data, setData] = useState([{ records: [] }])
37
 
12
 
38
-// 分页
39
-function onChange(pageNumber, set) {
40
-  // eslint-disable-next-line no-console
41
-  console.log('Page: ', pageNumber);
42
-  const data = [
13
+  const columns = [
14
+    {
15
+      title: '编号',
16
+      dataIndex: 'buildingTypeId',
17
+      key: 'buildingTypeId',
18
+    },
19
+    {
20
+      title: '类型名称',
21
+      dataIndex: 'buildingTypeName',
22
+      key: 'buildingTypeName',
23
+      render: (_, record) => <Tag color="blue" onClick={() => toEdi(record.buildingTypeId)}>{ record.buildingTypeName }</Tag>,
24
+    },
43
     {
25
     {
44
-      key: '1',
45
-      name: '一号',
46
-      age: 32,
47
-      address: '西湖区湖底公园1号',
26
+      title: '创建时间',
27
+      dataIndex: 'createDate',
28
+      key: 'createDate',
29
+      render: (_, record) => <sapn>{moment(record.createDate).format('YYYY-MM-DD')}</sapn>,
48
     },
30
     },
49
     {
31
     {
50
-      key: '2',
51
-      name: '二号',
52
-      age: 42,
53
-      address: '西湖区湖底公园1号',
32
+      title: '操作',
33
+      dataIndex: 'row',
34
+      key: 'row',
35
+      render: (_, record) => (
36
+        <span onClick={() => deleteType(record)}>
37
+          <span style={{
38
+              color: '#FF4A4A', right: '0',
39
+          }} >
40
+              删除
41
+          <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
42
+          </span>
43
+        </span>
44
+      ),
54
     },
45
     },
55
   ];
46
   ];
56
 
47
 
57
-  set(data)
58
-}
59
-
60
-function body() {
61
   // eslint-disable-next-line react-hooks/rules-of-hooks
48
   // eslint-disable-next-line react-hooks/rules-of-hooks
62
-  const [data, setData] = useState(dataSource || [])
49
+  useEffect(() => {
50
+    getList({ pageNum: 1, pageSize: 10 })
51
+  }, [])
52
+
53
+  function getList(params) {
54
+    request({ ...apis.buildingType.getList, params: { ...params } }).then(res => {
55
+      setData(res)
56
+    }).catch(err => {
57
+      // eslint-disable-next-line no-unused-expressions
58
+      <Alert
59
+        style={{
60
+          marginBottom: 24,
61
+        }}
62
+        message={err}
63
+        type="error"
64
+        showIcon
65
+      />
66
+    })
67
+  }
68
+
69
+  // 分页
70
+  function onChange(pageNumber) {
71
+    // eslint-disable-next-line no-console
72
+    console.log('Page: ', pageNumber);
73
+    getList({ pageNum: pageNumber, pageSize: 10 })
74
+  }
75
+
76
+  // 删除
77
+  function deleteType(row) {
78
+    const { url, method } = apis.buildingType.update
79
+    const tempUrl = url.substring(0, url.lastIndexOf('id')).concat(row.buildingTypeId)
80
+
81
+    row.status = -1
82
+    request({ url: tempUrl, method, data: { ...row } }).then(() => {
83
+      getList({ pageNum: data.current, pageSize: 10 })
84
+    })
85
+  }
86
+
87
+  // 跳转修改页
88
+  function toEdi(id) {
89
+    router.push({
90
+      pathname: '/building/type/edi',
91
+      query: {
92
+        id,
93
+      },
94
+    });
95
+  }
63
 
96
 
64
   return (
97
   return (
65
     <>
98
     <>
66
-      <Button type="primary" className={Styles.addButton}>新增类型</Button>
67
-      <Table dataSource={data} columns={columns} pagination={false}/>
99
+      <Button type="primary" className={Styles.addButton} onClick={toEdi}>新增类型</Button>
100
+      <Table dataSource={data.records} columns={columns} pagination={false}/>
68
       {/* 分页 */}
101
       {/* 分页 */}
69
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
102
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
70
-        <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={e => onChange(e, setData)} />
103
+        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={onChange} />
71
       </div>
104
       </div>
72
     </>
105
     </>
73
   )
106
   )

+ 19
- 1
src/services/apis.js View File

13
   },
13
   },
14
   building: {
14
   building: {
15
     getList: {
15
     getList: {
16
-      methods: 'GET',
16
+      method: 'GET',
17
       url: `${prefix}/buildinglist`,
17
       url: `${prefix}/buildinglist`,
18
     },
18
     },
19
   },
19
   },
20
+  buildingType: {
21
+    getList: {
22
+      method: 'GET',
23
+      url: `${prefix}/tdBuildingType`,
24
+    },
25
+    delete: {
26
+      method: 'DELETE',
27
+      url: `${prefix}/tdBuildingType/id`,
28
+    },
29
+    update: {
30
+      method: 'PUT',
31
+      url: `${prefix}/tdBuildingType/id`,
32
+    },
33
+    add: {
34
+      method: 'POST',
35
+      url: `${prefix}/tdBuildingType`,
36
+    },
37
+  },
20
 }
38
 }