车辆对接
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { STChange, STColumn, STComponent, STData, STRequestOptions } from '@delon/abc/st';
|
||||
import { SFComponent, SFSchema, SFSelectWidgetSchema, SFUISchema } from '@delon/form';
|
||||
import { ModalHelper } from '@delon/theme';
|
||||
import { processSingleSort } from '@shared';
|
||||
import { NzDrawerRef, NzDrawerService } from 'ng-zorro-antd/drawer';
|
||||
import { NzModalService } from 'ng-zorro-antd/modal';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal';
|
||||
import { SupplyManagementAddDriversComponent } from 'src/app/routes/supply-management/components/add-drivers/add-drivers.component';
|
||||
|
||||
import { SupplyManagementService } from '../../services/supply-management.service';
|
||||
import { CarAddmodalComponent } from '../addmodal/addmodal.component';
|
||||
import { PublishchooseFamifiarAddComponent } from './add/add.component';
|
||||
import { PublishchooseFamifiarSetCaptainComponent } from './set-captain/set-captain.component';
|
||||
|
||||
@ -18,6 +20,7 @@ import { PublishchooseFamifiarSetCaptainComponent } from './set-captain/set-capt
|
||||
export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
schema: SFSchema = {};
|
||||
columns!: STColumn[];
|
||||
i: any;
|
||||
ui!: SFUISchema;
|
||||
sfExpand = false;
|
||||
@ViewChild('st', { static: false })
|
||||
@ -30,45 +33,22 @@ export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
columns2!: STColumn[];
|
||||
st2Data: STData[] = [];
|
||||
|
||||
@Input()
|
||||
submitUrl = '';
|
||||
|
||||
@Input()
|
||||
submitParams = {};
|
||||
|
||||
constructor(
|
||||
private modal: NzModalService,
|
||||
private modal: NzModalRef,
|
||||
public router: Router,
|
||||
public ar: ActivatedRoute,
|
||||
private drawerService: NzDrawerService,
|
||||
public service: SupplyManagementService,
|
||||
private modalService: NzModalService
|
||||
private modalService: NzModalService,
|
||||
private modalHelper: ModalHelper
|
||||
) {}
|
||||
|
||||
dataInfo: STData[] = [
|
||||
{
|
||||
id: '1',
|
||||
name1: '1111',
|
||||
name2: '2222',
|
||||
name3: '3333',
|
||||
name4: '4444',
|
||||
name5: '5555',
|
||||
name6: '6666',
|
||||
name7: '7777',
|
||||
name8: '8888',
|
||||
name9: '9999',
|
||||
name10: '1010',
|
||||
name11: '1012',
|
||||
name12: '1013'
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
name1: '9999',
|
||||
name2: '8888',
|
||||
name3: '7777',
|
||||
name4: '6666',
|
||||
name5: '5555',
|
||||
name6: '4444',
|
||||
name7: '3333',
|
||||
name8: '2222',
|
||||
name9: '1111'
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*/
|
||||
@ -78,10 +58,6 @@ export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
isManage: 0
|
||||
};
|
||||
}
|
||||
|
||||
get selectedRows() {
|
||||
return this.st?.list.filter(item => item.checked) || [];
|
||||
}
|
||||
ngOnInit() {
|
||||
this.initSF();
|
||||
this.initST();
|
||||
@ -118,21 +94,28 @@ export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
this.columns = [
|
||||
{
|
||||
title: '司机姓名',
|
||||
index: 'name1'
|
||||
index: 'name'
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
index: 'name2'
|
||||
index: 'telephone'
|
||||
},
|
||||
{
|
||||
title: '指定车辆',
|
||||
index: 'name3',
|
||||
render: 'name3',
|
||||
width: '180px'
|
||||
width: 130,
|
||||
render: 'userCarLicenseDesensitizationVOList'
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
index: 'name4'
|
||||
className: 'text-center',
|
||||
index: 'certificationStatus',
|
||||
type: 'badge',
|
||||
badge: {
|
||||
'-1': { text: '未提交', color: 'default' },
|
||||
0: { text: '待审核', color: 'processing' },
|
||||
1: { text: '已认证', color: 'success' },
|
||||
2: { text: '未认证', color: 'error' }
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
@ -140,8 +123,9 @@ export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
buttons: [
|
||||
{
|
||||
text: '选择',
|
||||
iif: item => item.showChoose !== 'false',
|
||||
click: (_record, _modal, _instance) => this.choose(_record)
|
||||
iif: item => item.showChoose != false,
|
||||
click: (_record, _modal, _instance) => this.choose(_record),
|
||||
iifBehavior: 'disabled'
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -152,21 +136,22 @@ export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
this.columns2 = [
|
||||
{
|
||||
title: '司机姓名',
|
||||
index: 'name1'
|
||||
index: 'name'
|
||||
},
|
||||
{
|
||||
title: '手机号',
|
||||
index: 'name2'
|
||||
index: 'telephone',
|
||||
width: '120px'
|
||||
},
|
||||
{
|
||||
title: '车队长',
|
||||
index: 'name3',
|
||||
render: 'name3',
|
||||
width: '180px'
|
||||
render: 'captain',
|
||||
width: '200px'
|
||||
},
|
||||
{
|
||||
title: '指定车辆',
|
||||
index: 'name4'
|
||||
index: 'carNo',
|
||||
width: '130px'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
@ -183,36 +168,42 @@ export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
|
||||
// 选择
|
||||
choose(record: STData) {
|
||||
this.st2Data.push({ ...record });
|
||||
this.st2.load();
|
||||
this.st.setRow(record, { showChoose: 'false' });
|
||||
this.st2Data = [...this.st2Data, ...[record]];
|
||||
this.st.setRow(record, { showChoose: false });
|
||||
}
|
||||
// 移除
|
||||
remove(record: STData, value1: any, value2: any) {
|
||||
this.st.setRow(record, { showChoose: 'true' });
|
||||
let index = (this.st2Data || []).findIndex(obj => obj.id === record.id);
|
||||
this.st2Data.splice(index, 1);
|
||||
this.st2.load();
|
||||
|
||||
const stData = this.st.data;
|
||||
let index2 = (stData as any).findIndex((obj: any) => obj.id === record.id);
|
||||
this.st.setRow(index2, { showChoose: 'true' });
|
||||
remove(record: STData, value1: any, comp: any) {
|
||||
const index = this.st?.list.findIndex((obj: any) => obj.appUserId === record.appUserId);
|
||||
if (index >= 0) {
|
||||
comp!.removeRow(record);
|
||||
this.st2Data = this.st2Data.filter(item => item.appUserId !== record.appUserId);
|
||||
this.st.setRow(index, { showChoose: true });
|
||||
}
|
||||
}
|
||||
|
||||
//添加司机
|
||||
add() {
|
||||
this.modalService.create({
|
||||
nzTitle: '添加司机',
|
||||
nzContent: PublishchooseFamifiarAddComponent
|
||||
this.modalHelper.create(CarAddmodalComponent, {}, { size: 900, modalOptions: { nzMaskClosable: false } }).subscribe(res => {
|
||||
if (res) this.st.reload();
|
||||
});
|
||||
}
|
||||
|
||||
//设置车队长
|
||||
setCaptain(record: STData) {
|
||||
this.modalService.create({
|
||||
nzTitle: '设置车队长',
|
||||
nzContent: PublishchooseFamifiarSetCaptainComponent
|
||||
});
|
||||
setCaptain(record: STData, index: any) {
|
||||
this.modalHelper
|
||||
.create(
|
||||
SupplyManagementAddDriversComponent,
|
||||
{ dirvierInfo: record },
|
||||
{
|
||||
size: 900,
|
||||
modalOptions: { nzMaskClosable: false, nzTitle: '设置' }
|
||||
}
|
||||
)
|
||||
.subscribe(res => {
|
||||
if (res) {
|
||||
this.st2.setRow(index, { captainName: res.name, captainPhone: res.mobile, captainAppUserId: res.appUserId });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -229,16 +220,35 @@ export class PublishGoodsChooseFamifiarComponent implements OnInit {
|
||||
this.sf?.setValue('/_expand', this.sfExpand);
|
||||
}
|
||||
|
||||
// 排序
|
||||
reqProcess(requestOptions: STRequestOptions): STRequestOptions {
|
||||
return processSingleSort(requestOptions);
|
||||
// 熟车请求数据处理
|
||||
reqProcess(data: STData[]): STData[] {
|
||||
return data.map((i, index) => {
|
||||
const defaultCart = i.userCarLicenseDesensitizationVOList.find((cart: any) => cart.isDefault);
|
||||
return { ...i, default: defaultCart || '' };
|
||||
});
|
||||
}
|
||||
|
||||
cancel() {}
|
||||
|
||||
ok() {}
|
||||
|
||||
carChange(event: any, item: STData) {
|
||||
this.st.setRow(item, { name3: event });
|
||||
cancel() {
|
||||
this.modal.destroy();
|
||||
}
|
||||
|
||||
ok() {
|
||||
if (this.st2._data?.length <= 0) {
|
||||
this.service.msgSrv.warning('请选择熟车');
|
||||
return;
|
||||
}
|
||||
const data = this.st2._data.map(item => ({
|
||||
driverId: item.appUserId,
|
||||
carId: item.default?.carId || null,
|
||||
carCaptainId: item.captainAppUserId
|
||||
}));
|
||||
this.service.request(this.submitUrl, { ...this.submitParams, carDriverIds: data }).subscribe((rs: any) => {
|
||||
if (rs) {
|
||||
this.service.msgSrv.success('指派成功');
|
||||
this.modal.destroy(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
carChange(event: any, item: STData) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user