浏览代码

新需求

傅行帆 5 年前
父节点
当前提交
4c75382110

+ 20
- 10
src/pages/house/edit/components/house.jsx 查看文件

@@ -9,6 +9,7 @@ import BlockSelect from '../../../../components/HouseSelect/BlockSelect'
9 9
 import UnitSelect from '../../../../components/HouseSelect/UnitSelect'
10 10
 import FloorSelect from '../../../../components/HouseSelect/FloorSelect'
11 11
 import RoomSelect from '../../../../components/HouseSelect/RoomSelect'
12
+import ApartmentSelect from '../../../../components/HouseSelect/ApartmentSelect';
12 13
 
13 14
 /**
14 15
  *图片设置
@@ -150,6 +151,7 @@ function House(props) {
150 151
       title: '发布状态',
151 152
       dataIndex: 'status',
152 153
       key: 'status',
154
+      render: status => <><span>{status == 0 ? '否' : status == 1 ? '是' : ''}</span></>,
153 155
     },
154 156
     {
155 157
       title: '最后修改人',
@@ -162,7 +164,7 @@ function House(props) {
162 164
       key: 'apartmentId',
163 165
       render: (_, record) => (
164 166
         <>
165
-          <Button type="link" style={{ color: 'red' }} onClick={() => showEdi({type: "edit",record})}>编辑</Button>
167
+          <Button type="link" style={{ color: 'red' }} onClick={() => showEdi({type: "add",houseId: record.houseId})}>编辑</Button>
166 168
           <Button type="link" style={{ color: 'red' }} onClick={() => deleteApartment(record)}>删除</Button>
167 169
         </>
168 170
       ),
@@ -173,33 +175,41 @@ function House(props) {
173 175
     <>
174 176
     <Form layout="inline" onSubmit={e => handleSubmit(e)}>
175 177
         <Form.Item>
176
-          {getFieldDecorator('blockId')(
178
+          {getFieldDecorator('termName')(
179
+            <Input placeholder="请输入期/区"/>
180
+          )}
181
+        </Form.Item>
182
+        <Form.Item>
183
+          {getFieldDecorator('blockName')(
177 184
             <Input placeholder="请输入楼栋"/>
178 185
           )}
179 186
         </Form.Item>
180 187
         <Form.Item>
181
-          {getFieldDecorator('unitId')(
188
+          {getFieldDecorator('unitName')(
182 189
             <Input placeholder="请输入单元"/>
183 190
           )}
184 191
         </Form.Item>
185 192
         <Form.Item>
186
-          {getFieldDecorator('floorId')(
193
+          {getFieldDecorator('floorName')(
187 194
             <Input placeholder="请输入楼层"/>
188 195
           )}
189 196
         </Form.Item>
190 197
         <Form.Item>
191
-          {getFieldDecorator('roomId')(
198
+          {getFieldDecorator('roomName')(
192 199
              <Input placeholder="请输入房间号"/>
193 200
           )}
194 201
         </Form.Item>
195 202
         <Form.Item>
196
-          {getFieldDecorator('roomId')(
197
-             <Input placeholder="请输入户型"/>
203
+          {getFieldDecorator('apartmentId')(
204
+             <ApartmentSelect buildingId={props.buildingId} />
198 205
           )}
199 206
         </Form.Item>
200 207
         <Form.Item>
201
-          {getFieldDecorator('roomId')(
202
-             <Input placeholder="发布状态"/>
208
+          {getFieldDecorator('status')(
209
+             <Select placeholder="发布状态" style={{width: '120px'}}>
210
+             <Option value="0">否</Option>
211
+             <Option value="1">是</Option>
212
+           </Select>,
203 213
           )}
204 214
         </Form.Item>
205 215
         <Form.Item>
@@ -216,7 +226,7 @@ function House(props) {
216 226
             </Button>
217 227
         </Form.Item>
218 228
       </Form>
219
-      <Button type="primary" onClick={() => showEdi({type: "add"})}>新增房源</Button>
229
+      <Button type="primary" onClick={() => showEdi({type: "add",houseId: ''})}>新增房源</Button>
220 230
       <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量导入房源</Button>
221 231
       <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量修改对应户型</Button>
222 232
       <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>

+ 57
- 54
src/pages/house/edit/components/houseAdd.jsx 查看文件

@@ -3,8 +3,10 @@ import { Form, Input, Button, Icon, Select, Tabs, Radio, DatePicker, message, Up
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import moment from 'moment';
5 5
 import router from 'umi/router';
6
+import request from '../../../../utils/request';
6 7
 import apis from '../../../../services/apis';
7 8
 import XForm, { FieldTypes } from '../../../../components/XForm';
9
+import ApartmentSelect from '../../../../components/HouseSelect/ApartmentSelect';
8 10
 
9 11
 const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
10 12
 const { TextArea } = Input;
@@ -15,64 +17,73 @@ const formItemLayout = {
15 17
 };
16 18
 
17 19
 function HouseAdd(props) {
20
+  console.log(props,"props222")
21
+  const houseId = props.houseId
22
+    
23
+  useEffect(() => {
24
+    if (houseId && houseId !== '') {
25
+      getById(houseId)
26
+    }
27
+  }, [houseId])
28
+
29
+  function getById(houseId) {
30
+    request({ ...apis.house.getById, urlData: { id: houseId } }).then(data => {
31
+      props.form.setFieldsValue(data)
32
+    }).catch((err) => {
33
+      message.info(err.msg || err.message)
34
+    })
35
+  }
36
+
37
+  //校验房源
18 38
   function checkValues() {
19
-    props.form.validateFields((err, values) => {
20
-      if (!err) {
21
-        console.log(values,"valuesvaluesvalues")
22
-      }
23
-    });
39
+    request({ ...apis.house.checked, data: { ...props.form.getFieldsValue(), buildingId: props.buildingId } }).then(data => {
40
+      message.warn(data)
41
+    }).catch((err) => {
42
+      message.info(err.msg || err.message)
43
+    })
24 44
   }
25 45
 
26 46
   function handleSubmit(e) {
27 47
     e.preventDefault();
28 48
     props.form.validateFields((err, values) => {
29 49
       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
-        }
50
+          if(houseId){
51
+            request({ ...apis.house.houseEdit,urlData: {id: houseId}, data: { ...values,buildingId: props.buildingId, salesBatchId: props.salesBatchId } }).then((data) => {
52
+              message.info('保存成功')
53
+              props.onSuccess({type: "house"})
54
+            }).catch((err) => {
55
+              // message.info(err.msg || err.message)
56
+            })
57
+          }else{
58
+            request({ ...apis.house.houseAdd, data: { ...values,buildingId: props.buildingId, salesBatchId: props.salesBatchId } }).then((data) => {
59
+              message.info('保存成功')
60
+              props.onSuccess({type: "house"})
61
+            }).catch((err) => {
62
+              // message.info(err.msg || err.message)
63
+            })
64
+          }
64 65
       }
65 66
     });
66 67
   }
67 68
 
68 69
   function cancelPage(e) {
69
-    
70
+    props.onSuccess({type: "house"})
70 71
   }
71 72
 
72 73
   const { getFieldDecorator } = props.form;
73 74
   return (
74 75
     <>
75 76
       <Form {...formItemLayout} onSubmit={handleSubmit}>
77
+      <Form.Item label="期">
78
+        {getFieldDecorator('termName', {
79
+          rules: [
80
+            {
81
+              required: true,
82
+              message: '请输入楼栋',
83
+            },
84
+          ],
85
+        })(<Input/>)}
86
+        </Form.Item>
76 87
         <Form.Item label="楼栋">
77 88
         {getFieldDecorator('blockName', {
78 89
           rules: [
@@ -111,9 +122,12 @@ function HouseAdd(props) {
111 122
               message: '请输入房号',
112 123
             },
113 124
           ],
114
-        })(<Input/>)}
125
+        })(<Input/> )}
126
+         <Button type="primary" onClick={() => checkValues()}>
127
+            校验房源
128
+          </Button>
115 129
         </Form.Item>
116
-        <Form.Item label="价格">
130
+        <Form.Item label="价格" help="单位:万元">
117 131
         {getFieldDecorator('price', {
118 132
           rules: [
119 133
             {
@@ -134,14 +148,7 @@ function HouseAdd(props) {
134 148
         })(<Input/>)}
135 149
         </Form.Item>
136 150
         <Form.Item label="户型">
137
-        {getFieldDecorator('apartmentId', {
138
-          rules: [
139
-            {
140
-              required: true,
141
-              message: '请输入楼栋',
142
-            },
143
-          ],
144
-        })(<Input/>)}
151
+        {getFieldDecorator('apartmentId')(<ApartmentSelect buildingId={props.buildingId} />)}
145 152
         </Form.Item>
146 153
         <Form.Item label="发布状态">
147 154
         {getFieldDecorator('status', {
@@ -163,10 +170,6 @@ function HouseAdd(props) {
163 170
             确认
164 171
           </Button>
165 172
           &nbsp;&nbsp;&nbsp;&nbsp;
166
-          <Button type="primary" onClick={() => checkValues()}>
167
-            校验
168
-          </Button>
169
-          &nbsp;&nbsp;&nbsp;&nbsp;
170 173
           <Button onClick={() => cancelPage({type: "house"})}>
171 174
             取消
172 175
           </Button>

+ 5
- 2
src/pages/house/edit/components/houseTab.jsx 查看文件

@@ -12,17 +12,20 @@ import HouseAdd from './houseAdd'
12 12
 
13 13
 function EditHouse(props) {
14 14
   const [tab, setTab] = useState('house')
15
+  const [houseId, setHouseId] = useState('')
15 16
 
16 17
   function changeTab(e) {
17
-    console.log(e,"eeeee")
18 18
     setTab(e.type)
19
+    if(e.type === "add"){
20
+      setHouseId(e.houseId)
21
+    }
19 22
   }
20 23
 
21 24
   return (
22 25
     <>
23 26
       <div style={{ marginTop: '20px' }}>
24 27
         { (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)}/>)} 
28
+        { (tab === 'add' && <HouseAdd salesBatchId={props.salesBatchId} buildingId={props.buildingId} houseId={houseId} onSuccess={e => changeTab(e)}/>)} 
26 29
       </div>
27 30
     </>
28 31
   )

+ 2
- 4
src/pages/house/edit/index.jsx 查看文件

@@ -40,11 +40,9 @@ function openNotificationWithIcon(type, message) {
40 40
 function EditHouse(props) {
41 41
   const {salesBatchId} = props.location.query.id;
42 42
   console.log(props.location.query.id)
43
-  const [tab, setTab] = useState('base')
43
+  const [tab, setTab] = useState('house')
44 44
   const [salesBatchData, setSalesBatchData] = useState({ salesBatchId: undefined })
45 45
 
46
-  // const [tab, setTab] = useState('house')
47
-  
48 46
   function tabsCallback(e) {
49 47
     setTab(e.target.value)
50 48
   }
@@ -68,7 +66,7 @@ function EditHouse(props) {
68 66
       </Radio.Group>
69 67
       <div style={{ marginTop: '20px' }}>
70 68
         { (tab === 'base' && <Base salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }} onSuccess={e => buildingOnSuccess(e)}/>)} 
71
-        { (tab === 'house' && <HouseTab salesBatchId="1" buildingId="1"/>)}
69
+        { (tab === 'house' && <HouseTab salesBatchId={props.location.query.id} buildingId={props.location.query.buildingId}/>)}
72 70
         { (tab === 'poster' && <Poster />)}
73 71
         { (tab === 'share' && <Share />)}
74 72
         { (tab === 'preselectionImg' && <PreselectionImg />)}

+ 5
- 4
src/pages/house/list/index.jsx 查看文件

@@ -34,12 +34,13 @@ const header = props => {
34 34
   }, [])
35 35
 
36 36
   // 跳转到编辑商品
37
-  const toAddHouse = id => () => {
38
-    if(id) {
37
+  const toAddHouse = rowData => () => {
38
+    if(rowData) {
39 39
       router.push({
40 40
       pathname: '/house/edit',
41 41
       query: {
42
-        id
42
+        id: rowData.salesBatchId,
43
+        buildingId: rowData.buildingId,
43 44
       },
44 45
     });
45 46
       return
@@ -94,7 +95,7 @@ const header = props => {
94 95
       dataIndex: 'salesBatchName',
95 96
       key: 'salesBatchName',
96 97
       align: 'center',
97
-      render:  (x, row) => <><span style={{color: 'blue',cursor: 'pointer'}} onClick={toAddHouse(row.salesBatchId)}>{row.salesBatchName}</span></>,
98
+      render:  (x, row) => <><span style={{color: 'blue',cursor: 'pointer'}} onClick={toAddHouse(row)}>{row.salesBatchName}</span></>,
98 99
     },
99 100
     {
100 101
       title: '楼盘名称',

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

@@ -1128,6 +1128,31 @@ export default {
1128 1128
     method: 'GET',
1129 1129
     url: `${prefix}/taBuildingFloor`,
1130 1130
     action: 'admin.taBuildingFloor.get',
1131
+  },
1132
+  apartmentList: {
1133
+    method: 'GET',
1134
+    url: `${prefix}/apartmentList`,
1135
+    action: 'admin.apartmentList.get',
1136
+  },
1137
+  checked: {
1138
+    method: 'PUT',
1139
+    url: `${prefix}/house/checked`,
1140
+    action: 'admin.house.checked.get',
1141
+  },
1142
+  houseAdd: {
1143
+    url: `${prefix}/taHousingResources`,
1144
+    method: 'POST',
1145
+    action: 'admin.taHousingResources.get',
1146
+  },
1147
+  getById: {
1148
+    method: 'GET',
1149
+    url: `${prefix}/taHousingResources/:id`,
1150
+    action: 'admin.taHousingResources.id.get',
1151
+  },
1152
+  houseEdit: {
1153
+    url: `${prefix}/taHousingResources/:id`,
1154
+    method: 'PUT',
1155
+    action: 'admin.taHousingResources.id.put',
1131 1156
   }
1132 1157
  },
1133 1158
 }