Browse Source

提交

master
gwbvipvip 10 months ago
parent
commit
f63c332ea3
5 changed files with 361 additions and 0 deletions
  1. +21
    -0
      config/routes.js
  2. +114
    -0
      src/pages/authorization/platformAuthorization/index.jsx
  3. +30
    -0
      src/pages/authorization/platformAuthorization/services.js
  4. +160
    -0
      src/pages/authorization/storeAuthorization/index.jsx
  5. +36
    -0
      src/pages/authorization/storeAuthorization/services.js

+ 21
- 0
config/routes.js View File

@@ -241,6 +241,27 @@ export default [
],
},
{
name: '授权管理',
icon: 'BankFilled',
path: '/authorization',
routes: [
{
name: '平台授权',
icon: 'smile',
path: '/authorization/platformAuthorization',
component: './authorization/platformAuthorization',
access: 'k12',
},
{
name: '店铺授权',
icon: 'smile',
path: '/authorization/storeAuthorization',
component: './authorization/storeAuthorization',
access: 'k12',
}
],
},
{
path: '/',
redirect: '/welcome',


+ 114
- 0
src/pages/authorization/platformAuthorization/index.jsx View File

@@ -0,0 +1,114 @@
import React, { useState, useRef } from 'react';
import { Modal, Button, message, Popconfirm, Typography } from 'antd';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table';
const { Paragraph, Text } = Typography;

import { PageAuthorization, AddAuthorization, UpdateAuthorization } from "./services"
const App = () => {

const actionRef = useRef();
const [ModalVisible, handleModalVisible] = useState(false);
const [currentRow, setCurrentRow] = useState();
const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key'
},
{
title: 'TenantId',
dataIndex: 'groupId',
valueType: 'textarea',
search: false,
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>,
},
{
title: '授权码',
dataIndex: 'key',
valueType: 'textarea',
search: false,
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>,
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 450,
render: (_, record) => [
<Popconfirm
type="primary"
key="primary"
title="确认更新吗?"
okText="是"
cancelText="否"
onConfirm={() => {
UpdateAuthorization(record.id).then((r) => {
if (r.statusCode == 200 && r.data) {
actionRef.current.reload();
message.success("修改成功");
} else {
message.error(r.errors || "修改失败");
}
});
}}
onCancel={() => { }}
>
<a href="#">更新</a>
</Popconfirm>,

],
},
];

return (
<PageContainer host header={{ title: '', breadcrumb: {}, }}>
<ProTable
actionRef={actionRef}
rowKey="id"
pagination={{ defaultPageSize: 10 }}
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button
type="primary"
key="primary"
onClick={() => {
AddAuthorization().then((r) => {
if (r.statusCode == 200 && r.data) {
message.success("添加成功");
actionRef.current.reload();
} else {
message.error(r.errors || "添加失败");
}
});
}} >
<PlusOutlined /> 添加授权码
</Button>,
]}
request={async (params) => {
var data = [];
var total = 0;
await PageAuthorization(params).then((r) => {
total = r.data.total;
data = r.data.data;
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
/>

</PageContainer>
);
};

export default App;

+ 30
- 0
src/pages/authorization/platformAuthorization/services.js View File

@@ -0,0 +1,30 @@
import { request } from 'umi';
import { getDataBaseUrl,GetkitchbaseUrl } from '@/global_data';


/** 获取平台授权码 */
export async function PageAuthorization(data) {
return request(getDataBaseUrl()+`/api/authorization/pageauthorization`, {
method: 'POST',
data: data,
});
}

/** 添加平台授权码 */
export async function AddAuthorization(data) {
return request(getDataBaseUrl()+`/api/authorization/addauthorization`, {
method: 'POST',
data: data,
});
}

/** 修改平台授权码 */
export async function UpdateAuthorization(data) {
return request(getDataBaseUrl()+`/api/authorization/updateauthorization?id=`+data, {
method: 'POST',
data: data,
});
}




+ 160
- 0
src/pages/authorization/storeAuthorization/index.jsx View File

@@ -0,0 +1,160 @@
import React, { useState, useRef, useEffect } from 'react';
import { Modal, Button, message, Popconfirm, Typography, Select } from 'antd';
import { PageContainer, FooterToolbar } from '@ant-design/pro-layout';
import { PlusOutlined } from '@ant-design/icons';
import ProTable from '@ant-design/pro-table';
import { QuestionCircleOutlined } from '@ant-design/icons';
const { Paragraph, Text } = Typography;

import { PageStoreAuthorization, AddStoreAuthorization, UpdateStoreAuthorization, GetStoreList } from "./services"
const App = () => {

const actionRef = useRef();
const [ModalVisible, handleModalVisible] = useState(false);
const [currentRow, setCurrentRow] = useState();
const [storeList, setStoreList] = useState([]);

//初始化数据
useEffect(() => {
function initData() {
GetStoreList({ "current": 1, "pageSize": 9999 }).then((r) => {
let data = [];
if (r.statusCode == 200) {
r.data.data.forEach((item) => {
data.push({
id: item.id,
label: item.name,
value: item.id,
});
});
setStoreList(data);
}
});
}
initData();
}, []);



const columns = [
{
title: '主键',
dataIndex: 'id',
hideInSearch: true,
hideInTable: true,
tip: '规则名称是唯一的 key'
},
{
title: '授权码',
dataIndex: 'key',
valueType: 'textarea',
search: false,
render: (text) => <Paragraph style={{ display: 'inline' }} copyable>{text}</Paragraph>,
},
{
title: '店铺',
dataIndex: 'storeName',
valueType: 'textarea',
search: false,
},
{
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 450,
render: (_, record) => [
<Popconfirm
type="primary"
key="primary"
title="确认更新吗?"
okText="是"
cancelText="否"
onConfirm={async () => {
await UpdateStoreAuthorization(record.id).then((r) => {
if (r.statusCode == 200 && r.data) {
message.success("修改成功");
actionRef.current.reload();

} else {
message.error(r.errors || "修改失败");
}
});
}}
onCancel={() => { }}
>
<a href="#">更新</a>
</Popconfirm>,

],
},
];

return (
<PageContainer host header={{ title: '', breadcrumb: {}, }}>
<ProTable
actionRef={actionRef}
rowKey="id"
pagination={{ defaultPageSize: 10 }}
search={{
labelWidth: 120,
}}
toolBarRender={() => [
<Button type="primary" key="primary" onClick={() => {
handleModalVisible(true);
}} >
添加授权码
</Button>
]}
request={async (params) => {
var data = [];
var total = 0;
await PageStoreAuthorization(params).then((r) => {
total = r.data.total;
data = r.data.data;
});
return {
data: data,
success: true,
total: total,
};
}}
columns={columns}
/>

<Modal title="添加授权" open={ModalVisible}
onOk={() => {
if (!currentRow) {
message.error("请选择店铺");
return;
}
AddStoreAuthorization(currentRow).then((r) => {
if (r.statusCode == 200 && r.data) {
message.success("添加成功");
actionRef.current.reload();
handleModalVisible(false);
} else {
message.error(r.errors || "添加失败");
}
});

}}
onCancel={() => {
handleModalVisible(false);
}}>
<Select
style={{
width: 470,
}}
onChange={(value) => {
setCurrentRow(value);
}}
options={storeList}
/>
</Modal>

</PageContainer>
);
};

export default App;

+ 36
- 0
src/pages/authorization/storeAuthorization/services.js View File

@@ -0,0 +1,36 @@
import { request } from 'umi';
import { getDataBaseUrl,GetkitchbaseUrl } from '@/global_data';


/** 获取平台授权码 */
export async function PageStoreAuthorization(data) {
return request(GetkitchbaseUrl()+`/api/authorization/pagestoreauthorization`, {
method: 'POST',
data: data,
});
}

/** 添加平台授权码 */
export async function AddStoreAuthorization(data) {
return request(GetkitchbaseUrl()+`/api/authorization/addstoreauthorization?storeId=`+data, {
method: 'POST',
data: data,
});
}

/** 修改平台授权码 */
export async function UpdateStoreAuthorization(data) {
return request(GetkitchbaseUrl()+`/api/authorization/updatestoreauthorization?id=`+data, {
method: 'POST',
data: data,
});
}


/** 获取店铺列表 */
export async function GetStoreList(data) {
return request(GetkitchbaseUrl()+`/api/store/page`, {
method: 'POST',
data: data,
});
}

Loading…
Cancel
Save