You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import { useRef, useState, useEffect } from 'react';
  2. import { connect } from '@umijs/max';
  3. import type { ActionType, ProFormInstance } from '@ant-design/pro-components';
  4. import {
  5. ProTable
  6. } from '@ant-design/pro-components';
  7. import { Button, Image, ConfigProvider, Input } from 'antd';
  8. import { PostCompanyViplist ,PostCompanyFeechange} from '@/apis/api';
  9. import { Imageprefix } from '@/constants';
  10. const CompanyListPage: React.FC = ({ dispatch, getId, openModel }: any) => {
  11. const actionRef = useRef<ActionType>();
  12. const [list, setList] = useState<object[]>([])
  13. const [total, setTotal] = useState<number>(0)
  14. const [page, setPage] = useState<number>(1)
  15. const [pageSize, setPageSize] = useState<number>(10)
  16. const [fullname, setFullname] = useState<any>(sessionStorage.getItem('vip_company_info') ? JSON.parse(sessionStorage.getItem('vip_company_info')).full_name : '')
  17. const setId = (id: number) => {
  18. getId(id)
  19. }
  20. useEffect(() => {
  21. if (!openModel.openModal) {
  22. actionRef.current.reload();
  23. }
  24. }, [openModel.openModal])
  25. useEffect(() => {
  26. if (!openModel.openFeeModal) {
  27. actionRef.current.reload();
  28. }
  29. }, [openModel.openFeeModal])
  30. return (
  31. <>
  32. <ConfigProvider
  33. theme={{
  34. token: {
  35. colorPrimary: '#4FBE70',
  36. colorLink: '#4FBE70',
  37. }
  38. }}
  39. >
  40. <ProTable
  41. scroll={{ x: 1300 }}
  42. actionRef={actionRef}
  43. dataSource={list}
  44. columns={[
  45. {
  46. title: '筛选日期',
  47. dataIndex: 'date_range',
  48. hidden: true,
  49. width: 120,
  50. valueType: 'dateRange',
  51. },
  52. {
  53. title: 'ID',
  54. dataIndex: 'id',
  55. width: 80,
  56. fixed: 'left',
  57. },
  58. {
  59. title: '企业名称',
  60. dataIndex: 'full_name',
  61. width: 300,
  62. fixed: 'left',
  63. valueType: 'input',
  64. renderFormItem: () => {
  65. return (
  66. <><Input placeholder="请输入企业名称" value={fullname} onChange={(e) => {
  67. setFullname(e.target.value)
  68. }} /></>
  69. )
  70. }
  71. },
  72. {
  73. title: '见习基地',
  74. dataIndex: 'probation_text',
  75. search: false,
  76. width: 100,
  77. },
  78. {
  79. title: '知名企业',
  80. dataIndex: 'famous_text',
  81. search: false,
  82. width: 100
  83. },
  84. {
  85. title: '会员类型',
  86. dataIndex: 'member_type_text',
  87. search: false,
  88. width: 100
  89. },
  90. {
  91. title: '会员状态',
  92. dataIndex: 'member_status_text',
  93. width: 100,
  94. search: false,
  95. },
  96. {
  97. title: '开始时间',
  98. dataIndex: 'start_date',
  99. search: false,
  100. width: 200
  101. },
  102. {
  103. title: '到期时间',
  104. dataIndex: 'end_date',
  105. search: false,
  106. width: 200
  107. }, {
  108. title: '剩余点数',
  109. dataIndex: 'balance_fee',
  110. search: false,
  111. width: 100,
  112. },
  113. {
  114. title: '业务员',
  115. dataIndex: 'sales',
  116. search: false,
  117. width: 200
  118. },
  119. {
  120. title: '操作',
  121. width: 300,
  122. key: 'option',
  123. valueType: 'option',
  124. fixed: 'right',
  125. render: (_, record, action) => [
  126. <Button key='1' type='link' onClick={() => {
  127. setId(record.id)
  128. dispatch({ type: 'openModel/getOpenModal', payload: true })
  129. }}>编辑</Button>,
  130. <Button key='1' type='link' onClick={() => {
  131. setId(record.id)
  132. dispatch({ type: 'openModel/getOpenFeeModal', payload: true })
  133. }}>变更点数</Button>
  134. ],
  135. },
  136. ]}
  137. rowKey="id"
  138. pagination={{
  139. current: page,
  140. pageSize: pageSize,
  141. showSizeChanger: true,
  142. total: total,
  143. pageSizeOptions: [9, 18, 27, 99],
  144. onChange(page, pageSize) {
  145. setPage(page)
  146. setPageSize(pageSize)
  147. },
  148. onShowSizeChange(current, size) {
  149. setPage(current)
  150. setPageSize(size)
  151. }
  152. }}
  153. request={async (params = {} as Record<string, any>) =>
  154. PostCompanyViplist({
  155. page: page,
  156. pagesize: pageSize,
  157. sort: 'id',
  158. sortby: 'desc',
  159. keyword: fullname,
  160. start_date: params.date_range ? params.date_range[0] : '',
  161. end_date: params.date_range ? params.date_range[1] : '',
  162. }).then(res => {
  163. setList(res.data.list)
  164. setTotal(res.data.total)
  165. })
  166. }
  167. onReset={() => {
  168. if (sessionStorage.getItem('vip_company_info')) {
  169. sessionStorage.removeItem('vip_company_info')
  170. }
  171. setFullname('')
  172. actionRef.current.reload();
  173. }}
  174. headerTitle="企业列表"
  175. />
  176. </ConfigProvider>
  177. </>
  178. );
  179. };
  180. export default connect(({ dictModel, openModel }: any) => ({
  181. dictModel,
  182. openModel
  183. }))(CompanyListPage);