|
@ -1,10 +1,24 @@ |
|
|
import { useModel } from '@umijs/max'; |
|
|
import { useModel } from '@umijs/max'; |
|
|
import { Button, Col, Form, Input, InputNumber, Modal, Row, Select, Space, Table, Tag } from 'antd'; |
|
|
import { |
|
|
|
|
|
Button, |
|
|
|
|
|
Col, |
|
|
|
|
|
Form, |
|
|
|
|
|
Input, |
|
|
|
|
|
InputNumber, |
|
|
|
|
|
Modal, |
|
|
|
|
|
Row, |
|
|
|
|
|
Select, |
|
|
|
|
|
Space, |
|
|
|
|
|
Table, |
|
|
|
|
|
Tabs, |
|
|
|
|
|
Tag, |
|
|
|
|
|
} from 'antd'; |
|
|
import { ColumnsType } from 'antd/es/table'; |
|
|
import { ColumnsType } from 'antd/es/table'; |
|
|
import { useEffect, useState } from 'react'; |
|
|
import { useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
|
import { adminList, appList, saveAdmin } from '@/services/matrix/admin'; |
|
|
import { adminList, appList, saveAdmin } from '@/services/matrix/admin'; |
|
|
import { SearchOutlined } from '@ant-design/icons'; |
|
|
import { SearchOutlined } from '@ant-design/icons'; |
|
|
|
|
|
import TabPane from 'antd/es/tabs/TabPane'; |
|
|
|
|
|
|
|
|
const AdminManagement = () => { |
|
|
const AdminManagement = () => { |
|
|
const [data, setData] = useState<API.MatrixAdminBo[]>([]); |
|
|
const [data, setData] = useState<API.MatrixAdminBo[]>([]); |
|
@ -16,6 +30,13 @@ const AdminManagement = () => { |
|
|
const { initialState } = useModel('@@initialState'); |
|
|
const { initialState } = useModel('@@initialState'); |
|
|
const currentUser = initialState?.currentUser; |
|
|
const currentUser = initialState?.currentUser; |
|
|
|
|
|
|
|
|
|
|
|
const formatIncome = (v: number | undefined) => { |
|
|
|
|
|
if (!v) { |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
return parseFloat((v / 1000_00).toFixed(2)); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
const getAppNameById = (appId: number) => { |
|
|
const getAppNameById = (appId: number) => { |
|
|
const app = appArr.find((app) => app.id === appId); |
|
|
const app = appArr.find((app) => app.id === appId); |
|
|
return app ? app.name : ''; |
|
|
return app ? app.name : ''; |
|
@ -32,6 +53,7 @@ const AdminManagement = () => { |
|
|
{ |
|
|
{ |
|
|
title: '账号', |
|
|
title: '账号', |
|
|
dataIndex: 'name', |
|
|
dataIndex: 'name', |
|
|
|
|
|
ellipsis: true, |
|
|
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( |
|
|
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( |
|
|
<div style={{ padding: 8 }}> |
|
|
<div style={{ padding: 8 }}> |
|
|
<Input |
|
|
<Input |
|
@ -53,7 +75,11 @@ const AdminManagement = () => { |
|
|
), |
|
|
), |
|
|
onFilter: (value, record) => record?.name?.includes(value), |
|
|
onFilter: (value, record) => record?.name?.includes(value), |
|
|
filterIcon: (filtered) => ( |
|
|
filterIcon: (filtered) => ( |
|
|
<SearchOutlined style={{ color: filtered ? '#1890ff' : undefined }} onPointerEnterCapture={undefined} onPointerLeaveCapture={undefined} /> |
|
|
<SearchOutlined |
|
|
|
|
|
style={{ color: filtered ? '#1890ff' : undefined }} |
|
|
|
|
|
onPointerEnterCapture={undefined} |
|
|
|
|
|
onPointerLeaveCapture={undefined} |
|
|
|
|
|
/> |
|
|
), |
|
|
), |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
@ -104,6 +130,112 @@ const AdminManagement = () => { |
|
|
}, |
|
|
}, |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
const deviceColumns: ColumnsType<API.MatrixAdminBo> = [ |
|
|
|
|
|
{ |
|
|
|
|
|
title: '账号', |
|
|
|
|
|
dataIndex: 'name', |
|
|
|
|
|
ellipsis: true, |
|
|
|
|
|
filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => ( |
|
|
|
|
|
<div style={{ padding: 8 }}> |
|
|
|
|
|
<Input |
|
|
|
|
|
placeholder="搜索账号" |
|
|
|
|
|
value={selectedKeys[0]} |
|
|
|
|
|
onChange={(e) => setSelectedKeys(e.target.value ? [e.target.value] : [])} |
|
|
|
|
|
onPressEnter={() => confirm()} |
|
|
|
|
|
style={{ marginBottom: 8, display: 'block' }} |
|
|
|
|
|
/> |
|
|
|
|
|
<Space> |
|
|
|
|
|
<Button onClick={() => confirm()} type="primary"> |
|
|
|
|
|
搜索 |
|
|
|
|
|
</Button> |
|
|
|
|
|
<Button onClick={() => clearFilters()} type="link"> |
|
|
|
|
|
清除 |
|
|
|
|
|
</Button> |
|
|
|
|
|
</Space> |
|
|
|
|
|
</div> |
|
|
|
|
|
), |
|
|
|
|
|
onFilter: (value, record) => record?.name?.includes(value), |
|
|
|
|
|
filterIcon: (filtered) => ( |
|
|
|
|
|
<SearchOutlined |
|
|
|
|
|
style={{ color: filtered ? '#1890ff' : undefined }} |
|
|
|
|
|
onPointerEnterCapture={undefined} |
|
|
|
|
|
onPointerLeaveCapture={undefined} |
|
|
|
|
|
/> |
|
|
|
|
|
), |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
title: '游戏', |
|
|
|
|
|
dataIndex: 'appIds', |
|
|
|
|
|
render: (text: []) => ( |
|
|
|
|
|
<div> |
|
|
|
|
|
{text?.map((appId) => ( |
|
|
|
|
|
<Tag color="blue" key={appId}> |
|
|
|
|
|
{getAppNameById(appId)} |
|
|
|
|
|
</Tag> |
|
|
|
|
|
))} |
|
|
|
|
|
</div> |
|
|
|
|
|
), |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '角色', |
|
|
|
|
|
dataIndex: 'role', |
|
|
|
|
|
render: (r: number) => { |
|
|
|
|
|
let roleText = ''; |
|
|
|
|
|
switch (r) { |
|
|
|
|
|
case 1: |
|
|
|
|
|
roleText = '超级管理员'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 2: |
|
|
|
|
|
roleText = '管理员'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 3: |
|
|
|
|
|
roleText = '普通账号'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 4: |
|
|
|
|
|
roleText = '口子'; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
roleText = ''; |
|
|
|
|
|
} |
|
|
|
|
|
return roleText; |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '本月收入(元)', |
|
|
|
|
|
dataIndex: 'incomeThisMonth', |
|
|
|
|
|
render: (_, r: API.MatrixAdminBo) => { |
|
|
|
|
|
return formatIncome(r.overview?.thisMonthIncome); |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '上月收入(元)', |
|
|
|
|
|
dataIndex: 'incomeLastMonth', |
|
|
|
|
|
render: (_, r: API.MatrixAdminBo) => { |
|
|
|
|
|
return formatIncome(r.overview?.lastMonthIncome); |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '累计收入(元)', |
|
|
|
|
|
dataIndex: 'incomeTotal', |
|
|
|
|
|
render: (_, r: API.MatrixAdminBo) => { |
|
|
|
|
|
return formatIncome(r.overview?.totalIncome); |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '当前分成比例', |
|
|
|
|
|
dataIndex: 'incomeRate', |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
title: '操作', |
|
|
|
|
|
render: (record: API.MatrixAdminBo) => [ |
|
|
|
|
|
<a key="edit" onClick={() => handleEdit(record)}> |
|
|
|
|
|
编辑 |
|
|
|
|
|
</a>, |
|
|
|
|
|
], |
|
|
|
|
|
}, |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
const handleOk = () => { |
|
|
const handleOk = () => { |
|
|
form.submit(); |
|
|
form.submit(); |
|
|
}; |
|
|
}; |
|
@ -151,7 +283,16 @@ const AdminManagement = () => { |
|
|
return ( |
|
|
return ( |
|
|
<div> |
|
|
<div> |
|
|
<Button onClick={handleNew}>新建账号</Button> |
|
|
<Button onClick={handleNew}>新建账号</Button> |
|
|
<Table columns={columns} dataSource={data} /> |
|
|
<Tabs centered style={{ backgroundColor: 'white', padding: '20px' }}> |
|
|
|
|
|
{currentUser?.role && currentUser.role < 3 && ( |
|
|
|
|
|
<TabPane tab="普通账号" key="1"> |
|
|
|
|
|
<Table columns={columns} dataSource={data.filter((x) => x.role === 3)} /> |
|
|
|
|
|
</TabPane> |
|
|
|
|
|
)} |
|
|
|
|
|
<TabPane tab="口子" key="2"> |
|
|
|
|
|
<Table columns={deviceColumns} dataSource={data.filter((x) => x.role === 4)} /> |
|
|
|
|
|
</TabPane> |
|
|
|
|
|
</Tabs> |
|
|
|
|
|
|
|
|
<Modal title="编辑" visible={visible} onOk={handleOk} onCancel={handleCancel}> |
|
|
<Modal title="编辑" visible={visible} onOk={handleOk} onCancel={handleCancel}> |
|
|
<Form form={form} onFinish={handleSaveAdmin}> |
|
|
<Form form={form} onFinish={handleSaveAdmin}> |
|
|