车辆接口更新

This commit is contained in:
wangshiming
2022-01-26 10:16:37 +08:00
parent 5b6737f76a
commit 5b7261022b
20 changed files with 589 additions and 93 deletions

View File

@ -0,0 +1,12 @@
/*
* @Description :
* @Version : 1.0
* @Author : Shiming
* @Date : 2022-01-25 20:20:07
* @LastEditors : Shiming
* @LastEditTime : 2022-01-25 20:28:47
* @FilePath : \\tms-obc-web\\src\\app\\shared\\components\\insurance-table\\index.ts
* Copyright (C) 2022 huzhenhong. All rights reserved.
*/
export * from './insurance-table.module'
export * from './insurance-table.service'

View File

@ -0,0 +1,63 @@
<div nz-row>
<div nz-col nzSpan="24">
<div class="mb-md ml-xl" style="text-align: right;">
<button nz-button nzType="primary" (click)="add()">新增公里数</button>
<button class="ml-md" nz-button nzType="primary" (click)="save()">保存</button>
</div>
<nz-table #groupingTable [nzData]="data" nzBordered nzSize="small" [nzFrontPagination]="false"
[nzScroll]="{ x: '1200px' }" [nzShowPagination]="false" class="ml-xl" style="max-width: 1100px;">
<thead>
<tr>
<th rowspan="2" nzWidth="200px" nzAlign="center" nzLeft>公里数</th>
<th rowspan="2" nzWidth="130px" nzAlign="center">计算方式</th>
<th nzWidth="220px" nzAlign="center" *ngFor="let item of headers">车长(米)</th>
<th rowspan="2" nzWidth="60px" nzAlign="center" nzRight>操作</th>
</tr>
<tr>
<th nzWidth="220px" nzAlign="center" *ngFor="let item of headers;let i = index">
<div style="display: flex;align-items: center;justify-content: space-between;">
<label style="width: 65px;text-align: right;"> {{item.startLength}}</label>
<label>-</label>
<nz-input-number [ngModel]="item.endLength" (ngModelChange)="changeEndLength($event,i)"
[nzMin]="0" [nzFormatter]="formatterDollar" nzSize="small" class="mr-sm" disabled>
</nz-input-number>
</div>
</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of groupingTable.data;let i = index">
<td nzWidth="200px" nzAlign="center" nzLeft>
<div style="display: flex;align-items: center;justify-content: space-between;">
<label style="width: 65px;text-align: right;"> {{item.startKm}}</label>
<label>-</label>
<nz-input-number [ngModel]="item.endKm" (ngModelChange)="changeEndKm($event,i)" [nzMin]="0"
[nzFormatter]="formatterDollar" nzSize="small">
</nz-input-number>
</div>
</td>
<td nzWidth="130px" nzAlign="center">{{computeMode[item.computeMode] }}</td>
<td nzWidth="220px" nzAlign="center" *ngFor="let node of item.configValue">
<div style="display: flex;align-items: center;justify-content: center;">
<label>最高</label>
<nz-input-number [(ngModel)]="node.maxPrice" [nzMin]="0" nzSize="small" style="width: 55px;"
class="ml-sm mr-sm">
</nz-input-number>
<label>预警</label>
<nz-input-number [(ngModel)]="node.ewPrice" [nzMin]="0" nzSize="small" style="width: 55px;"
class="ml-sm">
</nz-input-number>
</div>
</td>
<td nzWidth="60px" nzAlign="center" nzRight>
<a *ngIf="i === groupingTable.data.length-1 && groupingTable.data.length>2" nz-popconfirm
nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="deleteRow(i)">删除</a>
</td>
</tr>
</tbody>
</nz-table>
</div>
</div>

View File

@ -0,0 +1,14 @@
:host::ng-deep {
nz-input-number {
width: 85px;
input {
width : 100%;
margin: 0;
}
.ant-input-number-handler-wrap {
display: none;
}
}
}

View File

@ -0,0 +1,136 @@
import { Component, OnInit } from '@angular/core';
import { BaseService } from '@shared';
@Component({
selector: 'app-insurance-table',
templateUrl: './insurance-table.component.html',
styleUrls: ['./insurance-table.component.less']
})
export class InsuranceTableComponent implements OnInit {
data: any[] = [];
headers: any[] = [];
formatterDollar = (value: number): string => `${value} (含)`;
computeMode: any = {
0: '总运价',
1: '单公里运价'
};
constructor(public service: BaseService) {}
ngOnInit(): void {
this.loadHeaders();
this.loadData();
}
loadHeaders() {
this.service.request('/api/mdc/cuc/freightConfigItem/list').subscribe(res => {
if (res) {
this.headers = res;
}
});
}
loadData() {
this.service.request('/api/mdc/cuc/freightConfig/list').subscribe(res => {
if (res) {
this.data = res;
}
});
}
/**
* 修改结束车长
* @param event 车长
* @param i 下标
*/
changeEndLength(event: any, i: number) {
if (event <= this.headers[i].startLength) {
this.headers[i].endLength = this.headers[i].startLength + 1;
this.changeNextStartLength(event, i + 1);
return;
}
this.headers[i].endLength = event;
this.changeNextStartLength(event, i + 1);
}
/**
* 修改结束公里数
* @param event 车长
* @param i 下标
*/
changeEndKm(event: any, i: number) {
if (event <= this.data[i].startKm) {
this.data[i].endKm = this.data[i].startKm + 1;
this.changeNextStartKm(event, i + 1);
return;
}
this.data[i].endKm = event;
this.changeNextStartKm(event, i + 1);
}
add() {
console.log(this.data);
const tem = this.data[this.data?.length - 1];
if (tem && tem.endKm) {
const list = this.headers.map(item => ({
ewPrice: null,
itemId: item.id,
maxPrice: null
}));
this.data.push({
computeMode: 1,
configValue: list,
endKm: '',
startKm: tem.endKm
});
this.data = [...this.data];
} else {
this.service.msgSrv.warning('请填写完整公里数');
}
}
deleteRow(index: number) {
this.data = this.data.filter((d, i) => index !== i);
}
save() {
this.service.request('/api/mdc/cuc/freightConfig/saveBatch', this.data).subscribe(res => {
if (res) {
console.log(res);
this.service.msgSrv.success('修改成功');
this.loadData();
}
});
}
/**
* 遍历同步后置位车长
* @param event 车长
* @param i 下标
*/
private changeNextStartLength(event: number, i: number) {
if (this.headers[i]) {
this.headers[i].startLength = event;
if (this.headers[i].endLength <= event) {
this.headers[i].endLength = this.headers[i].startLength + 0.5;
this.changeNextStartLength(event + 0.5, i + 1);
}
}
}
/**
* 遍历同步后置位公里数
* @param event 车长
* @param i 下标
*/
private changeNextStartKm(event: number, i: number) {
if (this.data[i]) {
this.data[i].startKm = event;
if (this.data[i].endKm <= event) {
this.data[i].endKm = this.data[i].startKm + 1;
this.changeNextStartKm(event + 1, i + 1);
}
}
}
}

View File

@ -0,0 +1,30 @@
/*
* @Description :
* @Version : 1.0
* @Author : Shiming
* @Date : 2022-01-25 20:23:54
* @LastEditors : Shiming
* @LastEditTime : 2022-01-25 20:35:32
* @FilePath : \\tms-obc-web\\src\\app\\shared\\components\\insurance-table\\insurance-table.module.ts
* Copyright (C) 2022 huzhenhong. All rights reserved.
*/
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NzInputNumberModule } from 'ng-zorro-antd/input-number';
import { NzTableModule } from 'ng-zorro-antd/table';
import { InsuranceTableComponent } from './insurance-table.component';
const COMPONENTS = [InsuranceTableComponent];
const COMPONENTSs = [
NzTableModule,
NzInputNumberModule
];
@NgModule({
declarations: COMPONENTS,
imports: [CommonModule, FormsModule,COMPONENTSs],
exports: COMPONENTS
})
export class InsuranceTableModule {}

View File

@ -0,0 +1,18 @@
/*
* @Description :
* @Version : 1.0
* @Author : Shiming
* @Date : 2022-01-25 20:21:04
* @LastEditors : Shiming
* @LastEditTime : 2022-01-25 20:35:52
* @FilePath : \\tms-obc-web\\src\\app\\shared\\components\\insurance-table\\insurance-table.service.ts
* Copyright (C) 2022 huzhenhong. All rights reserved.
*/
import { Injectable } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class InsuranceService {
}