From 121fcce44cafe476ab9c19b11f98142bf847a6fe Mon Sep 17 00:00:00 2001 From: Taric Xin Date: Thu, 20 Jan 2022 17:27:41 +0800 Subject: [PATCH] edit --- .../driver-account.component.html | 3 +- .../driver-account.component.ts | 6 +- .../freight-account.component.html | 3 +- .../freight-account.component.ts | 5 + .../recharge-record.component.ts | 2 +- .../withdrawals-record.component.ts | 2 +- .../api-auth/api-auth.component.html | 75 ++++++ .../api-auth/api-auth.component.less | 17 ++ .../components/api-auth/api-auth.component.ts | 80 +++++++ .../auth-drawer/auth-drawer.component.html | 37 +++ .../auth-drawer/auth-drawer.component.less | 0 .../auth-drawer/auth-drawer.component.ts | 134 +++++++++++ .../components/index/index.component.html | 51 +++-- .../components/index/index.component.ts | 215 ++++-------------- .../menu-modal/menu-modal.component.html | 9 + .../menu-modal/menu-modal.component.less | 0 .../index/menu-modal/menu-modal.component.ts | 148 ++++++++++++ .../menu-manager-routing.module.ts | 2 + .../menu-manager/menu-manager.module.ts | 7 +- .../services/menu-manager.service.ts | 134 ++++++++++- .../cancellation-invoice.component.html | 8 - src/assets/mocks/menu-data.json | 4 + 22 files changed, 727 insertions(+), 215 deletions(-) create mode 100644 src/app/routes/menu-manager/components/api-auth/api-auth.component.html create mode 100644 src/app/routes/menu-manager/components/api-auth/api-auth.component.less create mode 100644 src/app/routes/menu-manager/components/api-auth/api-auth.component.ts create mode 100644 src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.html create mode 100644 src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.less create mode 100644 src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.ts create mode 100644 src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.html create mode 100644 src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.less create mode 100644 src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.ts diff --git a/src/app/routes/financial-management/components/driver-account/driver-account.component.html b/src/app/routes/financial-management/components/driver-account/driver-account.component.html index 4ef9a36f..fdbfa5ae 100644 --- a/src/app/routes/financial-management/components/driver-account/driver-account.component.html +++ b/src/app/routes/financial-management/components/driver-account/driver-account.component.html @@ -28,7 +28,8 @@ [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }" [loading]="service.http.loading" [scroll]="{ y: '370px' }"> - {{ item.availableBalance | currency}} + {{ (parseFloat(item.availableBalance) + + parseFloat(item.freezeBalance)).toFixed(2) | currency}} \ No newline at end of file diff --git a/src/app/routes/financial-management/components/driver-account/driver-account.component.ts b/src/app/routes/financial-management/components/driver-account/driver-account.component.ts index fa7578b8..4b4c24b8 100644 --- a/src/app/routes/financial-management/components/driver-account/driver-account.component.ts +++ b/src/app/routes/financial-management/components/driver-account/driver-account.component.ts @@ -187,7 +187,7 @@ export class DriverAccountComponent implements OnInit { className: 'text-right', widget: { type: 'currency-chy', params: ({ record }) => ({ value: record.withdrawBalance }) } }, - { title: '账户总余额', render: 'availableBalance', className: 'text-right' }, + { title: '账户总余额', render: 'availableBalance', className: 'text-right', width: 180 }, { title: '创建时间', index: 'createTime', type: 'date', width: 150 }, { title: '操作', @@ -213,4 +213,8 @@ export class DriverAccountComponent implements OnInit { } ]; } + + parseFloat(num: any) { + return parseFloat(num); + } } diff --git a/src/app/routes/financial-management/components/freight-account/freight-account.component.html b/src/app/routes/financial-management/components/freight-account/freight-account.component.html index 1128560a..e82629cf 100644 --- a/src/app/routes/financial-management/components/freight-account/freight-account.component.html +++ b/src/app/routes/financial-management/components/freight-account/freight-account.component.html @@ -28,7 +28,8 @@ [page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }" [loading]="service.http.loading" [scroll]="{ y: '370px' }"> - {{ item.availableBalance | currency}} + {{ (parseFloat(item.availableBalance) + + parseFloat(item.freezeBalance)).toFixed(2) | currency}} \ No newline at end of file diff --git a/src/app/routes/financial-management/components/freight-account/freight-account.component.ts b/src/app/routes/financial-management/components/freight-account/freight-account.component.ts index 3b5dfaf9..0a3f4c01 100644 --- a/src/app/routes/financial-management/components/freight-account/freight-account.component.ts +++ b/src/app/routes/financial-management/components/freight-account/freight-account.component.ts @@ -7,6 +7,7 @@ import { CurrencyService } from '@delon/util'; import { CurrencyCNYPipe } from '@delon/util/pipes/currency/cny.pipe'; import { ShipperBaseService } from '@shared'; import { NzModalService } from 'ng-zorro-antd/modal'; +import { parse } from 'path'; import { SystemService } from 'src/app/routes/sys-setting/services/system.service'; import { AccountDetailComponent } from 'src/app/shared/components/account-detail/account-detail.component'; import { FreightAccountService } from '../../services/freight-account.service'; @@ -215,4 +216,8 @@ export class FreightAccountComponent implements OnInit { } ]; } + + parseFloat(num: any) { + return parseFloat(num); + } } diff --git a/src/app/routes/financial-management/components/recharge-record/recharge-record.component.ts b/src/app/routes/financial-management/components/recharge-record/recharge-record.component.ts index 83169344..dc4c59f5 100644 --- a/src/app/routes/financial-management/components/recharge-record/recharge-record.component.ts +++ b/src/app/routes/financial-management/components/recharge-record/recharge-record.component.ts @@ -181,7 +181,7 @@ export class RechargeRecordComponent implements OnInit { this.service.getReceiptUrl(item.receiptUrl, { bankType: item.bankType, rmYll: item.roleId, - snglFlgCd: item.paySerialNumber, + snglFlgCd: item.paySerialNumber2, bussType: '06' }) } diff --git a/src/app/routes/financial-management/components/withdrawals-record/withdrawals-record.component.ts b/src/app/routes/financial-management/components/withdrawals-record/withdrawals-record.component.ts index 097c8d55..0a0325fd 100644 --- a/src/app/routes/financial-management/components/withdrawals-record/withdrawals-record.component.ts +++ b/src/app/routes/financial-management/components/withdrawals-record/withdrawals-record.component.ts @@ -272,7 +272,7 @@ export class WithdrawalsRecordComponent implements OnInit { this.service.getReceiptUrl(item.receiptUrl, { bankType: item.bankType, rmYll: item.userId, - snglFlgCd: item.bankSerialNumber, + snglFlgCd: item.coreSerNo, bussType: '06' }) }, diff --git a/src/app/routes/menu-manager/components/api-auth/api-auth.component.html b/src/app/routes/menu-manager/components/api-auth/api-auth.component.html new file mode 100644 index 00000000..4af86ae4 --- /dev/null +++ b/src/app/routes/menu-manager/components/api-auth/api-auth.component.html @@ -0,0 +1,75 @@ + + + +
+
+ +
+
+ + + +
+
+
+ + + + + + + + + + + + + + 菜单名称 + 菜单编号 + 路由地址 + 菜单图标 + 菜单排序 + 操作 + + + + + + + + + {{ item.text }} + + {{ item.keyCode }} + {{ item.link }} + + + + {{ item.sorted }} + + 权限配置 + + + + + + + \ No newline at end of file diff --git a/src/app/routes/menu-manager/components/api-auth/api-auth.component.less b/src/app/routes/menu-manager/components/api-auth/api-auth.component.less new file mode 100644 index 00000000..b83ce9ee --- /dev/null +++ b/src/app/routes/menu-manager/components/api-auth/api-auth.component.less @@ -0,0 +1,17 @@ +:host { + ::ng-deep { + .pane-content-left { + padding-right: 12px; + + nz-select { + width: 100%; + margin-bottom: 1rem; + border-bottom: 2px solid #15408e; + } + } + .pane-content-right { + padding-left: 12px; + } + } + } + \ No newline at end of file diff --git a/src/app/routes/menu-manager/components/api-auth/api-auth.component.ts b/src/app/routes/menu-manager/components/api-auth/api-auth.component.ts new file mode 100644 index 00000000..bac79472 --- /dev/null +++ b/src/app/routes/menu-manager/components/api-auth/api-auth.component.ts @@ -0,0 +1,80 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { SFComponent, SFSchema } from '@delon/form'; +import { EAEnvironmentService } from '@shared'; +import { NzDrawerService } from 'ng-zorro-antd/drawer'; +import { NzModalService } from 'ng-zorro-antd/modal'; +import { MenuManagerService } from '../../services/menu-manager.service'; +import { MenuModalComponent } from '../index/menu-modal/menu-modal.component'; +import { AuthDrawerComponent } from './auth-drawer/auth-drawer.component'; + +@Component({ + selector: 'app-api-auth', + templateUrl: './api-auth.component.html', + styleUrls: ['./api-auth.component.less', '../../../commom/less/box.less'] +}) +export class ApiAuthComponent implements OnInit { + selectedPlatform!: { name: string; appId: string; enName: string }; + platforms: Array = [ + { name: '货主PC', appId: 'A48F72F0A304427F921794BAD86B3522', enName: 'tms-smc-web' }, + { name: '运营后台', appId: this.envSrv.env.appId, enName: 'tms-obc-web' } + ]; + + @ViewChild('sf', { static: false }) + sf!: SFComponent; + + searchSchema: SFSchema = { + properties: { + roleName: { + type: 'string', + title: '菜单名称', + ui: { placeholder: '请输入' } + } + } + }; + + mapOfExpandedData: { [key: string]: any[] } = {}; + listOfMapData: any[] = []; + constructor(private envSrv: EAEnvironmentService, public service: MenuManagerService, private drawer: NzDrawerService) { + this.initData(); + } + + ngOnInit(): void {} + + initData(): void { + this.selectedPlatform = this.platforms[0]; + this.loadMemu(this.selectedPlatform.appId); + } + + loadMemu(appId: string) { + this.service.request(this.service.$api_get_all, { appId }, 'POST', false).subscribe(res => { + if (res) { + this.listOfMapData = res; + this.listOfMapData.forEach(item => { + this.mapOfExpandedData[item.key] = this.service.convertTreeToList(item); + }); + console.log(this.listOfMapData, this.mapOfExpandedData); + } + }); + } + + changeMemu(key: number) { + this.selectedPlatform = this.platforms[key]; + this.loadMemu(this.selectedPlatform.appId); + } + + openDrawer(item: any) { + this.drawer.create({ + nzTitle: '接口权限配置', + nzContent: AuthDrawerComponent, + nzWidth: 900, + nzContentParams: { id: item.id, appId: this.selectedPlatform.appId } + }); + } + + /** + * 重置表单 + */ + resetSF() { + this.sf.reset(); + } +} diff --git a/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.html b/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.html new file mode 100644 index 00000000..b170fd99 --- /dev/null +++ b/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.html @@ -0,0 +1,37 @@ +
+
+ +
+
+ + +
+
+ +
+ +
+ + + + + + +
+ + + + + + + {{functionInfo.permissionsCode || '-'}} + + + + +
+
\ No newline at end of file diff --git a/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.less b/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.less new file mode 100644 index 00000000..e69de29b diff --git a/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.ts b/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.ts new file mode 100644 index 00000000..d2e7f5f1 --- /dev/null +++ b/src/app/routes/menu-manager/components/api-auth/auth-drawer/auth-drawer.component.ts @@ -0,0 +1,134 @@ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { STComponent, STColumn, STRequestOptions } from '@delon/abc/st'; +import { SFComponent, SFSchema, SFDateWidgetSchema } from '@delon/form'; +import { NzModalService } from 'ng-zorro-antd/modal'; +import { MenuManagerService } from '../../../services/menu-manager.service'; + +@Component({ + selector: 'app-auth-drawer', + templateUrl: './auth-drawer.component.html', + styleUrls: ['./auth-drawer.component.less'] +}) +export class AuthDrawerComponent implements OnInit { + @ViewChild('st', { static: true }) + st!: STComponent; + @ViewChild('sf', { static: false }) + sf!: SFComponent; + @ViewChild('configTypeItemModal', { static: false }) + configTypeItemModal!: any; + columns: STColumn[] = this.initST(); + searchSchema: SFSchema = this.initSF(); + + id = null; + appId = ''; + + functionInfo: any = {}; + functions: any[] = []; + isDisabled = false; + + constructor(public service: MenuManagerService, private modal: NzModalService) {} + + ngOnInit(): void { + this.loadFunctions(); + } + + beforeReq = (requestOptions: STRequestOptions) => { + Object.assign(requestOptions.body, { id: this.id }); + if (this.sf) { + Object.assign(requestOptions.body, { + ...this.sf.value + }); + } + return requestOptions; + }; + + loadFunctions() { + this.service.request(this.service.$api_get_functions, { appId: this.appId }, 'POST', false).subscribe(res => { + if (res) { + this.functions = res; + } + }); + } + + functionAction(item?: any, isDisabled = false) { + if (item) { + this.functionInfo = { ...item, buttonId: item.id }; + } else { + this.functionInfo = {}; + } + this.isDisabled = isDisabled; + const modal = this.modal.create({ + nzTitle: item ? '编辑' : '新增', + nzContent: this.configTypeItemModal, + nzWidth: 800, + nzCancelText: '取消', + nzOkText: '保存', + nzOnOk: () => { + this.service.request(this.service.$api_save_menu_function, { ...this.functionInfo, functionId: this.id }).subscribe(res => { + if (res) { + this.service.msgSrv.success(item ? '编辑成功' : '新增成功'); + this.st.load(1); + modal.destroy(); + } + }); + return false; + } + }); + } + + /** + * 重置表单 + */ + resetSF() { + this.sf.reset(); + } + + private initSF(): SFSchema { + return { + properties: { + vc2code: { + type: 'string', + title: '权限名称', + ui: { + autocomplete: 'off', + placeholder: '请输入权限名称' + } + }, + vc2c2ode: { + type: 'string', + title: '权限编号', + ui: { + autocomplete: 'off', + placeholder: '请输入权限编号' + } + } + } + }; + } + + private initST(): STColumn[] { + return [ + { title: '权限名称', index: 'name' }, + { title: '权限编码', index: 'permissionsCode' }, + { title: '权限路径', index: 'permissionsUrl' }, + { + title: '操作', + width: '150px', + className: 'text-center', + buttons: [ + { + text: '查看', + click: item => this.functionAction(item, true) + }, + { + text: '编辑', + click: item => this.functionAction(item) + }, + { + text: '删除' + } + ] + } + ]; + } +} diff --git a/src/app/routes/menu-manager/components/index/index.component.html b/src/app/routes/menu-manager/components/index/index.component.html index 6e01eca2..dad1c241 100644 --- a/src/app/routes/menu-manager/components/index/index.component.html +++ b/src/app/routes/menu-manager/components/index/index.component.html @@ -7,14 +7,9 @@ [button]="'none'">
- + - - - + + 菜单名称 + 菜单编号 路由地址 - 菜单图标 - 菜单排序 - 操作 + 菜单图标 + 菜单排序 + 操作 - + + + (nzExpandChange)="service.collapse(mapOfExpandedData[data.key], item, $event)"> {{ item.text }} + {{ item.keyCode }} {{ item.link }} - + - {{ item.sorted }} - - 查看 + {{ item.sorted }} + + 查看 - 编辑 + 编辑 - 删除 + 删除 - 新增子项 + 新增子项 - diff --git a/src/app/routes/menu-manager/components/index/index.component.ts b/src/app/routes/menu-manager/components/index/index.component.ts index 087b2e33..00f03d03 100644 --- a/src/app/routes/menu-manager/components/index/index.component.ts +++ b/src/app/routes/menu-manager/components/index/index.component.ts @@ -7,6 +7,7 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types'; import { NzModalService } from 'ng-zorro-antd/modal'; import { SettingRoleEditComponent } from 'src/app/routes/sys-setting/components/role-management/edit/edit.component'; import { MenuManagerService } from './../../services/menu-manager.service'; +import { MenuModalComponent } from './menu-modal/menu-modal.component'; @Component({ selector: 'app-menu-manager-components-index', @@ -15,18 +16,11 @@ import { MenuManagerService } from './../../services/menu-manager.service'; }) export class MenuManagerComponentsIndexComponent implements OnInit { selectedPlatform!: { name: string; appId: string; enName: string }; - menus: Array = []; - platforms: Array = []; - currentSelectedNode: any; - transferData!: string; - dropType = { - dropPrev: true, - dropNext: true, - dropInner: true - }; + platforms: Array = [ + { name: '货主PC', appId: 'A48F72F0A304427F921794BAD86B3522', enName: 'tms-smc-web' }, + { name: '运营后台', appId: this.envSrv.env.appId, enName: 'tms-obc-web' } + ]; - @ViewChild('st', { static: true }) - st!: STComponent; @ViewChild('sf', { static: false }) sf!: SFComponent; @@ -34,14 +28,12 @@ export class MenuManagerComponentsIndexComponent implements OnInit { properties: { roleName: { type: 'string', - title: '角色名称', + title: '菜单名称', ui: { placeholder: '请输入' } } } }; - selectedRows: any[] = []; - mapOfExpandedData: { [key: string]: any[] } = {}; listOfMapData: any[] = []; constructor(private envSrv: EAEnvironmentService, public service: MenuManagerService, private modal: NzModalService) { @@ -51,10 +43,6 @@ export class MenuManagerComponentsIndexComponent implements OnInit { ngOnInit(): void {} initData(): void { - this.platforms = [ - { name: '货主PC', appId: 'A48F72F0A304427F921794BAD86B3522', enName: 'tms-smc-web' }, - { name: '运营后台', appId: this.envSrv.env.appId, enName: 'tms-obc-web' } - ]; this.selectedPlatform = this.platforms[0]; this.loadMemu(this.selectedPlatform.appId); } @@ -64,115 +52,32 @@ export class MenuManagerComponentsIndexComponent implements OnInit { if (res) { this.listOfMapData = res; this.listOfMapData.forEach(item => { - this.mapOfExpandedData[item.key] = this.convertTreeToList(item); + this.mapOfExpandedData[item.key] = this.service.convertTreeToList(item); }); console.log(this.listOfMapData, this.mapOfExpandedData); } }); } - platformChange(e: { name: string; appId: string }) { - if (e) { - this.loadMenus(e.appId); - } else { - this.menus = []; - this.currentSelectedNode = null; - } - } - - loadMenus(appId: string) { - this.service.request(this.service.$api_get_one, { appId }, 'POST', false).subscribe(res => { - this.menus = res; - }); - } - - editValueChange(event: any) {} - - menuImport(index: number) { - this.selectedPlatform = this.platforms[index]; - if (!this.selectedPlatform) { - return; - } - - this.service.http.request('GET', `assets/mocks/platform/${this.selectedPlatform.enName}.json`).subscribe((res: any) => { - this.addMenu(res.menu); - }); - } - - addMenu(menus: Array, parentId: string = '') { - menus.forEach(r => { - if (parentId !== '') { - r.parentId = parentId; - } - this.service.request(this.service.$api_get_one, { appId: this.selectedPlatform.appId }, 'POST', false).subscribe(res => { - // 如果res.data存在,则更新菜单 - if (res.data) { - r.id = res.data.id; - } - this.service - .addOne({ appId: this.selectedPlatform.appId, ...r, isLeaf: !(r.children && r.children.length > 0) }) - .subscribe(result => { - if (result) { - if (r.children && r.children.length > 0) { - this.addMenu(r.children, result.id); - } - } - }); - }); - }); - - // this.loadMenus(this.selectedPlatform.appId); - } - - addMenuRecursion() {} - - delMenu(type: number) { - this.modal.confirm({ - nzTitle: '删除确认', - nzContent: `是否确认删除?`, - nzOnOk: () => { - this.getMenuByAppID(type === 0 ? 'A48F72F0A304427F921794BAD86B3522' : this.envSrv.env.appId); - } - }); - } - - getMenuByAppID(appId: string) { - this.service.request(this.service.$api_get_one, { appId }, 'POST', false).subscribe(res => { - if (res) { - const menus = res.data; - if (res.data?.length > 0) { - this.deleteMenuByAppID(res.data); - } else { - this.service.msgSrv.success('菜单已清空'); - } - } - }); - } - - deleteMenuByAppID(arr: Array) { - let ids: any[] = arr?.map(item => item.id) || []; - arr.forEach(item => { - if (item.children?.length > 0) { - this.deleteMenuByAppID(item.children); - } - }); - this.service.request(this.service.$api_del_many, ids).subscribe(res => {}); - } - changeMemu(key: number) { this.selectedPlatform = this.platforms[key]; this.loadMemu(this.selectedPlatform.appId); } - roleAction(item?: any) { + menuAction(nzTitle: string, item?: any, parentId?: string, isDisabled = false) { const modal = this.modal.create({ - nzContent: SettingRoleEditComponent, + nzTitle, + nzContent: MenuModalComponent, nzWidth: 900, - nzComponentParams: item ? { i: { ...item } } : { i: { id: 0 } }, + nzComponentParams: item + ? { formData: { ...item }, isDisabled, params: { parentId, appId: this.selectedPlatform.appId } } + : { formData: { id: null }, params: { parentId, appId: this.selectedPlatform.appId } }, nzFooter: null }); modal.afterClose.subscribe(res => { - this.st.load(); + if (res) { + this.loadMemu(this.selectedPlatform.appId); + } }); } @@ -182,12 +87,12 @@ export class MenuManagerComponentsIndexComponent implements OnInit { nzClosable: false, nzCancelText: '取消', nzOnOk: () => { - // this.service.request(this.service.$api_dalete_role, [item.id]).subscribe(res => { - // if (res) { - // this.service.msgSrv.success('删除角色成功'); - // this.st.load(); - // } - // }); + this.service.request(this.service.$api_del_many, [item.id]).subscribe(res => { + if (res) { + this.service.msgSrv.success('删除菜单成功'); + this.loadMemu(this.selectedPlatform.appId); + } + }); } }); } @@ -199,63 +104,25 @@ export class MenuManagerComponentsIndexComponent implements OnInit { this.sf.reset(); } - collapse(array: TreeNodeInterface[], data: TreeNodeInterface, $event: boolean): void { - if (!$event) { - if (data.children) { - data.children.forEach(d => { - const target = array.find(a => a.key === d.key)!; - target.expand = false; - this.collapse(array, target, false); - }); - } else { - return; + menuImport(index: number) { + if (this.listOfMapData?.length > 0) { + this.service.msgSrv.warning('请先清空菜单'); + return; + } + if (!this.selectedPlatform) { + return; + } + + this.service.menuImport(this.selectedPlatform.enName, this.selectedPlatform.appId); + } + + delMenu(type: number) { + this.modal.confirm({ + nzTitle: '删除确认', + nzContent: `是否确认删除?`, + nzOnOk: () => { + this.service.getMenuByAppID(type === 0 ? 'A48F72F0A304427F921794BAD86B3522' : this.envSrv.env.appId); } - } - } - - convertTreeToList(root: TreeNodeInterface): TreeNodeInterface[] { - const stack: TreeNodeInterface[] = []; - const array: TreeNodeInterface[] = []; - const hashMap = {}; - stack.push({ ...root, level: 0, expand: true }); - - while (stack.length !== 0) { - const node = stack.pop()!; - this.visitNode(node, hashMap, array); - if (node.children) { - for (let i = node.children.length - 1; i >= 0; i--) { - stack.push({ ...node.children[i], level: node.level! + 1, expand: false, parent: node, iconType: this.formatIcon(node.children[i].icon) }); - } - } - } - - return array; - } - - visitNode(node: TreeNodeInterface, hashMap: { [key: string]: boolean }, array: TreeNodeInterface[]): void { - if (!hashMap[node.key]) { - hashMap[node.key] = true; - array.push(node); - } - } - - private formatIcon(icon: any) { - let value = icon; - // compatible `anticon anticon-user` - if (~icon.indexOf(`anticon-`)) { - value = value.split('-').slice(1).join('-'); - } - return value; + }); } } -export interface TreeNodeInterface { - key: string; - name: string; - age?: number; - level?: number; - expand?: boolean; - address?: string; - children?: TreeNodeInterface[]; - parent?: TreeNodeInterface; - [key: string]: any; -} diff --git a/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.html b/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.html new file mode 100644 index 00000000..d243c49b --- /dev/null +++ b/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.html @@ -0,0 +1,9 @@ +
+ +
+ + \ No newline at end of file diff --git a/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.less b/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.less new file mode 100644 index 00000000..e69de29b diff --git a/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.ts b/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.ts new file mode 100644 index 00000000..3d1b6f77 --- /dev/null +++ b/src/app/routes/menu-manager/components/index/menu-modal/menu-modal.component.ts @@ -0,0 +1,148 @@ +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; +import { SFComponent, SFSchema, SFUISchema } from '@delon/form'; +import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; +import { SettingMenuComponent } from 'src/app/routes/sys-setting/components/role-management/menu/menu.component'; +import { MenuManagerService } from '../../../services/menu-manager.service'; + +@Component({ + selector: 'app-menu-modal', + templateUrl: './menu-modal.component.html', + styleUrls: ['./menu-modal.component.less'], + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class MenuModalComponent implements OnInit { + @ViewChild('sf', { static: false }) + sf!: SFComponent; + formData: any; + schema!: SFSchema; + ui!: SFUISchema; + isDisabled = false; + + params = {}; + + constructor(public service: MenuManagerService, private modal: NzModalRef, private cdr: ChangeDetectorRef) {} + + ngOnInit(): void { + if (this.formData.id) { + this.loadMenu(); + } else { + this.initSF(); + } + } + + initSF(data?: any) { + this.schema = { + properties: { + text: { + title: '菜单名称', + type: 'string', + default: this.formData.text, + maxLength: 20, + ui: { + widget: this.isDisabled ? 'text' : 'string', + placeholder: '请输入菜单名称' + } + }, + keyCode: { + title: '菜单编码', + type: 'string', + default: this.formData.keyCode, + ui: { + widget: this.isDisabled ? 'text' : 'string', + placeholder: '请输入菜单编码' + } + }, + isLeaf: { + title: '是否叶子节点', + type: 'boolean', + default: this.formData.isLeaf || true, + enum: [true, false], + readOnly: this.isDisabled, + ui: { + widget: 'radio' + } + }, + hide: { + title: '是否隐藏', + type: 'boolean', + default: this.formData.hide || false, + enum: [true, false], + readOnly: this.isDisabled, + ui: { + widget: 'radio' + } + }, + link: { + title: '菜单路由', + type: 'string', + default: this.formData.link, + maxLength: 20, + ui: { + widget: this.isDisabled ? 'text' : 'string', + placeholder: '请输入菜单路由' + } + }, + icon: { + title: '菜单图标', + type: 'string', + default: this.formData.icon, + ui: { + widget: this.isDisabled ? 'text' : 'string', + placeholder: '请输入菜单图标' + } + }, + sortId: { + title: '排序', + type: 'number', + default: this.formData.sortId, + ui: { + widget: this.isDisabled ? 'text' : 'number' + } + } + }, + required: ['text'] + }; + this.ui = { + '*': { + spanLabelFixed: 120, + grid: { span: 12 } + } + }; + this.cdr.detectChanges(); + } + + loadMenu() { + this.service.request(this.service.$api_get_menu_by_id, { id: this.formData.id }).subscribe(res => { + if (res) { + this.formData = res; + this.initSF(this.formData); + } + }); + } + + close() { + this.modal.destroy(); + } + + sure() { + const params = { + ...this.sf.value, + ...this.params, + i18n: this.sf.value.keyCode, + menuType: 0, + reuse: 0, + shortcut: 0, + hideInBreadcrumb: 0, + functionType: 0, + sortId: this.sf.value.sortId?.toString() || null + }; + console.log(params); + + this.service.request(this.service.$api_add_one, params).subscribe(res => { + if (res) { + this.service.msgSrv.success(this.formData.id ? '修改菜单成功' : '新增菜单成功'); + this.modal.destroy(true); + } + }); + } +} diff --git a/src/app/routes/menu-manager/menu-manager-routing.module.ts b/src/app/routes/menu-manager/menu-manager-routing.module.ts index d03e89c2..d46c398f 100644 --- a/src/app/routes/menu-manager/menu-manager-routing.module.ts +++ b/src/app/routes/menu-manager/menu-manager-routing.module.ts @@ -1,10 +1,12 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { ApiAuthComponent } from './components/api-auth/api-auth.component'; import { MenuManagerComponentsIndexComponent } from './components/index/index.component'; const routes: Routes = [ { path: '', redirectTo: 'index', pathMatch: 'full' }, { path: 'index', component: MenuManagerComponentsIndexComponent }, + { path: 'auth', component: ApiAuthComponent }, ]; @NgModule({ diff --git a/src/app/routes/menu-manager/menu-manager.module.ts b/src/app/routes/menu-manager/menu-manager.module.ts index 8c73d083..31435f7b 100644 --- a/src/app/routes/menu-manager/menu-manager.module.ts +++ b/src/app/routes/menu-manager/menu-manager.module.ts @@ -2,9 +2,12 @@ import { NgModule, Type } from '@angular/core'; import { SharedModule } from '@shared'; import { MenuManagerComponentsIndexComponent } from './components/index/index.component'; import { MenuManagerRoutingModule } from './menu-manager-routing.module'; +import { MenuModalComponent } from './components/index/menu-modal/menu-modal.component'; +import { ApiAuthComponent } from './components/api-auth/api-auth.component'; +import { AuthDrawerComponent } from './components/api-auth/auth-drawer/auth-drawer.component'; -const COMPONENTS: Type[] = [MenuManagerComponentsIndexComponent]; -const COMPONENTS_NOROUNT: Type[] = []; +const COMPONENTS: Type[] = [MenuManagerComponentsIndexComponent, ApiAuthComponent]; +const COMPONENTS_NOROUNT: Type[] = [MenuModalComponent, AuthDrawerComponent]; @NgModule({ imports: [SharedModule, MenuManagerRoutingModule], declarations: [...COMPONENTS, ...COMPONENTS_NOROUNT] diff --git a/src/app/routes/menu-manager/services/menu-manager.service.ts b/src/app/routes/menu-manager/services/menu-manager.service.ts index 8bbb7605..cb76b572 100644 --- a/src/app/routes/menu-manager/services/menu-manager.service.ts +++ b/src/app/routes/menu-manager/services/menu-manager.service.ts @@ -1,23 +1,149 @@ import { Injectable, Injector } from '@angular/core'; +import { Menu } from '@delon/theme'; import { BaseService } from '@shared'; @Injectable({ - providedIn: 'root', + providedIn: 'root' }) export class MenuManagerService extends BaseService { // 新增/更新菜单 $api_add_one = `/api/mdc/cuc/functionInfo/saveFunctionInfo`; - // 根据应用ID获取所有菜单 $api_get_all = `/api/mdc/cuc/functionInfo/getAllFunctionInfoByAppId`; - + // 获取菜单详情 + $api_get_menu_by_id = `/api/mdc/cuc/functionInfo/getFunctionInfo`; // 根据应用ID获取菜单 $api_get_one = `/api/mdc/cuc/functionInfo/getAllFunctionInfoByAppId?_allow_badcode=true`; - // 删除多个菜单 $api_del_many = `/api/mdc/cuc/functionInfo/deletebatchFunctionInfo`; + // 获取菜单下按钮权限列表 + $api_get_functions_by_id = `/api/mdc/cuc/functionButton/getFunctionButtonByFunctionId`; + // 获取所有按钮信息 + $api_get_functions= `/api/mdc/cuc/buttonInfo/getButtonInfoList`; + // 保存菜单按钮关联 + $api_save_menu_function= `/api/mdc/cuc/functionButton/saveFunctionButton`; + constructor(public injector: Injector) { super(injector); } + + getMenuByAppID(appId: string) { + this.request(this.$api_get_one, { appId }, 'POST', false).subscribe(res => { + if (res) { + const menus = res.data; + if (res.data?.length > 0) { + this.deleteMenuByAppID(res.data); + } else { + this.msgSrv.success('菜单已清空'); + } + } + }); + } + + deleteMenuByAppID(arr: Array) { + let ids: any[] = arr?.map(item => item.id) || []; + arr.forEach(item => { + if (item.children?.length > 0) { + this.deleteMenuByAppID(item.children); + } + }); + this.request(this.$api_del_many, ids).subscribe(res => {}); + } + + menuImport(enName: string, appId: string) { + this.http.request('GET', `assets/mocks/platform/${enName}.json`).subscribe((res: any) => { + this.addMenu(res.menu, appId); + }); + } + + addMenu(menus: Array, appId: string, parentId: string = '') { + menus.forEach(r => { + if (parentId !== '') { + r.parentId = parentId; + } + this.request(this.$api_get_one, { appId }, 'POST', false).subscribe(res => { + // 如果res.data存在,则更新菜单 + if (res.data) { + r.id = res.data.id; + } + this.addOne({ appId, ...r, isLeaf: !(r.children && r.children.length > 0) }).subscribe(result => { + if (result) { + if (r.children && r.children.length > 0) { + this.addMenu(r.children, appId, result.id); + } + } + }); + }); + }); + + // this.loadMenus(this.selectedPlatform.appId); + } + + collapse(array: TreeNodeInterface[], data: TreeNodeInterface, $event: boolean): void { + if (!$event) { + if (data.children) { + data.children.forEach(d => { + const target = array.find(a => a.key === d.key)!; + target.expand = false; + this.collapse(array, target, false); + }); + } else { + return; + } + } + } + + convertTreeToList(root: TreeNodeInterface): TreeNodeInterface[] { + const stack: TreeNodeInterface[] = []; + const array: TreeNodeInterface[] = []; + const hashMap = {}; + stack.push({ ...root, level: 0, expand: true }); + + while (stack.length !== 0) { + const node = stack.pop()!; + this.visitNode(node, hashMap, array); + if (node.children) { + for (let i = node.children.length - 1; i >= 0; i--) { + stack.push({ + ...node.children[i], + level: node.level! + 1, + expand: false, + parent: node, + iconType: this.formatIcon(node.children[i].icon) + }); + } + } + } + + return array; + } + + visitNode(node: TreeNodeInterface, hashMap: { [key: string]: boolean }, array: TreeNodeInterface[]): void { + if (!hashMap[node.key]) { + hashMap[node.key] = true; + array.push(node); + } + } + + private formatIcon(icon: any) { + let value = icon; + // compatible `anticon anticon-user` + if (~icon.indexOf(`anticon-`)) { + value = value.split('-').slice(1).join('-'); + } + return value; + } +} + +export interface TreeNodeInterface { + key: string; + name: string; + age?: number; + level?: number; + expand?: boolean; + address?: string; + children?: TreeNodeInterface[]; + parent?: TreeNodeInterface; + [key: string]: any; } diff --git a/src/app/routes/ticket-management/components/cancellation-invoice/cancellation-invoice.component.html b/src/app/routes/ticket-management/components/cancellation-invoice/cancellation-invoice.component.html index 4b29d2d7..d8fa8e42 100644 --- a/src/app/routes/ticket-management/components/cancellation-invoice/cancellation-invoice.component.html +++ b/src/app/routes/ticket-management/components/cancellation-invoice/cancellation-invoice.component.html @@ -1,11 +1,3 @@ - diff --git a/src/assets/mocks/menu-data.json b/src/assets/mocks/menu-data.json index e8c10f01..fdd060d5 100644 --- a/src/assets/mocks/menu-data.json +++ b/src/assets/mocks/menu-data.json @@ -509,6 +509,10 @@ "text": "菜单管理", "link": "/menu-management/index" }, + { + "text": "接口权限", + "link": "/menu-management/auth" + }, { "text": "系统配置", "link": "/system/system-config"