123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import { useRef, useState, useEffect } from 'react';
- import { connect, history } from '@umijs/max';
- import type { ActionType, ProFormInstance } from '@ant-design/pro-components';
- import {
- ProTable, TableDropdown
- } from '@ant-design/pro-components';
- import { Button, Image, ConfigProvider, Popconfirm } from 'antd';
- import { getAccount } from '@/apis/api';
- import { Imageprefix } from '@/constants';
-
- const PagesPermissionAccountTable: React.FC = ({ dispatch, openModel, getId }: any) => {
- const actionRef = useRef<ActionType>();
- const [list, setList] = useState<object[]>([])
- const [total, setTotal] = useState<number>(0)
- const [page, setPage] = useState<number>(1)
- const [pageSize, setPageSize] = useState<number>(10)
-
- const setId = (id: number) => {
- getId(id)
- }
-
- useEffect(() => {
- if (!openModel.openModal) {
- actionRef.current.reload();
- }
- }, [openModel.openModal])
-
- return (
- <>
- <ConfigProvider
- theme={{
- token: {
- colorPrimary: '#4FBE70',
- colorLink: '#4FBE70',
- }
- }}
- >
- <ProTable
- scroll={{ y: 480, x: 'auto' }}
- bordered={true}
- actionRef={actionRef}
- dataSource={list}
- search={{ span: 8, labelWidth: 'auto' }}
- columns={[
- {
- title: '手机号码',
- dataIndex: 'mobile'
- }, {
- title: '昵称',
- dataIndex: 'nickname',
- search: false,
-
- }, {
- title: '头像',
- dataIndex: 'avatar',
- search: false,
-
- }, {
- title: '电子邮箱',
- dataIndex: 'email',
- search: false,
-
- }, {
- title: '角色ID',
- dataIndex: 'roleids',
- search: false,
- },
- {
- title: '操作',
- key: 'option',
- valueType: 'option',
- render: (_, record, action) => [
- <Button key='1' type='link' onClick={() => {
- setId(record.id)
- dispatch({ type: 'openModel/getOpenModal', payload: true })
- }}>编辑</Button>,
- <Popconfirm
- title="是否删除"
- onConfirm={(e) => {
- PostActivityaddressDel({ id: record.id }).then(res => {
- message.success('删除成功')
- actionRef.current?.reload();
- })
- }}
- okText="删除"
- cancelText="取消"
- >
- <Button danger type='link'>删除</Button>
- </Popconfirm>
- ],
- },
- ]}
- rowKey="id"
- pagination={{
- current: page,
- pageSize: pageSize,
- showSizeChanger: true,
- total: total,
- pageSizeOptions: [9, 18, 27, 99],
- onChange(page, pageSize) {
- setPage(page)
- setPageSize(pageSize)
- },
- onShowSizeChange(current, size) {
- setPage(current)
- setPageSize(size)
- }
- }}
- request={async (params = {} as Record<string, any>) =>
- getAccount({
- page: page,
- pagesize: pageSize,
- sort: 'id',
- sortby: 'desc',
- keyword: params.mobile,
-
- }).then(res => {
- setList(res.data.users)
- setTotal(res.data.total)
- })
- }
- headerTitle="账号列表"
- toolBarRender={() => [
- <Button type="primary" onClick={() => {
- dispatch({ type: 'openModel/getOpenModal', payload: true })
- }}>
- 添加账号
- </Button>
- ]}
- />
- </ConfigProvider>
- </>
- );
- };
-
-
- export default connect(({ openModel }: any) => ({
- openModel
- }))(PagesPermissionAccountTable);
|