reuse
This commit is contained in:
		| @ -3,6 +3,7 @@ import { NavigationEnd, Router } from '@angular/router'; | ||||
| import { ReuseTabService } from '@delon/abc/reuse-tab'; | ||||
| import { MenuService } from '@delon/theme'; | ||||
| import { InputBoolean } from '@delon/util'; | ||||
| import { SearchDrawerService } from '@shared'; | ||||
| import { NzMenuModeType } from 'ng-zorro-antd/menu'; | ||||
| import { Subject } from 'rxjs'; | ||||
| import { filter, takeUntil } from 'rxjs/operators'; | ||||
| @ -31,7 +32,8 @@ export class LayoutProMenuComponent implements OnInit, OnDestroy { | ||||
|     private router: Router, | ||||
|     public pro: BrandService, | ||||
|     private cdr: ChangeDetectorRef, | ||||
|     private reuseService: ReuseTabService | ||||
|     private reuseService: ReuseTabService, | ||||
|     private searchDrawerService: SearchDrawerService | ||||
|   ) {} | ||||
|  | ||||
|   private cd(): void { | ||||
| @ -132,6 +134,7 @@ export class LayoutProMenuComponent implements OnInit, OnDestroy { | ||||
|   routeTo(link: string | undefined) { | ||||
|     if (link) { | ||||
|       this.reuseService.clear(); | ||||
|       this.searchDrawerService.unsubscribe(); | ||||
|       this.router.navigate([link]); | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @ -30,15 +30,11 @@ export class BasicTableComponent implements AfterViewInit, OnDestroy, OnReuseDes | ||||
|  | ||||
|   sf!: SFComponent; | ||||
|   sfValue: Record<string, any> = {}; | ||||
|   drawer: Subscription[] = []; | ||||
|   schema: SFSchema = {}; | ||||
|  | ||||
|   deviationHeight = 0; | ||||
|  | ||||
|   constructor(public searchDrawerService: SearchDrawerService) {} | ||||
|   _onReuseDestroy(): void { | ||||
|     this.drawer.forEach(sub => sub.unsubscribe()); | ||||
|   } | ||||
|  | ||||
|   ngAfterViewInit(): void { | ||||
|     setTimeout(() => { | ||||
| @ -51,23 +47,31 @@ export class BasicTableComponent implements AfterViewInit, OnDestroy, OnReuseDes | ||||
|       }); | ||||
|   } | ||||
|  | ||||
|   _onReuseDestroy(): void { | ||||
|     console.log(1); | ||||
|  | ||||
|     // this.drawer.forEach(sub => sub.unsubscribe()); | ||||
|   } | ||||
|  | ||||
|   ngOnDestroy(): void { | ||||
|     this.drawer.forEach(sub => sub.unsubscribe()); | ||||
|     this.searchDrawerService.unsubscribe(); | ||||
|   } | ||||
|  | ||||
|   openDrawer() { | ||||
|     if (this.drawer?.length > 0) { | ||||
|     console.log(this.sfValue); | ||||
|      | ||||
|     if (this.searchDrawerService.drawer?.length > 0) { | ||||
|       this.searchDrawerService.create(this.sfValue, this.schema); | ||||
|     } else { | ||||
|       const drawer = this.searchDrawerService.create(this.sfValue, this.schema); | ||||
|       this.drawer.push( | ||||
|       this.searchDrawerService.drawer.push( | ||||
|         drawer.initEvent.subscribe((sf: SFComponent) => { | ||||
|           if (sf) { | ||||
|             this.sf = sf; | ||||
|           } | ||||
|         }) | ||||
|       ); | ||||
|       this.drawer.push( | ||||
|       this.searchDrawerService.drawer.push( | ||||
|         drawer.closeEvent.subscribe((res: Record<string, any>) => { | ||||
|           this.sfValue = res; | ||||
|           if (res) { | ||||
|  | ||||
| @ -67,8 +67,6 @@ export class ETCBlacklistComponent extends BasicTableComponent { | ||||
|       item.isActived = !item.isActived; | ||||
|       // this.st.load(1); | ||||
|       this.st.resetColumns(); | ||||
|       console.log(this.st); | ||||
|        | ||||
|     }, 500); | ||||
|   } | ||||
|  | ||||
|  | ||||
| @ -28,10 +28,44 @@ | ||||
| <nz-card class="table-box"> | ||||
|   <div class="tab_header"> | ||||
|     <label class="page_title"><label class="driver">|</label>企业审核列表</label> | ||||
|     <nz-tabset [nzTabBarExtraContent]="extraTemplate"> | ||||
|       <nz-tab *ngFor="let tab of tabs" [nzTitle]="tab.name" (nzSelect)="changeTab(tab)"> </nz-tab> | ||||
|     </nz-tabset> | ||||
|   </div> | ||||
|   <nz-tabset [nzTabBarExtraContent]="extraTemplate"> | ||||
|     <nz-tab nzTitle="企业审核" (nzSelect)="changeTab(1)"> | ||||
|       <st #entst multiSort [data]="service.$api_get_freight_list" [columns]="enterColumns" | ||||
|         [req]="{  process: beforeReq }" [page]=" {}" [loading]="false" [scroll]="{ x: '1200px',y:scrollY }"> | ||||
|         <ng-template st-row="approvalStatus" let-item let-index="index"> | ||||
|           <ng-container [ngSwitch]="item.approvalStatus"> | ||||
|             <nz-badge *ngSwitchCase="10" nzColor="#108ee9" nzText="待审核"></nz-badge> | ||||
|             <nz-badge *ngSwitchCase="15" nzColor="gold" nzText="已撤销"></nz-badge> | ||||
|             <nz-badge *ngSwitchCase="20" nzColor="#87d068" nzText="已成功"></nz-badge> | ||||
|             <ng-container *ngSwitchCase="30"> | ||||
|               <nz-badge nzColor="volcano" nzText="已驳回"></nz-badge><br> | ||||
|               <label style="color: #ff4d4f;">(驳回原因:{{item.approvalOpinion}})</label> | ||||
|             </ng-container> | ||||
|  | ||||
|             <p *ngSwitchDefault></p> | ||||
|           </ng-container> | ||||
|         </ng-template> | ||||
|       </st> | ||||
|     </nz-tab> | ||||
|     <nz-tab nzTitle="企业管理员审核" (nzSelect)="changeTab(2)"> | ||||
|       <st #adminst multiSort [data]="service.$api_get_enterprise_admin_list" [columns]="adminColumns" | ||||
|         [req]="{  process: beforeReq }" [page]=" {}" [loading]="false" [scroll]="{ x: '1200px',y:scrollY }"> | ||||
|         <ng-template st-row="approvalStatus" let-item let-index="index"> | ||||
|           <ng-container [ngSwitch]="item.approvalStatus"> | ||||
|             <nz-badge *ngSwitchCase="10" nzColor="#108ee9" nzText="待审核"></nz-badge> | ||||
|             <nz-badge *ngSwitchCase="15" nzColor="gold" nzText="已撤销"></nz-badge> | ||||
|             <nz-badge *ngSwitchCase="20" nzColor="#87d068" nzText="已成功"></nz-badge> | ||||
|             <ng-container *ngSwitchCase="30"> | ||||
|               <nz-badge nzColor="volcano" nzText="已驳回"></nz-badge><br> | ||||
|               <label style="color: #ff4d4f;">(驳回原因:{{item.approvalOpinion}})</label> | ||||
|             </ng-container> | ||||
|             <p *ngSwitchDefault></p> | ||||
|           </ng-container> | ||||
|         </ng-template> | ||||
|       </st> | ||||
|     </nz-tab> | ||||
|   </nz-tabset> | ||||
|  | ||||
|   <ng-template #extraTemplate> | ||||
|     <div class="mr-sm"> | ||||
| @ -41,23 +75,6 @@ | ||||
|         [acl-ability]="['USERCENTER-FREIGHT-ENTERPRISE-export']"> 导出</button> | ||||
|     </div> | ||||
|   </ng-template> | ||||
|   <!-- 数据列表 --> | ||||
|   <st #st multiSort [data]="service.$api_get_freight_list" [columns]="tabType===1?enterColumns:adminColumns" | ||||
|     [req]="{  process: beforeReq }" [page]=" {}" [loading]="false" [scroll]="{ x: '1200px',y:scrollY }"> | ||||
|     <ng-template st-row="approvalStatus" let-item let-index="index"> | ||||
|       <ng-container [ngSwitch]="item.approvalStatus"> | ||||
|         <nz-badge *ngSwitchCase="10" nzColor="#108ee9" nzText="待审核"></nz-badge> | ||||
|         <nz-badge *ngSwitchCase="15" nzColor="gold" nzText="已撤销"></nz-badge> | ||||
|         <nz-badge *ngSwitchCase="20" nzColor="#87d068" nzText="已成功"></nz-badge> | ||||
|         <ng-container *ngSwitchCase="30"> | ||||
|           <nz-badge nzColor="volcano" nzText="已驳回"></nz-badge><br> | ||||
|           <label style="color: #ff4d4f;">(驳回原因:{{item.approvalOpinion}})</label> | ||||
|         </ng-container> | ||||
|  | ||||
|         <p *ngSwitchDefault></p> | ||||
|       </ng-container> | ||||
|     </ng-template> | ||||
|   </st> | ||||
| </nz-card> | ||||
|  | ||||
| <ng-template #approvedModal> | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| import { Component, OnInit, ViewChild } from '@angular/core'; | ||||
| import {  Router } from '@angular/router'; | ||||
| import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; | ||||
| import { Router } from '@angular/router'; | ||||
| import { STChange, STColumn, STComponent, STData, STRequestOptions } from '@delon/abc/st'; | ||||
| import { SFComponent, SFDateWidgetSchema, SFSchema, SFUISchema } from '@delon/form'; | ||||
| import { SearchDrawerService } from '@shared'; | ||||
| @ -11,13 +11,15 @@ import { AuditAdminComponent } from './audit-admin/audit-admin.component'; | ||||
| @Component({ | ||||
|   selector: 'app-Freight-components-enterprise-audit', | ||||
|   templateUrl: './enterprise-audit.component.html', | ||||
|   styleUrls: ['../../../../commom/less/commom-table.less'] | ||||
|   styleUrls: ['../../../../commom/less/commom-table.less'], | ||||
|   changeDetection: ChangeDetectionStrategy.OnPush | ||||
| }) | ||||
| export class FreightComponentsEnterpriseAuditComponent extends BasicTableComponent implements OnInit { | ||||
|   enterColumns: STColumn[] = this.initEnterST(); | ||||
|   adminColumns: STColumn[] = this.initAdminST(); | ||||
|   schema = this.initSF(); | ||||
|   @ViewChild('st', { static: false }) st!: STComponent; | ||||
|   @ViewChild('entst', { static: false }) entst!: STComponent; | ||||
|   @ViewChild('adminst', { static: false }) adminst!: STComponent; | ||||
|   tabType = 1; | ||||
|   tabs = [ | ||||
|     { | ||||
| @ -44,6 +46,7 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone | ||||
|   networkTransporter = null; | ||||
|   roleId = null; | ||||
|   customerServiceId = null; | ||||
|   deviationHeight = 30; | ||||
|   constructor( | ||||
|     public service: UsermanageService, | ||||
|     private router: Router, | ||||
| @ -54,7 +57,11 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone | ||||
|   } | ||||
|  | ||||
|   search() { | ||||
|     this.st?.load(1); | ||||
|     if (this.tabType === 1) { | ||||
|       this.entst?.load(1); | ||||
|     } else { | ||||
|       this.adminst?.load(1); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   beforeReq = (requestOptions: STRequestOptions) => { | ||||
| @ -205,7 +212,7 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone | ||||
|         if (res) { | ||||
|           this.service.msgSrv.success(status === 20 ? '审核通过' : '驳回成功'); | ||||
|         } | ||||
|         this.st.load(1); | ||||
|         this.entst.load(1); | ||||
|       }); | ||||
|   } | ||||
|  | ||||
| @ -214,13 +221,14 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone | ||||
|   } | ||||
|  | ||||
|   // 切换Tab | ||||
|   changeTab(item: any) { | ||||
|     this.tabType = item.type; | ||||
|     this.sf?.reset(); | ||||
|     this.st.data = this.tabType === 1 ? this.service.$api_get_freight_list : this.service.$api_get_enterprise_admin_list; | ||||
|     setTimeout(() => { | ||||
|       this.st.load(1); | ||||
|     }, 100); | ||||
|   changeTab(type: number) { | ||||
|     this.tabType = type; | ||||
|     if (this.tabType === 1) { | ||||
|       this.schema = this.initSF(); | ||||
|     } else { | ||||
|       this.schema = this.initAdminSF(); | ||||
|     } | ||||
|     this.search(); | ||||
|   } | ||||
|  | ||||
|   private adminAuditUser(params: any, modal: any) { | ||||
| @ -228,7 +236,7 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone | ||||
|       if (res) { | ||||
|         this.service.msgSrv.success('审核成功'); | ||||
|         modal.destroy(); | ||||
|         this.st.load(1); | ||||
|         this.adminst.load(1); | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| @ -507,4 +515,48 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone | ||||
|       } | ||||
|     }; | ||||
|   } | ||||
|  | ||||
|   initAdminSF(): SFSchema { | ||||
|     return { | ||||
|       properties: { | ||||
|         enterpriseName: { | ||||
|           title: '企业名称', | ||||
|           type: 'string', | ||||
|           ui: { | ||||
|             placeholder: '请输入' | ||||
|           } | ||||
|         }, | ||||
|         contactName: { | ||||
|           title: '管理员', | ||||
|           type: 'string', | ||||
|           ui: { | ||||
|             placeholder: '请输入' | ||||
|           } | ||||
|         }, | ||||
|         mobile: { | ||||
|           title: '手机号', | ||||
|           type: 'string', | ||||
|           maxLength: 11, | ||||
|           ui: { | ||||
|             placeholder: '请输入' | ||||
|           } | ||||
|         }, | ||||
|         approvalStatus: { | ||||
|           type: 'string', | ||||
|           title: '审核状态', | ||||
|           enum: [ | ||||
|             { label: '全部', value: '' }, | ||||
|             { label: '待审核', value: 10 }, | ||||
|             { label: '已撤销', value: 15 }, | ||||
|             { label: '已成功', value: 20 }, | ||||
|             { label: '审核失败', value: 30 } | ||||
|           ], | ||||
|           default: '', | ||||
|           ui: { | ||||
|             widget: 'select' | ||||
|           } | ||||
|         } | ||||
|       } | ||||
|     }; | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| import { Injectable } from '@angular/core'; | ||||
| import { SFComponent, SFSchema, SFUISchema } from '@delon/form'; | ||||
| import { Subject } from 'rxjs'; | ||||
| import { Subject, Subscription } from 'rxjs'; | ||||
|  | ||||
| @Injectable({ | ||||
|   providedIn: 'root' | ||||
| @ -11,10 +11,16 @@ export class SearchDrawerService { | ||||
|   initEvent = new Subject<any>(); | ||||
|  | ||||
|   visible = false; | ||||
|  | ||||
|   drawer: Subscription[] = []; | ||||
|   constructor() {} | ||||
|  | ||||
|   create(defaultValue: Record<string, any>, newSchema?: SFSchema, newUI?: SFUISchema) { | ||||
|     this.createEvent.next({ defaultValue, newSchema, newUI }); | ||||
|     return this; | ||||
|   } | ||||
|  | ||||
|   unsubscribe() { | ||||
|     this.drawer.forEach(sub => sub.unsubscribe()); | ||||
|   } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user