nili
9 months ago
26 changed files with 1302 additions and 1105 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1 @@ |
|||
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[857],{46701:function(O,i,e){e.r(i);var p=e(15009),d=e.n(p),v=e(99289),o=e.n(v),m=e(48357),h=e(90930),E=e(1507),f=e(35312),I=e(67294),c=e(85893),x=function(){var T=(0,I.useRef)(),M=(0,f.useIntl)(),D=function(){var u=o()(d()().mark(function a(){var s,_,r;return d()().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,(0,m.ln)();case 2:return _=n.sent,r=[],(s=_.data)===null||s===void 0||s.forEach(function(t){r.push({label:t.name,value:t.code})}),n.abrupt("return",r);case 6:case"end":return n.stop()}},a)}));return function(){return u.apply(this,arguments)}}(),P=[{title:"\u5E94\u7528\u540D\u79F0",hideInTable:!0,dataIndex:"code",valueType:"select",request:D},{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(a){return a/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"}];return(0,c.jsx)(h._z,{children:(0,c.jsx)(E.Z,{headerTitle:M.formatMessage({id:"pages.searchTable.title",defaultMessage:"Enquiry form"}),actionRef:T,rowKey:"key",search:{labelWidth:120},request:function(){var u=o()(d()().mark(function a(s){var _,r,l;return d()().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,m._5)(s);case 2:return l=t.sent,t.abrupt("return",{data:(_=l.data)===null||_===void 0?void 0:_.data,total:(r=l.data)===null||r===void 0?void 0:r.total,success:!0});case 4:case"end":return t.stop()}},a)}));return function(a){return u.apply(this,arguments)}}(),columns:P})})};i.default=x}}]); |
@ -1 +0,0 @@ |
|||
"use strict";(self.webpackChunkant_design_pro=self.webpackChunkant_design_pro||[]).push([[857],{46701:function(O,i,e){e.r(i);var p=e(15009),d=e.n(p),v=e(99289),o=e.n(v),m=e(48357),h=e(90930),E=e(76104),f=e(35312),I=e(67294),c=e(85893),x=function(){var T=(0,I.useRef)(),M=(0,f.useIntl)(),D=function(){var u=o()(d()().mark(function a(){var s,_,r;return d()().wrap(function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,(0,m.ln)();case 2:return _=n.sent,r=[],(s=_.data)===null||s===void 0||s.forEach(function(t){r.push({label:t.name,value:t.code})}),n.abrupt("return",r);case 6:case"end":return n.stop()}},a)}));return function(){return u.apply(this,arguments)}}(),P=[{title:"\u5E94\u7528\u540D\u79F0",hideInTable:!0,dataIndex:"code",valueType:"select",request:D},{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(a){return a/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"}];return(0,c.jsx)(h._z,{children:(0,c.jsx)(E.Z,{headerTitle:M.formatMessage({id:"pages.searchTable.title",defaultMessage:"Enquiry form"}),actionRef:T,rowKey:"key",search:{labelWidth:120},request:function(){var u=o()(d()().mark(function a(s){var _,r,l;return d()().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,(0,m._5)(s);case 2:return l=t.sent,t.abrupt("return",{data:(_=l.data)===null||_===void 0?void 0:_.data,total:(r=l.data)===null||r===void 0?void 0:r.total,success:!0});case 4:case"end":return t.stop()}},a)}));return function(a){return u.apply(this,arguments)}}(),columns:P})})};i.default=x}}]); |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -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; |
Loading…
Reference in new issue