diff --git a/config/proxy.ts b/config/proxy.ts
index e313afd..2fb5081 100644
--- a/config/proxy.ts
+++ b/config/proxy.ts
@@ -11,8 +11,9 @@ export default {
// localhost:8000/api/** -> https://preview.pro.ant.design/api/**
'/tbg/api/v1': {
// 要代理的地址
- // target: 'http://81.71.13.173:9080',
- target: 'http://127.0.0.1:9999',
+ target: 'http://81.71.13.173:9080',
+ // target: 'http://192.168.88.238:9999',
+ // target: 'http://127.0.0.1:9999',
// 配置了这个可以从 http 代理到 https
// 依赖 origin 的功能可能需要这个,比如 cookie
changeOrigin: true,
diff --git a/src/app.tsx b/src/app.tsx
index f0d6e93..8cb205d 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -4,18 +4,15 @@ import { history } from 'umi';
import RightContent from '@/components/RightContent';
import RoutePath from '@/routes/routePath';
import { CACHE_TOKEN } from '@/constants/cacheKey';
-import { getRoleList } from './services/system/role';
+import { getAccounPermission } from './services/system/accountManage';
// ProLayout 支持的api https://procomponents.ant.design/components/layout
export async function getInitialState() {
if (localStorage.getItem(CACHE_TOKEN)) {
- const res = await getRoleList({});
- // return {
- // routeList: res,
- // };
+ const res = await getAccounPermission({});
return {
- routeList: [],
+ routeList: res,
};
}
}
diff --git a/src/pages/Nft/NftContract/List/index.tsx b/src/pages/Nft/NftContract/List/index.tsx
index db26c55..ae79545 100644
--- a/src/pages/Nft/NftContract/List/index.tsx
+++ b/src/pages/Nft/NftContract/List/index.tsx
@@ -64,6 +64,9 @@ const Address: React.FC = () => {
]}
request={async (params) => {
const res = await fetchTableData(getNFTContractList, params);
+ if (res.data == null) {
+ return [];
+ }
return res;
}}
/>
@@ -84,7 +87,6 @@ const Address: React.FC = () => {
message.success('添加成功');
setVisible(false);
} catch (e) {
- console.log(e);
message.success('发生错误');
setVisible(false);
}
diff --git a/src/pages/Nft/NftToken/List/components/AddNftModel.tsx b/src/pages/Nft/NftToken/List/components/AddNftModel.tsx
index 444368d..5c71ffc 100644
--- a/src/pages/Nft/NftToken/List/components/AddNftModel.tsx
+++ b/src/pages/Nft/NftToken/List/components/AddNftModel.tsx
@@ -2,7 +2,6 @@ import React, { useRef, useState } from 'react';
import { createForm } from '@formily/core';
import { createSchemaField } from '@formily/react';
import Modal, { ModalProps } from '@/components/Modal';
-// import { fetchTableData } from '@/utils/table';
import { Form, FormItem, Input, NumberPicker } from '@formily/antd';
import { Button } from 'antd';
import { initWeb3, NFTMint } from '@/utils/web3';
@@ -13,7 +12,6 @@ import { ContractType } from '@/constants/enum/contract';
interface AddNftModalPropsType extends ModalProps {
onOk: () => void;
onCancel: () => void;
- // loading: boolean;
}
const SchemaField = createSchemaField({
@@ -42,7 +40,6 @@ const AddNftModal = ({ onOk, onCancel, ...rest }: AddNftModalPropsType) => {
toAddress: formState.values.toAddress,
name: formState.values.name,
});
- console.log('tx_hash = ', tx_hash);
formState.values.tx_hash = tx_hash;
await mintNFT(formState.values);
setLoading(false);
diff --git a/src/pages/Nft/NftToken/List/index.tsx b/src/pages/Nft/NftToken/List/index.tsx
index 3678e0a..258fcd5 100644
--- a/src/pages/Nft/NftToken/List/index.tsx
+++ b/src/pages/Nft/NftToken/List/index.tsx
@@ -43,7 +43,7 @@ const Address: React.FC = () => {
{
rowKey="id"
actionRef={tableRef}
request={async (params) => {
- console.log('params = ', params);
if ((params.time ?? '') !== '') {
const start = Date.parse(params.time[0] + ' 00:00:00');
const end = Date.parse(params.time[1] + ' 23:59:59');
diff --git a/src/pages/Recharge/CoinType/List/index.tsx b/src/pages/Recharge/CoinType/List/index.tsx
index 625b07f..f9836b9 100644
--- a/src/pages/Recharge/CoinType/List/index.tsx
+++ b/src/pages/Recharge/CoinType/List/index.tsx
@@ -66,7 +66,7 @@ const CoinTypeList = () => {
{
return (
{
if ((params.searchTime ?? '') !== '') {
diff --git a/src/pages/Recharge/Wallet/List/index.tsx b/src/pages/Recharge/Wallet/List/index.tsx
index 57ac079..effcefe 100644
--- a/src/pages/Recharge/Wallet/List/index.tsx
+++ b/src/pages/Recharge/Wallet/List/index.tsx
@@ -69,7 +69,7 @@ const CollectionAddressList = () => {
{
const [coinTypeData, setCoinTypeData] = useState({});
-
const getSelectData = async () => {
const list = await getCoinTypeList({ page: 1, size: 10 });
setCoinTypeData(list);
};
- const useAsyncDataSource = (
+ const UseAsyncDataSource = (
pattern: FormPathPattern,
service: (field: Field) => Promise<{ label: string; value: any }[]>,
) => {
@@ -43,8 +42,7 @@ const AddWalletModal = ({ onOk, onCancel, ...rest }: AddWalletModalPropsType) =>
const form = createForm({
effects: () => {
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useAsyncDataSource('name', async (field) => {
+ UseAsyncDataSource('name', async (field) => {
const list = coinTypeData;
const option = [];
for (let index = 0; index < list.items.length; index++) {
diff --git a/src/pages/Recharge/Wallet/components/EditWalletModal.tsx b/src/pages/Recharge/Wallet/components/EditWalletModal.tsx
index 199916e..1371370 100644
--- a/src/pages/Recharge/Wallet/components/EditWalletModal.tsx
+++ b/src/pages/Recharge/Wallet/components/EditWalletModal.tsx
@@ -22,14 +22,7 @@ const SchemaField = createSchemaField({
});
const EditWalletModal = ({ onOk, onCancel, editModalData, ...rest }: EditWalletModalPropsType) => {
- const [coinTypeData, setCoinTypeData] = useState({});
-
- const getSelectData = async () => {
- const list = await getCoinTypeList({ page: 1, size: 10 });
- setCoinTypeData(list);
- };
-
- const useAsyncDataSource = (
+ const UseAsyncDataSource = (
pattern: FormPathPattern,
service: (field: Field) => Promise<{ label: string; value: any }[]>,
) => {
@@ -44,10 +37,8 @@ const EditWalletModal = ({ onOk, onCancel, editModalData, ...rest }: EditWalletM
const form = createForm({
effects: () => {
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useAsyncDataSource('name', async (field) => {
- getSelectData();
- const list = coinTypeData;
+ UseAsyncDataSource('name', async (field) => {
+ const list = await getCoinTypeList({ page: 1, size: 10 });
const option = [];
for (let index = 0; index < list.items.length; index++) {
const element = list.items[index];
diff --git a/src/pages/Recharge/Withdraw/List/index.tsx b/src/pages/Recharge/Withdraw/List/index.tsx
index 4c1077f..81f393d 100644
--- a/src/pages/Recharge/Withdraw/List/index.tsx
+++ b/src/pages/Recharge/Withdraw/List/index.tsx
@@ -107,7 +107,7 @@ const WithdrawList = () => {
{
const res = await fetchTableData(getWithdrawList, params);
diff --git a/src/pages/System/Account/List/index.tsx b/src/pages/System/Account/List/index.tsx
index 6cacf5d..4c70992 100644
--- a/src/pages/System/Account/List/index.tsx
+++ b/src/pages/System/Account/List/index.tsx
@@ -11,6 +11,7 @@ import DeleteButton from '@/components/Table/DeleteButton';
import { Popover, Switch } from 'antd';
import AddAccountModal from '../components/AddAccountModal';
import EditAccountModal from '../components/EditAccountModal';
+import { getRoleList } from '@/services/system/role';
const AccountManageList = () => {
const [isModalVisible, setIsModalVisible] = useState(false);
@@ -37,7 +38,15 @@ const AccountManageList = () => {
title: '角色',
dataIndex: 'role',
hideInSearch: true,
- ellipsis: true,
+ valueType: 'select',
+ request: async () => {
+ const res = await getRoleList({ page: 1, size: 10 });
+ const options = new Array();
+ res.items.forEach((element) => {
+ options.push({ label: element.role_name, value: element.id });
+ });
+ return options;
+ },
},
{
title: '操作',
diff --git a/src/pages/System/Account/components/AddAccountModal.tsx b/src/pages/System/Account/components/AddAccountModal.tsx
index c2a495b..378f5c0 100644
--- a/src/pages/System/Account/components/AddAccountModal.tsx
+++ b/src/pages/System/Account/components/AddAccountModal.tsx
@@ -24,7 +24,7 @@ const SchemaField = createSchemaField({
const AddAccountModal = ({ onOk, onCancel, ...rest }: AddAccountModalPropsType) => {
const [roleListData, setRoleListData] = useState({});
- const useAsyncDataSource = (
+ const UseAsyncDataSource = (
pattern: FormPathPattern,
service: (field: Field) => Promise<{ label: string; value: any }[]>,
) => {
@@ -39,8 +39,7 @@ const AddAccountModal = ({ onOk, onCancel, ...rest }: AddAccountModalPropsType)
const form = createForm({
effects: () => {
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useAsyncDataSource('role', async (field) => {
+ UseAsyncDataSource('role', async (field) => {
const list = roleListData;
const option = [];
for (let index = 0; index < list.items.length; index++) {
@@ -69,7 +68,6 @@ const AddAccountModal = ({ onOk, onCancel, ...rest }: AddAccountModalPropsType)
form.submit(async () => {
onOk();
const formState = form.getFormState();
- formState.values.role = parseInt(formState.values.role);
await addUser(formState.values);
});
};
@@ -112,6 +110,7 @@ const AddAccountModal = ({ onOk, onCancel, ...rest }: AddAccountModalPropsType)
x-decorator="FormItem"
x-component="Select"
x-component-props={{
+ mode: 'multiple',
placeholder: '请选择角色',
}}
/>
diff --git a/src/pages/System/Account/components/EditAccountModal.tsx b/src/pages/System/Account/components/EditAccountModal.tsx
index e22225e..36d3379 100644
--- a/src/pages/System/Account/components/EditAccountModal.tsx
+++ b/src/pages/System/Account/components/EditAccountModal.tsx
@@ -28,14 +28,14 @@ const EditAccountModal = ({
editModalData,
...rest
}: EditAccountModalPropsType) => {
- const [roleListData, setRoleListData] = useState({});
+ // const [roleListData, setRoleListData] = useState({});
- const getSelectData = async () => {
- const list = await getRoleList({ page: 1, size: 10 });
- setRoleListData(list);
- };
+ // const getSelectData = async () => {
+ // const list =
+ // setRoleListData(list);
+ // };
- const useAsyncDataSource = (
+ const UseAsyncDataSource = (
pattern: FormPathPattern,
service: (field: Field) => Promise<{ label: string; value: any }[]>,
) => {
@@ -50,10 +50,8 @@ const EditAccountModal = ({
const form = createForm({
effects: () => {
- // eslint-disable-next-line react-hooks/rules-of-hooks
- useAsyncDataSource('role', async (field) => {
- getSelectData();
- const list = roleListData;
+ UseAsyncDataSource('role', async (field) => {
+ const list = await getRoleList({ page: 1, size: 10 });
const option = [];
for (let index = 0; index < list.items.length; index++) {
const element = list.items[index];
@@ -76,7 +74,6 @@ const EditAccountModal = ({
form.submit(async () => {
onOk();
const formState = form.getFormState();
- formState.values.role = parseInt(formState.values.role);
await updateUser(formState.values);
});
};
diff --git a/src/pages/System/Notice/List/index.tsx b/src/pages/System/Notice/List/index.tsx
index db3f855..decd712 100644
--- a/src/pages/System/Notice/List/index.tsx
+++ b/src/pages/System/Notice/List/index.tsx
@@ -3,7 +3,7 @@ import Table, { ProColumns, ActionType } from '@/components/Table';
import { getNoticeList, createNotice, updateNotice, deleteNotice } from '@/services/system/notice';
import { fetchTableData } from '@/utils/table';
import DeleteButton from '@/components/Table/DeleteButton';
-import { Switch } from 'antd';
+import { Popover, Switch } from 'antd';
import AddNoticeModal from '../components/AddNoticeModal';
import EditNoticeModal from '../components/EditNoticeModal';
import { NoticeType } from '@/constants/enum/notice';
@@ -80,15 +80,25 @@ const NoticeList = () => {
>
编辑
,
- {
- row.status = checked;
- await updateNotice(row);
- }}
- />,
+
+ 通知启用/禁用
+
+ }
+ >
+ {
+ row.status = checked;
+ await updateNotice(row);
+ }}
+ />
+ ,
+ ,
+
{
@@ -102,7 +112,7 @@ const NoticeList = () => {
{
const [isModalVisible, setIsModalVisible] = useState(false);
@@ -27,15 +28,20 @@ const PermissionsList = () => {
};
const deleteLoopChildren = (rowData, children) => {
- debugger;
for (let index = 0; index < children.length; index++) {
const childrenElement = children[index];
if (rowData.name == childrenElement.name) {
+ if (children.length == 1) {
+ return 1;
+ }
children.splice(index, 1);
return true;
} else {
if (Object.prototype.hasOwnProperty.call(childrenElement, 'children')) {
- deleteLoopChildren(rowData, childrenElement.children);
+ const childrenLength = deleteLoopChildren(rowData, childrenElement.children);
+ if (childrenLength == 1) {
+ delete childrenElement.children;
+ }
} else {
continue;
}
@@ -174,7 +180,7 @@ const PermissionsList = () => {
if (!result) {
rowData.children.push(val);
} else {
- console.log('已有改权限名');
+ message.warning('已有改权限名');
}
} else {
rowData.children = [val];
diff --git a/src/pages/System/Role/List/index.tsx b/src/pages/System/Role/List/index.tsx
index 05d18f2..d092688 100644
--- a/src/pages/System/Role/List/index.tsx
+++ b/src/pages/System/Role/List/index.tsx
@@ -14,12 +14,14 @@ const RoleList = () => {
const [isModalVisible, setIsModalVisible] = useState(false);
const [isEditModal, setIsEditModal] = useState(false);
const [modalData, setModalData] = useState({});
+ const [rowData, setRowData] = useState({});
const handleEdit = (row: any) => {
setModalData(row);
setIsEditModal(true);
};
const handleAuth = (row: any) => {
+ setRowData(row);
setIsDrawerVisible(true);
};
const handleDelete = async (id: any) => {
@@ -116,11 +118,13 @@ const RoleList = () => {
/>
diff --git a/src/pages/System/Role/components/AuthPermissionsDrawer.tsx b/src/pages/System/Role/components/AuthPermissionsDrawer.tsx
index bf21b95..8a49ffa 100644
--- a/src/pages/System/Role/components/AuthPermissionsDrawer.tsx
+++ b/src/pages/System/Role/components/AuthPermissionsDrawer.tsx
@@ -1,17 +1,15 @@
// 创建弹窗
-import React, { useRef, useState } from 'react';
-
-import { Form, FormItem, Input } from '@formily/antd';
+import React, { useEffect, useRef, useState } from 'react';
import { Button, Drawer, DrawerProps, message, Space } from 'antd';
import { ActionType, ProColumns } from '@ant-design/pro-table';
import Table from '@/components/Table';
import { TableRowSelection } from 'antd/lib/table/interface';
-import routes from '@/routes';
import { getPermission } from '@/services/system/permission';
interface AuthPermissionsDrawerPropsType extends DrawerProps {
onCancel: () => void;
onOk: (val: any) => void;
+ rowData: any;
}
const columnsPermissions: ProColumns[] = [
@@ -22,9 +20,8 @@ const columnsPermissions: ProColumns[] = [
];
const valueMap = {};
-function loops(list, parent) {
+const loops = (list, parent) => {
return (list || []).map(({ children, name }) => {
- // console.log('children = ', children);
const node = (valueMap[name] = {
parent,
name,
@@ -32,9 +29,9 @@ function loops(list, parent) {
node.children = loops(children, node);
return node;
});
-}
+};
-function getPath(name) {
+const getPath = (name) => {
const path = [];
let current = valueMap[name];
while (current) {
@@ -42,39 +39,75 @@ function getPath(name) {
current = current.parent;
}
return path;
-}
+};
-const AuthPermissionsDrawer = ({ onOk, onCancel, ...rest }: AuthPermissionsDrawerPropsType) => {
+const mergeArray = (arr1, arr2) => {
+ const _arr = new Array();
+ for (let i = 0; i < arr1.length; i++) {
+ _arr.push(arr1[i]);
+ }
+ for (let i = 0; i < arr2.length; i++) {
+ let flag = true;
+ for (let j = 0; j < arr1.length; j++) {
+ if (arr2[i] == arr1[j]) {
+ flag = false;
+ break;
+ }
+ }
+ if (flag) {
+ _arr.push(arr2[i]);
+ }
+ }
+ return _arr;
+};
+
+const AuthPermissionsDrawer = ({
+ onOk,
+ onCancel,
+ rowData,
+ ...rest
+}: AuthPermissionsDrawerPropsType) => {
const tableRef = useRef();
- const [selectedKeys, setSelectedKeys] = useState(['']);
- const [postSelectedKeys, setPostSelectedKeys] = useState([]);
+ const [selectedKeys, setSelectedKeys] = useState(new Array());
const rowSelection: TableRowSelection = {
onChange: (selectedRowKeys, selectedRows) => {
setSelectedKeys(selectedRowKeys);
- console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
},
- onSelect: (record, selected, selectedRows) => {
- const path = getPath(record.name);
- const newArray = selectedKeys.concat(path);
- setPostSelectedKeys(newArray);
- },
- // onSelectAll: (selected, selectedRows, changeRows) => {
- // console.log(selected, selectedRows, changeRows);
- // },
};
const handleOk = () => {
+ let postSelectedKeys = new Array();
+ selectedKeys.forEach((element) => {
+ const path = getPath(element);
+ postSelectedKeys = mergeArray(postSelectedKeys, path);
+ });
if (postSelectedKeys.length == 0) {
message.warning('请选择权限。');
return;
}
- onOk(postSelectedKeys);
+ onOk({ id: rowData.id, permission: postSelectedKeys });
};
const handleCancel = () => {
onCancel();
};
+ useEffect(() => {
+ const parentArray = new Array();
+ let newPermission = new Array();
+ for (const key in valueMap) {
+ if (Object.prototype.hasOwnProperty.call(valueMap, key)) {
+ const element = valueMap[key];
+ if (element.children.length != 0) {
+ parentArray.push(element.name);
+ }
+ }
+ }
+ if (rowData.permission != undefined && rowData.permission != [] && rowData.permission != null) {
+ newPermission = rowData.permission.filter((item) => !parentArray.includes(item));
+ }
+ setSelectedKeys(newPermission);
+ }, [rowData.permission]);
return (
{
return (
{
const res = await fetchTableData(getUserList, params);
+ if (res.data == null) {
+ return [];
+ }
return res;
}}
/>
diff --git a/src/services/system/accountManage.ts b/src/services/system/accountManage.ts
index 32b7644..b2840a9 100644
--- a/src/services/system/accountManage.ts
+++ b/src/services/system/accountManage.ts
@@ -73,3 +73,16 @@ export const deleteUser = (data) => {
data,
});
};
+
+/**
+ * 获取后台用户权限
+ * @param {object} params
+ * @returns {array} data
+ */
+export const getAccounPermission = (params) => {
+ return request.request({
+ url: '/user/role/get',
+ method: 'get',
+ params,
+ });
+};
diff --git a/src/utils/web3.ts b/src/utils/web3.ts
index e9b61a8..11ba76a 100644
--- a/src/utils/web3.ts
+++ b/src/utils/web3.ts
@@ -14,7 +14,7 @@ export async function initWeb3() {
provider = await detectEthereumProvider();
if (!provider) {
- console.log('请安装MetaMask');
+ message.warning('请安装MetaMask');
return false;
}