|
|
@ -1,9 +1,10 @@ |
|
|
|
import { useModel } from '@umijs/max'; |
|
|
|
import { Button, Col, Form, Input, InputNumber, Modal, Row, Select, Table, Tag } from 'antd'; |
|
|
|
import { Button, Col, Form, Input, InputNumber, Modal, Row, Select, Table, Tabs, Tag } from 'antd'; |
|
|
|
import { ColumnsType } from 'antd/es/table'; |
|
|
|
import { useEffect, useState } from 'react'; |
|
|
|
|
|
|
|
import { adminList, appList, saveAdmin } from '@/services/matrix/admin'; |
|
|
|
import TabPane from 'antd/es/tabs/TabPane'; |
|
|
|
|
|
|
|
const AdminManagement = () => { |
|
|
|
const [data, setData] = useState<API.MatrixAdminBo[]>([]); |
|
|
@ -15,6 +16,13 @@ const AdminManagement = () => { |
|
|
|
const { initialState } = useModel('@@initialState'); |
|
|
|
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 app = appArr.find((app) => app.id === appId); |
|
|
|
return app ? app.name : ''; |
|
|
@ -80,6 +88,85 @@ const AdminManagement = () => { |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
const deviceColumns: ColumnsType<API.MatrixAdminBo> = [ |
|
|
|
{ |
|
|
|
title: '姓名', |
|
|
|
dataIndex: 'name', |
|
|
|
ellipsis: true, |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
title: '应用IDs', |
|
|
|
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 = () => { |
|
|
|
form.submit(); |
|
|
|
}; |
|
|
@ -127,7 +214,16 @@ const AdminManagement = () => { |
|
|
|
return ( |
|
|
|
<div> |
|
|
|
<Button onClick={handleNew}>新建账号</Button> |
|
|
|
<Table columns={columns} dataSource={data} /> |
|
|
|
<Tabs centered style={{ backgroundColor: 'white', padding: '20px' }}> |
|
|
|
{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}> |
|
|
|
<Form form={form} onFinish={handleSaveAdmin}> |
|
|
|