张延森 4 anni fa
parent
commit
ce27f1662d

+ 62
- 2
src/pages/property/proprietor/index.jsx Vedi File

@@ -2,11 +2,13 @@ import React, { useState, useEffect } from 'react'
2 2
 import { Select, Spin, Table, Button, Form, Input, Icon, Modal, Popconfirm } from 'antd'
3 3
 import NavLink from 'umi/navlink'
4 4
 import { fetch, fetchList, apis } from '@/utils/request'
5
+import { exportExcel } from '@/utils/utils'
5 6
 import Search from '../components/Search'
6 7
 import List from '../components/List'
7 8
 import useRoomSelect from '../utils/hooks/useRoomSelect'
8 9
 
9 10
 const buildingInfoList = fetch(apis.buildingOwnerInfo.buildingList)
11
+const buildingInfoListExport = fetch(apis.buildingOwnerInfo.buildingListExport)
10 12
 const deleteBuilding = fetch(apis.buildingOwnerInfo.deleteBuilding)
11 13
 
12 14
 const Condition = props => {
@@ -129,6 +131,17 @@ const Condition = props => {
129 131
               getFieldDecorator('idCard')(<Input style={{ width: '200px' }} placeholder="身份证" />)
130 132
             }
131 133
             </Form.Item>
134
+            <Form.Item>
135
+            {
136
+              getFieldDecorator('roleName')(
137
+                <Select style={{ width: '200px' }} placeholder="身份">
138
+                  <Select.Option value={1}>户主</Select.Option>
139
+                  <Select.Option value={3}>家属</Select.Option>
140
+                  <Select.Option value={2}>租客</Select.Option>
141
+                </Select>
142
+              )
143
+            }
144
+            </Form.Item>
132 145
           </>
133 146
         )
134 147
       }}
@@ -145,9 +158,17 @@ const verifyStatusDict = {
145 158
 export default props => {
146 159
   const [loading, setLoading] = useState(false)
147 160
   const [listData, setListData] = useState([])
161
+  const [selectedKeys, setSelectedKeys] = useState([])
148 162
   const [pagination, setPagination] = useState({})
149 163
   const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10 })
150 164
 
165
+  const rowSelection = {
166
+    onChange: (selectedRowKeys, selectedRows) => {
167
+      console.log('------>', selectedRowKeys)
168
+      setSelectedKeys(selectedRowKeys)
169
+    }
170
+  }
171
+
151 172
   const handleSearch = (vals) => {
152 173
     setQueryParams({
153 174
       ...vals,      
@@ -167,6 +188,17 @@ export default props => {
167 188
     })
168 189
   }
169 190
 
191
+  const handleDeleteSelected = () => {
192
+    deleteBuilding({ data: selectedKeys }).then(res => {
193
+      Modal.success({
194
+        content: '数据删除成功',
195
+        onOk: () => {
196
+          window.location.reload()
197
+        }
198
+      })
199
+    })
200
+  }
201
+
170 202
   const handlePageChange = (pageNum, pageSize) => {
171 203
     setQueryParams({
172 204
       ...queryParams,      
@@ -175,6 +207,14 @@ export default props => {
175 207
     })
176 208
   }
177 209
 
210
+  const handleExport = () => {
211
+    setLoading(true)
212
+    buildingInfoListExport({ data: {...queryParams, pageNum: 1, pageSize: 9999} }).then(res => {
213
+      setLoading(false)
214
+      exportExcel(res, "业主列表")
215
+    }).catch(() => setLoading(false))
216
+  }
217
+
178 218
   useEffect(() => {
179 219
     setLoading(true)
180 220
     buildingInfoList({ data: queryParams }).then(res => {
@@ -192,12 +232,31 @@ export default props => {
192 232
         <NavLink to={`/property/proprietor/add`}>
193 233
           <Button type="primary">添加</Button>
194 234
         </NavLink>
235
+        <div style={{marginLeft: 16, display: 'inline-block'}}>
236
+          <Popconfirm
237
+            title="确认进行批量删除操作?"
238
+            onConfirm={handleDeleteSelected}
239
+            okText="确定"
240
+            cancelText="取消"
241
+          >
242
+            <Button type="danger" disabled={!selectedKeys.length}>批量删除</Button>
243
+          </Popconfirm>
244
+        </div>
245
+        <div style={{marginLeft: 16, display: 'inline-block'}}>
246
+          <Button onClick={handleExport}>导出</Button>
247
+        </div>
195 248
         <NavLink to={`/property/proprietor/batch`}>
196 249
           <Button type="link"><Icon type="upload"/>批量导入业主资料</Button>
197 250
         </NavLink>
198 251
       </div>
199
-      <List dataSource={listData} loading={loading} onPageChange={handlePageChange} pagination={pagination} rowKey="userVerifyId">
200
-        <Table.Column title="编号" dataIndex="userVerifyId" key="userVerifyId" />
252
+      <List
253
+        dataSource={listData}
254
+        loading={loading}
255
+        pagination={pagination}
256
+        rowSelection={rowSelection}
257
+        onPageChange={handlePageChange}
258
+        rowKey="id"
259
+      >
201 260
         <Table.Column
202 261
           title="姓名"
203 262
           dataIndex="ownerName"
@@ -212,6 +271,7 @@ export default props => {
212 271
         />
213 272
         <Table.Column title="手机号" dataIndex="ownerTel" key="ownerTel" />
214 273
         <Table.Column title="身份证" dataIndex="idCard" key="idCard" />
274
+        <Table.Column title="性别" dataIndex="idCard" key="idCard1" render={t => (t.substring(-2, 1) - 0) % 2 === 1 ? '男' : '女'} />
215 275
         <Table.Column
216 276
           title="房间号"
217 277
           dataIndex="roomNoName"

+ 7
- 0
src/services/buildingOwnerInfo_api.js Vedi File

@@ -51,6 +51,13 @@ export default prefix => {
51 51
       action: `admin.${moduleName}.list.post`
52 52
     },
53 53
 
54
+    // 导出楼栋户主信息列表
55
+    buildingListExport: {
56
+      url: `${prefix}/${moduleName}/list/export`,
57
+      method: 'post',
58
+      action: `admin.${moduleName}.list-export.post`
59
+    },
60
+
54 61
     // 认证通过户主信息
55 62
     userPassCertification: {
56 63
       url: `${prefix}/${moduleName}/userPassCertification`,