车辆接口更新

This commit is contained in:
wangshiming
2022-02-09 17:22:46 +08:00
parent 9b2c25524a
commit de20e1859a
10 changed files with 158 additions and 87 deletions

View File

@ -1,3 +1,13 @@
<!--
* @Description :
* @Version : 1.0
* @Author : Shiming
* @Date : 2022-01-25 20:18:52
* @LastEditors : Shiming
* @LastEditTime : 2022-02-09 14:57:23
* @FilePath : \\tms-obc-web\\src\\app\\shared\\components\\insurance-table\\insurance-table.component.html
* Copyright (C) 2022 huzhenhong. All rights reserved.
-->
<div nz-row>
<div nz-col nzSpan="24">
<div class="mb-md ml-xl" style="text-align: right;">
@ -9,12 +19,13 @@
[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="250px" nzAlign="center" nzLeft>险种</th>
<!-- <th rowspan="2" nzWidth="130px" nzAlign="center">计算方式</th> -->
<th nzWidth="220px" nzAlign="center" >普货-基本险</th>
<th nzWidth="220px" nzAlign="center" >普货-综合险</th>
<th rowspan="2" nzWidth="60px" nzAlign="center" nzRight>操作</th>
</tr>
<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>
@ -24,35 +35,46 @@
</nz-input-number>
</div>
</th>
</tr>
</tr> -->
</thead>
<tbody>
<tr *ngFor="let item of groupingTable.data;let i = index">
<td nzWidth="200px" nzAlign="center" nzLeft>
<td nzWidth="250px" 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">
<div >
公里数km
</div>
<div style="color:#f0f0f0;">|</div>
<div >
<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>
</div>
</td>
<!-- <td nzWidth="130px" nzAlign="center">{{computeMode[item.computeMode] }}</td> -->
<td nzWidth="220px" nzAlign="center" >
<div style="display: flex;align-items: center;justify-content: center;" >
<nz-input-number [(ngModel)]="item.baseInsuranceRate" [nzMin]="0" nzSize="small" style="width: 55px;"
class="ml-sm mr-sm">
</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">
<td nzWidth="220px" nzAlign="center" >
<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;"
<nz-input-number [(ngModel)]="item.blanketInsuranceRate" [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>
<a *ngIf="i === groupingTable.data.length-1 && groupingTable.data.length>2"
nz-popconfirm
nzPopconfirmTitle="是否确认删除?" (nzOnConfirm)="deleteRow(i)"
>删除</a>
</td>
</tr>
</tbody>

View File

@ -1,4 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { debounceTime } from 'rxjs/operators';
import { Subject } from 'rxjs';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { BaseService } from '@shared';
@Component({
@ -11,29 +13,21 @@ export class InsuranceTableComponent implements OnInit {
headers: any[] = [];
formatterDollar = (value: number): string => `${value} (含)`;
computeMode: any = {
0: '总运价',
1: '单公里运价'
};
constructor(public service: BaseService) {}
changeSub = new Subject<string>();
constructor(public service: BaseService, private cdr: ChangeDetectorRef) {}
ngOnInit(): void {
this.loadHeaders();
this.loadData();
}
loadHeaders() {
this.service.request('/api/mdc/cuc/freightConfigItem/list').subscribe(res => {
if (res) {
this.headers = res;
}
});
this.changeEndKmAction();
}
loadData() {
this.service.request('/api/mdc/cuc/freightConfig/list').subscribe(res => {
this.service.request('/api/mdc/cuc/insuranceConfig/list').subscribe(res => {
if (res) {
console.log(res);
this.data = res;
this.cdr.detectChanges();
}
});
}
@ -59,13 +53,35 @@ export class InsuranceTableComponent implements OnInit {
* @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;
// console.log(this.debounce4(event, i));
// console.log(this.data[i].startKm);
// console.log(event);
// console.log(i);
if (event) {
console.log(event);
this.changeSub.next(`${event},${i}`);
}
this.data[i].endKm = event;
this.changeNextStartKm(event, i + 1);
}
changeEndKmAction() {
this.changeSub.pipe(debounceTime(500)).subscribe((res: string) => {
if (res) {
const paras = res.split(',');
const num = Number(paras[0]);
const i = Number(paras[1]);
if (num <= this.data[i].startKm) {
this.data[i].endKm = null;
setTimeout(() => {
this.data[i].endKm = this.data[i].startKm + 1 ;
}, 0);
this.changeNextStartKm(this.data[i].startKm + 1, i + 1);
return;
}
this.data[i].endKm = num;
this.changeNextStartKm(num, i + 1);
}
});
}
add() {
@ -73,14 +89,7 @@ export class InsuranceTableComponent implements OnInit {
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
});
@ -91,17 +100,24 @@ export class InsuranceTableComponent implements OnInit {
}
deleteRow(index: number) {
this.data = this.data.filter((d, i) => index !== i);
console.log(index);
this.data = this.data.filter((d, i) => {
console.log(d);
console.log(i);
index !== i;
});
console.log(this.data);
}
save() {
this.service.request('/api/mdc/cuc/freightConfig/saveBatch', this.data).subscribe(res => {
if (res) {
console.log(res);
this.service.msgSrv.success('修改成功');
this.loadData();
}
});
console.log(this.data);
// this.service.request('/api/mdc/cuc/freightConfig/saveBatch', this.data).subscribe(res => {
// if (res) {
// console.log(res);
// this.service.msgSrv.success('修改成功');
// this.loadData();
// }
// });
}
/**

View File

@ -4,7 +4,7 @@
* @Author : Shiming
* @Date : 2022-01-25 20:23:54
* @LastEditors : Shiming
* @LastEditTime : 2022-01-25 20:35:32
* @LastEditTime : 2022-02-09 14:57:05
* @FilePath : \\tms-obc-web\\src\\app\\shared\\components\\insurance-table\\insurance-table.module.ts
* Copyright (C) 2022 huzhenhong. All rights reserved.
*/
@ -14,12 +14,13 @@ 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';
import { NzPopconfirmModule } from 'ng-zorro-antd/popconfirm';
const COMPONENTS = [InsuranceTableComponent];
const COMPONENTSs = [
NzTableModule,
NzInputNumberModule
NzInputNumberModule,
NzPopconfirmModule
];
@NgModule({