瀏覽代碼

新需求

傅行帆 5 年之前
父節點
當前提交
0d62b7a01a

+ 9
- 9
src/components/HouseSelect/BlockSelect.jsx 查看文件

19
  * @param {*} props
19
  * @param {*} props
20
  * @returns
20
  * @returns
21
  */
21
  */
22
-const BuildingSelect = props => {
22
+const BlockSelect = props => {
23
   const [data, setData] = useState([])
23
   const [data, setData] = useState([])
24
   const [value, setValue] = useState([])
24
   const [value, setValue] = useState([])
25
   useEffect(() => {
25
   useEffect(() => {
26
-    getBuildList();
26
+    getList();
27
   }, [props.value])
27
   }, [props.value])
28
 
28
 
29
 
29
 
30
-  const getBuildList = e => {
31
-    request({ ...apis.building.buildingSelect, params: { pageNum: 1, pageSize: 999 } }).then(data => {
30
+  const getList = e => {
31
+    request({ ...apis.house.block, params: { pageNum: 1, pageSize: 999, buildingId: props.buildingId} }).then(data => {
32
         setData(data.records)
32
         setData(data.records)
33
         checkValue(data.records)
33
         checkValue(data.records)
34
         // 默认选中第一个
34
         // 默认选中第一个
39
   const checkValue = (data) => {
39
   const checkValue = (data) => {
40
     if (props.value) {
40
     if (props.value) {
41
       const tempData = data.filter(f => f.buildingId == props.value)
41
       const tempData = data.filter(f => f.buildingId == props.value)
42
-      const va = (tempData.length > 0) ? props.value : '项目已下线,请重新选择项目'
42
+      const va = (tempData.length > 0) ? props.value : '已删除,请重新选择'
43
       props.onChange(va)
43
       props.onChange(va)
44
 
44
 
45
     }
45
     }
50
       showSearch
50
       showSearch
51
       value={props.value}
51
       value={props.value}
52
       style={{ width: '300px' }}
52
       style={{ width: '300px' }}
53
-      placeholder="请选择项目"
53
+      placeholder="请选择楼栋"
54
       onChange={props.onChange}
54
       onChange={props.onChange}
55
       filterOption={(input, option) =>
55
       filterOption={(input, option) =>
56
         option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
56
         option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
57
       }>
57
       }>
58
-          {data.map(building => (
59
-            <Option key={building.buildingId} value={building.buildingId}>{building.buildingName}</Option>
58
+          {data.map(block => (
59
+            <Option key={block.blockId} value={block.blockId}>{block.blockName}</Option>
60
           ))}
60
           ))}
61
       </Select>
61
       </Select>
62
   )
62
   )
63
 }
63
 }
64
-export default BuildingSelect
64
+export default BlockSelect

+ 64
- 0
src/components/HouseSelect/FloorSelect.jsx 查看文件

1
+import React, { useState, useEffect, useRef } from 'react';
2
+import { Select } from 'antd';
3
+import apis from '../../services/apis';
4
+import request from '../../utils/request'
5
+
6
+const { Option } = Select;
7
+
8
+function usePrevious(props) {
9
+  const ref = useRef();
10
+  useEffect(() => {
11
+    ref.current = props;
12
+  });
13
+  return ref.current;
14
+}
15
+
16
+/**
17
+ *
18
+ *
19
+ * @param {*} props
20
+ * @returns
21
+ */
22
+const FloorSelect = props => {
23
+  const [data, setData] = useState([])
24
+  const [value, setValue] = useState([])
25
+  useEffect(() => {
26
+    getList();
27
+  }, [props.value])
28
+
29
+
30
+  const getList = e => {
31
+    request({ ...apis.house.floor, params: { pageNum: 1, pageSize: 999, buildingId: props.buildingId, blockId: props.blockId, unitId: props.unitId} }).then(data => {
32
+        setData(data.records)
33
+        checkValue(data.records)
34
+        // 默认选中第一个
35
+    })
36
+  }
37
+
38
+
39
+  const checkValue = (data) => {
40
+    if (props.value) {
41
+      const tempData = data.filter(f => f.buildingId == props.value)
42
+      const va = (tempData.length > 0) ? props.value : '已删除,请重新选择'
43
+      props.onChange(va)
44
+
45
+    }
46
+  }
47
+
48
+  return (
49
+      <Select
50
+      showSearch
51
+      value={props.value}
52
+      style={{ width: '300px' }}
53
+      placeholder="请选择楼层"
54
+      onChange={props.onChange}
55
+      filterOption={(input, option) =>
56
+        option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
57
+      }>
58
+          {data.map(floor => (
59
+            <Option key={floor.floorId} value={floor.floorId}>{floor.floorName}</Option>
60
+          ))}
61
+      </Select>
62
+  )
63
+}
64
+export default FloorSelect

+ 64
- 0
src/components/HouseSelect/RoomSelect.jsx 查看文件

1
+import React, { useState, useEffect, useRef } from 'react';
2
+import { Select } from 'antd';
3
+import apis from '../../services/apis';
4
+import request from '../../utils/request'
5
+
6
+const { Option } = Select;
7
+
8
+function usePrevious(props) {
9
+  const ref = useRef();
10
+  useEffect(() => {
11
+    ref.current = props;
12
+  });
13
+  return ref.current;
14
+}
15
+
16
+/**
17
+ *
18
+ *
19
+ * @param {*} props
20
+ * @returns
21
+ */
22
+const RoomSelect = props => {
23
+  const [data, setData] = useState([])
24
+  const [value, setValue] = useState([])
25
+  useEffect(() => {
26
+    getList();
27
+  }, [props.value])
28
+
29
+
30
+  const getList = e => {
31
+    request({ ...apis.house.room, params: { pageNum: 1, pageSize: 999, buildingId: props.buildingId, blockId: props.blockId, unitId: props.unitId, floorId: props.floorId} }).then(data => {
32
+        setData(data.records)
33
+        checkValue(data.records)
34
+        // 默认选中第一个
35
+    })
36
+  }
37
+
38
+
39
+  const checkValue = (data) => {
40
+    if (props.value) {
41
+      const tempData = data.filter(f => f.buildingId == props.value)
42
+      const va = (tempData.length > 0) ? props.value : '已删除,请重新选择'
43
+      props.onChange(va)
44
+
45
+    }
46
+  }
47
+
48
+  return (
49
+      <Select
50
+      showSearch
51
+      value={props.value}
52
+      style={{ width: '300px' }}
53
+      placeholder="请选择房号"
54
+      onChange={props.onChange}
55
+      filterOption={(input, option) =>
56
+        option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
57
+      }>
58
+          {data.map(room => (
59
+            <Option key={room.roomId} value={room.roomId}>{room.roomName}</Option>
60
+          ))}
61
+      </Select>
62
+  )
63
+}
64
+export default RoomSelect

+ 64
- 0
src/components/HouseSelect/UnitSelect.jsx 查看文件

1
+import React, { useState, useEffect, useRef } from 'react';
2
+import { Select } from 'antd';
3
+import apis from '../../services/apis';
4
+import request from '../../utils/request'
5
+
6
+const { Option } = Select;
7
+
8
+function usePrevious(props) {
9
+  const ref = useRef();
10
+  useEffect(() => {
11
+    ref.current = props;
12
+  });
13
+  return ref.current;
14
+}
15
+
16
+/**
17
+ *
18
+ *
19
+ * @param {*} props
20
+ * @returns
21
+ */
22
+const UnitSelect = props => {
23
+  const [data, setData] = useState([])
24
+  const [value, setValue] = useState([])
25
+  useEffect(() => {
26
+    getList();
27
+  }, [props.value])
28
+
29
+
30
+  const getList = e => {
31
+    request({ ...apis.house.unit, params: { pageNum: 1, pageSize: 999, buildingId: props.buildingId, blockId: props.blockId} }).then(data => {
32
+        setData(data.records)
33
+        checkValue(data.records)
34
+        // 默认选中第一个
35
+    })
36
+  }
37
+
38
+
39
+  const checkValue = (data) => {
40
+    if (props.value) {
41
+      const tempData = data.filter(f => f.buildingId == props.value)
42
+      const va = (tempData.length > 0) ? props.value : '已删除,请重新选择'
43
+      props.onChange(va)
44
+
45
+    }
46
+  }
47
+
48
+  return (
49
+      <Select
50
+      showSearch
51
+      value={props.value}
52
+      style={{ width: '300px' }}
53
+      placeholder="请选择单元"
54
+      onChange={props.onChange}
55
+      filterOption={(input, option) =>
56
+        option.props.children && option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
57
+      }>
58
+          {data.map(unit => (
59
+            <Option key={unit.unitId} value={unit.unitId}>{unit.unitName}</Option>
60
+          ))}
61
+      </Select>
62
+  )
63
+}
64
+export default UnitSelect

+ 45
- 19
src/pages/house/edit/components/house.jsx 查看文件

5
 import apis from '../../../../services/apis';
5
 import apis from '../../../../services/apis';
6
 import Styles from './style.less';
6
 import Styles from './style.less';
7
 import { router } from 'umi';
7
 import { router } from 'umi';
8
+import BlockSelect from '../../../../components/HouseSelect/BlockSelect'
9
+import UnitSelect from '../../../../components/HouseSelect/UnitSelect'
10
+import FloorSelect from '../../../../components/HouseSelect/FloorSelect'
11
+import RoomSelect from '../../../../components/HouseSelect/RoomSelect'
8
 
12
 
9
 /**
13
 /**
10
  *图片设置
14
  *图片设置
56
     },
60
     },
57
   };
61
   };
58
 
62
 
59
-  function showEdi() {
60
-    window.location.href = "/house/add";
63
+  function showEdi(e) {
64
+    props.onSuccess(e);
65
+  }
66
+
67
+  // 提交事件
68
+  const handleSubmit = e => {
69
+    e.preventDefault();
70
+    props.form.validateFields((err, values) => {
71
+      if (!err) {
72
+        console.log('提交数据: ', values)
73
+        getList({ pageNumber: 1, pageSize: 10, ...values })
74
+      }
75
+    });
61
   }
76
   }
62
 
77
 
63
   /**
78
   /**
147
       key: 'apartmentId',
162
       key: 'apartmentId',
148
       render: (_, record) => (
163
       render: (_, record) => (
149
         <>
164
         <>
150
-          <Button type="link" style={{ color: 'red' }} onClick={() => showEdi(record)}>编辑</Button>
165
+          <Button type="link" style={{ color: 'red' }} onClick={() => showEdi({type: "edit",record})}>编辑</Button>
151
           <Button type="link" style={{ color: 'red' }} onClick={() => deleteApartment(record)}>删除</Button>
166
           <Button type="link" style={{ color: 'red' }} onClick={() => deleteApartment(record)}>删除</Button>
152
         </>
167
         </>
153
       ),
168
       ),
158
     <>
173
     <>
159
     <Form layout="inline" onSubmit={e => handleSubmit(e)}>
174
     <Form layout="inline" onSubmit={e => handleSubmit(e)}>
160
         <Form.Item>
175
         <Form.Item>
161
-          {getFieldDecorator('cityId')(
162
-            <Input
163
-            prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
164
-            placeholder="请输入标题"
165
-          />,
176
+          {getFieldDecorator('blockId')(
177
+            <Input placeholder="请输入楼栋"/>
178
+          )}
179
+        </Form.Item>
180
+        <Form.Item>
181
+          {getFieldDecorator('unitId')(
182
+            <Input placeholder="请输入单元"/>
183
+          )}
184
+        </Form.Item>
185
+        <Form.Item>
186
+          {getFieldDecorator('floorId')(
187
+            <Input placeholder="请输入楼层"/>
188
+          )}
189
+        </Form.Item>
190
+        <Form.Item>
191
+          {getFieldDecorator('roomId')(
192
+             <Input placeholder="请输入房间号"/>
193
+          )}
194
+        </Form.Item>
195
+        <Form.Item>
196
+          {getFieldDecorator('roomId')(
197
+             <Input placeholder="请输入户型"/>
166
           )}
198
           )}
167
         </Form.Item>
199
         </Form.Item>
168
         <Form.Item>
200
         <Form.Item>
169
-          {getFieldDecorator('buildingId')(
170
-            <Input
171
-            prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
172
-            placeholder="请输入标题"
173
-          />,
201
+          {getFieldDecorator('roomId')(
202
+             <Input placeholder="发布状态"/>
174
           )}
203
           )}
175
         </Form.Item>
204
         </Form.Item>
176
         <Form.Item>
205
         <Form.Item>
177
-          {getFieldDecorator('title')(
178
-            <Input
179
-              prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
180
-              placeholder="请输入标题"
181
-            />,
206
+          {getFieldDecorator('houseId')(
207
+            <Input placeholder="请输入房源编号"/>,
182
           )}
208
           )}
183
         </Form.Item>
209
         </Form.Item>
184
         <Form.Item>
210
         <Form.Item>
190
             </Button>
216
             </Button>
191
         </Form.Item>
217
         </Form.Item>
192
       </Form>
218
       </Form>
193
-      <Button type="primary" onClick={() => showEdi()}>新增房源</Button>
219
+      <Button type="primary" onClick={() => showEdi({type: "add"})}>新增房源</Button>
194
       <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量导入房源</Button>
220
       <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量导入房源</Button>
195
       <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量修改对应户型</Button>
221
       <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量修改对应户型</Button>
196
       <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>
222
       <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>

+ 179
- 0
src/pages/house/edit/components/houseAdd.jsx 查看文件

1
+import React, { useState, useEffect } from 'react';
2
+import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Upload } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import moment from 'moment';
5
+import router from 'umi/router';
6
+import apis from '../../../../services/apis';
7
+import XForm, { FieldTypes } from '../../../../components/XForm';
8
+
9
+const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
10
+const { TextArea } = Input;
11
+
12
+const formItemLayout = {
13
+  labelCol: { span: 6 },
14
+  wrapperCol: { span: 14 },
15
+};
16
+
17
+function HouseAdd(props) {
18
+  function checkValues() {
19
+    props.form.validateFields((err, values) => {
20
+      if (!err) {
21
+        console.log(values,"valuesvaluesvalues")
22
+      }
23
+    });
24
+  }
25
+
26
+  function handleSubmit(e) {
27
+    e.preventDefault();
28
+    props.form.validateFields((err, values) => {
29
+      if (!err) {
30
+        console.log('Received values of form: ', values);
31
+        const { activityTime, signupTime } = values
32
+        const [startDate, endDate] = activityTime
33
+        values.startDate = moment(startDate).format('YYYY-MM-DD HH:mm');
34
+        values.endDate = moment(endDate).format('YYYY-MM-DD HH:mm');
35
+        if (signupTime) {
36
+          const [enlistStart, enlistEnd] = signupTime
37
+          values.enlistStart = moment(enlistStart).format('YYYY-MM-DD HH:mm');
38
+          values.enlistEnd = moment(enlistEnd).format('YYYY-MM-DD HH:mm');
39
+        }
40
+        
41
+        console.log('submit data --->', values)
42
+        if (dynamicId) {
43
+          values.dynamicId = dynamicId
44
+          request({ ...apis.activity.update, data: values }).then(data => {
45
+            message.info('保存成功')
46
+            // router.go(-1)
47
+          }).catch((err) => {
48
+            message.info(err.msg || err.message)
49
+          })
50
+        } else {
51
+          request({ ...apis.activity.add, data: { ...values } }).then((data) => {
52
+            message.info('保存成功')
53
+            router.push({
54
+              pathname: '/activity/editActivity',
55
+              query: {
56
+                dynamicId: data.dynamicId,
57
+              },
58
+            });
59
+            // router.go(-1)
60
+          }).catch((err) => {
61
+            message.info(err.msg || err.message)
62
+          })
63
+        }
64
+      }
65
+    });
66
+  }
67
+
68
+  function cancelPage(e) {
69
+    
70
+  }
71
+
72
+  const { getFieldDecorator } = props.form;
73
+  return (
74
+    <>
75
+      <Form {...formItemLayout} onSubmit={handleSubmit}>
76
+        <Form.Item label="楼栋">
77
+        {getFieldDecorator('blockName', {
78
+          rules: [
79
+            {
80
+              required: true,
81
+              message: '请输入楼栋',
82
+            },
83
+          ],
84
+        })(<Input/>)}
85
+        </Form.Item>
86
+        <Form.Item label="单元">
87
+        {getFieldDecorator('unitName', {
88
+          rules: [
89
+            {
90
+              required: true,
91
+              message: '请输入单元',
92
+            },
93
+          ],
94
+        })(<Input/>)}
95
+        </Form.Item>
96
+        <Form.Item label="层">
97
+        {getFieldDecorator('floorName', {
98
+          rules: [
99
+            {
100
+              required: true,
101
+              message: '请输入楼层',
102
+            },
103
+          ],
104
+        })(<Input/>)}
105
+        </Form.Item>
106
+        <Form.Item label="房号">
107
+        {getFieldDecorator('roomName', {
108
+          rules: [
109
+            {
110
+              required: true,
111
+              message: '请输入房号',
112
+            },
113
+          ],
114
+        })(<Input/>)}
115
+        </Form.Item>
116
+        <Form.Item label="价格">
117
+        {getFieldDecorator('price', {
118
+          rules: [
119
+            {
120
+              required: true,
121
+              message: '请输入价格',
122
+            },
123
+          ],
124
+        })(<Input type="Number"/>)}
125
+        </Form.Item>
126
+        <Form.Item label="预选基础热度">
127
+        {getFieldDecorator('heat', {
128
+          rules: [
129
+            {
130
+              required: true,
131
+              message: '请输入楼栋',
132
+            },
133
+          ],
134
+        })(<Input/>)}
135
+        </Form.Item>
136
+        <Form.Item label="户型">
137
+        {getFieldDecorator('apartmentId', {
138
+          rules: [
139
+            {
140
+              required: true,
141
+              message: '请输入楼栋',
142
+            },
143
+          ],
144
+        })(<Input/>)}
145
+        </Form.Item>
146
+        <Form.Item label="发布状态">
147
+        {getFieldDecorator('status', {
148
+          rules: [
149
+            {
150
+              required: true,
151
+              message: '请输入楼栋',
152
+            },
153
+          ],
154
+        })(
155
+          <Select placeholder="发布状态">
156
+            <Option value="0">否</Option>
157
+            <Option value="1">是</Option>
158
+          </Select>,
159
+        )}
160
+        </Form.Item>
161
+        <Form.Item wrapperCol={{ span: 12, offset: 8 }}>
162
+          <Button type="primary" htmlType="submit">
163
+            确认
164
+          </Button>
165
+          &nbsp;&nbsp;&nbsp;&nbsp;
166
+          <Button type="primary" onClick={() => checkValues()}>
167
+            校验
168
+          </Button>
169
+          &nbsp;&nbsp;&nbsp;&nbsp;
170
+          <Button onClick={() => cancelPage({type: "house"})}>
171
+            取消
172
+          </Button>
173
+        </Form.Item>
174
+      </Form>
175
+    </>
176
+  )
177
+}
178
+const WrappedHouseAdd = Form.create({ name: 'house_add' })(HouseAdd);
179
+export default WrappedHouseAdd

+ 9
- 23
src/pages/house/edit/components/houseTab.jsx 查看文件

6
 import { router } from 'umi';
6
 import { router } from 'umi';
7
 
7
 
8
 import House from './house'
8
 import House from './house'
9
+import HouseAdd from './houseAdd'
9
 
10
 
10
-const { Option } = Select
11
-const { TabPane } = Tabs;
12
-
13
-const formItemLayout = {
14
-  labelCol: {
15
-    xs: { span: 24 },
16
-    sm: { span: 2 },
17
-  },
18
-  wrapperCol: {
19
-    xs: { span: 24 },
20
-    sm: { span: 16 },
21
-  },
22
-};
23
-
24
-function openNotificationWithIcon(type, message) {
25
-  notification[type]({
26
-    message,
27
-    description:
28
-      '',
29
-  });
30
-}
31
 
11
 
32
-function EditHouse(props) {
33
 
12
 
13
+function EditHouse(props) {
34
   const [tab, setTab] = useState('house')
14
   const [tab, setTab] = useState('house')
35
 
15
 
16
+  function changeTab(e) {
17
+    console.log(e,"eeeee")
18
+    setTab(e.type)
19
+  }
20
+
36
   return (
21
   return (
37
     <>
22
     <>
38
       <div style={{ marginTop: '20px' }}>
23
       <div style={{ marginTop: '20px' }}>
39
-        { (tab === 'house' && <House salesBatchId="1" buildingId="1" />)} 
24
+        { (tab === 'house' && <House salesBatchId={props.salesBatchId} buildingId={props.buildingId} onSuccess={e => changeTab(e)}/>)} 
25
+        { (tab === 'add' && <HouseAdd salesBatchId={props.salesBatchId} buildingId={props.buildingId} onSuccess={e => changeTab(e)}/>)} 
40
       </div>
26
       </div>
41
     </>
27
     </>
42
   )
28
   )

+ 15
- 0
src/services/apis.js 查看文件

1093
     method: 'GET',
1093
     method: 'GET',
1094
     url: `${prefix}/taHousingResources`,
1094
     url: `${prefix}/taHousingResources`,
1095
     action: 'admin.taHousingResources.id.get',
1095
     action: 'admin.taHousingResources.id.get',
1096
+  },
1097
+  block: {
1098
+    method: 'GET',
1099
+    url: `${prefix}/taBuildingBlock`,
1100
+    action: 'admin.taBuildingBlock.get',
1101
+  },
1102
+  unit: {
1103
+    method: 'GET',
1104
+    url: `${prefix}/taBuildingUnit`,
1105
+    action: 'admin.taBuildingUnit.get',
1106
+  },
1107
+  floor: {
1108
+    method: 'GET',
1109
+    url: `${prefix}/taBuildingFloor`,
1110
+    action: 'admin.taBuildingFloor.get',
1096
   }
1111
   }
1097
  },
1112
  },
1098
 }
1113
 }