魏熙美 5 年 前
コミット
07fd3e62fc

+ 5
- 0
config/config.js ファイルの表示

@@ -122,6 +122,11 @@ export default {
122 122
                   name: '项目列表',
123 123
                   component: './building/list/index',
124 124
                 },
125
+                {
126
+                  path: '/building/type',
127
+                  name: '项目类型',
128
+                  component: './building/type/index',
129
+                },
125 130
               ],
126 131
             },
127 132
             // {

+ 22
- 0
src/models/building.js ファイルの表示

@@ -0,0 +1,22 @@
1
+import { getList } from '@/services/building';
2
+
3
+const buildingModel = {
4
+  namespaced: 'building',
5
+  state: {
6
+
7
+  },
8
+  effect: {
9
+    *fetch(_, { call, put }) {
10
+      const response = yield call(getList);
11
+      yield put({
12
+        type: 'get',
13
+        payload: response,
14
+      });
15
+    },
16
+  },
17
+  reducers: {
18
+
19
+  },
20
+}
21
+
22
+export default buildingModel

+ 120
- 56
src/pages/building/list/index.jsx ファイルの表示

@@ -1,16 +1,62 @@
1 1
 import React from 'react';
2 2
 import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination } from 'antd';
3
+import { connect } from 'dva';
3 4
 import Styles from './style.less';
4 5
 
6
+
5 7
 const { Option } = Select;
8
+// eslint-disable-next-line @typescript-eslint/no-unused-vars
6 9
 const { Meta } = Card;
7 10
 
11
+// 假数据
12
+const tempData = [
13
+  {
14
+    code: 'S101',
15
+    name: '城开花园',
16
+    price: '111',
17
+    address: '顾戴路1801弄',
18
+    status: '1', // 已发布
19
+    createDate: '2019-08-28 17',
20
+  },
21
+  {
22
+    code: 'S102',
23
+    name: '星河天街',
24
+    price: '111',
25
+    address: '长征路1801弄',
26
+    status: '1', // 已发布
27
+    createDate: '2019-08-29 17',
28
+  },
29
+  {
30
+    code: 'S103',
31
+    name: '喜洋洋别墅',
32
+    price: '111',
33
+    address: '阳杨路1801弄',
34
+    status: '1', // 已发布
35
+    createDate: '2019-08-29 17',
36
+  },
37
+  {
38
+    code: 'S104',
39
+    name: '武大郎洋房',
40
+    price: '111',
41
+    address: '太郎路1801弄',
42
+    status: '1', // 已发布
43
+    createDate: '2019-08-29 17',
44
+  },
45
+]
46
+
47
+
48
+// 网路数据请求
49
+connect(({ getList, loading }) => ({
50
+  getList,
51
+  submitting: loading.effects['building/getList'],
52
+}))
8 53
 
9 54
 // 提交事件
10 55
 function handleSubmit(e, props) {
11 56
   e.preventDefault();
12 57
   props.form.validateFields((err, values) => {
13 58
     if (!err) {
59
+      // eslint-disable-next-line no-console
14 60
       console.log('提交数据: ', values)
15 61
     }
16 62
   });
@@ -18,23 +64,86 @@ function handleSubmit(e, props) {
18 64
 
19 65
 // Change 事件
20 66
 function handleSelectChange(props) {
67
+  // eslint-disable-next-line no-console
21 68
   console.log(props)
22 69
 }
23 70
 
24 71
 // 分页
25 72
 function onChange(pageNumber) {
73
+  // eslint-disable-next-line no-console
26 74
   console.log('Page: ', pageNumber);
27 75
 }
28 76
 
77
+/**
78
+ *卡片
79
+ *
80
+ * @returns
81
+ */
82
+function CartBody(props) {
83
+  const { data } = props
84
+
85
+  return (
86
+          <Card
87
+            hoverable
88
+            style={{ minWidth: '400px', borderRadius: '12px', margin: '10px', boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)' }}
89
+            cover={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" style={{ borderRadius: '12px 12px 0 0', width: '100%', height: '14vw' }}></img>}
90
+            bodyStyle={{ padding: '10px 20px' }}
91
+          >
92
+            <p className={Styles.cardText}>
93
+              <span className={Styles.title}>楼盘编号</span>
94
+              <span >:{ data.code }</span>
95
+              <span className={Styles.ediText}>
96
+                编辑
97
+                <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
98
+              </span>
99
+            </p>
100
+            <p className={Styles.cardText}>
101
+              <span className={Styles.title}>楼盘名称</span>
102
+              <span >:{ data.name }</span>
103
+            </p>
104
+            <p className={Styles.cardItem}>
105
+              <span className={Styles.title}>均价</span>
106
+              <span >
107
+                :约<span style={{ color: '#FF0707', fontSize: '20px' }}> { data.price } </span>元/m
108
+        </span>
109
+            </p>
110
+            <p className={Styles.cardItem}>
111
+              <span className={Styles.title}>项目地址</span>
112
+              <span >:{ data.address }</span>
113
+            </p>
114
+            <p className={Styles.cardItem}>
115
+              <span className={Styles.title}>发布状态</span>
116
+              <span >:{ data.status === '1' ? '已发布' : '未发布' }</span>
117
+            </p>
118
+            <p className={Styles.cardItem}>
119
+              <span className={Styles.title}>录入时间</span>
120
+              <span >:2019-08-28 17</span>
121
+            </p>
122
+            <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
123
+              <span style={{ color: '#1990FF' }}>
124
+                取消发布
125
+                <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
126
+              </span>
127
+              <span style={{
128
+                color: '#FF4A4A', position: 'absolute', right: '0',
129
+              }} >
130
+                删除
131
+                <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
132
+              </span>
133
+            </p>
134
+          </Card>
135
+  )
136
+}
137
+
29 138
 /**
30 139
  *
31 140
  *
32 141
  * @param {*} props
33 142
  * @returns
34 143
  */
35
-function header(props) {
144
+function body(props) {
36 145
   const { getFieldDecorator } = props.form
37
-
146
+  connect()
38 147
   return (
39 148
     <>
40 149
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
@@ -104,58 +213,13 @@ function header(props) {
104 213
 
105 214
       {/* 卡片内容,显示楼盘项目  */}
106 215
       <Row style={{ padding: ' 0 10px' }}>
107
-        <Col span={8}>
108
-          <Card
109
-            hoverable
110
-            style={{ minWidth: '400px', borderRadius: '12px',margin:'10px', boxShadow: '0px 0px 16px 2px rgba(0,0,0,0.12)', }}
111
-            cover={<img alt="example" src="https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png" style={{ borderRadius: '12px 12px 0 0', width: '100%', height: '14vw' }}></img>}
112
-            bodyStyle={{ padding: '10px 20px' }}
113
-          >
114
-            <p className={Styles.cardText}>
115
-              <span className={Styles.title}>楼盘编号</span>
116
-              <span >:S101</span>
117
-              <span className={Styles.ediText}>
118
-                编辑
119
-                <Icon type="form" style={{ color: '#C0C4CC', marginLeft: '10px' }} />
120
-              </span>
121
-            </p>
122
-            <p className={Styles.cardText}>
123
-              <span className={Styles.title}>楼盘名称</span>
124
-              <span >:城开花园</span>
125
-            </p>
126
-            <p className={Styles.cardItem}>
127
-              <span className={Styles.title}>均价</span>
128
-              <span >
129
-                :约<span style={{ color: '#FF0707', fontSize: '20px' }}> 111 </span>元/m
130
-        </span>
131
-            </p>
132
-            <p className={Styles.cardItem}>
133
-              <span className={Styles.title}>项目地址</span>
134
-              <span >:顾戴路1801弄</span>
135
-            </p>
136
-            <p className={Styles.cardItem}>
137
-              <span className={Styles.title}>发布状态</span>
138
-              <span >:已发布</span>
139
-            </p>
140
-            <p className={Styles.cardItem}>
141
-              <span className={Styles.title}>录入时间</span>
142
-              <span >:2019-08-28 17</span>
143
-            </p>
144
-            <p style={{ margin: '15px 0', position: 'relative', fontSize: '18px' }}>
145
-              <span style={{ color: '#1990FF' }}>
146
-                取消发布
147
-                <Icon type="close-circle" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
148
-              </span>
149
-              <span style={{
150
-                color: '#FF4A4A', position: 'absolute',
151
-                right: '0'
152
-              }} >
153
-                删除
154
-                <Icon type="rest" style={{ color: '#C0C4CC', marginLeft: '8px' }} />
155
-              </span>
156
-            </p>
157
-          </Card>
158
-        </Col>
216
+        {
217
+          tempData.map((item, index) => (
218
+              <Col span={8}>
219
+                <CartBody data={item} />
220
+              </Col>
221
+            ))
222
+        }
159 223
       </Row>
160 224
       {/* 分页 */}
161 225
       <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
@@ -164,6 +228,6 @@ function header(props) {
164 228
     </>
165 229
   );
166 230
 }
167
-const WrappedHeader = Form.create({ name: 'header' })(header);
231
+const WrappedBody = Form.create({ name: 'body' })(body);
168 232
 
169
-export default WrappedHeader
233
+export default WrappedBody

+ 76
- 0
src/pages/building/type/index.jsx ファイルの表示

@@ -0,0 +1,76 @@
1
+import React, { useState } from 'react';
2
+import { Button, Table, Pagination } from 'antd'
3
+import Styles from './style.less'
4
+
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
+];
37
+
38
+// 分页
39
+function onChange(pageNumber, set) {
40
+  // eslint-disable-next-line no-console
41
+  console.log('Page: ', pageNumber);
42
+  const data = [
43
+    {
44
+      key: '1',
45
+      name: '一号',
46
+      age: 32,
47
+      address: '西湖区湖底公园1号',
48
+    },
49
+    {
50
+      key: '2',
51
+      name: '二号',
52
+      age: 42,
53
+      address: '西湖区湖底公园1号',
54
+    },
55
+  ];
56
+
57
+  set(data)
58
+}
59
+
60
+function body() {
61
+  // eslint-disable-next-line react-hooks/rules-of-hooks
62
+  const [data, setData] = useState(dataSource || [])
63
+
64
+  return (
65
+    <>
66
+      <Button type="primary" className={Styles.addButton}>新增类型</Button>
67
+      <Table dataSource={data} columns={columns} pagination={false}/>
68
+      {/* 分页 */}
69
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
70
+        <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={e => onChange(e, setData)} />
71
+      </div>
72
+    </>
73
+  )
74
+}
75
+
76
+export default body

+ 47
- 0
src/pages/building/type/style.css ファイルの表示

@@ -0,0 +1,47 @@
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
- 0
src/pages/building/type/style.less ファイルの表示

@@ -0,0 +1,48 @@
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
+}
27
+.cardItem{
28
+  font-size: 18px;
29
+  font-weight: 400;
30
+  color: #666;
31
+  line-height: 24px;
32
+  display: flex;
33
+  align-items: center;  
34
+}
35
+.ediText {
36
+  font-size: 18px;
37
+  color: #ff925c;
38
+  line-height: 24px;
39
+  position: absolute;
40
+  right: 0;
41
+}
42
+.title{
43
+  display: inline-block;
44
+  width: 84px;
45
+  justify-content: space-between;
46
+  text-align: justify;
47
+  text-align-last:justify
48
+}

+ 47
- 0
src/pages/building/type/style.wxss ファイルの表示

@@ -0,0 +1,47 @@
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
+}

+ 12
- 0
src/services/building.js ファイルの表示

@@ -0,0 +1,12 @@
1
+import request from '@/utils/request';
2
+
3
+/**
4
+ * 项目
5
+ */
6
+
7
+/**
8
+ * 获取列表
9
+ */
10
+export async function getList() {
11
+  return request('/api/admin/buildinglist')
12
+}