知与行后台管理端

list.jsx 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import React, { useState, useEffect } from 'react'
  2. import { Table, Form, Icon, Input, Button, message } from 'antd'
  3. import request from '../../../utils/request';
  4. import apis from '../../../services/apis';
  5. import { router } from 'umi';
  6. import moment from 'moment';
  7. import AuthButton from '../../../components/AuthButton';
  8. function body(props) {
  9. // eslint-disable-next-line react-hooks/rules-of-hooks
  10. const [dataSource, setDataSource] = useState({ records: [] })
  11. useEffect(() => {
  12. getList({ pageNumber: 1, pageSize: 10 })
  13. }, [])
  14. function getList(params) {
  15. // 网路请求
  16. request({ ...apis.system.documentVerifylist, params: { ...params } }).then(data => {
  17. console.log('data:',data)
  18. setDataSource(data)
  19. }).catch(err => {
  20. // eslint-disable-next-line no-unused-expressions
  21. })
  22. }
  23. /**
  24. * 提交
  25. * @param e
  26. */
  27. function handleSubmit(e) {
  28. e.preventDefault();
  29. props.form.validateFields((err, values) => {
  30. getList({ pageNumber: 1, pageSize: 10, ...values})
  31. // if (!err) {
  32. // console.log('Received values of form: ', values);
  33. // }
  34. });
  35. }
  36. /**
  37. * 翻页
  38. * @param page
  39. * @param pageSize
  40. */
  41. function onPageNum(page, pageSize) {
  42. console.log(page, pageSize)
  43. }
  44. /**
  45. * 重置
  46. */
  47. function handleReset(e) {
  48. props.form.resetFields();
  49. }
  50. function audit(record){
  51. router.push({
  52. pathname: '/system/document/audit',
  53. query: {
  54. id: record.personId,
  55. },
  56. })
  57. }
  58. const columns = [
  59. {
  60. title: '姓名',
  61. dataIndex: 'name',
  62. key: 'name',
  63. align: 'center',
  64. },
  65. {
  66. title: '手机号',
  67. dataIndex: 'tel',
  68. key: 'tel',
  69. align: 'center',
  70. },
  71. {
  72. title: '提交时间',
  73. dataIndex: 'summitDate',
  74. key: 'summitDate',
  75. align: 'center',
  76. render: (summitDate) => moment(summitDate).format('YYYY-MM-DD HH:mm:ss')
  77. },
  78. {
  79. title: '已审核数',
  80. dataIndex: 'totalSummit',
  81. key: 'totalSummit',
  82. align: 'center',
  83. },
  84. {
  85. title: '未审核数',
  86. dataIndex: 'unverified',
  87. key: 'unverified',
  88. align: 'center',
  89. },
  90. {
  91. title: '操作',
  92. dataIndex: 'documentVerifyId',
  93. key: 'documentVerifyId',
  94. align: 'center',
  95. render: (x,row) => (
  96. <>
  97. <AuthButton name="admin.documentVerify.id.get" noRight={null}>
  98. <span style={{ color: '#1990FF',cursor: 'pointer' }} onClick={()=>audit(row)}>{ row.unverified === 0 ? '查看' : '审核' }</span>
  99. </AuthButton>
  100. </>
  101. )
  102. },
  103. ]
  104. const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = props.form;
  105. return (
  106. <>
  107. <Form layout="inline" onSubmit={handleSubmit}>
  108. <Form.Item>
  109. {getFieldDecorator('name')(
  110. <Input
  111. placeholder="用户名"
  112. />,
  113. )}
  114. </Form.Item>
  115. <Form.Item>
  116. {getFieldDecorator('tel')(
  117. <Input
  118. placeholder="手机号"
  119. />,
  120. )}
  121. </Form.Item>
  122. <Form.Item>
  123. <Button type="primary" htmlType="submit">
  124. 查询
  125. </Button>
  126. &nbsp;&nbsp;&nbsp;&nbsp;
  127. <Button onClick={(e) => handleReset(e)}>
  128. 清空
  129. </Button>
  130. </Form.Item>
  131. </Form>
  132. <Table style={{marginTop: '30px'}} dataSource={dataSource.records} pagination={{ total: dataSource.total, pageSize: dataSource.pageSize, onChange: (page, pageSize) => onPageNum(page, pageSize), defaultCurrent: 1 }} columns={columns} />
  133. </>
  134. )
  135. }
  136. const WrappedbodyForm = Form.create({ name: 'body' })(body)
  137. export default WrappedbodyForm