车辆对接

This commit is contained in:
wangshiming
2021-12-21 11:05:39 +08:00
parent 6dfc1e75fc
commit f95e9336b6
13 changed files with 1114 additions and 31 deletions

View File

@ -1,10 +1,19 @@
import { Component, OnInit } from '@angular/core';
import { STColumn } from '@delon/abc/st';
import { SFSchema, SFUISchema } from '@delon/form';
import { _HttpClient } from '@delon/theme';
import { Component, OnInit, ViewChild } from '@angular/core';
import { STChange, STColumn, STColumnBadge, STComponent, STData } from '@delon/abc/st';
import { SFComponent, SFSchema, SFUISchema } from '@delon/form';
import { ModalHelper, _HttpClient } from '@delon/theme';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { SupplyManagementService } from '../../services/supply-management.service';
import { SupplyManagementAddDriversComponent } from '../add-drivers/add-drivers.component';
import { CarAddmodalComponent } from '../addmodal/addmodal.component';
const BADGE: STColumnBadge = {
1: { text: '空闲', color: 'success' },
2: { text: '未实名', color: 'error' },
3: { text: '在途', color: 'warning' },
};
@Component({
selector: 'app-supply-management-assigned-car',
@ -16,15 +25,38 @@ export class SupplyManagementAssignedCarComponent implements OnInit {
schema: SFSchema = {};
ui: SFUISchema = {};
columns: STColumn[] = [];
@ViewChild('st') st!: STComponent;
@ViewChild('sf', { static: false }) sf!: SFComponent;
status: string = 'anew';
url = ''; // 请求的api地址
params: any = {}; // 传进来的参数
cardBADGE: STColumnBadge | any = {
0: { text: '空闲', color: 'success' },
1: { text: '在途', color: 'warning' },
2: { text: '未认证', color: 'error' },
};
selectedRows: any = null; // 已选行
constructor(
private modal: NzModalRef,
private msgSrv: NzMessageService,
public service: SupplyManagementService
public service: SupplyManagementService,
private modalHelper: ModalHelper,
) {
this.initSF();
this.initSt();
}
/**
* 查询参数
*/
get reqParams() {
return {
...this.sf?.value,
};
}
/**
* 初始化查询表单
*/
@ -32,24 +64,24 @@ export class SupplyManagementAssignedCarComponent implements OnInit {
this.schema = {
properties: {
_$expand: { type: 'boolean', ui: { hidden: true } },
no: {
nameOrPhone: {
type: 'string',
title: '',
ui: {
placholder: '请输入司机姓名/手机号'
placeholder: '请输入司机姓名/手机号'
}
},
no2: {
carNo: {
type: 'string',
title: '',
ui: {
placholder: '请输入车牌号'
placeholder: '请输入车牌号'
}
},
},
type: 'object',
};
this.ui = { '*': { spanLabelFixed: 80, grid: { span: 12, gutter: 4 } } };
this.ui = { '*': { spanLabelFixed: 10, grid: { span: 8, gutter: 1 } } };
}
/**
@ -57,25 +89,79 @@ export class SupplyManagementAssignedCarComponent implements OnInit {
*/
initSt() {
this.columns = [
{ width: 50, type: 'checkbox', className: 'text-center' },
{ title: '司机姓名', width: 80, index: 'owner', className: 'text-center' },
{ title: '手机号', index: 'goodsQuantity', width: 100, className: 'text-center' },
{ title: '车牌号', width: 100, index: 'carNo', className: 'text-center' },
{ title: '状态', index: 'status', width: 100, className: 'text-center' },
{ width: 50, type: 'radio', className: 'text-center' },
{ title: '司机姓名', width: 120, index: 'name', className: 'text-center' },
{ title: '手机号', index: 'telephone', width: 200, className: 'text-center' },
{ title: '车队长', render: 'carCaptain', className: 'text-center' },
{ title: '指定车辆', width: 300, render: 'carId', className: 'text-center' },
{ title: '状态', render: 'driverStatus', className: 'text-center', type: 'badge', badge: BADGE },
];
}
ngOnInit(): void {
}
save(value: any): void {
this.service.request(`/user/${this.record.id}`, value).subscribe(res => {
this.msgSrv.success('保存成功');
this.modal.close(true);
dataProcess(data: STData[]): STData[] {
return data.map((i, index) => {
i.carId = '';
i.disabled = i.carStatus === '1';
const defaultCar = i?.userCarLicenseDesensitizationVOList?.filter((item: any) => item.isDefault);
if (defaultCar.length > 0) {
i.carId = defaultCar[0].carId;
}
return i;
});
}
save(): void {
console.log(this.selectedRows);
if (this.selectedRows) {
const { carId, userId: driverId } = this.selectedRows;
const params: any = { carId, driverId };
this.service.request(this.url, { ...params, ...this.params }).subscribe((res: any) => {
if (res) {
this.modal.close(res);
}
})
}
}
changeSt(e: STChange): void {
if (e?.type === 'loaded') this.selectedRows = null;
if (e?.type === 'radio') this.selectedRows = e?.radio;
console.log(this.selectedRows);
}
/**
* 添加司机
* @param item
*/
addDriver() {
this.modalHelper.create(CarAddmodalComponent, {}, { size: 900, modalOptions: { nzMaskClosable: false } }).subscribe((res) => {
if (res) this.st.reload();
});
}
/**
* 设置车队长
*/
setCarCaptain(item: any) {
this.modalHelper.create(SupplyManagementAddDriversComponent, { dirvierInfo: item }, {
size: 900,
modalOptions: { nzMaskClosable: false, nzTitle: '设置' }
}
).subscribe((res) => {
if (res) this.st.reload();
});
}
close(): void {
this.modal.destroy();
}
reset() {
this.sf.reset();
this.st.load(1);
}
}