Skip to content

Commit

Permalink
Merge pull request #152 from suyuan32/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
suyuan32 authored Dec 20, 2023
2 parents 3777f32 + 50c2f4b commit 527ef18
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-admin",
"version": "1.2.5",
"version": "1.2.8",
"homepage": "https://github.com/suyuan32/simple-admin-backend-ui",
"bugs": {
"url": "https://github.com/suyuan32/simple-admin-backend-ui/issues"
Expand Down
5 changes: 3 additions & 2 deletions src/api/sys/model/apiModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export interface ApiInfo {
id?: number;
createdAt?: number;
updatedAt?: number;
trans: string;
trans?: string;
path: string;
description: string;
description?: string;
group: string;
method: string;
isRequired: boolean;
serviceName: string;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/en/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default {
description: 'Description',
method: 'Method',
group: 'Group',
serviceName: 'Service Name',
// action
addApi: 'Add API',
editApi: 'Edit API',
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/zh-CN/sys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export default {
description: '描述',
method: '方法',
group: '分组',
serviceName: '所属服务',
// action
addApi: '添加接口',
editApi: '编辑接口',
Expand Down
2 changes: 1 addition & 1 deletion src/views/dashboard/workbench/components/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ export const navItems: NavItem[] = [

export const systemInfoData = [
['sys.sys.Name', 'Simple Admin'],
['sys.sys.version', 'V 1.2.5'],
['sys.sys.version', 'V 1.2.8'],
];
18 changes: 18 additions & 0 deletions src/views/sys/api/api.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const columns: BasicColumn[] = [
dataIndex: 'group',
width: 20,
},
{
title: t('sys.apis.serviceName'),
dataIndex: 'serviceName',
width: 20,
},
{
title: t('sys.apis.description'),
dataIndex: 'trans',
Expand Down Expand Up @@ -65,6 +70,13 @@ export const searchFormSchema: FormSchema[] = [
colProps: { span: 8 },
rules: [{ max: 200 }],
},
{
field: 'serviceName',
label: t('sys.apis.serviceName'),
component: 'Input',
colProps: { span: 8 },
rules: [{ max: 20 }],
},
{
field: 'group',
label: t('sys.apis.group'),
Expand Down Expand Up @@ -110,6 +122,12 @@ export const formSchema: FormSchema[] = [
component: 'Input',
rules: [{ max: 200 }],
},
{
field: 'serviceName',
label: t('sys.apis.serviceName'),
component: 'Input',
rules: [{ max: 20 }],
},
{
field: 'group',
label: t('sys.apis.group'),
Expand Down
5 changes: 5 additions & 0 deletions src/views/sys/dictionary/dictionary.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export const columns: BasicColumn[] = [
dataIndex: 'trans',
width: 100,
},
{
title: t('sys.dictionary.name'),
dataIndex: 'name',
width: 100
},
{
title: t('common.status'),
dataIndex: 'status',
Expand Down
31 changes: 26 additions & 5 deletions src/views/sys/role/role.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ApiInfo } from '/@/api/sys/model/apiModel';
import { ApiAuthorityInfo } from '/@/api/sys/model/authorityModel';
import { formatToDateTime } from '/@/utils/dateUtil';
import { updateRole } from '/@/api/sys/role';
import { union } from 'lodash-es';
import { cloneDeep, union } from 'lodash-es';

const { t } = useI18n();

Expand Down Expand Up @@ -132,14 +132,17 @@ export const formSchema: FormSchema[] = [
*/

export function convertApiTreeData(params: ApiInfo[]): DataNode[] {
const finalData: DataNode[] = []
const apiData: DataNode[] = [];
if (params.length === 0) {
return apiData;
}

const apiMap = new Map<string, boolean>();
const apiMap = new Map<string, string>();
const serviceMap = new Map<string, boolean>();
for (let i = 0; i < params.length; i++) {
apiMap.set(params[i].group, true);
apiMap.set(params[i].group, params[i].serviceName);
serviceMap.set(params[i].serviceName, true);
}

for (const k of apiMap.keys()) {
Expand All @@ -152,7 +155,7 @@ export function convertApiTreeData(params: ApiInfo[]): DataNode[] {
for (let i = 0; i < params.length; i++) {
if (params[i].group == k) {
apiTmp.children?.push({
title: t(params[i].trans),
title: params[i].trans,
key: params[i].id as number,
disableCheckbox: params[i].isRequired,
});
Expand All @@ -161,7 +164,24 @@ export function convertApiTreeData(params: ApiInfo[]): DataNode[] {

apiData.push(apiTmp);
}
return apiData;

for (const k1 of serviceMap.keys()) {
const svcTmp: DataNode = {
title: k1,
key: k1,
children: [],
};

for (let i = 0; i < apiData.length; i++) {
if (apiMap.get(apiData[i].title) === k1) {
svcTmp.children?.push(cloneDeep(apiData[i]));
}
}

finalData.push(svcTmp);
}

return finalData;
}

/**
Expand All @@ -176,6 +196,7 @@ export function convertApiCheckedKeysToReq(checked: number[], data: ApiInfo[]):
pureDigit.push(checked[i]);
}
}

// sort data
data.sort(function (a, b) {
if (a.id !== undefined && b.id !== undefined) return a.id - b.id;
Expand Down

0 comments on commit 527ef18

Please sign in to comment.