车辆对接
This commit is contained in:
@ -1,15 +1,59 @@
|
||||
<!--
|
||||
* @Author: your name
|
||||
* @Date: 2021-12-03 11:10:14
|
||||
* @LastEditTime: 2021-12-07 19:51:34
|
||||
* @LastEditTime: 2021-12-21 10:56:30
|
||||
* @LastEditors: your name
|
||||
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
* @FilePath: \tms-obc-web\src\app\routes\supply-management\components\assigned-car\assigned-car.component.html
|
||||
-->
|
||||
<div>
|
||||
<sf #sf [schema]="schema" [ui]="ui" [compact]="true" [button]="'none'"></sf>
|
||||
<div>
|
||||
<!-- <st #st [data]="service.$api_get_catalogue_member" [columns]="columns"> -->
|
||||
<!-- </st> -->
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<st #st [data]="service.$api_get_catalogue_member"
|
||||
[req]="{ method: 'POST', allInBody: true, reName: { pi: 'pageIndex', ps: 'pageSize' }, params: reqParams }"
|
||||
[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)">
|
||||
<ng-template st-row="carId" let-item let-index="index">
|
||||
<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 === '0'" class="text-success-dark">空闲</span>
|
||||
<span *ngIf="car?.approvalStatus === '20' && car.carStatus === '1'" 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.name}} {{item.phone}}</span>
|
||||
<a (click)="setCarCaptain(item)">设置</a>
|
||||
</ng-template>
|
||||
<ng-template st-row="driverStatus" let-item let-index>
|
||||
<span *ngIf="item?.certificationStatus === '20' && item.driverStatus === '0'"
|
||||
class="text-success-dark">空闲</span>
|
||||
<span *ngIf="item?.certificationStatus === '20' && item.driverStatus === '1'"
|
||||
class="text-warning-dark">已被指派</span>
|
||||
<span *ngIf="item?.certificationStatus !== '20'" 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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user