瀏覽代碼

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

张延森 5 年之前
父節點
當前提交
a2b5200ab1

+ 1
- 1
src/components/HouseSelect/ApartmentSelect.jsx 查看文件

@@ -38,7 +38,7 @@ const ApartmentSelect = props => {
38 38
 
39 39
   const checkValue = (data) => {
40 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 42
       const va = (tempData.length > 0) ? props.value : '已删除,请重新选择'
43 43
       props.onChange(va)
44 44
 

+ 63
- 7
src/pages/house/edit/components/house.jsx 查看文件

@@ -20,6 +20,8 @@ import ApartmentSelect from '../../../../components/HouseSelect/ApartmentSelect'
20 20
 function House(props) {
21 21
   // eslint-disable-next-line react-hooks/rules-of-hooks
22 22
   const [data, setData] = useState([])
23
+  const [viable, setViable] = useState(false)
24
+  const [houseIdList, setHouseIdList] = useState([])
23 25
 
24 26
   useEffect(() => {
25 27
     getList()
@@ -58,6 +60,7 @@ function House(props) {
58 60
   const rowSelection = {
59 61
     onChange: (selectedRowKeys, selectedRows) => {
60 62
       console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
63
+      setHouseIdList(selectedRows)
61 64
     },
62 65
   };
63 66
 
@@ -65,6 +68,19 @@ function House(props) {
65 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 85
   const handleSubmit = e => {
70 86
     e.preventDefault();
@@ -76,21 +92,39 @@ function House(props) {
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 116
    * @param {*} record
83 117
    */
84
-  function deleteApartment(record) {
85
-    confirm({
118
+  function deleteHouseResource(record) {
119
+    Modal.confirm({
86 120
       title: '确认删除当前数据?',
87 121
       content: '确定后成功删除,点击取消则放弃当前操作',
88 122
       okText: '确定',
89 123
       cancelText: '取消',
90 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 128
           openNotificationWithIcon('success', '操作成功')
95 129
         }).catch(err => {
96 130
           // openNotificationWithIcon('error', err.message)
@@ -165,7 +199,7 @@ function House(props) {
165 199
       render: (_, record) => (
166 200
         <>
167 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,10 +261,32 @@ function House(props) {
227 261
         </Form.Item>
228 262
       </Form>
229 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 266
       <Button type="danger" style={{ marginLeft: '18px'}} onClick={() => router.go(-1)}>返回</Button>
233 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 查看文件

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

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

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

+ 186
- 9
src/pages/house/edit/components/preselectionRecord.jsx 查看文件

@@ -1,15 +1,192 @@
1 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 3
 import moment from 'moment';
5
-import router from 'umi/router';
4
+import request from '../../../../utils/request';
6 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 查看文件

@@ -70,7 +70,7 @@ function EditHouse(props) {
70 70
         { (tab === 'poster' && <Poster salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
71 71
         { (tab === 'share' && <Share salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
72 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 74
         { (tab === 'shareRecord' && <ShareRecord salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
75 75
         { (tab === 'visitRecord' && <VisitRecord salesBatchId={{ salesBatchId: salesBatchData.salesBatchId || (props.location.query && props.location.query.id) }}/>)}
76 76
       </div>

+ 16
- 1
src/services/apis.js 查看文件

@@ -1158,6 +1158,21 @@ export default {
1158 1158
     url: `${prefix}/taHousingResources/:id`,
1159 1159
     method: 'PUT',
1160 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
 }