This commit is contained in:
wangshiming
2022-03-02 14:16:26 +08:00
parent c16b7e82c8
commit 0ae6f030be
4 changed files with 114 additions and 55 deletions

View File

@ -1,66 +1,49 @@
<!--
* @Description :
* @Version : 1.0
* @Author : Shiming
* @Date : 2021-12-03 11:10:14
* @LastEditors : Shiming
* @LastEditTime : 2022-01-18 17:27:30
* @FilePath : \\tms-obc-web\\src\\app\\routes\\supply-management\\components\\assigned-car\\assigned-car.component.html
* Copyright (C) 2022 huzhenhong. All rights reserved.
-->
<div>
<div nz-row>
<div nz-col nzSpan="18">
<sf #sf [schema]="schema" mode="search" [ui]="ui" [compact]="true" (formSubmit)="st.load(1)" (formReset)="reset()"></sf>
</div>
<div nz-col nzSpan="6">
<button nz-button nzType="primary" style="margin-bottom: 24px" (click)="addDriver()"><i nz-icon nzType="plus"></i>添加司机</button>
<sf #sf [schema]="schema" mode="search" [ui]="ui" [compact]="true" (formSubmit)="st.load(1)"
(formReset)="reset()"></sf>
</div>
<!-- <div nz-col nzSpan="6">
<button nz-button nzType="primary" style="margin-bottom: 24px" (click)="addDriver()"><i nz-icon
nzType="plus"></i>添加司机</button>
</div> -->
</div>
<div>
<st
#st
[data]="service.$api_get_practice_car_list"
<st #st [data]="service.$api_get_practice_car_list"
[req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
[columns]="columns"
[res]="{ reName: { list: 'data.records', total: 'data.total' }, process: dataProcess }"
[columns]="columns" [res]="{ reName: { list: 'data.records', total: 'data.total' },process:dataProcess }"
[page]="{ show: true, showSize: true, pageSizes: [10, 20, 30, 50, 100, 200, 300, 500, 1000] }"
(change)="changeSt($event)"
>
(change)="changeSt($event)">
<ng-template st-row="carId" let-item let-index="index">
<nz-select [(ngModel)]="item.carId" style="width: 280px">
<nz-select [(ngModel)]="item.carId" style="width: 280px;">
<nz-option [nzValue]="''" nzLabel="不限"></nz-option>
<nz-option
[nzValue]="car.carId"
[nzLabel]="car.carNo"
*ngFor="let car of item.userCarLicenseDesensitizationVOList"
[nzCustomContent]="true"
>
<span>{{ car.carNo }} -</span>
<span>{{ car.carLength }}米,{{ car.carLoad }}吨 -</span>
<span *ngIf="car?.approvalStatus === 20 && !car.carStatus" class="text-success-dark">空闲</span>
<span *ngIf="car?.approvalStatus === 20 && car.carStatus" class="text-warning-dark">已被指派</span>
<nz-option [nzValue]="car.carId" [nzLabel]="car.carNo"
*ngFor="let car of item.userCarLicenseDesensitizationVOList" [nzCustomContent]="true">
<span>{{car.carNo}} -</span>
<span>{{car.carLength}}米,{{car.carLoad}}吨 -</span>
<span *ngIf="car?.approvalStatus === 20 && !car.carStatus " class="text-success-dark">空闲</span>
<span *ngIf="car?.approvalStatus === 20 && car.carStatus " class="text-warning-dark">在途</span>
<span *ngIf="car?.approvalStatus !== 20" class="text-red-dark">未认证</span>
<!-- <span [ngClass]="cardBADGE[car.carStatus]?.color">{{cardBADGE[car.carStatus]?.text}}</span> -->
</nz-option>
</nz-select>
</ng-template>
<ng-template st-row="carCaptain" let-item let-index>
<span>{{ item.captainName }} {{ item.captainPhone }}</span>
<a (click)="setCarCaptain(item)">设置</a>
<span>{{item.captainName}} {{item.captainPhone}}</span>
<a (click)="verifyCanSetCarCaptain(item)">设置</a>
</ng-template>
<ng-template st-row="driverStatus" let-item let-index>
<span *ngIf="item?.certificationStatus === 1 && item.driverStatus === 0" class="text-success-dark">空闲</span>
<span *ngIf="item?.certificationStatus === 1 && item.driverStatus === 1" class="text-warning-dark">已被指派</span>
<span *ngIf="item?.certificationStatus === 1 && item.driverStatus === 1" class="text-warning-dark">在途</span>
<span *ngIf="item?.certificationStatus !== 1" class="text-red-dark">未认证</span>
</ng-template>
</st>
</div>
<div class="modal-footer">
<button nz-button type="button" (click)="close()">关闭</button>
<button nz-button type="submit" nzType="primary" (click)="save()" [disabled]="!selectedRows" [nzLoading]="service.http.loading"
>发布并指派给司机</button
>
<button nz-button type="submit" nzType="primary" (click)="verifyVechicleStatus(params)" [disabled]="!selectedRows"
[nzLoading]="service.http.loading">发布并指派给司机</button>
</div>
</div>

View File

@ -2,8 +2,9 @@ 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 { EAEnvironmentService } from '@shared';
import { NzMessageService } from 'ng-zorro-antd/message';
import { NzModalRef } from 'ng-zorro-antd/modal';
import { NzModalRef, NzModalService } 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';
@ -29,7 +30,6 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
@ViewChild('st') st!: STComponent;
@ViewChild('sf', { static: false }) sf!: SFComponent;
status: string = 'anew';
type: any;
url = ''; // 请求的api地址
params: any = {}; // 传进来的参数
cardBADGE: STColumnBadge | any = {
@ -43,6 +43,8 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
private msgSrv: NzMessageService,
public service: SupplyManagementService,
private modalHelper: ModalHelper,
private envSrv: EAEnvironmentService,
private modalSrv: NzModalService
) {
this.initSF();
this.initSt();
@ -54,10 +56,14 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
get reqParams() {
return {
...this.sf?.value,
loadingTime: this.params?.loadingTime,
unloadingTime: this.params?.unloadingTime
};
}
/**
* 初始化查询表单
*/
@ -67,14 +73,15 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
_$expand: { type: 'boolean', ui: { hidden: true } },
nameOrPhone: {
type: 'string',
title: '',
title: '承运司机',
ui: {
placeholder: '请输入司机姓名/手机号'
}
},
carNo: {
type: 'string',
title: '',
title: '车牌号',
maxLength: 9,
ui: {
placeholder: '请输入车牌号'
}
@ -100,13 +107,12 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
}
ngOnInit(): void {
console.log(this.type)
}
dataProcess(data: STData[]): STData[] {
return data.map((i, index) => {
i.carId = '';
i.disabled = i.carStatus === '1';
i.disabled = (i?.certificationStatus === 1 && i.driverStatus === 1);
const defaultCar = i?.userCarLicenseDesensitizationVOList?.find((item: any) => item.isDefault);
if (defaultCar) {
i.carId = defaultCar?.carId;
@ -116,16 +122,15 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
}
save(): void {
if (this.selectedRows) {
const { carId, appUserId: driverId, captainAppUserId: carCaptainId } = this.selectedRows;
const params: any = { carId, driverId, carCaptainId };
this.service.request(this.url, { ...params, ...this.params }).subscribe((res: any) => {
if (res) {
this.modal.close(res);
}
})
const { carId, appUserId: driverId, captainAppUserId: carCaptainId } = this.selectedRows;
const params: any = { carId, driverId, carCaptainId };
this.service.request(this.url, { ...params, ...this.params }).subscribe((res: any) => {
if (res) {
this.service.msgSrv.success('指派成功!');
this.modal.close(res);
}
})
}
}
changeSt(e: STChange): void {
@ -143,10 +148,28 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
});
}
/**
* 校验司机是否能设置车队长
* @param item 当前对象
*/
verifyCanSetCarCaptain(item: any) {
this.service.request(this.service.$api_get_sys_config, [{ itemKey: 'sys.config.shipper.setCarCaptain', businessId: this.envSrv.env.enterpriseId }]).subscribe(res => {
if (res && res.length > 0) {
const { itemValue } = res[0];
if (itemValue !== '1') {
this.service.msgSrv.error('不可设置车队长!');
return;
}
this.setCarCaptain(item);
}
})
}
/**
* 设置车队长
*/
setCarCaptain(item: any) {
this.modalHelper.create(SupplyManagementAddDriversComponent, { dirvierInfo: item }, {
size: 900,
modalOptions: { nzMaskClosable: false, nzTitle: '设置' }
@ -168,4 +191,57 @@ export class SupplyManagementVehicleAssignedCarComponent implements OnInit {
this.sf.reset();
this.st.load(1);
}
/**
* 验证车辆的状态
*/
verifyVechicleStatus(params: any) {
if (this.selectedRows) {
const obj = this.status === 'anew' ? { resourceId: params.id } : { ...params };
const { carId, appUserId: driverId, captainAppUserId: carCaptainId } = this.selectedRows;
const carInfo: any = { carId, driverId, carCaptainId };
this.service.request(this.service.$api_verify_vehicle_status, { ...obj, ...carInfo }).subscribe(res => {
if (res) {
const { title, alert, subContent, content } = res;
switch (alert) {
case 'Error':
// if (code === '3' || code === '4' || code === '8') {
// this.error(title, subContent, '#CF3834');
// } else {
this.error(title, content, subContent);
break;
case 'Warn':
this.showConfirm(title, content, subContent);
break;
case 'Success':
this.save();
break;
}
}
})
}
}
error(title: string, content: string, subContent: string): void {
this.modalSrv.error({
nzTitle: title,
nzContent: `<span class="text-error-dark">${content ? content : ''}</span><span class="text-grey-dark">${subContent ? subContent : ''}</span>`,
nzOkText: '知道了'
});
}
showConfirm(title: string, content: string, subContent: string): void {
this.modalSrv.confirm({
nzTitle: title,
nzContent: `<span class="text-error-dark">${content ? content : ''}</span><span class="text-grey-dark">${subContent ? subContent : ''}</span>`,
nzOkText: '继续',
nzCancelText: '取消',
nzOnOk: () => {
this.save();
}
});
}
}

View File

@ -864,7 +864,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
//指派熟车
chooseFamifiar(item: any) {
console.log('999');
const modalRef = this.modalService.create({
nzTitle: '指派熟车',
nzContent: SupplyManagementVehicleAssignedCarComponent,
@ -873,7 +872,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
status: 'new',
url: this.service.$api_save_assign_whole,
params: item,
type: 'next'
},
nzFooter: null
});

View File

@ -163,4 +163,6 @@ export class SupplyManagementService extends BaseService {
public $api_goodsResourceOperateImport = '/api/sdc/uploadGoodsResource/goodsResourceOperateImport';
// 根据货主ID查询网络货运人信息
public $api_getNetworkTransporter = '/api/mdc/cuc/enterpriseInfo/operate/getNetworkTransporter';
$api_verify_vehicle_status = `/api/sdc/goodsResourceShipper/saveVerify`;// 发布货源校验司机/车队长的状态
$api_get_sys_config = `/api/mdc/pbc/sysConfigItem/findConfigValues`; // 根据项key、业务id获取配置信息
}