Browse Source

加人员管理的功能

master
nili 9 months ago
parent
commit
6263211ba9
  1. 17
      config/routes.ts
  2. 193
      dist/104.6ba2d1be.async.js
  3. 284
      dist/140.016265e7.async.js
  4. 302
      dist/140.d86f6b29.async.js
  5. 10
      dist/393.fb29dfde.async.js
  6. 150
      dist/507.7e792448.async.js
  7. 83
      dist/51.d90b1fa5.async.js
  8. 40
      dist/64.c7fff68e.async.js
  9. 30
      dist/706.1c4598f2.async.js
  10. 12
      dist/913.dea6f481.async.js
  11. 2
      dist/index.html
  12. 1
      dist/p__Admin.d103d507.async.js
  13. 1
      dist/p__AdminManagement.3d8845fe.async.js
  14. 1
      dist/p__AdvRecordList.39e7df79.async.js
  15. 1
      dist/p__AdvRecordList.bf32001c.async.js
  16. 1
      dist/p__Welcome.61596037.async.js
  17. 10
      dist/p__Welcome.a2bd332c.async.js
  18. 433
      dist/umi.62542788.js
  19. 433
      dist/umi.f88ab783.js
  20. 11
      src/access.ts
  21. 18
      src/app.tsx
  22. 158
      src/pages/AdminManagement.tsx
  23. 35
      src/services/matrix/admin.ts
  24. 25
      src/services/matrix/typings.d.ts

17
config/routes.ts

@ -35,21 +35,10 @@ export default [
component: './AdvRecordList',
},
{
path: '/admin',
name: 'admin',
icon: 'crown',
path: '/adminList',
name: '人员管理',
access: 'canAdmin',
routes: [
{
path: '/admin',
redirect: '/admin/sub-page',
},
{
path: '/admin/sub-page',
name: 'sub-page',
component: './Admin',
},
],
component: './AdminManagement'
},
{
path: '/',

193
dist/104.6ba2d1be.async.js

File diff suppressed because one or more lines are too long

284
dist/140.016265e7.async.js

File diff suppressed because one or more lines are too long

302
dist/140.d86f6b29.async.js

File diff suppressed because one or more lines are too long

10
dist/393.fb29dfde.async.js

File diff suppressed because one or more lines are too long

150
dist/507.7e792448.async.js

File diff suppressed because one or more lines are too long

83
dist/51.d90b1fa5.async.js

File diff suppressed because one or more lines are too long

40
dist/64.c7fff68e.async.js

File diff suppressed because one or more lines are too long

30
dist/706.1c4598f2.async.js

File diff suppressed because one or more lines are too long

12
dist/913.dea6f481.async.js

File diff suppressed because one or more lines are too long

2
dist/index.html

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

1
dist/p__Admin.d103d507.async.js

@ -1 +0,0 @@
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[551],{9940:function(j,l,e){e.r(l),e.d(l,{default:function(){return y}});var o=e(1413),s=e(67294),m={icon:function(a,n){return{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z",fill:a}},{tag:"path",attrs:{d:"M512 140c-205.4 0-372 166.6-372 372s166.6 372 372 372 372-166.6 372-372-166.6-372-372-372zM288 421a48.01 48.01 0 0196 0 48.01 48.01 0 01-96 0zm224 272c-85.5 0-155.6-67.3-160-151.6a8 8 0 018-8.4h48.1c4.2 0 7.8 3.2 8.1 7.4C420 589.9 461.5 629 512 629s92.1-39.1 95.8-88.6c.3-4.2 3.9-7.4 8.1-7.4H664a8 8 0 018 8.4C667.6 625.7 597.5 693 512 693zm176-224a48.01 48.01 0 010-96 48.01 48.01 0 010 96z",fill:n}},{tag:"path",attrs:{d:"M288 421a48 48 0 1096 0 48 48 0 10-96 0zm376 112h-48.1c-4.2 0-7.8 3.2-8.1 7.4-3.7 49.5-45.3 88.6-95.8 88.6s-92-39.1-95.8-88.6c-.3-4.2-3.9-7.4-8.1-7.4H360a8 8 0 00-8 8.4c4.4 84.3 74.5 151.6 160 151.6s155.6-67.3 160-151.6a8 8 0 00-8-8.4zm-24-112a48 48 0 1096 0 48 48 0 10-96 0z",fill:a}}]}},name:"smile",theme:"twotone"},g=m,i=e(91146),c=function(a,n){return s.createElement(i.Z,(0,o.Z)((0,o.Z)({},a),{},{ref:n,icon:g}))};c.displayName="SmileTwoTone";var f=s.forwardRef(c),T={icon:function(a,n){return{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M923 283.6a260.04 260.04 0 00-56.9-82.8 264.4 264.4 0 00-84-55.5A265.34 265.34 0 00679.7 125c-49.3 0-97.4 13.5-139.2 39-10 6.1-19.5 12.8-28.5 20.1-9-7.3-18.5-14-28.5-20.1-41.8-25.5-89.9-39-139.2-39-35.5 0-69.9 6.8-102.4 20.3-31.4 13-59.7 31.7-84 55.5a258.44 258.44 0 00-56.9 82.8c-13.9 32.3-21 66.6-21 101.9 0 33.3 6.8 68 20.3 103.3 11.3 29.5 27.5 60.1 48.2 91 32.8 48.9 77.9 99.9 133.9 151.6 92.8 85.7 184.7 144.9 188.6 147.3l23.7 15.2c10.5 6.7 24 6.7 34.5 0l23.7-15.2c3.9-2.5 95.7-61.6 188.6-147.3 56-51.7 101.1-102.7 133.9-151.6 20.7-30.9 37-61.5 48.2-91 13.5-35.3 20.3-70 20.3-103.3.1-35.3-7-69.6-20.9-101.9zM512 814.8S156 586.7 156 385.5C156 283.6 240.3 201 344.3 201c73.1 0 136.5 40.8 167.7 100.4C543.2 241.8 606.6 201 679.7 201c104 0 188.3 82.6 188.3 184.5 0 201.2-356 429.3-356 429.3z",fill:a}},{tag:"path",attrs:{d:"M679.7 201c-73.1 0-136.5 40.8-167.7 100.4C480.8 241.8 417.4 201 344.3 201c-104 0-188.3 82.6-188.3 184.5 0 201.2 356 429.3 356 429.3s356-228.1 356-429.3C868 283.6 783.7 201 679.7 201z",fill:n}}]}},name:"heart",theme:"twotone"},v=T,d=function(a,n){return s.createElement(i.Z,(0,o.Z)((0,o.Z)({},a),{},{ref:n,icon:v}))};d.displayName="HeartTwoTone";var h=s.forwardRef(d),u=e(90930),p=e(35312),w=e(4393),x=e(38925),z=e(31064),t=e(85893),M=function(){var a=(0,p.useIntl)();return(0,t.jsxs)(u._z,{content:a.formatMessage({id:"pages.admin.subPage.title",defaultMessage:"This page can only be viewed by admin"}),children:[(0,t.jsxs)(w.Z,{children:[(0,t.jsx)(x.Z,{message:a.formatMessage({id:"pages.welcome.alertMessage",defaultMessage:"Faster and stronger heavy-duty components have been released."}),type:"success",showIcon:!0,banner:!0,style:{margin:-12,marginBottom:48}}),(0,t.jsxs)(z.Z.Title,{level:2,style:{textAlign:"center"},children:[(0,t.jsx)(f,{})," Ant Design Pro ",(0,t.jsx)(h,{twoToneColor:"#eb2f96"})," You"]})]}),(0,t.jsxs)("p",{style:{textAlign:"center",marginTop:24},children:["Want to add more pages? Please refer to"," ",(0,t.jsx)("a",{href:"https://pro.ant.design/docs/block-cn",target:"_blank",rel:"noopener noreferrer",children:"use block"}),"\u3002"]})]})},y=M}}]);

1
dist/p__AdminManagement.3d8845fe.async.js

File diff suppressed because one or more lines are too long

1
dist/p__AdvRecordList.39e7df79.async.js

@ -0,0 +1 @@
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[857],{46701:function(U,d,e){e.r(d);var E=e(15009),u=e.n(E),p=e(97857),l=e.n(p),x=e(99289),f=e.n(x),I=e(48357),h=e(90930),D=e(1507),M=e(35312),i=e(67294),T=e(96974),o=e(85893),P=function(){var m=(0,i.useRef)(),O=(0,M.useIntl)(),j=[{title:"\u8BBE\u5907Id",dataIndex:"deviceId",valueType:"textarea",ellipsis:!0,copyable:!0},{title:"\u5E94\u7528\u540D\u79F0",hideInSearch:!0,dataIndex:"appName",valueType:"textarea"},{title:"\u5E73\u53F0",dataIndex:"platform",valueEnum:{1:{text:"\u7A7F\u5C71\u7532"},2:{text:"\u817E\u8BAF"},3:{text:"\u767E\u5EA6\u8054\u76DF"},4:{text:"Mintegral"},5:{text:"\u5FEB\u624B"},6:{text:"\u6E38\u53EF\u8D62"},7:{text:"Sigmob"},8:{text:"Admob"}}},{title:"\u5E7F\u544A\u7C7B\u578B",dataIndex:"advType",valueEnum:{1:{text:"\u6A2A\u5E45",status:"Default"},2:{text:"\u63D2\u9875",status:"Processing"},3:{text:"\u6FC0\u52B1\u89C6\u9891",status:"Success"}}},{title:"ecpm(\u5143)",dataIndex:"ecpm",hideInSearch:!0,renderText:function(_){return _/100}},{title:"\u8BBE\u5907\u54C1\u724C",dataIndex:"deviceBrand",hideInSearch:!0,valueType:"textarea"},{title:"\u8BBE\u5907\u540D",dataIndex:"deviceName",hideInSearch:!0,valueType:"textarea"},{title:"ip",dataIndex:"ip",hideInSearch:!0,valueType:"textarea"},{title:"\u65F6\u95F4",hideInSearch:!0,dataIndex:"createdAt",valueType:"dateTime"},{title:"\u65F6\u95F4",hideInTable:!0,dataIndex:"createdAt",valueType:"dateRange"}],b=(0,T.UO)(),c=b.code,R=function(){var t=f()(u()().mark(function _(v){var r,n,s;return u()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,(0,I._5)(l()(l()({},v),{},{code:c}));case 2:return s=a.sent,a.abrupt("return",{data:(r=s.data)===null||r===void 0?void 0:r.data,total:(n=s.data)===null||n===void 0?void 0:n.total,success:!0});case 4:case"end":return a.stop()}},_)}));return function(v){return t.apply(this,arguments)}}();return(0,i.useEffect)(function(){var t;(t=m.current)===null||t===void 0||t.reload()},[c]),(0,o.jsx)(h._z,{children:(0,o.jsx)(D.Z,{headerTitle:O.formatMessage({id:"pages.searchTable.title",defaultMessage:"Enquiry form"}),actionRef:m,rowKey:"key",search:{labelWidth:120},request:R,columns:j})})};d.default=P}}]);

1
dist/p__AdvRecordList.bf32001c.async.js

@ -1 +0,0 @@
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[857],{46701:function(U,d,e){e.r(d);var E=e(15009),u=e.n(E),p=e(97857),l=e.n(p),x=e(99289),f=e.n(x),I=e(48357),h=e(90930),D=e(76104),M=e(35312),i=e(67294),T=e(96974),o=e(85893),P=function(){var m=(0,i.useRef)(),O=(0,M.useIntl)(),j=[{title:"\u8BBE\u5907Id",dataIndex:"deviceId",valueType:"textarea",ellipsis:!0,copyable:!0},{title:"\u5E94\u7528\u540D\u79F0",hideInSearch:!0,dataIndex:"appName",valueType:"textarea"},{title:"\u5E73\u53F0",dataIndex:"platform",valueEnum:{1:{text:"\u7A7F\u5C71\u7532"},2:{text:"\u817E\u8BAF"},3:{text:"\u767E\u5EA6\u8054\u76DF"},4:{text:"Mintegral"},5:{text:"\u5FEB\u624B"},6:{text:"\u6E38\u53EF\u8D62"},7:{text:"Sigmob"},8:{text:"Admob"}}},{title:"\u5E7F\u544A\u7C7B\u578B",dataIndex:"advType",valueEnum:{1:{text:"\u6A2A\u5E45",status:"Default"},2:{text:"\u63D2\u9875",status:"Processing"},3:{text:"\u6FC0\u52B1\u89C6\u9891",status:"Success"}}},{title:"ecpm(\u5143)",dataIndex:"ecpm",hideInSearch:!0,renderText:function(_){return _/100}},{title:"\u8BBE\u5907\u54C1\u724C",dataIndex:"deviceBrand",hideInSearch:!0,valueType:"textarea"},{title:"\u8BBE\u5907\u540D",dataIndex:"deviceName",hideInSearch:!0,valueType:"textarea"},{title:"ip",dataIndex:"ip",hideInSearch:!0,valueType:"textarea"},{title:"\u65F6\u95F4",hideInSearch:!0,dataIndex:"createdAt",valueType:"dateTime"},{title:"\u65F6\u95F4",hideInTable:!0,dataIndex:"createdAt",valueType:"dateRange"}],b=(0,T.UO)(),c=b.code,R=function(){var t=f()(u()().mark(function _(v){var r,n,s;return u()().wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,(0,I._5)(l()(l()({},v),{},{code:c}));case 2:return s=a.sent,a.abrupt("return",{data:(r=s.data)===null||r===void 0?void 0:r.data,total:(n=s.data)===null||n===void 0?void 0:n.total,success:!0});case 4:case"end":return a.stop()}},_)}));return function(v){return t.apply(this,arguments)}}();return(0,i.useEffect)(function(){var t;(t=m.current)===null||t===void 0||t.reload()},[c]),(0,o.jsx)(h._z,{children:(0,o.jsx)(D.Z,{headerTitle:O.formatMessage({id:"pages.searchTable.title",defaultMessage:"Enquiry form"}),actionRef:m,rowKey:"key",search:{labelWidth:120},request:R,columns:j})})};d.default=P}}]);

1
dist/p__Welcome.61596037.async.js

@ -1 +0,0 @@
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[185],{9622:function(g,i,n){n.r(i);var o=n(90930),d=n(35312),r=n(9361),s=n(4393),c=n(67294),a=n(85893),l=function(){var e,u=r.Z.useToken(),_=u.token,A=(0,d.useModel)("@@initialState"),t=A.initialState;return(0,a.jsx)(o._z,{children:(0,a.jsx)(s.Z,{style:{borderRadius:8},bodyStyle:{backgroundImage:(t==null||(e=t.settings)===null||e===void 0?void 0:e.navTheme)==="realDark"?"background-image: linear-gradient(75deg, #1A1B1F 0%, #191C1F 100%)":"background-image: linear-gradient(75deg, #FBFDFF 0%, #F5F7FF 100%)"},children:(0,a.jsx)("div",{style:{backgroundPosition:"100% -30%",backgroundRepeat:"no-repeat",backgroundSize:"274px auto",backgroundImage:"url('https://gw.alipayobjects.com/mdn/rms_a9745b/afts/img/A*BuFmQqsB2iAAAAAAAAAAAAAAARQnAQ')"},children:(0,a.jsx)("div",{style:{fontSize:"20px",color:_.colorTextHeading},children:"\u6B22\u8FCE\u4F7F\u7528 Matrix"})})})})};i.default=l}}]);

10
dist/p__Welcome.a2bd332c.async.js

File diff suppressed because one or more lines are too long

433
dist/umi.62542788.js

File diff suppressed because one or more lines are too long

433
dist/umi.f88ab783.js

File diff suppressed because one or more lines are too long

11
src/access.ts

@ -1,9 +1,14 @@
/**
* @see https://umijs.org/docs/max/access#access
* */
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
export default function access(initialState: { currentUser?: API.MatrixAdmin } | undefined) {
const { currentUser } = initialState ?? {};
return {
canAdmin: currentUser && currentUser.access === 'admin',
console.log("access");
console.log(currentUser);
let data = {
canAdmin: currentUser && currentUser.role && currentUser.role < 3
};
console.log(data);
return data;
}

18
src/app.tsx

@ -8,6 +8,7 @@ import React from 'react';
import defaultSettings from '../config/defaultSettings';
import { errorConfig } from './requestErrorConfig';
import { appList } from './services/matrix/admin';
import access from './access';
import type { Settings as LayoutSettings } from '@ant-design/pro-components';
import type { RunTimeLayoutConfig } from '@umijs/max';
@ -68,9 +69,26 @@ export const layout: RunTimeLayoutConfig = ({ initialState, setInitialState }) =
"component": "./AdvRecordList"
})
})
menuData.push( {
path: '/adminList',
name: '人员管理',
access: 'canAdmin'
})
return menuData;
},
},
// 添加权限校验逻辑
menuDataRender: (menuData) =>
menuData.map((item) => {
if (item.access && !access(initialState).canAdmin) {
return {
...item,
hideInMenu: true, // 隐藏菜单项
};
}
return item;
}),
actionsRender: () => [<Question key="doc" />, <SelectLang key="SelectLang" />],
avatarProps: {
// src: initialState?.currentUser?.avatar,

158
src/pages/AdminManagement.tsx

@ -0,0 +1,158 @@
import { Button, Form, Input, Modal, Select, Table, Tag } from 'antd';
import { ColumnsType } from 'antd/es/table';
import React, { useEffect, useState } from 'react';
import { adminList, appList, saveAdmin } from '../services/matrix/admin';
const AdminManagement = () => {
const [data, setData] = useState<API.MatrixAdminBo[]>([]);
const [visible, setVisible] = useState(false);
const [form] = Form.useForm();
const [appArr, setAppArr] = useState<API.MatrixApp[]>([]);
const getAppNameById = (appId:number) => {
const app = appArr.find(app => app.id === appId);
return app ? app.name : '';
};
const handleEdit = (record:API.MatrixAdminBo) => {
form.setFieldsValue(record);
setVisible(true);
};
const columns:ColumnsType<API.MatrixAdminBo> = [
{
title: '姓名',
dataIndex: 'name',
},
{
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;
default:
roleText = '';
}
return roleText;
},
},
{
title: '操作',
render: (record:API.MatrixAdminBo) => [
<a key="edit" onClick={() => handleEdit(record)}></a>,
],
},
];
const handleOk = () => {
form.submit();
};
const handleCancel = () => {
setVisible(false);
};
const fetchData = async () => {
const res = await adminList();
if (res.data) {
setData(res.data);
}
};
const fetchApp = async() =>{
const res = await appList();
if (res.data) {
setAppArr(res.data);
}
}
useEffect(() => {
fetchData();
fetchApp();
}, []);
const handleNew = () => {
form.resetFields(); // 重置表单字段
setVisible(true);
};
const handleSaveAdmin = async (values: API.MatrixAdminBo) => {
try{
await saveAdmin(values);
} catch (e) {
return;
}
setVisible(false);
fetchData();
};
return (
<div>
<Button onClick={handleNew}></Button>
<Table columns={columns} dataSource={data} />
<Modal
title="编辑"
visible={visible}
onOk={handleOk}
onCancel={handleCancel}
>
<Form form={form} onFinish={handleSaveAdmin}>
<Form.Item name="id" style={{ display: 'none' }}>
<Input type="hidden" />
</Form.Item>
<Form.Item label="用户名" name="name">
<Input />
</Form.Item>
<Form.Item label="密码" name="password">
<Input.Password />
</Form.Item>
<Form.Item label="应用" name="appIds">
<Select mode="multiple">
{appArr.map(app => (
<Select.Option key={app.id} value={app.id}>
{app.name}
</Select.Option>
))}
</Select>
</Form.Item>
<Form.Item label="角色" name="role">
<Select>
<Select.Option value={2}></Select.Option>
<Select.Option value={3}></Select.Option>
</Select>
</Form.Item>
</Form>
</Modal>
</div>
);
};
export default AdminManagement;

35
src/services/matrix/admin.ts

@ -2,6 +2,14 @@
/* eslint-disable */
import { request } from '@umijs/max';
/** 此处后端没有提供注释 GET /api/admin/adminList */
export async function adminList(options?: { [key: string]: any }) {
return request<API.RListMatrixAdminBo>('/api/admin/adminList', {
method: 'GET',
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/advList */
export async function advList(body: API.AdvRecordQuery, options?: { [key: string]: any }) {
return request<API.RPageResultMatrixAdvRecordBo>('/api/admin/advList', {
@ -30,6 +38,21 @@ export async function current(options?: { [key: string]: any }) {
});
}
/** 此处后端没有提供注释 POST /api/admin/grantApp */
export async function grantApp(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
params: API.grantAppParams,
options?: { [key: string]: any },
) {
return request<API.RVoid>('/api/admin/grantApp', {
method: 'POST',
params: {
...params,
},
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/login */
export async function adminLogin(
// 叠加生成的Param类型 (非body参数swagger默认没有生成对象)
@ -44,3 +67,15 @@ export async function adminLogin(
...(options || {}),
});
}
/** 此处后端没有提供注释 POST /api/admin/saveAdmin */
export async function saveAdmin(body: API.MatrixAdminBo, options?: { [key: string]: any }) {
return request<API.RVoid>('/api/admin/saveAdmin', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}

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

@ -10,6 +10,7 @@ declare namespace API {
advType?: number;
platform?: number;
deviceId?: string;
code?: string;
createdAt?: string[];
};
@ -32,6 +33,11 @@ declare namespace API {
appId?: string;
};
type grantAppParams = {
appIds: string;
adminId: number;
};
type InviteInfo = {
inviteCnt?: number;
list?: InviteUserInfo[];
@ -61,6 +67,17 @@ declare namespace API {
id?: number;
name?: string;
password?: string;
appIds?: string;
role?: number;
channel?: string;
};
type MatrixAdminBo = {
id?: number;
name?: string;
password?: string;
appIds?: number[];
role?: number;
};
type MatrixAdvRecordBo = {
@ -94,7 +111,7 @@ declare namespace API {
name?: string;
code?: string;
url?: string;
ownerId?: number;
income?: number;
};
type PageResultMatrixAdvRecordBo = {
@ -132,6 +149,12 @@ declare namespace API {
data?: InviteInfo;
};
type RListMatrixAdminBo = {
code?: number;
message?: string;
data?: MatrixAdminBo[];
};
type RListMatrixApp = {
code?: number;
message?: string;

Loading…
Cancel
Save