Files
bbq/src/app/routes/usercenter/components/driver/captain/captain.component.ts
Taric Xin d971d09d12 reuse
2022-05-09 11:23:33 +08:00

227 lines
6.6 KiB
TypeScript

import { Component, OnInit, ViewChild } from '@angular/core';
import { Router } from '@angular/router';
import { STColumn, STComponent, STData } from '@delon/abc/st';
import { SFSchema } from '@delon/form';
import { ModalHelper } from '@delon/theme';
import { DynamicSettingModalComponent, SearchDrawerService } from '@shared';
import { NzModalService } from 'ng-zorro-antd/modal';
import { BasicTableComponent } from 'src/app/routes/commom';
import { UsermanageService } from '../../../services/usercenter.service';
import { CtcCaptatinAddComponent } from './add/add.component';
@Component({
selector: 'app-usercenter-components-driver-captain',
templateUrl: './captain.component.html',
styleUrls: ['../../../../commom/less/commom-table.less']
})
export class UserCenterComponentsDriverCaptainComponent extends BasicTableComponent implements OnInit {
schema: SFSchema = this.initSF();
columns: STColumn[] = this.initST();
@ViewChild('st', { static: false }) st!: STComponent;
@ViewChild('promoterModal', { static: false })
promoterModal!: any;
promotersTelephone = '';
constructor(
public service: UsermanageService,
private modal: NzModalService,
private router: Router,
private modalHelper: ModalHelper,
public searchDrawerService: SearchDrawerService
) {
super(searchDrawerService);
}
search() {
this.st?.load(1);
}
/**
* 查询参数
*/
get reqParams() {
const params: any = {
...(this.sf && this.sf?.value)
};
if (this.sf?.value.effectiveDate) {
params.effectiveDateStart = this.sf?.value.effectiveDate[0];
params.effectiveDateEnd = this.sf?.value.effectiveDate[1];
}
delete params.effectiveDate;
delete params.expand;
return params;
}
get selectedRows() {
return this.st?.list.filter(item => item.checked) || [];
}
ngOnInit() {}
dataProcess(data: STData[]): STData[] {
return data.map((i, index) => {
i.showSortFlag = false;
return i;
});
}
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: '4',
businessId: item.id
},
nzFooter: null
});
}
exportList() {
const params = this.reqParams;
this.service.downloadFile(this.service.$api_export_driver_cap, { ...params, pageSize: -1 });
}
private initSF(): SFSchema {
return {
properties: {
expand: {
type: 'boolean',
ui: {
hidden: true
}
},
name: { title: '车队长姓名', type: 'string', ui: { placeholder: '请输入', showRequired: false } },
mobile: {
title: '手机号',
type: 'string',
maxLength: 11,
ui: {
placeholder: '请输入'
}
},
identityNo: {
title: '身份证号',
type: 'string',
ui: {
placeholder: '请输入'
}
},
promotersTelephone: {
title: '业务员手机号',
type: 'string',
maxLength: 11,
ui: {
placeholder: '请输入'
}
},
identityStatus: {
type: 'string',
title: '实名认证状态',
enum: [
{ label: '全部', value: '' },
{ label: '待审核', value: 0 },
{ label: '审核通过', value: 1 },
{ label: '驳回', value: 2 }
],
default: '',
ui: {
widget: 'select'
}
},
source: {
type: 'string',
title: '注册渠道',
enum: [
{ label: '全部', value: '' },
{ label: '用户注册', value: 1 },
{ label: '货主添加', value: 2 },
{ label: '运营添加', value: 3 }
],
default: '',
ui: {
widget: 'select'
}
}
}
};
}
private initST(): STColumn[] {
return [
// { title: '', type: 'checkbox', className: 'text-center' },
{ title: '车队长姓名', className: 'text-center', index: 'name' },
{ title: '手机号', className: 'text-center', index: 'mobile' },
{ title: '身份证号', className: 'text-center', index: 'identityNo' },
{
title: '实名认证状态',
className: 'text-center',
index: 'identityStatus',
type: 'badge',
badge: {
'-1': { text: '未提交', color: 'default' },
0: { text: '待审核', color: 'processing' },
1: { text: '审核通过', color: 'success' },
2: { text: '驳回', color: 'warning' }
}
},
{ title: '推广业务员', className: 'text-center', render: 'promotersTelephone' },
{ title: '注册渠道', className: 'text-center', index: 'source', type: 'enum', enum: { 1: '用户注册', 2: '货主添加', 3: '运营添加' } },
{ title: '注册时间', className: 'text-center', index: 'createTime' },
{
title: '操作',
width: '170px',
className: 'text-center',
buttons: [
{
text: '查看',
click: item => {
this.router.navigate(['/usercenter/driver/captain/detail', item.appUserId]);
},
acl: { ability: ['USERCENTER-DRIVER-CAPTAIN-view'] }
}
// {
// text: '基础设置',
// click: item => this.settingAction(item),
// acl: { ability: ['USERCENTER-DRIVER-CAPTAIN-basicSetting'] }
// }
]
}
];
}
/**
* 新增单个实例
*/
add() {
this.modalHelper.create(CtcCaptatinAddComponent, { i: { id: '' } }, { size: 900 }).subscribe(res => {
this.st.reload();
});
}
}