import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { STChange, STColumn, STComponent, STData, STRequestOptions } from '@delon/abc/st'; import { SFComponent, SFSchema, SFUISchema } from '@delon/form'; import { NzModalService } from 'ng-zorro-antd/modal'; import { UsermanageService } from '../../../services/usercenter.service'; import { AuditAdminComponent } from './audit-admin/audit-admin.component'; @Component({ selector: 'app-Freight-components-enterprise-audit', templateUrl: './enterprise-audit.component.html', styleUrls: ['./enterprise-audit.component.less'] }) export class FreightComponentsEnterpriseAuditComponent implements OnInit { _$expand = false; ui: SFUISchema = { '*': { spanLabelFixed: 90, grid: { lg: 8, md: 12, sm: 12, xs: 24 } } }; schema: SFSchema = this.initSF(); enterColumns: STColumn[] = this.initEnterST(); adminColumns: STColumn[] = this.initAdminST(); @ViewChild('st', { static: false }) st!: STComponent; @ViewChild('sf', { static: false }) sf!: SFComponent; tabType = 1; tabs = [ { name: '企业审核', type: 1, isActived: false }, { name: '企业管理员审核', type: 2, isActived: false } ]; constructor(public service: UsermanageService, private router: Router, private modal: NzModalService) {} beforeReq = (requestOptions: STRequestOptions) => { if (this.sf) { Object.assign(requestOptions.body, { ...this.sf.value }); } Object.assign(requestOptions.body, { flag: this.tabType, listSource: 2 }); return requestOptions; }; /** * 伸缩查询条件 */ expandToggle(status: boolean) { this._$expand = status; this.sf?.setValue('/expand', this._$expand); } /** * 重置表单 */ resetSF() { this.sf.reset(); this._$expand = false; } /** * 程序初始化入口 */ ngOnInit() {} /** * 查看详情 */ ViewAdimin(record: any, isReadOnly = false) { const modal = this.modal.create({ nzTitle: isReadOnly ? '查看' : '审核', nzContent: AuditAdminComponent, nzWidth: 650, nzComponentParams: { i: { ...record }, isReadOnly }, nzFooter: isReadOnly ? [] : [ { label: '驳回', type: 'primary', onClick: instance => { if (!instance?.sf.value.approvalOpinion) { this.service.msgSrv.warning('请填写备注'); return false; } this.adminAuditUser( { id: record.id, approvalStatus: '30', approvalOpinion: instance?.sf.value.approvalOpinion }, modal ); return; } }, { label: '通过', type: 'primary', onClick: () => { this.adminAuditUser( { id: record.id, approvalStatus: '20' }, modal ); } } ] }); modal.afterClose.subscribe(res => { // this.st.load(1); }); } View(record: any) { this.router.navigate([`/usercenter/freight/enterprise/detail/${record.id}`]); } // 切换Tab changeTab(item: any) { this.tabType = item.type; this.expandToggle(false); 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); } private adminAuditUser(params: any, modal: any) { this.service.request(this.service.$api_audit_enterprise_admin, params).subscribe(res => { if (res) { this.service.msgSrv.success('审核成功'); modal.destroy(); this.st.load(1); } }); } exportList() { const params = { ...this.sf.value, flag: this.tabType, listSource: 2 }; this.service.downloadFile(this.service.$api_export_enterprise, params); } /** * 初始化数据列表 */ initEnterST(): STColumn[] { return [ { title: '企业名称', className: 'text-center', index: 'enterpriseName' }, { title: '联系人', className: 'text-center', index: 'contacter' }, { title: '手机号', className: 'text-center', index: 'mobile' }, { title: '申请时间', className: 'text-center', index: 'createTime' }, { title: '审核状态', className: 'text-center', index: 'approvalStatus', type: 'badge', badge: { 10: { text: '待审核', color: 'processing' }, 15: { text: '已撤销', color: 'processing' }, 20: { text: '已成功', color: 'success' }, 30: { text: '审核失败', color: 'warning' } } }, { title: '常用服务', className: 'text-center', index: 'oftenUsedServices', type: 'enum', enum: { 10: '整车发货', 20: '大宗发货' } }, { title: '推广业务员', className: 'text-center', index: 'promotersTelephone' }, { title: '操作', fixed: 'right', width: '180px', className: 'text-center', buttons: [{ text: '查看', click: _record => this.View(_record), acl: { ability: ['USERCENTER-FREIGHT-ENTERPRISE-view'] } }] } ]; } initAdminST(): STColumn[] { return [ { title: '企业名称', className: 'text-center', index: 'enterpriseName' }, { title: '当前管理员', className: 'text-center', index: 'oldAdminName' }, { title: '当前管理员手机号', className: 'text-center', index: 'oldAdminMobile' }, { title: '转授对象', className: 'text-center', index: 'newAdminName' }, { title: '转授对象手机号', className: 'text-center', index: 'newAdminMobile' }, { title: '申请时间', className: 'text-center', index: 'createTime' }, { title: '状态', className: 'text-center', index: 'approvalStatus', type: 'badge', badge: { 10: { text: '待审核', color: 'processing' }, 20: { text: '已成功', color: 'success' }, 30: { text: '已驳回', color: 'warning' } } }, { title: '操作', fixed: 'right', width: '180px', className: 'text-center', buttons: [ { text: '审核', click: _record => this.ViewAdimin(_record), iif: (item: any) => item.approvalStatus === 10 }, { text: '查看', click: _record => this.ViewAdimin(_record, true) } ] } ]; } /** * 初始化查询表单 */ initSF(): SFSchema { return { properties: { expand: { type: 'boolean', ui: { hidden: true } }, enterpriseName: { title: '企业名称', type: 'string', ui: { placeholder: '请输入' } }, contactName: { title: '联系人', type: 'string', ui: { placeholder: '请输入', visibleIf: { expand: (value: boolean) => this.tabType === 1 } } }, name: { title: '管理员', type: 'string', ui: { placeholder: '请输入', visibleIf: { expand: (value: boolean) => this.tabType !== 1 } } }, 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', visibleIf: { expand: (value: boolean) => value } } } } }; } }