Browse Source

设备主收入

master
nili 5 months ago
parent
commit
0c1e541ce2
  1. 2
      dist/index.html
  2. 1
      dist/p__AdminManagement.1126dff2.async.js
  3. 1
      dist/p__AdminManagement.a1779b54.async.js
  4. 4
      dist/umi.e8d45b1c.js
  5. 100
      src/pages/AdminManagement.tsx
  6. 3
      src/services/matrix/typings.d.ts

2
dist/index.html

@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="/umi.4523c287.js"></script> <script src="/umi.e8d45b1c.js"></script>
</body></html> </body></html>

1
dist/p__AdminManagement.1126dff2.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdminManagement.a1779b54.async.js

File diff suppressed because one or more lines are too long

4
dist/umi.4523c287.js → dist/umi.e8d45b1c.js

File diff suppressed because one or more lines are too long

100
src/pages/AdminManagement.tsx

@ -1,9 +1,10 @@
import { useModel } from '@umijs/max'; 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 { 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 TabPane from 'antd/es/tabs/TabPane';
const AdminManagement = () => { const AdminManagement = () => {
const [data, setData] = useState<API.MatrixAdminBo[]>([]); const [data, setData] = useState<API.MatrixAdminBo[]>([]);
@ -15,6 +16,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 : '';
@ -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 = () => { const handleOk = () => {
form.submit(); form.submit();
}; };
@ -127,7 +214,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' }}>
{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}>

3
src/services/matrix/typings.d.ts

@ -28,6 +28,7 @@ declare namespace API {
deviceId?: string; deviceId?: string;
code?: string; code?: string;
createdAt?: string[]; createdAt?: string[];
adminId?: number;
}; };
type AppInfo = { type AppInfo = {
@ -142,6 +143,7 @@ declare namespace API {
role?: number; role?: number;
deviceCnt?: number; deviceCnt?: number;
incomeRate?: number; incomeRate?: number;
overview?: OverviewBo;
}; };
type MatrixAdminDevice = { type MatrixAdminDevice = {
@ -169,6 +171,7 @@ declare namespace API {
appId?: number; appId?: number;
createdAt?: number; createdAt?: number;
id?: number; id?: number;
adminName?: string;
}; };
type MatrixAdvRecordEditBo = { type MatrixAdvRecordEditBo = {

Loading…
Cancel
Save