This commit is contained in:
Taric Xin
2022-05-12 11:48:44 +08:00
parent bba5cfcca8
commit 2d5df21245
6 changed files with 126 additions and 46 deletions

View File

@ -3,6 +3,7 @@ import { NavigationEnd, Router } from '@angular/router';
import { ReuseTabService } from '@delon/abc/reuse-tab'; import { ReuseTabService } from '@delon/abc/reuse-tab';
import { MenuService } from '@delon/theme'; import { MenuService } from '@delon/theme';
import { InputBoolean } from '@delon/util'; import { InputBoolean } from '@delon/util';
import { SearchDrawerService } from '@shared';
import { NzMenuModeType } from 'ng-zorro-antd/menu'; import { NzMenuModeType } from 'ng-zorro-antd/menu';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators'; import { filter, takeUntil } from 'rxjs/operators';
@ -31,7 +32,8 @@ export class LayoutProMenuComponent implements OnInit, OnDestroy {
private router: Router, private router: Router,
public pro: BrandService, public pro: BrandService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private reuseService: ReuseTabService private reuseService: ReuseTabService,
private searchDrawerService: SearchDrawerService
) {} ) {}
private cd(): void { private cd(): void {
@ -132,6 +134,7 @@ export class LayoutProMenuComponent implements OnInit, OnDestroy {
routeTo(link: string | undefined) { routeTo(link: string | undefined) {
if (link) { if (link) {
this.reuseService.clear(); this.reuseService.clear();
this.searchDrawerService.unsubscribe();
this.router.navigate([link]); this.router.navigate([link]);
} }
} }

View File

@ -30,15 +30,11 @@ export class BasicTableComponent implements AfterViewInit, OnDestroy, OnReuseDes
sf!: SFComponent; sf!: SFComponent;
sfValue: Record<string, any> = {}; sfValue: Record<string, any> = {};
drawer: Subscription[] = [];
schema: SFSchema = {}; schema: SFSchema = {};
deviationHeight = 0; deviationHeight = 0;
constructor(public searchDrawerService: SearchDrawerService) {} constructor(public searchDrawerService: SearchDrawerService) {}
_onReuseDestroy(): void {
this.drawer.forEach(sub => sub.unsubscribe());
}
ngAfterViewInit(): void { ngAfterViewInit(): void {
setTimeout(() => { 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 { ngOnDestroy(): void {
this.drawer.forEach(sub => sub.unsubscribe()); this.searchDrawerService.unsubscribe();
} }
openDrawer() { openDrawer() {
if (this.drawer?.length > 0) { console.log(this.sfValue);
if (this.searchDrawerService.drawer?.length > 0) {
this.searchDrawerService.create(this.sfValue, this.schema); this.searchDrawerService.create(this.sfValue, this.schema);
} else { } else {
const drawer = this.searchDrawerService.create(this.sfValue, this.schema); const drawer = this.searchDrawerService.create(this.sfValue, this.schema);
this.drawer.push( this.searchDrawerService.drawer.push(
drawer.initEvent.subscribe((sf: SFComponent) => { drawer.initEvent.subscribe((sf: SFComponent) => {
if (sf) { if (sf) {
this.sf = sf; this.sf = sf;
} }
}) })
); );
this.drawer.push( this.searchDrawerService.drawer.push(
drawer.closeEvent.subscribe((res: Record<string, any>) => { drawer.closeEvent.subscribe((res: Record<string, any>) => {
this.sfValue = res; this.sfValue = res;
if (res) { if (res) {

View File

@ -67,8 +67,6 @@ export class ETCBlacklistComponent extends BasicTableComponent {
item.isActived = !item.isActived; item.isActived = !item.isActived;
// this.st.load(1); // this.st.load(1);
this.st.resetColumns(); this.st.resetColumns();
console.log(this.st);
}, 500); }, 500);
} }

View File

@ -28,10 +28,44 @@
<nz-card class="table-box"> <nz-card class="table-box">
<div class="tab_header"> <div class="tab_header">
<label class="page_title"><label class="driver">|</label>企业审核列表</label> <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> </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> <ng-template #extraTemplate>
<div class="mr-sm"> <div class="mr-sm">
@ -41,23 +75,6 @@
[acl-ability]="['USERCENTER-FREIGHT-ENTERPRISE-export']"> 导出</button> [acl-ability]="['USERCENTER-FREIGHT-ENTERPRISE-export']"> 导出</button>
</div> </div>
</ng-template> </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> </nz-card>
<ng-template #approvedModal> <ng-template #approvedModal>

View File

@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core'; import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { STChange, STColumn, STComponent, STData, STRequestOptions } from '@delon/abc/st'; import { STChange, STColumn, STComponent, STData, STRequestOptions } from '@delon/abc/st';
import { SFComponent, SFDateWidgetSchema, SFSchema, SFUISchema } from '@delon/form'; import { SFComponent, SFDateWidgetSchema, SFSchema, SFUISchema } from '@delon/form';
import { SearchDrawerService } from '@shared'; import { SearchDrawerService } from '@shared';
@ -11,13 +11,15 @@ import { AuditAdminComponent } from './audit-admin/audit-admin.component';
@Component({ @Component({
selector: 'app-Freight-components-enterprise-audit', selector: 'app-Freight-components-enterprise-audit',
templateUrl: './enterprise-audit.component.html', 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 { export class FreightComponentsEnterpriseAuditComponent extends BasicTableComponent implements OnInit {
enterColumns: STColumn[] = this.initEnterST(); enterColumns: STColumn[] = this.initEnterST();
adminColumns: STColumn[] = this.initAdminST(); adminColumns: STColumn[] = this.initAdminST();
schema = this.initSF(); schema = this.initSF();
@ViewChild('st', { static: false }) st!: STComponent; @ViewChild('entst', { static: false }) entst!: STComponent;
@ViewChild('adminst', { static: false }) adminst!: STComponent;
tabType = 1; tabType = 1;
tabs = [ tabs = [
{ {
@ -44,6 +46,7 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone
networkTransporter = null; networkTransporter = null;
roleId = null; roleId = null;
customerServiceId = null; customerServiceId = null;
deviationHeight = 30;
constructor( constructor(
public service: UsermanageService, public service: UsermanageService,
private router: Router, private router: Router,
@ -54,7 +57,11 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone
} }
search() { search() {
this.st?.load(1); if (this.tabType === 1) {
this.entst?.load(1);
} else {
this.adminst?.load(1);
}
} }
beforeReq = (requestOptions: STRequestOptions) => { beforeReq = (requestOptions: STRequestOptions) => {
@ -205,7 +212,7 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone
if (res) { if (res) {
this.service.msgSrv.success(status === 20 ? '审核通过' : '驳回成功'); this.service.msgSrv.success(status === 20 ? '审核通过' : '驳回成功');
} }
this.st.load(1); this.entst.load(1);
}); });
} }
@ -214,13 +221,14 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone
} }
// 切换Tab // 切换Tab
changeTab(item: any) { changeTab(type: number) {
this.tabType = item.type; this.tabType = type;
this.sf?.reset(); if (this.tabType === 1) {
this.st.data = this.tabType === 1 ? this.service.$api_get_freight_list : this.service.$api_get_enterprise_admin_list; this.schema = this.initSF();
setTimeout(() => { } else {
this.st.load(1); this.schema = this.initAdminSF();
}, 100); }
this.search();
} }
private adminAuditUser(params: any, modal: any) { private adminAuditUser(params: any, modal: any) {
@ -228,7 +236,7 @@ export class FreightComponentsEnterpriseAuditComponent extends BasicTableCompone
if (res) { if (res) {
this.service.msgSrv.success('审核成功'); this.service.msgSrv.success('审核成功');
modal.destroy(); 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'
}
}
}
};
}
} }

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { SFComponent, SFSchema, SFUISchema } from '@delon/form'; import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
import { Subject } from 'rxjs'; import { Subject, Subscription } from 'rxjs';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
@ -11,10 +11,16 @@ export class SearchDrawerService {
initEvent = new Subject<any>(); initEvent = new Subject<any>();
visible = false; visible = false;
drawer: Subscription[] = [];
constructor() {} constructor() {}
create(defaultValue: Record<string, any>, newSchema?: SFSchema, newUI?: SFUISchema) { create(defaultValue: Record<string, any>, newSchema?: SFSchema, newUI?: SFUISchema) {
this.createEvent.next({ defaultValue, newSchema, newUI }); this.createEvent.next({ defaultValue, newSchema, newUI });
return this; return this;
} }
unsubscribe() {
this.drawer.forEach(sub => sub.unsubscribe());
}
} }