index.jsx 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import React, { useRef, useState, useEffect } from 'react'
  2. import { Spin, Form, Input, Divider, Button, Row, Col, Popconfirm } from 'antd'
  3. import router from 'umi/router'
  4. import NavLink from 'umi/navlink'
  5. import { fetch, fetchList, apis } from '@/utils/request'
  6. import Search from '../../components/Search'
  7. import List from '../../components/List'
  8. const Condition = props => {
  9. return (
  10. <Search
  11. onSearch={props.onSearch}
  12. onReset={props.onReset}
  13. render={form => {
  14. const { getFieldDecorator } = form
  15. return (
  16. <>
  17. <Form.Item label="收费组编号">
  18. {
  19. getFieldDecorator('billId')(<Input />)
  20. }
  21. </Form.Item>
  22. <Form.Item label="收费组名">
  23. {
  24. getFieldDecorator('billName')(<Input />)
  25. }
  26. </Form.Item>
  27. <Form.Item label="收费组说明">
  28. {
  29. getFieldDecorator('billExplain')(<Input />)
  30. }
  31. </Form.Item>
  32. </>
  33. )
  34. }}
  35. />
  36. )
  37. }
  38. const TableList = props => {
  39. const columns = [
  40. {
  41. title: '收费组编号',
  42. dataIndex: 'id',
  43. key: 'id',
  44. align: 'center',
  45. },
  46. {
  47. title: '收费组名称',
  48. dataIndex: 'billName',
  49. key: 'billName',
  50. },
  51. {
  52. title: '收费组说明',
  53. dataIndex: 'billExplain',
  54. key: 'billExplain',
  55. },
  56. {
  57. title: '应缴户数',
  58. dataIndex: 'payTotalNum',
  59. key: 'payTotalNum',
  60. },
  61. {
  62. title: '已缴户数',
  63. dataIndex: 'payedNum',
  64. key: 'payedNum',
  65. },
  66. {
  67. title: '未缴户数',
  68. dataIndex: 'unpayedNum',
  69. key: 'unpayedNum',
  70. },
  71. {
  72. title: '收费组状态',
  73. key: 'billStatus',
  74. render: (t, row) => {
  75. switch (row.billStatus) {
  76. case '0':
  77. return '正在收费'
  78. case '1':
  79. return '收费完成'
  80. case '2':
  81. return '草稿'
  82. default:
  83. return '异常'
  84. }
  85. }
  86. },
  87. {
  88. title: '发布时间',
  89. dataIndex: 'createDate',
  90. key: 'createDate',
  91. render: dt => (dt || '').substr(0, 16)
  92. },
  93. {
  94. title: '截止时间',
  95. dataIndex: 'endDate',
  96. key: 'endDate',
  97. render: dt => (dt || '').substr(0, 16)
  98. },
  99. {
  100. title: '操作',
  101. key: 'action',
  102. render: (_, row) => {
  103. return (
  104. <span>
  105. <Button type="link" size="small" onClick={() => props.onDetail(row)}>详情</Button>
  106. <Divider type="vertical" />
  107. <Popconfirm
  108. title="确认删除当前记录?"
  109. onConfirm={() => props.onDeleteRow(row)}
  110. okText="Yes"
  111. cancelText="No"
  112. >
  113. <Button type="link" size="small">删除</Button>
  114. </Popconfirm>
  115. </span>
  116. )
  117. }
  118. },
  119. ]
  120. return (
  121. <List
  122. {...props}
  123. columns={columns}
  124. rowKey="id"
  125. />
  126. )
  127. }
  128. const FetchBillList = fetchList(apis.bill.fetchBillList)
  129. const deleteBillBeach = fetch(apis.bill.deleteBillBeach)
  130. export default props => {
  131. const [loading, setLoading] = useState(false)
  132. const [listData, setListData] = useState([])
  133. const [pagination, setPagination] = useState({})
  134. const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10 })
  135. const handleQuery = vals => {
  136. setQueryParams({
  137. ...queryParams,
  138. ...vals,
  139. pageNum: 1
  140. })
  141. }
  142. const handlePageChange = (pageNum, pageSize) => {
  143. setQueryParams({
  144. ...queryParams,
  145. pageSize,
  146. pageNum
  147. })
  148. }
  149. const handleDetail = row => {
  150. if (row.billStatus === '2') {
  151. router.push(`/bill/management/edi?id=${row.billId}`)
  152. } else {
  153. router.push(`/bill/management/info?id=${row.billId}`);
  154. }
  155. }
  156. const handleDeleteRow = row => {
  157. setLoading(true)
  158. deleteBillBeach({ data: [row.id] }).then(res => {
  159. setLoading(false)
  160. getListData()
  161. })
  162. }
  163. useEffect(() => {
  164. setLoading(true)
  165. FetchBillList(queryParams).then(res => {
  166. console.log(res,"2323")
  167. const {list, ...pagi} = res[1]
  168. setListData(list)
  169. setPagination(pagi)
  170. setLoading(false)
  171. })
  172. }, [queryParams])
  173. return (
  174. <div>
  175. <Condition onReset={handleQuery} onSearch={handleQuery} />
  176. <div style={{ margin: '24px 0' }}>
  177. <NavLink to={`/property/bill/management/add`}>
  178. <Button type="primary">添加</Button>
  179. </NavLink>
  180. </div>
  181. <Spin spinning={loading}>
  182. <TableList
  183. dataSource={listData}
  184. pagination={pagination}
  185. onPageChange={handlePageChange}
  186. onDetail={handleDetail}
  187. onDeleteRow={handleDeleteRow}
  188. />
  189. </Spin>
  190. </div>
  191. )
  192. }