import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { STColumn, STColumnBadge, STComponent, STData } from '@delon/abc/st'; import { SFComponent, SFDateWidgetSchema, SFSchema, SFUISchema } from '@delon/form'; import { DynamicSettingModalComponent } from '@shared'; import { NzModalService } from 'ng-zorro-antd/modal'; import { AccountDetailComponent } from 'src/app/shared/components/account-detail/account-detail.component'; import { UsermanageService } from '../../services/usercenter.service'; @Component({ selector: 'app-usercenter-components-driver', styleUrls: ['./driver.component.less'], templateUrl: './driver.component.html' }) export class UserCenterComponentsDriverComponent implements OnInit { _$expand = false; @ViewChild('st', { static: false }) st!: STComponent; @ViewChild('sf', { static: false }) sf!: SFComponent; ui: SFUISchema = { '*': { spanLabelFixed: 120, grid: { lg: 8, md: 12, sm: 12, xs: 24 }, enter: () => this.st.load() } }; schema: SFSchema = this.initSF(); columns: STColumn[] = this.initST(); @ViewChild('promoterModal', { static: false }) promoterModal!: any; promotersTelephone = ''; resourceStatus: any = 10; constructor(public service: UsermanageService, private modal: NzModalService, private router: Router, private ar: ActivatedRoute) {} /** * 查询参数 */ get reqParams() { const params: any = { ...(this.sf && this.sf.value), auditStatus: this.resourceStatus }; if (this.sf?.value.effectiveDate) { Object.assign(params, { createTime: { start: this.sf?.value.effectiveDate[0], end: this.sf?.value.effectiveDate[1] } }); // params.effectiveDateStart = this.sf?.value.effectiveDate[0]; // params.effectiveDateEnd = this.sf?.value.effectiveDate[1]; } delete params.effectiveDate; delete params.expand; return params; } ngOnInit() { this.ar.url.subscribe(params => { this.st?.load(1); }); } selectChange(e: any) { this.resourceStatus = e; setTimeout(() => { this.st.load(); }, 200); } addPromoter(item?: any) { this.promotersTelephone = item?.promotersTelephone; const modal = this.modal.create({ nzTitle: '推广业务员', nzContent: this.promoterModal, nzOnOk: () => { if (!!!this.promotersTelephone) { return false; } if (typeof this.promotersTelephone === 'string' && !/(^1\d{10}$)/.test(this.promotersTelephone)) { this.service.msgSrv.error('手机格式错误'); return false; } this.service .request(this.service.$api_add_user_salesman, { userId: item.userId, mobile: this.promotersTelephone }) .subscribe(res => { if (res) { this.service.msgSrv.success(item?.promotersTelephone ? '添加推广员成功' : '修改推广员成功'); } this.st.load(); }); return; } }); } settingAction(item?: any) { this.modal.create({ nzTitle: '基础设置', nzContent: DynamicSettingModalComponent, nzWidth: 900, nzComponentParams: { extendType: '3', businessId: item.id }, nzFooter: null }); } showAccountDetail(item: any) { this.modal.create({ nzTitle: '资金账户', nzContent: AccountDetailComponent, nzNoAnimation: true, nzWidth: 600, nzComponentParams: { isCanCreate: true }, nzFooter: null }); } expandToggle() { this._$expand = !this._$expand; this.sf?.setValue('/expand', this._$expand); } /** * 重置表单 */ resetSF() { this.sf.reset(); this._$expand = false; } exportList() { const params = this.reqParams; this.service.downloadFile(this.service.$api_export_driver, params); } private initSF(): SFSchema { return { properties: { expand: { type: 'boolean', ui: { hidden: true } }, name: { title: '司机姓名', type: 'string', ui: { placeholder: '请输入', showRequired: false } }, mobile: { title: '手机号', type: 'string', format: 'mobile', maxLength: 11, ui: { placeholder: '请输入' } }, identityStatus: { type: 'string', title: '实名状态', enum: [ { label: '全部', value: '' }, { label: '待审核', value: 0 }, { label: '通过', value: 1 }, { label: '驳回', value: 2 } ], default: '', ui: { widget: 'select' } }, driverLicenseStatus: { type: 'string', title: '驾驶证状态', enum: [ { label: '全部', value: '' }, { label: '待审核', value: 10 }, { label: '审核通过', value: 20 }, { label: '驳回', value: 30 }, { label: '证件过期', value: 40 } ], default: '', ui: { widget: 'select', visibleIf: { expand: (value: boolean) => value } } }, practiceSenioritLicenseStatus: { type: 'string', title: '从业资格证状态', enum: [ { label: '全部', value: '' }, { label: '待审核', value: 10 }, { label: '审核通过', value: 20 }, { label: '驳回', value: 30 }, { label: '证件过期', value: 40 } ], default: '', ui: { widget: 'select', visibleIf: { expand: (value: boolean) => value } } }, promotersTelephone: { title: '推广业务员', type: 'string', format: 'mobile', maxLength: 11, ui: { placeholder: '请输入手机号', visibleIf: { expand: (value: boolean) => value } } }, source: { type: 'string', title: '注册渠道', enum: [ { label: '全部', value: '' }, { label: '用户注册', value: 1 }, { label: '货主添加', value: 2 } ], default: '', ui: { widget: 'select', visibleIf: { expand: (value: boolean) => value } } }, effectiveDate: { title: '申请时间', type: 'string', ui: { widget: 'date', mode: 'range', format: 'yyyy-MM-dd', visibleIf: { expand: (value: boolean) => value } } as SFDateWidgetSchema } } }; } private initST(): STColumn[] { return [ { title: '司机姓名', className: 'text-center', index: 'name' }, { title: '手机号', className: 'text-center', index: 'mobile' }, { title: '当前车辆', className: 'text-center', index: 'carNo' }, { title: '实名认证状态', className: 'text-center', index: 'identityStatus', type: 'badge', badge: { '-1': { text: '未提交', color: 'default' }, 0: { text: '待审核', color: 'default' }, 1: { text: '通过', color: 'success' }, 2: { text: '驳回', color: 'warning' } } }, { title: '驾驶证状态', className: 'text-center', index: 'driverLicenseStatus', type: 'badge', badge: { '-1': { text: '未提交', color: 'default' }, 10: { text: '待审核', color: 'default' }, 20: { text: '审核通过', color: 'success' }, 30: { text: '驳回', color: 'warning' }, 40: { text: '证件过期', color: 'error' } } }, { title: '从业资格证状态', className: 'text-center', index: 'practiceSenioritLicenseStatus', type: 'badge', badge: { '-1': { text: '未提交', color: 'default' }, 10: { text: '待审核', color: 'default' }, 20: { text: '审核通过', color: 'success' }, 30: { text: '驳回', color: 'warning' }, 40: { text: '证件过期', color: 'error' } } }, { title: '推广业务员', className: 'text-center', render: 'promotersTelephone' }, { title: '注册渠道', className: 'text-center', index: 'source', type: 'enum', enum: { 1: '用户注册', 2: '货主添加' } }, { title: '注册时间', className: 'text-center', index: 'createTime' }, { title: '操作', width: '170px', className: 'text-center', buttons: [ { text: '查看', click: item => { this.router.navigate(['./detail', item.appUserId], { relativeTo: this.ar }); // this.router.navigate(['./view', item.id], { relativeTo: this.ar, queryParams: { tenantId: item.tenantId } }); } }, { text: '基础设置', click: item => this.settingAction(item) }, { text: '资金账户', click: item => this.showAccountDetail(item) } ] } ]; } }