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.

3 月之前
2 月之前
3 月之前
2 月之前
3 月之前
3 月之前
9 月之前
3 月之前
9 月之前
2 月之前
3 月之前
2 月之前
2 月之前
3 月之前
3 月之前
3 月之前
3 月之前
2 月之前
2 月之前
2 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
3 月之前
9 月之前
3 月之前
9 月之前
3 月之前
3 月之前
3 月之前
2 月之前
2 月之前
2 月之前
2 月之前
2 月之前
3 月之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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, Descriptions, Space, Modal, Radio, Row, Col, InputNumber, message, Flex } from 'antd';
  8. import { PostCompanyViplist, PostCompanyFeechange, PostCompanyMultiopenvip } 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 [openMultieditPreview, setOpenMultieditPreview] = useState(false);
  18. const [ids, setIds] = useState<number[]>([])
  19. const [memberType, setMemberType] = useState<number>(1)
  20. const [startDate, setStartDate] = useState<Date | String | null>(null);
  21. const [endDate, setEndDate] = useState<Date | String | null>(null);
  22. const setId = (id: number) => {
  23. getId(id)
  24. }
  25. useEffect(() => {
  26. if (!openModel.openModal) {
  27. actionRef.current?.reload();
  28. }
  29. return () => {
  30. sessionStorage.removeItem('company_info')
  31. sessionStorage.removeItem('post_company_info')
  32. sessionStorage.removeItem('vip_company_info')
  33. };
  34. }, [openModel.openModal])
  35. useEffect(() => {
  36. if (!openModel.openFeeModal) {
  37. actionRef.current?.reload();
  38. }
  39. }, [openModel.openFeeModal])
  40. const handleTimeChange = (value) => {
  41. const today = new Date();
  42. let start_date = today;
  43. let end_date = new Date(today);
  44. end_date.setDate(today.getDate() + value);
  45. // 格式化日期为 YYYY-MM-DD
  46. const formatDate = (date: Date): string => {
  47. const year = date.getFullYear();
  48. const month = String(date.getMonth() + 1).padStart(2, '0');
  49. const day = String(date.getDate()).padStart(2, '0');
  50. return `${year}-${month}-${day}`;
  51. };
  52. const formattedStartDate = formatDate(start_date);
  53. const formattedEndDate = formatDate(end_date);
  54. setStartDate(formattedStartDate);
  55. setEndDate(formattedEndDate);
  56. console.log(formattedStartDate);
  57. console.log(formattedEndDate);
  58. };
  59. const expandedRowRender = (record) => {
  60. return (
  61. <>
  62. <Space direction='vertical' style={{ width: '100%' }}>
  63. <Descriptions title="基本信息" bordered column={3} contentStyle={{ fontWeight: 'bold' }} labelStyle={{ width: 180 }}>
  64. <Descriptions.Item label="见习基地">{record.probation_text}</Descriptions.Item>
  65. <Descriptions.Item label="知名企业">{record.famous_text}</Descriptions.Item>
  66. <Descriptions.Item label="业务员">{record.sales}</Descriptions.Item>
  67. </Descriptions>
  68. </Space >
  69. </>
  70. );
  71. };
  72. return (
  73. <>
  74. <ConfigProvider
  75. theme={{
  76. token: {
  77. colorPrimary: '#4FBE70',
  78. colorLink: '#4FBE70',
  79. },
  80. components: {
  81. Modal: {
  82. colorPrimary: '#4FBE70',
  83. }
  84. }
  85. }}
  86. >
  87. <ProTable
  88. scroll={{ y: 480, x: 'auto' }}
  89. bordered={true}
  90. actionRef={actionRef}
  91. dataSource={list}
  92. search={{
  93. span: 8, labelWidth: 'auto'
  94. }}
  95. tableAlertRender={({
  96. selectedRowKeys,
  97. selectedRows,
  98. onCleanSelected,
  99. }) => {
  100. setIds(selectedRowKeys)
  101. return (
  102. <Space size={24}>
  103. <span>
  104. 已选 {selectedRowKeys.length} 项
  105. <a style={{ marginInlineStart: 8 }} onClick={onCleanSelected}>
  106. 取消选择
  107. </a>
  108. </span>
  109. </Space>
  110. );
  111. }}
  112. tableAlertOptionRender={() => {
  113. return (
  114. <Space size={16}>
  115. <Button onClick={() => {
  116. if (ids.length === 0) {
  117. message.error('请选择要操作的数据')
  118. } else {
  119. setOpenMultieditPreview(true)
  120. }
  121. }}>
  122. 批量开通会员
  123. </Button>,
  124. </Space>
  125. );
  126. }}
  127. rowSelection={{
  128. type: 'checkbox'
  129. }}
  130. expandable={{
  131. expandedRowRender
  132. }}
  133. columns={[
  134. {
  135. title: '筛选日期',
  136. dataIndex: 'date_range',
  137. hidden: true,
  138. valueType: 'dateRange',
  139. },
  140. {
  141. title: 'ID',
  142. dataIndex: 'id',
  143. width: 200,
  144. },
  145. {
  146. title: '企业名称',
  147. dataIndex: 'full_name',
  148. width: 200,
  149. valueType: 'input',
  150. renderFormItem: () => {
  151. return (
  152. <><Input placeholder="请输入企业名称" value={fullname} onChange={(e) => {
  153. setFullname(e.target.value)
  154. }} /></>
  155. )
  156. }
  157. },
  158. {
  159. title: '会员类型',
  160. dataIndex: 'member_type_text',
  161. width: 200,
  162. search: false,
  163. },
  164. {
  165. title: '会员状态',
  166. dataIndex: 'member_status',
  167. width: 200,
  168. search: false,
  169. valueEnum: {
  170. 0: { text: '全部' },
  171. 1: {
  172. text: '待审',
  173. status: 'Error'
  174. },
  175. 2: {
  176. text: '正常',
  177. status: 'Processing'
  178. },
  179. 3: {
  180. text: '到期',
  181. status: 'Error'
  182. },
  183. 4: {
  184. text: '推荐',
  185. status: 'Error'
  186. },
  187. },
  188. },
  189. {
  190. title: '开始时间',
  191. dataIndex: 'start_date',
  192. width: 200,
  193. search: false,
  194. },
  195. {
  196. title: '到期时间',
  197. dataIndex: 'end_date',
  198. width: 200,
  199. search: false,
  200. }, {
  201. title: '剩余点数',
  202. dataIndex: 'balance_fee',
  203. width: 200,
  204. search: false,
  205. },
  206. {
  207. title: '操作',
  208. key: 'option',
  209. valueType: 'option',
  210. render: (_, record, action) => [
  211. <Button key='1' type='link' onClick={() => {
  212. setId(record.id)
  213. dispatch({ type: 'openModel/getOpenModal', payload: true })
  214. }}>编辑</Button>,
  215. <Button key='2' type='link' onClick={() => {
  216. setId(record.id)
  217. dispatch({ type: 'openModel/getOpenFeeModal', payload: true })
  218. }}>变更点数</Button>
  219. ],
  220. },
  221. ]}
  222. rowKey="id"
  223. pagination={{
  224. current: page,
  225. pageSize: pageSize,
  226. showSizeChanger: true,
  227. total: total,
  228. pageSizeOptions: [9, 18, 27, 99],
  229. onChange(page, pageSize) {
  230. setPage(page)
  231. setPageSize(pageSize)
  232. },
  233. onShowSizeChange(current, size) {
  234. setPage(current)
  235. setPageSize(size)
  236. }
  237. }}
  238. request={async (params = {} as Record<string, any>) =>
  239. PostCompanyViplist({
  240. page: page,
  241. pagesize: pageSize,
  242. sort: 'id',
  243. sortby: 'desc',
  244. keyword: fullname,
  245. start_date: params.date_range ? params.date_range[0] : '',
  246. end_date: params.date_range ? params.date_range[1] : '',
  247. }).then(res => {
  248. setList(res.data.list)
  249. setTotal(res.data.total)
  250. })
  251. }
  252. onReset={() => {
  253. if (sessionStorage.getItem('vip_company_info')) {
  254. sessionStorage.removeItem('vip_company_info')
  255. }
  256. setFullname('')
  257. actionRef.current?.reload();
  258. }}
  259. headerTitle="VIP企业列表"
  260. />
  261. <Modal
  262. open={openMultieditPreview}
  263. title='请选择对批量数据进行何种操作'
  264. centered
  265. maskClosable={false}
  266. destroyOnClose
  267. width={400}
  268. onCancel={() => {
  269. setOpenMultieditPreview(false)
  270. }}
  271. onOk={() => {
  272. if (memberType && startDate && endDate) {
  273. PostCompanyMultiopenvip({ ids: ids, member_type: memberType, start_date: startDate, end_date: endDate }).then(res => {
  274. setOpenMultieditPreview(false)
  275. actionRef.current?.clearSelected();
  276. actionRef.current?.reload();
  277. })
  278. } else {
  279. message.error('请完成表单')
  280. return false
  281. }
  282. }
  283. }
  284. >
  285. <Flex vertical justify='center' style={{ minHeight: 100 }}>
  286. <Space direction='vertical'>
  287. <h4 style={{ fontWeight: 'bold' }}>类型:</h4>
  288. <Radio.Group size='small' value={memberType} onChange={(e) => {
  289. setMemberType(e.target.value)
  290. }}>
  291. {/* <Radio value={1}>试用申请中</Radio>
  292. <Radio value={2}>试用正式</Radio>
  293. <Radio value={3}>普通申请中</Radio> */}
  294. <Radio value={4}>普通用户</Radio>
  295. {/* <Radio value={5}>VIP申请中</Radio> */}
  296. <Radio value={6}>会员用户</Radio>
  297. </Radio.Group>
  298. <h4 style={{ fontWeight: 'bold' }}>时长:</h4>
  299. <InputNumber min={1} placeholder='请输入时长' onChange={(value) => {
  300. handleTimeChange(value)
  301. }} style={{ width: '100%' }} />
  302. </Space>
  303. </Flex>
  304. </Modal >
  305. </ConfigProvider>
  306. </>
  307. );
  308. };
  309. export default connect(({ dictModel, openModel }: any) => ({
  310. dictModel,
  311. openModel
  312. }))(CompanyListPage);