Browse Source

feat: 代理部分功能

lihao
nili 6 months ago
parent
commit
0f283db493
  1. 1
      dist/942.561ac28f.async.js
  2. 2
      dist/_umi_route_preload_helper.e927dc81.js
  3. 4
      dist/index.html
  4. 1
      dist/p__AdminManagement.16f4328b.async.js
  5. 1
      dist/p__AdminManagement.5e2368b3.async.js
  6. 1
      dist/p__AdvRecordListV2.1e89410d.async.js
  7. 1
      dist/p__AdvRecordListV2.a637838a.async.js
  8. 1
      dist/p__UserManagement.5e827801.async.js
  9. 1
      dist/p__UserManagement.ec0defdd.async.js
  10. 142
      dist/umi.a9af9b44.js
  11. 2
      src/pages/Admin/AdminHideForm.tsx
  12. 150
      src/pages/Admin/GrantUserForm.tsx
  13. 55
      src/pages/AdminManagement.tsx
  14. 6
      src/pages/AdvRecordListV2.tsx
  15. 2
      src/pages/SuperAdmin/EvilAppManagement.tsx
  16. 2
      src/pages/UserManagement.tsx
  17. 35
      src/services/matrix/admin.ts
  18. 15
      src/services/matrix/matrixUserController.ts
  19. 26
      src/services/matrix/typings.d.ts

1
dist/942.561ac28f.async.js

File diff suppressed because one or more lines are too long

2
dist/_umi_route_preload_helper.a128d8b0.js → dist/_umi_route_preload_helper.e927dc81.js

@ -1 +1 @@
!function(){"use strict";var t="/".replace(/([^/])$/,"$1/"),e=location.pathname,n=e.startsWith(t)&&decodeURI("/".concat(e.slice(t.length)));if(n){var a=document,c=a.head,r=a.createElement.bind(a),i=function(t,e,n){var a,c=e.r[t]||(null===(a=Object.entries(e.r).find((function(e){var n=e[0];return new RegExp("^".concat(n.replace(/\/:[^/]+/g,"/[^/]+").replace("/*","/.+"),"$")).test(t)})))||void 0===a?void 0:a[1]);return null==c?void 0:c.map((function(t){var a=e.f[t][1],c=e.f[t][0];return{type:c.split(".").pop(),url:"".concat(n.publicPath).concat(c),attrs:[["data-".concat(e.b),"".concat(e.p,":").concat(a)]]}}))}(n,{"p":"ant-design-pro","b":"webpack","f":[["51.a2ea1b3b.async.js",51],["134.6fc81d91.async.js",134],["169.57647c7d.async.js",169],["p__Welcome.61596037.async.js",185],["p__MoneyManagement.7ad34f8d.async.js",190],["247.3fe8fb10.async.js",247],["t__plugin-layout__Layout.6cae69f5.chunk.css",301],["t__plugin-layout__Layout.4594a64b.async.js",301],["p__User__Login__index.9d3ab92e.async.js",366],["p__DeviceOwnerApp.ec53e5c4.async.js",371],["390.41467286.async.js",390],["393.38316f72.async.js",393],["397.fb5f72c1.async.js",397],["p__SuperAdmin.92290426.async.js",455],["531.4c68f902.async.js",531],["539.49b7b156.async.js",539],["p__AdvRecordListV2.a637838a.async.js",542],["p__Bind.b6ee068f.async.js",557],["559.016bfdbb.async.js",559],["p__404.0c100574.async.js",571],["635.20e45f05.async.js",635],["p__App__AppManagement.7b88d7c4.async.js",731],["p__AdminManagement.5e2368b3.async.js",816],["822.4ba8fa04.async.js",822],["841.614ef4c0.async.js",841],["p__AdvRecordList.8e5ef22c.async.js",857],["p__UserManagement.ec0defdd.async.js",903],["905.6e225d1b.async.js",905],["930.fca7adbf.async.js",930]],"r":{"/*":[19,27],"/":[1,6,7,18,20,27],"/welcome":[1,2,3,11,18,28,6,7,20,27],"/super":[0,1,2,5,13,14,15,23,27,28,6,7,18,20],"/adminList":[0,2,22,23,1,6,7,18,20,27],"/bind":[1,2,11,12,17,18,28,6,7,20,27],"/appList":[0,1,2,5,12,14,15,21,23,27,28,6,7,18,20],"/advList/:code":[0,1,2,14,15,18,23,24,25,27,28,6,7,20],"/advListV2/:code":[0,1,2,14,15,16,18,23,24,27,28,6,7,20],"/user/:code":[0,1,2,14,15,23,26,27,28,6,7,18,20],"/money/:code":[0,1,2,4,14,15,23,27,28,6,7,18,20],"/app/:code":[0,1,2,9,14,15,18,23,24,27,28,6,7,20],"/user/login":[1,2,8,14,23]}},{publicPath:"/"});null==i||i.forEach((function(t){var e,n=t.type,a=t.url;if("js"===n)(e=r("script")).src=a,e.async=!0;else{if("css"!==n)return;(e=r("link")).href=a,e.rel="preload",e.as="style"}t.attrs.forEach((function(t){e.setAttribute(t[0],t[1]||"")})),c.appendChild(e)}))}}();
!function(){"use strict";var t="/".replace(/([^/])$/,"$1/"),e=location.pathname,n=e.startsWith(t)&&decodeURI("/".concat(e.slice(t.length)));if(n){var a=document,c=a.head,r=a.createElement.bind(a),i=function(t,e,n){var a,c=e.r[t]||(null===(a=Object.entries(e.r).find((function(e){var n=e[0];return new RegExp("^".concat(n.replace(/\/:[^/]+/g,"/[^/]+").replace("/*","/.+"),"$")).test(t)})))||void 0===a?void 0:a[1]);return null==c?void 0:c.map((function(t){var a=e.f[t][1],c=e.f[t][0];return{type:c.split(".").pop(),url:"".concat(n.publicPath).concat(c),attrs:[["data-".concat(e.b),"".concat(e.p,":").concat(a)]]}}))}(n,{"p":"ant-design-pro","b":"webpack","f":[["51.a2ea1b3b.async.js",51],["134.6fc81d91.async.js",134],["169.57647c7d.async.js",169],["p__Welcome.61596037.async.js",185],["p__MoneyManagement.7ad34f8d.async.js",190],["247.3fe8fb10.async.js",247],["t__plugin-layout__Layout.6cae69f5.chunk.css",301],["t__plugin-layout__Layout.4594a64b.async.js",301],["p__User__Login__index.9d3ab92e.async.js",366],["p__DeviceOwnerApp.ec53e5c4.async.js",371],["390.41467286.async.js",390],["393.38316f72.async.js",393],["397.fb5f72c1.async.js",397],["p__SuperAdmin.92290426.async.js",455],["531.4c68f902.async.js",531],["539.49b7b156.async.js",539],["p__AdvRecordListV2.1e89410d.async.js",542],["p__Bind.b6ee068f.async.js",557],["559.016bfdbb.async.js",559],["p__404.0c100574.async.js",571],["635.20e45f05.async.js",635],["p__App__AppManagement.7b88d7c4.async.js",731],["p__AdminManagement.16f4328b.async.js",816],["822.4ba8fa04.async.js",822],["841.614ef4c0.async.js",841],["p__AdvRecordList.8e5ef22c.async.js",857],["p__UserManagement.5e827801.async.js",903],["905.6e225d1b.async.js",905],["930.fca7adbf.async.js",930],["942.561ac28f.async.js",942]],"r":{"/*":[19,27],"/":[1,6,7,18,20,27],"/welcome":[1,2,3,11,18,28,6,7,20,27],"/super":[0,1,2,5,13,14,15,23,27,28,6,7,18,20],"/adminList":[0,1,2,22,23,29,6,7,18,20,27],"/bind":[1,2,11,12,17,18,28,6,7,20,27],"/appList":[0,1,2,5,12,14,15,21,23,27,28,6,7,18,20],"/advList/:code":[0,1,2,14,15,18,23,24,25,27,28,6,7,20],"/advListV2/:code":[0,1,2,14,15,16,18,23,24,27,28,6,7,20],"/user/:code":[0,1,2,14,15,23,26,27,28,6,7,18,20],"/money/:code":[0,1,2,4,14,15,23,27,28,6,7,18,20],"/app/:code":[0,1,2,9,14,15,18,23,24,27,28,6,7,20],"/user/login":[1,2,8,14,23]}},{publicPath:"/"});null==i||i.forEach((function(t){var e,n=t.type,a=t.url;if("js"===n)(e=r("script")).src=a,e.async=!0;else{if("css"!==n)return;(e=r("link")).href=a,e.rel="preload",e.as="style"}t.attrs.forEach((function(t){e.setAttribute(t[0],t[1]||"")})),c.appendChild(e)}))}}();

4
dist/index.html

@ -7,10 +7,10 @@
<title>Ant Design Pro</title>
<link rel="stylesheet" href="/umi.1ca9308c.css">
<script async src="/scripts/loading.js"></script>
<script src="/_umi_route_preload_helper.a128d8b0.js"></script>
<script src="/_umi_route_preload_helper.e927dc81.js"></script>
</head>
<body>
<div id="root"></div>
<script src="/umi.4ab72899.js"></script>
<script src="/umi.a9af9b44.js"></script>
</body>
</html>

1
dist/p__AdminManagement.16f4328b.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdminManagement.5e2368b3.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdvRecordListV2.1e89410d.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdvRecordListV2.a637838a.async.js

File diff suppressed because one or more lines are too long

1
dist/p__UserManagement.5e827801.async.js

File diff suppressed because one or more lines are too long

1
dist/p__UserManagement.ec0defdd.async.js

File diff suppressed because one or more lines are too long

142
dist/umi.4ab72899.js → dist/umi.a9af9b44.js

File diff suppressed because one or more lines are too long

2
src/pages/Admin/AdminHideForm.tsx

@ -1,7 +1,7 @@
import { changeAdminHide } from '@/services/matrix/admin';
import { Modal, Switch, Table } from 'antd';
import { ColumnsType } from 'antd/es/table';
import React from 'react';
import { changeAdminHide } from '../../services/matrix/admin';
export type AdminHideFormProps = {
onSubmit: () => void;

150
src/pages/Admin/GrantUserForm.tsx

@ -0,0 +1,150 @@
import { getGrantUser, saveGrantUser } from '@/services/matrix/admin';
import { queryById } from '@/services/matrix/matrixUserController';
import { MinusCircleOutlined } from '@ant-design/icons';
import { Button, Col, Flex, Form, InputNumber, Modal, Popover, Row, message } from 'antd';
import React, { useEffect, useState } from 'react';
import UserInfo from '../User/UserInfo';
export type GrantUserFormProps = {
onSubmit: () => void;
onCancel: () => void;
data: API.MatrixAdminBo;
};
const GrantUserForm: React.FC<GrantUserFormProps> = (props) => {
const [userList, setUserList] = useState<API.UserBo[]>([]);
const [newAddList, setNewAddList] = useState<API.UserBo[]>([]);
const [form] = Form.useForm();
const fetchConfig = async (id: number) => {
const data = await getGrantUser({ adminId: id });
setUserList(data.data || []);
};
useEffect(() => {
if (props.data.id) {
fetchConfig(props.data.id);
}
}, [props.data.id]);
return (
<Modal
title="绑定账号"
visible
centered
onCancel={() => {
props.onCancel();
}}
footer={[
<Button
key="back"
onClick={() => {
props.onCancel();
}}
>
</Button>,
<Popover
key="confirm"
title="确定保存吗"
content={
<div style={{ textAlign: 'center' }}>
<p></p>
<a
onClick={async () => {
let uids = [...userList, ...newAddList]
.map((x) => x.id)
.filter(Boolean) as number[];
if (props.data.id && uids) {
await saveGrantUser({ adminId: props.data.id }, uids);
props.onSubmit();
} else {
props.onCancel();
}
}}
>
</a>
</div>
}
>
<Button type="primary"></Button>
</Popover>,
]}
>
{userList.length > 0 && (
<Row gutter={6} style={{ marginTop: 20 }}>
<Col span={4}>:</Col>
<Flex vertical gap="small">
{userList.map((x) => (
<Row key={x.id}>
<UserInfo data={x} />
</Row>
))}
</Flex>
</Row>
)}
{newAddList.length > 0 && (
<Row gutter={6} style={{ marginTop: 20 }}>
<Col span={4}>:</Col>
<Flex vertical gap="small">
{newAddList.map((x) => (
<Row key={x.id}>
<UserInfo data={x} />
<MinusCircleOutlined
style={{ marginLeft: 20 }}
onClick={() => {
setNewAddList(newAddList.filter((a) => a.id !== x.id));
}}
/>
</Row>
))}
</Flex>
</Row>
)}
<Form
style={{ marginTop: 20 }}
labelCol={{ span: 4 }}
wrapperCol={{ span: 18 }}
form={form}
onFinish={async ({ uid }) => {
if (!uid) {
message.error('uid不能为空');
return;
}
if (props.data.id && uid) {
if (newAddList.filter((x) => x.id === uid).length > 0) {
message.error('该账号已添加');
return;
}
if (userList.filter((x) => x.id === uid).length > 0) {
message.error('该账号已添加');
return;
}
const data = await queryById({ adminId: props.data.id, userId: uid });
if (!data.data) {
message.error('uid非法');
} else {
setNewAddList([...newAddList, data.data]);
}
}
}}
>
<Row>
<Form.Item name="uid" label="uid">
<InputNumber style={{ width: 200 }} />
</Form.Item>
<Form.Item wrapperCol={{ offset: 8, span: 16 }}>
<Button type="primary" htmlType="submit">
</Button>
</Form.Item>
</Row>
</Form>
</Modal>
);
};
export default GrantUserForm;

55
src/pages/AdminManagement.tsx

@ -6,10 +6,12 @@ import TabPane from 'antd/es/tabs/TabPane';
import { useEffect, useState } from 'react';
import AdminHideForm from './Admin/AdminHideForm';
import GrantUserForm from './Admin/GrantUserForm';
const AdminManagement = () => {
const [data, setData] = useState<API.MatrixAdminBo[]>([]);
const [visible, setVisible] = useState(false);
const [grantingUser, setGrantingUser] = useState<API.MatrixAdminBo | undefined>(undefined);
const [hideFormVisible, setHideFormVisible] = useState(false);
const [editing, setEditing] = useState(false);
const [role, setRole] = useState<number>(0);
@ -128,6 +130,9 @@ const AdminManagement = () => {
case 4:
roleText = '设备主';
break;
case 5:
roleText = '代理';
break;
default:
roleText = '';
}
@ -161,11 +166,30 @@ const AdminManagement = () => {
},
{
title: '操作',
render: (record: API.MatrixAdminBo) => [
render: (record: API.MatrixAdminBo) => {
return (
<Row gutter={6}>
<Col>
<a key="edit" onClick={() => handleEdit(record)}>
</a>,
],
</a>
</Col>
{record.role === 5 && (
<Col>
<a
key="grant"
onClick={() => {
setGrantingUser(record);
}}
>
</a>
</Col>
)}
</Row>
);
},
},
];
@ -244,8 +268,14 @@ const AdminManagement = () => {
dataSource={data.filter((x) => x.role === 4 && x.hide === 0)}
/>
</TabPane>
<TabPane tab="代理" key="3">
<Table
columns={deviceColumns}
dataSource={data.filter((x) => x.role === 5 && x.hide === 0)}
/>
</TabPane>
{currentUser?.role && currentUser.role < 2 && (
<TabPane tab="管理员" key="3">
<TabPane tab="管理员" key="4">
<Table
columns={columns}
dataSource={data.filter((x) => x.role === 2 && x.hide === 0)}
@ -295,6 +325,7 @@ const AdminManagement = () => {
</Select.Option>
<Select.Option value={4}></Select.Option>
<Select.Option value={5}></Select.Option>
</Select>
</Form.Item>
{role > 3 && (
@ -304,11 +335,15 @@ const AdminManagement = () => {
<InputNumber placeholder="1-100整数" style={{ width: '80%' }} />
</Form.Item>
</Col>
{role === 4 ? (
<Col span={12}>
<Form.Item labelCol={{ span: 8 }} label="设备数" name="deviceCnt">
<InputNumber style={{ width: '80%' }} />
</Form.Item>
</Col>
) : (
''
)}
</Row>
)}
</Form>
@ -323,6 +358,18 @@ const AdminManagement = () => {
}}
/>
)}
{grantingUser && (
<GrantUserForm
data={grantingUser}
onCancel={() => {
setGrantingUser(undefined);
}}
onSubmit={() => {
setGrantingUser(undefined);
fetchData();
}}
/>
)}
</div>
);
};

6
src/pages/AdvRecordListV2.tsx

@ -130,6 +130,12 @@ const AdvRecordListV2: React.FC = () => {
hideInSearch: true,
valueType: 'textarea',
},
{
title: '代理',
dataIndex: 'adminName',
hideInSearch: true,
valueType: 'textarea',
},
{
title: '用户',
dataIndex: 'user',

2
src/pages/SuperAdmin/EvilAppManagement.tsx

@ -3,7 +3,7 @@ import { ProColumns, ProTable } from '@ant-design/pro-components';
import { Button, Form, Input, Modal, Space } from 'antd';
import { useEffect, useState } from 'react';
import { evilAppList, saveEvilApp } from '../../services/matrix/superAdmin';
import { evilAppList, saveEvilApp } from '@/services/matrix/superAdmin';
const EvilAppManagement = () => {
const [visible, setVisible] = useState(false);

2
src/pages/UserManagement.tsx

@ -1,8 +1,8 @@
import { changeStatus, list } from '@/services/matrix/matrixUserController';
import { ActionType, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { useParams } from '@umijs/max';
import { Flex, Popconfirm, Tag } from 'antd';
import { useEffect, useRef } from 'react';
import { changeStatus, list } from '../services/matrix/matrixUserController';
import { cent2Yuan, formatIncome } from '../utils/numberUtils';
import UserInfo from './User/UserInfo';

35
src/services/matrix/admin.ts

@ -118,6 +118,41 @@ export async function grantApp(
});
}
/** 此处后端没有提供注释 GET /api/admin/grantUser */
export async function getGrantUser(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.getGrantUserParams,
options?: { [key: string]: any },
) {
return request<API.RListUserBo>('/api/admin/grantUser', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/grantUser */
export async function saveGrantUser(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.saveGrantUserParams,
body: number[],
options?: { [key: string]: any },
) {
return request<API.RVoid>('/api/admin/grantUser', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
params: {
...params,
},
data: body,
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/incomeDaily */
export async function incomeDaily(body: API.IncomeQuery, options?: { [key: string]: any }) {
return request<API.RListDateIncome>('/api/admin/incomeDaily', {

15
src/services/matrix/matrixUserController.ts

@ -28,3 +28,18 @@ export async function list(body: API.UserQuery, options?: { [key: string]: any }
...(options || {}),
});
}
/** 此处后端没有提供注释 GET /api/admin/user/queryById */
export async function queryById(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.queryByIdParams,
options?: { [key: string]: any },
) {
return request<API.RUserBo>('/api/admin/user/queryById', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}

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

@ -110,6 +110,10 @@ declare namespace API {
appCode: string;
};
type getGrantUserParams = {
adminId: number;
};
type getUMengConfigParams = {
appCode: string;
};
@ -147,6 +151,7 @@ declare namespace API {
channel?: string;
parentAdminId?: number;
deviceCnt?: number;
userIds?: string;
incomeRate?: number;
hide?: number;
};
@ -309,6 +314,11 @@ declare namespace API {
sum?: number;
};
type queryByIdParams = {
adminId: number;
userId: number;
};
type RAliPayConfigBo = {
code?: number;
message?: string;
@ -369,6 +379,12 @@ declare namespace API {
data?: MatrixWhiteDevice[];
};
type RListUserBo = {
code?: number;
message?: string;
data?: UserBo[];
};
type RListWhiteUserBo = {
code?: number;
message?: string;
@ -423,6 +439,12 @@ declare namespace API {
data?: UmengConfigBo;
};
type RUserBo = {
code?: number;
message?: string;
data?: UserBo;
};
type RVoid = {
code?: number;
message?: string;
@ -439,6 +461,10 @@ declare namespace API {
appCode: string;
};
type saveGrantUserParams = {
adminId: number;
};
type saveNormalConfigParams = {
appCode: string;
};

Loading…
Cancel
Save