Merge branch 'develop' of https://gitlab.eascs.com/tms-ui/tms-obc-web into develop
This commit is contained in:
		| @ -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' }"> | ||||
|         <ng-template st-row="availableBalance" let-item let-index="index"> | ||||
|             <a (click)="showAccountDetail(item)">{{ item.availableBalance | currency}}</a> | ||||
|             <a (click)="showAccountDetail(item)">{{ (parseFloat(item.availableBalance) + | ||||
|                 parseFloat(item.freezeBalance)).toFixed(2) | currency}}</a> | ||||
|         </ng-template> | ||||
|     </st> | ||||
| </nz-card> | ||||
| @ -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); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -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' }"> | ||||
|         <ng-template st-row="description" let-item let-index="index"> | ||||
|             <a (click)="showAccountDetail(item)">{{ item.availableBalance | currency}}</a> | ||||
|             <a (click)="showAccountDetail(item)">{{ (parseFloat(item.availableBalance) + | ||||
|                 parseFloat(item.freezeBalance)).toFixed(2) | currency}}</a> | ||||
|         </ng-template> | ||||
|     </st> | ||||
| </nz-card> | ||||
| @ -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); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -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' | ||||
|               }) | ||||
|           } | ||||
|  | ||||
| @ -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' | ||||
|               }) | ||||
|           }, | ||||
|  | ||||
| @ -0,0 +1,75 @@ | ||||
| <page-header-wrapper title="接口权限"></page-header-wrapper> | ||||
|  | ||||
| <nz-card class="search-box"> | ||||
|     <div nz-row nzGutter="8"> | ||||
|         <div nz-col [nzSpan]="6"> | ||||
|             <sf #sf [schema]="searchSchema" [ui]="{ '*': { spanLabelFixed: 90,grid: { span: 24 } }}" [compact]="true" | ||||
|                 [button]="'none'"></sf> | ||||
|         </div> | ||||
|         <div nz-col [nzSpan]="8" nzOffset="1"> | ||||
|             <button nz-button nzType="primary" [nzLoading]="service.http.loading" | ||||
|                 (click)="loadMemu(selectedPlatform.appId)">查询</button> | ||||
|             <button nz-button (click)="resetSF()">重置</button> | ||||
|             <!-- <button nz-button (click)="delMenu(0)" [nzLoading]="service.http.loading"> | ||||
|         清空货主菜单 | ||||
|       </button> | ||||
|       <button nz-button (click)="delMenu(1)" [nzLoading]="service.http.loading"> | ||||
|         清空运营后台菜单 | ||||
|       </button> --> | ||||
|         </div> | ||||
|     </div> | ||||
| </nz-card> | ||||
|  | ||||
| <nz-card class="content-box"> | ||||
|  | ||||
|     <nz-tabset> | ||||
|         <nz-tab nzTitle="货主菜单" (nzClick)="changeMemu(0)"></nz-tab> | ||||
|         <nz-tab nzTitle="运营后台菜单" (nzClick)="changeMemu(1)"></nz-tab> | ||||
|     </nz-tabset> | ||||
|  | ||||
|     <!-- <st #st [data]="service.$api_get_all" [columns]="columns" [expand]="expand" expandRowByClick | ||||
|     [req]="{ method: 'POST',  reName: { pi: 'pageIndex', ps: 'pageSize' },params:{appId:selectedPlatform?.appId} }" | ||||
|     [res]="{ reName: { list: 'data' } }" [page]="{ show: false }" [loading]="service.http.loading" | ||||
|     [scroll]="{ y: '370px' }" (change)="stChange($event)"> | ||||
|     <ng-template #expand let-item let-index="index" let-column="column"> | ||||
|       {{ item.description }} | ||||
|     </ng-template> | ||||
|   </st> --> | ||||
|     <nz-table #expandTable [nzData]="listOfMapData" nzTableLayout="fixed" nzBordered nzSize="small" | ||||
|         [nzLoading]="service.http.loading"> | ||||
|         <thead> | ||||
|             <tr> | ||||
|                 <!-- <th nzWidth="70px" nzAlign="center">#</th> --> | ||||
|                 <th>菜单名称</th> | ||||
|                 <th>菜单编号</th> | ||||
|                 <th>路由地址</th> | ||||
|                 <th nzAlign="center" nzWidth="120px">菜单图标</th> | ||||
|                 <th nzWidth="100px">菜单排序</th> | ||||
|                 <th nzAlign="center">操作</th> | ||||
|             </tr> | ||||
|         </thead> | ||||
|         <tbody> | ||||
|             <ng-container *ngFor="let data of expandTable.data"> | ||||
|                 <ng-container *ngFor="let item of mapOfExpandedData[data.key];let i = index"> | ||||
|                     <tr *ngIf="(item.parent && item.parent.expand) || !item.parent"> | ||||
|                         <!-- <td nzWidth="70px" nzAlign="center" [nzChecked]="item.checked">{{ i+1 }}</td> --> | ||||
|                         <td [nzIndentSize]="item.level! * 20" [nzShowExpand]="!!item.children" | ||||
|                             [(nzExpand)]="item.expand" | ||||
|                             (nzExpandChange)="service.collapse(mapOfExpandedData[data.key], item, $event)"> | ||||
|                             {{ item.text }} | ||||
|                         </td> | ||||
|                         <td>{{ item.keyCode }}</td> | ||||
|                         <td>{{ item.link }}</td> | ||||
|                         <td nzAlign="center" nzWidth="120px"> | ||||
|                             <i nz-icon [nzType]="item.iconType"></i> | ||||
|                         </td> | ||||
|                         <td nzWidth="100px">{{ item.sorted }}</td> | ||||
|                         <td nzAlign="center"> | ||||
|                             <a (click)="openDrawer(item)">权限配置</a> | ||||
|                         </td> | ||||
|                     </tr> | ||||
|                 </ng-container> | ||||
|             </ng-container> | ||||
|         </tbody> | ||||
|     </nz-table> | ||||
| </nz-card> | ||||
| @ -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; | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|    | ||||
| @ -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<any> = [ | ||||
|     { 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(); | ||||
|   } | ||||
| } | ||||
| @ -0,0 +1,37 @@ | ||||
| <div nz-row nzGutter="8"> | ||||
|     <div nz-col [nzXl]="20" [nzLg]="24" [nzSm]="24" [nzXs]="24"> | ||||
|         <sf #sf [schema]="searchSchema" [ui]="{ '*': { spanLabelFixed: 100,grid: { lg: 12, md: 12, sm: 12, xs: 24 } }}" | ||||
|             [compact]="true" [button]="'none'"></sf> | ||||
|     </div> | ||||
|     <div nz-col [nzXl]="4" [nzLg]="24" [nzSm]="24" [nzXs]="24" class="text-right"> | ||||
|         <button nz-button nzType="primary" [nzLoading]="service.http.loading" (click)="st?.load(1)">查询</button> | ||||
|         <button nz-button [disabled]="service.http.loading" (click)="resetSF()">重置</button> | ||||
|     </div> | ||||
| </div> | ||||
|  | ||||
| <div class="d-flex align-items-center mb-md mt-md"> | ||||
|     <button nz-button nzType="primary" (click)="functionAction()">新增</button> | ||||
| </div> | ||||
|  | ||||
| <st #st [data]="service.$api_get_functions_by_id" [columns]="columns" bordered size="small" | ||||
|     [req]="{ method: 'POST', allInBody: true, process: beforeReq }" | ||||
|     [res]="{ reName: { list: 'data' } }" [page]="{ show: false}" | ||||
|     [loading]="service.http.loading" class="mt-md"> | ||||
| </st> | ||||
|  | ||||
|  | ||||
| <ng-template #configTypeItemModal> | ||||
|     <div se-container [labelWidth]="110" [col]="2"> | ||||
|         <se label="权限名称" required> | ||||
|             <nz-select [(ngModel)]="functionInfo.buttonId" nzPlaceHolder="请选择权限名称" [disabled]="isDisabled"> | ||||
|                 <nz-option [nzValue]="item.id" [nzLabel]="item.name" *ngFor="let item of functions"></nz-option> | ||||
|             </nz-select> | ||||
|         </se> | ||||
|         <se label="权限编码" required> | ||||
|             {{functionInfo.permissionsCode || '-'}} | ||||
|         </se> | ||||
|         <se label="权限路径" required> | ||||
|             <input nz-input [(ngModel)]="functionInfo.permissionsUrl" placeholder="请输入权限路径" [disabled]="isDisabled" /> | ||||
|         </se> | ||||
|     </div> | ||||
| </ng-template> | ||||
| @ -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: '删除' | ||||
|           } | ||||
|         ] | ||||
|       } | ||||
|     ]; | ||||
|   } | ||||
| } | ||||
| @ -7,14 +7,9 @@ | ||||
|         [button]="'none'"></sf> | ||||
|     </div> | ||||
|     <div nz-col [nzSpan]="8" nzOffset="1"> | ||||
|       <button nz-button nzType="primary" [nzLoading]="service.http.loading" (click)="st?.load(1)">查询</button> | ||||
|       <button nz-button nzType="primary" [nzLoading]="service.http.loading" | ||||
|         (click)="loadMemu(selectedPlatform.appId)">查询</button> | ||||
|       <button nz-button (click)="resetSF()">重置</button> | ||||
|       <button nz-button (click)="menuImport(0)" [nzLoading]="service.http.loading"> | ||||
|         导入货主菜单 | ||||
|       </button> | ||||
|       <button nz-button (click)="menuImport(1)" [nzLoading]="service.http.loading"> | ||||
|         导入运营后台菜单 | ||||
|       </button> | ||||
|       <!-- <button nz-button (click)="delMenu(0)" [nzLoading]="service.http.loading"> | ||||
|         清空货主菜单 | ||||
|       </button> | ||||
| @ -34,7 +29,15 @@ | ||||
|   <ng-template #extraTemplate> | ||||
|     <div class="d-flex align-items-center"> | ||||
|       <div> | ||||
|         <button nz-button nzType="primary" (click)="roleAction()">新增</button> | ||||
|         <button nz-button nzType="primary" (click)="menuAction('新增菜单')">新增</button> | ||||
|         <button nz-button nzType="primary" (click)="menuImport(0)" [disabled]="service.http.loading" | ||||
|           *ngIf="selectedPlatform.enName==='tms-smc-web'"> | ||||
|           导入货主菜单 | ||||
|         </button> | ||||
|         <button nz-button nzType="primary" (click)="menuImport(1)" [disabled]="service.http.loading" | ||||
|           *ngIf="selectedPlatform.enName==='tms-obc-web'"> | ||||
|           导入运营后台菜单 | ||||
|         </button> | ||||
|       </div> | ||||
|     </div> | ||||
|   </ng-template> | ||||
| @ -47,40 +50,44 @@ | ||||
|       {{ item.description }} | ||||
|     </ng-template> | ||||
|   </st> --> | ||||
|   <nz-table #expandTable [nzData]="listOfMapData" nzTableLayout="fixed" nzBordered> | ||||
|   <nz-table #expandTable [nzData]="listOfMapData" nzTableLayout="fixed" nzBordered nzSize="small" | ||||
|     [nzLoading]="service.http.loading"> | ||||
|     <thead> | ||||
|       <tr> | ||||
|         <!-- <th nzWidth="70px" nzAlign="center">#</th> --> | ||||
|         <th>菜单名称</th> | ||||
|         <th>菜单编号</th> | ||||
|         <th>路由地址</th> | ||||
|         <th>菜单图标</th> | ||||
|         <th>菜单排序</th> | ||||
|         <th class="text-center">操作</th> | ||||
|         <th nzAlign="center" nzWidth="120px">菜单图标</th> | ||||
|         <th nzWidth="100px">菜单排序</th> | ||||
|         <th nzAlign="center">操作</th> | ||||
|       </tr> | ||||
|     </thead> | ||||
|     <tbody> | ||||
|       <ng-container *ngFor="let data of expandTable.data"> | ||||
|         <ng-container *ngFor="let item of mapOfExpandedData[data.key]"> | ||||
|         <ng-container *ngFor="let item of mapOfExpandedData[data.key];let i = index"> | ||||
|           <tr *ngIf="(item.parent && item.parent.expand) || !item.parent"> | ||||
|             <!-- <td nzWidth="70px" nzAlign="center" [nzChecked]="item.checked">{{ i+1 }}</td> --> | ||||
|             <td [nzIndentSize]="item.level! * 20" [nzShowExpand]="!!item.children" [(nzExpand)]="item.expand" | ||||
|               (nzExpandChange)="collapse(mapOfExpandedData[data.key], item, $event)"> | ||||
|               (nzExpandChange)="service.collapse(mapOfExpandedData[data.key], item, $event)"> | ||||
|               {{ item.text }} | ||||
|             </td> | ||||
|             <td>{{ item.keyCode }}</td> | ||||
|             <td>{{ item.link }}</td> | ||||
|             <td> | ||||
|             <td nzAlign="center" nzWidth="120px"> | ||||
|               <i nz-icon [nzType]="item.iconType"></i> | ||||
|             </td> | ||||
|             <td>{{ item.sorted }}</td> | ||||
|             <td class="text-center"> | ||||
|               <a>查看</a> | ||||
|             <td nzWidth="100px">{{ item.sorted }}</td> | ||||
|             <td nzAlign="center"> | ||||
|               <a (click)="menuAction('查看菜单',item,item.parentId,true)">查看</a> | ||||
|               <nz-divider nzType="vertical"></nz-divider> | ||||
|               <a>编辑</a> | ||||
|               <a (click)="menuAction('编辑菜单',item,item.parentId)">编辑</a> | ||||
|               <nz-divider nzType="vertical"></nz-divider> | ||||
|               <a>删除</a> | ||||
|               <a (click)="deleteAction(item)">删除</a> | ||||
|               <ng-container *ngIf="item.level!==3"> | ||||
|                 <nz-divider nzType="vertical"></nz-divider> | ||||
|                 <a>新增子项</a> | ||||
|                 <a (click)="menuAction('新增菜单',null,item.id)">新增子项</a> | ||||
|               </ng-container> | ||||
|  | ||||
|             </td> | ||||
|           </tr> | ||||
|         </ng-container> | ||||
|  | ||||
| @ -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<any> = []; | ||||
|   platforms: Array<any> = []; | ||||
|   currentSelectedNode: any; | ||||
|   transferData!: string; | ||||
|   dropType = { | ||||
|     dropPrev: true, | ||||
|     dropNext: true, | ||||
|     dropInner: true | ||||
|   }; | ||||
|   platforms: Array<any> = [ | ||||
|     { 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<Menu>, 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: '<i>删除确认</i>', | ||||
|       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<any>) { | ||||
|     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: '<i>删除确认</i>', | ||||
|       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; | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,9 @@ | ||||
| <div *ngIf="schema"> | ||||
|     <sf #sf [compact]="true" [ui]="ui" [schema]="schema" [button]="'none'" [formData]="formData"> </sf> | ||||
| </div> | ||||
|  | ||||
| <div class="modal-footer"> | ||||
|     <button nz-button type="button" (click)="close()">{{ isDisabled ? '关闭' : '取消' }}</button> | ||||
|     <button nz-button type="button" nzType="primary" (click)="sure()" *ngIf="!isDisabled" | ||||
|         [disabled]="!sf?.valid">确定</button> | ||||
| </div> | ||||
| @ -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); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| } | ||||
| @ -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({ | ||||
|  | ||||
| @ -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<void>[] = [MenuManagerComponentsIndexComponent]; | ||||
| const COMPONENTS_NOROUNT: Type<void>[] = []; | ||||
| const COMPONENTS: Type<void>[] = [MenuManagerComponentsIndexComponent, ApiAuthComponent]; | ||||
| const COMPONENTS_NOROUNT: Type<void>[] = [MenuModalComponent, AuthDrawerComponent]; | ||||
| @NgModule({ | ||||
|   imports: [SharedModule, MenuManagerRoutingModule], | ||||
|   declarations: [...COMPONENTS, ...COMPONENTS_NOROUNT] | ||||
|  | ||||
| @ -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<any>) { | ||||
|     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<Menu>, 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; | ||||
| } | ||||
|  | ||||
| @ -1,11 +1,3 @@ | ||||
| <!-- | ||||
|  * @Author: your name | ||||
|  * @Date: 2021-12-27 14:08:49 | ||||
|  * @LastEditTime: 2021-12-30 15:44:54 | ||||
|  * @LastEditors: Please set LastEditors | ||||
|  * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE | ||||
|  * @FilePath: \tms-obc-web\src\app\routes\ticket-management\components\cancellation-invoice\cancellation-invoice.component.html | ||||
| --> | ||||
| <page-header-wrapper [title]="'销票处理'"> | ||||
| </page-header-wrapper> | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user