Browse Source

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

张延森 5 years ago
parent
commit
a2b5200ab1

+ 1
- 1
src/components/HouseSelect/ApartmentSelect.jsx View File

38
 
38
 
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.apartmentId == 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
 

+ 63
- 7
src/pages/house/edit/components/house.jsx View File

20
 function House(props) {
20
 function House(props) {
21
   // eslint-disable-next-line react-hooks/rules-of-hooks
21
   // eslint-disable-next-line react-hooks/rules-of-hooks
22
   const [data, setData] = useState([])
22
   const [data, setData] = useState([])
23
+  const [viable, setViable] = useState(false)
24
+  const [houseIdList, setHouseIdList] = useState([])
23
 
25
 
24
   useEffect(() => {
26
   useEffect(() => {
25
     getList()
27
     getList()
58
   const rowSelection = {
60
   const rowSelection = {
59
     onChange: (selectedRowKeys, selectedRows) => {
61
     onChange: (selectedRowKeys, selectedRows) => {
60
       console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
62
       console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
63
+      setHouseIdList(selectedRows)
61
     },
64
     },
62
   };
65
   };
63
 
66
 
65
     props.onSuccess(e);
68
     props.onSuccess(e);
66
   }
69
   }
67
 
70
 
71
+  //打开model
72
+  function showAparement() {
73
+    if(houseIdList.length < 1){
74
+      openNotificationWithIcon('error', '请先选择需要改变的房源')
75
+      return
76
+    }
77
+    setViable(true)
78
+  }
79
+
80
+  function handleCancel() {
81
+    setViable(false)
82
+  }
83
+
68
   // 提交事件
84
   // 提交事件
69
   const handleSubmit = e => {
85
   const handleSubmit = e => {
70
     e.preventDefault();
86
     e.preventDefault();
76
     });
92
     });
77
   }
93
   }
78
 
94
 
95
+    // model提交事件
96
+    const handleSubmitApartMent = e => {
97
+      props.form.validateFields((err, values) => {
98
+        if (!err) {
99
+          if(!values.apartmentIdSelected){
100
+            openNotificationWithIcon('error', '请选择户型')
101
+            return
102
+          }
103
+          request({ ...apis.house.changeApartment, data: { apartmentId: values.apartmentIdSelected, houseIdList } }).then(res => {
104
+            setViable(false)
105
+            getList({ pageNumber: 1, pageSize: 10 })
106
+            openNotificationWithIcon('success', '操作成功')
107
+          }).catch(err => {
108
+            openNotificationWithIcon('error', err.message)
109
+          })
110
+        }
111
+      });
112
+    }
79
   /**
113
   /**
80
    * 删除
114
    * 删除
81
    *
115
    *
82
    * @param {*} record
116
    * @param {*} record
83
    */
117
    */
84
-  function deleteApartment(record) {
85
-    confirm({
118
+  function deleteHouseResource(record) {
119
+    Modal.confirm({
86
       title: '确认删除当前数据?',
120
       title: '确认删除当前数据?',
87
       content: '确定后成功删除,点击取消则放弃当前操作',
121
       content: '确定后成功删除,点击取消则放弃当前操作',
88
       okText: '确定',
122
       okText: '确定',
89
       cancelText: '取消',
123
       cancelText: '取消',
90
       onOk() {
124
       onOk() {
91
         // 网路请求
125
         // 网路请求
92
-        request({ ...apis.building.buildingApartmentDelete, urlData: { id: record.apartmentId } }).then(res => {
93
-          getList()
126
+        request({ ...apis.house.houseDelete, urlData: { id: record.houseId } }).then(res => {
127
+          getList({ pageNumber: 1, pageSize: 10 })
94
           openNotificationWithIcon('success', '操作成功')
128
           openNotificationWithIcon('success', '操作成功')
95
         }).catch(err => {
129
         }).catch(err => {
96
           // openNotificationWithIcon('error', err.message)
130
           // openNotificationWithIcon('error', err.message)
165
       render: (_, record) => (
199
       render: (_, record) => (
166
         <>
200
         <>
167
           <Button type="link" style={{ color: 'red' }} onClick={() => showEdi({type: "add",houseId: record.houseId})}>编辑</Button>
201
           <Button type="link" style={{ color: 'red' }} onClick={() => showEdi({type: "add",houseId: record.houseId})}>编辑</Button>
168
-          <Button type="link" style={{ color: 'red' }} onClick={() => deleteApartment(record)}>删除</Button>
202
+          <Button type="link" style={{ color: 'red' }} onClick={() => deleteHouseResource(record)}>删除</Button>
169
         </>
203
         </>
170
       ),
204
       ),
171
     },
205
     },
227
         </Form.Item>
261
         </Form.Item>
228
       </Form>
262
       </Form>
229
       <Button type="primary" onClick={() => showEdi({type: "add",houseId: ''})}>新增房源</Button>
263
       <Button type="primary" onClick={() => showEdi({type: "add",houseId: ''})}>新增房源</Button>
230
-      <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量导入房源</Button>
231
-      <Button type="primary" onClick={() => showEdi()} style={{ marginLeft: '18px'}}>批量修改对应户型</Button>
264
+      <Button type="primary" onClick={() => showEdi({type: "batch"})} style={{ marginLeft: '18px'}}>批量导入房源</Button>
265
+      <Button type="primary" onClick={() => showAparement()} style={{ marginLeft: '18px'}}>批量修改对应户型</Button>
232
       <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>
266
       <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>
233
       <Table rowSelection={rowSelection} dataSource={data.records} columns={columns} pagination={{ total: data.total, onChange: e => this.changePageNum(e) }} rowKey="House" />
267
       <Table rowSelection={rowSelection} dataSource={data.records} columns={columns} pagination={{ total: data.total, onChange: e => this.changePageNum(e) }} rowKey="House" />
268
+      <Modal
269
+            title="批量修改对应户型"
270
+            width={400}
271
+            destroyOnClose="true"
272
+            footer={null}
273
+            visible={viable}
274
+            onOk={() => this.handleOk()}
275
+            onCancel={e => handleCancel(e)}
276
+          >
277
+            <Form onSubmit={e => handleSubmitApartMent(e)}>
278
+              <Form.Item label="将所选房源对应户型信息修改为" >
279
+                {getFieldDecorator('apartmentIdSelected')(
280
+                <ApartmentSelect buildingId={props.buildingId} />
281
+                )}
282
+              </Form.Item>
283
+              <Form.Item style={{ width: '400px', margin: 'auto', display: 'flex', justifyContent: 'space-between' }}>
284
+                <Button type="primary" htmlType="submit">保存</Button>
285
+                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
286
+                <Button onClick={() => handleCancel()}>取消</Button>
287
+              </Form.Item>
288
+            </Form>
289
+        </Modal>
234
     </>
290
     </>
235
   )
291
   )
236
 }
292
 }

+ 8
- 8
src/pages/house/edit/components/houseAdd.jsx View File

49
       if (!err) {
49
       if (!err) {
50
           if(houseId){
50
           if(houseId){
51
             request({ ...apis.house.houseEdit,urlData: {id: houseId}, data: { ...values,buildingId: props.buildingId, salesBatchId: props.salesBatchId } }).then((data) => {
51
             request({ ...apis.house.houseEdit,urlData: {id: houseId}, data: { ...values,buildingId: props.buildingId, salesBatchId: props.salesBatchId } }).then((data) => {
52
-              message.info('保存成功')
52
+              message.info('修改成功')
53
               props.onSuccess({type: "house"})
53
               props.onSuccess({type: "house"})
54
             }).catch((err) => {
54
             }).catch((err) => {
55
               // message.info(err.msg || err.message)
55
               // message.info(err.msg || err.message)
74
   return (
74
   return (
75
     <>
75
     <>
76
       <Form {...formItemLayout} onSubmit={handleSubmit}>
76
       <Form {...formItemLayout} onSubmit={handleSubmit}>
77
-      <Form.Item label="期">
77
+      <Form.Item label="期" >
78
         {getFieldDecorator('termName', {
78
         {getFieldDecorator('termName', {
79
           rules: [
79
           rules: [
80
             {
80
             {
82
               message: '请输入楼栋',
82
               message: '请输入楼栋',
83
             },
83
             },
84
           ],
84
           ],
85
-        })(<Input/>)}
85
+        })(<Input disabled={houseId && houseId !== '' ? true : false}/>)}
86
         </Form.Item>
86
         </Form.Item>
87
         <Form.Item label="楼栋">
87
         <Form.Item label="楼栋">
88
         {getFieldDecorator('blockName', {
88
         {getFieldDecorator('blockName', {
92
               message: '请输入楼栋',
92
               message: '请输入楼栋',
93
             },
93
             },
94
           ],
94
           ],
95
-        })(<Input/>)}
95
+        })(<Input disabled={houseId && houseId !== '' ? true : false}/>)}
96
         </Form.Item>
96
         </Form.Item>
97
         <Form.Item label="单元">
97
         <Form.Item label="单元">
98
         {getFieldDecorator('unitName', {
98
         {getFieldDecorator('unitName', {
102
               message: '请输入单元',
102
               message: '请输入单元',
103
             },
103
             },
104
           ],
104
           ],
105
-        })(<Input/>)}
105
+        })(<Input disabled={houseId && houseId !== '' ? true : false}/>)}
106
         </Form.Item>
106
         </Form.Item>
107
         <Form.Item label="层">
107
         <Form.Item label="层">
108
         {getFieldDecorator('floorName', {
108
         {getFieldDecorator('floorName', {
112
               message: '请输入楼层',
112
               message: '请输入楼层',
113
             },
113
             },
114
           ],
114
           ],
115
-        })(<Input/>)}
115
+        })(<Input disabled={houseId && houseId !== '' ? true : false}/>)}
116
         </Form.Item>
116
         </Form.Item>
117
         <Form.Item label="房号">
117
         <Form.Item label="房号">
118
         {getFieldDecorator('roomName', {
118
         {getFieldDecorator('roomName', {
160
           ],
160
           ],
161
         })(
161
         })(
162
           <Select placeholder="发布状态">
162
           <Select placeholder="发布状态">
163
-            <Option value="0">否</Option>
164
-            <Option value="1">是</Option>
163
+            <Option value={0}>否</Option>
164
+            <Option value={1}>是</Option>
165
           </Select>,
165
           </Select>,
166
         )}
166
         )}
167
         </Form.Item>
167
         </Form.Item>

+ 2
- 0
src/pages/house/edit/components/houseTab.jsx View File

7
 
7
 
8
 import House from './house'
8
 import House from './house'
9
 import HouseAdd from './houseAdd'
9
 import HouseAdd from './houseAdd'
10
+import HouseBatch from './HouseBatch'
10
 
11
 
11
 
12
 
12
 
13
 
26
       <div style={{ marginTop: '20px' }}>
27
       <div style={{ marginTop: '20px' }}>
27
         { (tab === 'house' && <House salesBatchId={props.salesBatchId} buildingId={props.buildingId} onSuccess={e => changeTab(e)}/>)} 
28
         { (tab === 'house' && <House 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)}/>)} 
29
         { (tab === 'add' && <HouseAdd salesBatchId={props.salesBatchId} buildingId={props.buildingId} houseId={houseId} onSuccess={e => changeTab(e)}/>)} 
30
+        { (tab === 'batch' && <HouseBatch salesBatchId={props.salesBatchId} buildingId={props.buildingId} onSuccess={e => changeTab(e)}/>)} 
29
       </div>
31
       </div>
30
     </>
32
     </>
31
   )
33
   )

+ 186
- 9
src/pages/house/edit/components/preselectionRecord.jsx View File

1
 import React, { useState, useEffect } from 'react';
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';
2
+import { Form, Icon, Input, Button, DatePicker, Select, Card, Row, Col, Pagination, Alert, Radio, Tag, Tooltip, Tabs, Table, notification, Modal } from 'antd';
4
 import moment from 'moment';
3
 import moment from 'moment';
5
-import router from 'umi/router';
4
+import request from '../../../../utils/request';
6
 import apis from '../../../../services/apis';
5
 import apis from '../../../../services/apis';
6
+import Styles from './style.less';
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'
12
+import ApartmentSelect from '../../../../components/HouseSelect/ApartmentSelect';
7
 
13
 
8
-const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
9
-const { TextArea } = Input;
14
+/**
15
+ *图片设置
16
+ *
17
+ * @param {*} props
18
+ * @returns
19
+ */
20
+function PreselectionRecord(props) {
21
+  // eslint-disable-next-line react-hooks/rules-of-hooks
22
+  const [data, setData] = useState([])
23
+  const {salesBatchId} = props.salesBatchId
24
+  console.log(salesBatchId,'updateNameupdateNameupdateName');
25
+  useEffect(() => {
26
+    getList()
27
+  }, [])
10
 
28
 
11
-const PreselectionRecord = props => {
12
-  return <div><span>预选记录</span></div>
13
-}
29
+  function openNotificationWithIcon(type, message) {
30
+    notification[type]({
31
+      message,
32
+      description:
33
+        '',
34
+    });
35
+  }
36
+
37
+  function getList(params) {
38
+    // 网路请求
39
+    request({ ...apis.house.taPreselectRecord, params: { ...params,salesBatchId: salesBatchId } }).then(res => {
40
+      console.log(res,"resresres")
41
+      setData(res)
42
+    }).catch(err => {
43
+      openNotificationWithIcon('error', err.message)
44
+    })
45
+  }
46
+
47
+    // 重置搜索
48
+    function handleReset () {
49
+      props.form.resetFields();
50
+      getList({ pageNumber: 1, pageSize: 10 })
51
+    }
52
+
53
+      // 分页
54
+  function changePageNum(pageNumber) {
55
+    // eslint-disable-next-line react-hooks/rules-of-hooks
56
+    getList({ pageNumber: pageNumber, pageSize: 10})
57
+  }
14
 
58
 
15
-export default PreselectionRecord
59
+  const rowSelection = {
60
+    onChange: (selectedRowKeys, selectedRows) => {
61
+      console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
62
+    },
63
+  };
64
+
65
+  // 提交事件
66
+  const handleSubmit = e => {
67
+    e.preventDefault();
68
+    props.form.validateFields((err, values) => {
69
+      if (!err) {
70
+        console.log('提交数据: ', values)
71
+        getList({ pageNumber: 1, pageSize: 10, ...values })
72
+      }
73
+    });
74
+  }
75
+
76
+
77
+  const columns = [
78
+    {
79
+      title: '房源编号',
80
+      dataIndex: 'houseId',
81
+      key: 'houseId',
82
+    },
83
+    {
84
+      title: '楼栋',
85
+      dataIndex: 'blockName',
86
+      key: 'blockName',
87
+      render: blockName => <><span>{blockName}幢</span></>,
88
+    },
89
+    {
90
+      title: '单元',
91
+      dataIndex: 'unitName',
92
+      key: 'unitName',
93
+      render: unitName => <><span>{unitName}单元</span></>,
94
+    },
95
+    {
96
+      title: '层',
97
+      dataIndex: 'floorName',
98
+      key: 'floorName',
99
+      render: floorName => <><span>{floorName}层</span></>,
100
+    },
101
+    {
102
+      title: '房号',
103
+      dataIndex: 'roomName',
104
+      key: 'roomName',
105
+    },
106
+    {
107
+      title: '对应户型',
108
+      dataIndex: 'apartmentName',
109
+      key: 'apartmentName',
110
+    },
111
+    {
112
+      title: '用户昵称',
113
+      dataIndex: 'nameOrnick',
114
+      key: 'nameOrnick',
115
+    },
116
+    {
117
+      title: '用户姓名',
118
+      dataIndex: 'name',
119
+      key: 'name',
120
+    },
121
+    {
122
+      title: '用户头像',
123
+      dataIndex: 'avatarurl',
124
+      key: 'avatarurl',
125
+      render: (text, records) => <img src={records.avatarurl} width={50} height={50} />,
126
+    },
127
+    {
128
+      title: '用户手机号',
129
+      dataIndex: 'phone',
130
+      key: 'phone',
131
+    },
132
+    
133
+    {
134
+      title: '预选状态',
135
+      dataIndex: 'status',
136
+      key: 'status',
137
+      render: status => <><span>{status == 0 ? '否' : status == 1 ? '是' : ''}</span></>,
138
+    },
139
+    {
140
+      title: '状态修改时间',
141
+      dataIndex: 'updateDate',
142
+      key: 'updateDate',
143
+    },
144
+    {
145
+      title: '最后修改人',
146
+      dataIndex: 'updateName',
147
+      key: 'updateName',
148
+    },
149
+  ]
150
+  const { getFieldDecorator } = props.form
151
+  return (
152
+    <>
153
+    <Form layout="inline" onSubmit={e => handleSubmit(e)}>
154
+        <Form.Item>
155
+          {getFieldDecorator('houseId')(
156
+            <Input placeholder="房源编号"/>,
157
+          )}
158
+        </Form.Item>
159
+        <Form.Item>
160
+          {getFieldDecorator('phone')(
161
+            <Input placeholder="用户手机号"/>,
162
+          )}
163
+        </Form.Item>
164
+        <Form.Item>
165
+          {getFieldDecorator('apartmentId')(
166
+             <ApartmentSelect buildingId={props.buildingId} />
167
+          )}
168
+        </Form.Item>
169
+        <Form.Item>
170
+          {getFieldDecorator('status')(
171
+             <Select placeholder="预选状态" style={{width: '120px'}}>
172
+             <Option value="0">否</Option>
173
+             <Option value="1">是</Option>
174
+           </Select>,
175
+          )}
176
+        </Form.Item>
177
+        
178
+        <Form.Item>
179
+          <Button type="primary" htmlType="submit" >
180
+            搜索
181
+          </Button>
182
+          <Button style={{ marginLeft: 8 }} onClick={handleReset}>
183
+            重置
184
+            </Button>
185
+        </Form.Item>
186
+      </Form>
187
+      <Table rowSelection={rowSelection} dataSource={data.records} columns={columns} pagination={{ total: data.total, onChange: e => this.changePageNum(e) }} rowKey="House" />
188
+    </>
189
+  )
190
+}
191
+const WrappedHeader = Form.create({ name: 'PreselectionRecord' })(PreselectionRecord);
192
+export default WrappedHeader

+ 1
- 1
src/pages/house/edit/index.jsx View File

70
         { (tab === 'poster' && <Poster salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
70
         { (tab === 'poster' && <Poster salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
71
         { (tab === 'share' && <Share salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
71
         { (tab === 'share' && <Share salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
72
         { (tab === 'preselectionImg' && <PreselectionImg />)}
72
         { (tab === 'preselectionImg' && <PreselectionImg />)}
73
-        { (tab === 'preselectionRecord' && <PreselectionRecord />)}
73
+        { (tab === 'preselectionRecord' && <PreselectionRecord buildingId={props.location.query.buildingId} salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
74
         { (tab === 'shareRecord' && <ShareRecord salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
74
         { (tab === 'shareRecord' && <ShareRecord salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
75
         { (tab === 'visitRecord' && <VisitRecord salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
75
         { (tab === 'visitRecord' && <VisitRecord salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
76
       </div>
76
       </div>

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

1158
     url: `${prefix}/taHousingResources/:id`,
1158
     url: `${prefix}/taHousingResources/:id`,
1159
     method: 'PUT',
1159
     method: 'PUT',
1160
     action: 'admin.taHousingResources.id.put',
1160
     action: 'admin.taHousingResources.id.put',
1161
-  }
1161
+  },
1162
+  taPreselectRecord: {
1163
+    url: `${prefix}/taPreselectRecord`,
1164
+    method: 'GET',
1165
+    action: 'admin.taPreselectRecord.get',
1166
+  },
1167
+  houseDelete: {
1168
+    url: `${prefix}/houseDelete/:id`,
1169
+    method: 'DELETE',
1170
+    action: 'admin.houseDelete.id.put',
1171
+  },
1172
+  changeApartment: {
1173
+    method: 'PUT',
1174
+    url: `${prefix}/house/changeApartment`,
1175
+    action: 'admin.house.changeApartment.get',
1176
+  },
1162
  },
1177
  },
1163
 }
1178
 }