index.jsx 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. import React, { useState, useEffect } from 'react';
  2. import { PageHeaderWrapper } from '@ant-design/pro-layout';
  3. import { Form, Pagination, Card, Button, Icon, Tooltip, message, notification, Modal, Table, Select, Input, DatePicker } from 'antd';
  4. import router from 'umi/router';
  5. import moment from 'moment';
  6. import className from 'classnames';
  7. import Cell from '../../../components/Cell';
  8. import styles from './style.less';
  9. import { fetch, apis } from '../../../utils/request';
  10. import request from '../../../utils/request';
  11. import AuthButton from '@/components/AuthButton';
  12. const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
  13. function header(props) {
  14. // 获取初始化数据
  15. const [ data, setData ] = useState({})
  16. const [deleteList, setDeleteList] = useState([])
  17. useEffect(() => {
  18. getList({ pageNum: 1, pageSize: 10 });
  19. },[])
  20. // 查询列表
  21. const getList = (params) => {
  22. request({ ...apis.company.list, params: { ...params } }).then((data) => {
  23. console.log(data)
  24. setData(data)
  25. })
  26. }
  27. // 提交事件
  28. const handleSubmit = (e, props) => {
  29. e.preventDefault();
  30. props.form.validateFields((err, values) => {
  31. if (!err) {
  32. getList({ pageNum: 1, pageSize: 10, ...values })
  33. }
  34. });
  35. }
  36. const changePageNum = (pageNumber) => {
  37. let values = props.form.getFieldsValue()
  38. getList({ pageNum: pageNumber, pageSize: 10, ...values })
  39. }
  40. const rowSelection = {
  41. onChange: (selectedRowKeys, selectedRows) => {
  42. console.log('selectedRowKeys:', selectedRowKeys, 'selectedRows: ', selectedRows);
  43. setDeleteList(selectedRows)
  44. },
  45. };
  46. // 跳转到编辑资讯
  47. const toEditCompany = (id) => () => {
  48. router.push({
  49. pathname: '/eContract/company/edit',
  50. query: {
  51. id
  52. },
  53. });
  54. }
  55. // 跳转到编辑资讯
  56. const toAddCompany = () => {
  57. router.push({
  58. pathname: '/eContract/company/add',
  59. });
  60. }
  61. const changeStatus = () => {
  62. if(deleteList.length < 1){
  63. message.error('请先选择要删除的数据!')
  64. return
  65. }
  66. const title = '确认将所选的' + deleteList.length + '条数据删除?认证通过的企业不会被删除'
  67. Modal.confirm({
  68. title: title,
  69. okText: '确认',
  70. cancelText: '取消',
  71. onOk() {
  72. request({ ...apis.company.delete, data: { ids: deleteList.map(x => x.companyId) } }).then((data) => {
  73. const resultMessage = '操作成功,其中'+data.successNum+'条成功删除,'+data.failNum+'条已认证数据无法删除。'
  74. message.info(resultMessage)
  75. getList({ pageNum: 1, pageSize: 10 });
  76. }).catch((err) => {
  77. console.log(err)
  78. message.info(err.msg || err.message)
  79. })
  80. }
  81. });
  82. }
  83. /**
  84. *
  85. *
  86. * @param {*} props
  87. * @returns
  88. */
  89. const columns = [
  90. {
  91. title: '企业名称',
  92. dataIndex: 'companyName',
  93. key: 'companyName',
  94. align: 'center',
  95. },
  96. {
  97. title: '企业编号',
  98. dataIndex: 'companyCode',
  99. key: 'companyCode',
  100. align: 'center',
  101. },
  102. {
  103. title: '法大大客户编号',
  104. dataIndex: 'fadadaCode',
  105. key: 'fadadaCode',
  106. align: 'center',
  107. },
  108. {
  109. title: '实名认证状态',
  110. dataIndex: 'status',
  111. key: 'status',
  112. align: 'center',
  113. render: (status) => <span>{status === 0 ? '未认证' : status === 1 ? "管理员资料已提交" : status === 2 ? "企业基本资料(没有申请表)已提交" : status === 3 ? "已提交待审核" :
  114. status === 4 ? '审核通过' : status === 5 ? "审核不通过" : status === 6 ? "人工初审通过" : "" }</span>,
  115. },
  116. {
  117. title: '企业管理员身份',
  118. dataIndex: 'companyManagerType',
  119. key: 'companyManagerType',
  120. align: 'center',
  121. render: (companyManagerType) => <span>{companyManagerType === 'legal' ? '法人' : companyManagerType === 'agent' ? "代理人" : "" }</span>,
  122. },
  123. {
  124. title: '操作',
  125. dataIndex: 'handle',
  126. key: 'handle',
  127. align: 'center',
  128. render: (x, row) => (
  129. <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditCompany(row.companyId)}>
  130. 查看详情<Icon type="form" className={styles.edit} />
  131. </span>
  132. ),
  133. },
  134. ];
  135. function handleReset() {
  136. props.form.resetFields();
  137. getList({ pageNum: 1, pageSize: 10 })
  138. }
  139. const { getFieldDecorator } = props.form
  140. return (
  141. <>
  142. <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
  143. <Form.Item>
  144. {getFieldDecorator('companyName')(
  145. <Input
  146. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  147. placeholder="企业名称"
  148. />,
  149. )}
  150. </Form.Item>
  151. <Form.Item>
  152. {getFieldDecorator('companyCode')(
  153. <Input
  154. prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
  155. placeholder="企业编号"
  156. />,
  157. )}
  158. </Form.Item>
  159. <Form.Item>
  160. {getFieldDecorator('status')(
  161. <Select style={{ width: '180px' }} placeholder="实名认证状态">
  162. <Select.Option value="0">未认证</Select.Option>
  163. <Select.Option value="1">管理员资料已提交</Select.Option>
  164. <Select.Option value="2">企业基本资料(没有申请表)已提交</Select.Option>
  165. <Select.Option value="3">已提交待审核</Select.Option>
  166. <Select.Option value="4">审核通过</Select.Option>
  167. <Select.Option value="5">审核不通过</Select.Option>
  168. <Select.Option value="6">人工初审通过</Select.Option>
  169. </Select>,
  170. )}
  171. </Form.Item>
  172. <Form.Item>
  173. <Button type="primary" htmlType="submit" className={styles.searchBtn}>
  174. 搜索
  175. </Button>
  176. <Button style={{ marginLeft: 8 }} onClick={handleReset}>
  177. 重置
  178. </Button>
  179. </Form.Item>
  180. </Form>
  181. <AuthButton name="admin.taNewsType.post" noRight={null}>
  182. <Button type="danger" className={styles.addBtn} onClick={toAddCompany}>新增</Button>
  183. </AuthButton>
  184. <AuthButton name="admin.taNewsType.post" noRight={null}>
  185. <Button type="danger" style={{ marginLeft: 15 }} onClick={changeStatus}>删除</Button>
  186. </AuthButton>
  187. <Table rowSelection={rowSelection} rowKey="newsType" dataSource={data.records} columns={columns} pagination={false} />
  188. <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
  189. <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} current={data.current}/>
  190. </div>
  191. </>
  192. )
  193. }
  194. const WrappedHeader = Form.create({ name: 'header' })(header);
  195. export default WrappedHeader