From 35d19d4d7ea6bcbc8bcabf121ab59107c6082f76 Mon Sep 17 00:00:00 2001 From: wangshiming Date: Fri, 18 Feb 2022 10:45:58 +0800 Subject: [PATCH] fix bug --- .../onecar-publish.component.html | 15 +++-- .../onecar-publish.component.ts | 65 +++++++++++++------ .../services/supply-management.service.ts | 38 ++++++----- .../shared/components/amap/amap.service.ts | 18 +++-- 4 files changed, 86 insertions(+), 50 deletions(-) diff --git a/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.html b/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.html index 4aad2e3e..94975a59 100644 --- a/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.html +++ b/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.html @@ -220,21 +220,21 @@
服务信息
-
+
-
+
- 购买货运险 + 购买货运险
- 推荐投保,填写货值自动估保费,司机接单后不可退保。详见《投保告知》 + 推荐投保,填写货值自动估保费,司机接单后不可退保。详见《投保告知》
-
+
@@ -243,12 +243,12 @@ [nzMin]="50000" [nzMax]="3000000" [nzStep]="0.01" - (ngModelChange)="i.setValue($event)" + (ngModelChange)="i.setValue($event);goodsValuesChange($event)" nzPlaceHolder="请输入50000-3000000之间数值" >
- +
+
补充信息
diff --git a/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts b/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts index 4033ca1c..406b07e5 100644 --- a/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts +++ b/src/app/routes/supply-management/components/onecar-publish/onecar-publish.component.ts @@ -446,19 +446,25 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { widget: 'custom' } }, - insureInfo: { + insurancePremium: { type: 'string', title: '', ui: { widget: 'custom' } + }, + insuranceRate: { + type: 'string', + title: '保险费率', + ui: { + hidden: true + } } - }, - required: ['goodsValue'] + } }; this.ui5 = { '*': { - spanLabelFixed: 90, + spanLabelFixed: 115, grid: { span: 12 } } }; @@ -1059,6 +1065,16 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`unloadPhone${controlId}`, new FormControl(null, Validators.required)); } + + // 计算里程,时间 + if (this.startInfo?.[0]?.area && this.endInfo?.[0]?.area) { + console.log(this.startInfo[0]?.area); + console.log(this.endInfo[0]?.area); + this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => { + this.totalDistance = res.distance; + this.totalTime = res.time; + }); + } }); this.sf3data = { @@ -1086,21 +1102,9 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { }; if (res?.loadingTime) { this.loadingTime = res?.loadingTime; - // this.validateForm1.patchValue( - // { - // loadingTime: res?.loadingTime, - // }, - // { onlySelf: true }, - // ); } if (res?.unloadingTime) { this.unloadingTime = res?.unloadingTime; - // this.validateForm1.patchValue( - // { - // unloadingTime: res?.unloadingTime, - // }, - // { onlySelf: true }, - // ); } if (this.PageStatus === '整车修改') { @@ -1108,7 +1112,9 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { } this.totalFees = res?.shippingInformationVO?.totalFee || '0'; this.sf5data = { - goodsValue: res?.goodsValue + goodsValue: res?.goodsValue, + insurancePremium: res?.insurancePremium || '', + insuranceRate: res?.insuranceRate || '' }; this.sf55data = { insuranceType: res?.insuranceType || '' @@ -1122,9 +1128,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { receiptAddress: res?.receiptAddress || '', remarks: res?.supplementaryInformationVO?.remarks || '' }; - // if (this.PageStatus === '整车修改') { - // this.sf6data.id = res?.supplementaryInformationVO?.id - // } this.sf7data = { prePay: res?.shippingInformationVO?.prePay, toPay: res?.shippingInformationVO?.toPay, @@ -1250,7 +1253,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { this.validateForm1.addControl(`unloadName${index}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`unloadPhone${index}`, new FormControl(null, [Validators.required, Validators.pattern('^[0-9]*$')])); }); - // 计算里程,时间 if (this.startInfo[0]?.area && this.endInfo[0]?.area) { this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => { @@ -1259,4 +1261,25 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { }); } } + goodsValuesChange(value: any) { + console.log(value); + console.log(this.totalDistance); + + if(value >= 50000 && this.totalDistance > 0){ + const params = { + goodsValue: value, + insuranceType: this.sf55.value.insuranceType, + km: this.totalDistance + }; + this.service + .request(this.service.$api_getWholeInsuranceInfo, params) + .subscribe(res => { + if (res) { + this.sf5.setValue('/insurancePremium',res.insurancePremium); + }else{ + this.sf5.setValue('/insurancePremium',null); + } + }); + } + } } diff --git a/src/app/routes/supply-management/services/supply-management.service.ts b/src/app/routes/supply-management/services/supply-management.service.ts index 9b1d4ac2..09c8ca38 100644 --- a/src/app/routes/supply-management/services/supply-management.service.ts +++ b/src/app/routes/supply-management/services/supply-management.service.ts @@ -109,26 +109,28 @@ export class SupplyManagementService extends BaseService { $api_consignBulkQRCode = '/api/sdc/goodsResourceOperate/consignBulkQRCode'; // 获取操作日志列表 public $api_getOperationLogRecordsList = '/api/mdc/pbc/operationLogRecords/getOperationLogRecordsList'; - // 获取数据字典 - $api_getDictValue = `/api/mdc/pbc/dictItems/getDictValue`; + // 获取数据字典 + $api_getDictValue = `/api/mdc/pbc/dictItems/getDictValue`; - /** - * 获取车型、车长字典数据 - * @returns - */ - getDictOptions(params = {}) { - return this.request(this.$api_getDictValue, params).pipe( - map((res: any) => { - if (!res) { - return []; - } - const obj = []; - obj.push({ label: '不限', value: "999" }) - return [...obj,...res]; - }) - ) - } + /** + * 获取车型、车长字典数据 + * @returns + */ + getDictOptions(params = {}) { + return this.request(this.$api_getDictValue, params).pipe( + map((res: any) => { + if (!res) { + return []; + } + const obj = []; + obj.push({ label: '不限', value: '999' }); + return [...obj, ...res]; + }) + ); + } constructor(public injector: Injector) { super(injector); } + // 获取保价费信息 + public $api_getWholeInsuranceInfo = '/api/sdc/goodsResourceShipper/getWholeInsuranceInfo'; } diff --git a/src/app/shared/components/amap/amap.service.ts b/src/app/shared/components/amap/amap.service.ts index d05e58fe..d4c97636 100644 --- a/src/app/shared/components/amap/amap.service.ts +++ b/src/app/shared/components/amap/amap.service.ts @@ -1,3 +1,13 @@ +/* + * @Description : + * @Version : 1.0 + * @Author : Shiming + * @Date : 2021-12-24 15:37:00 + * @LastEditors : Shiming + * @LastEditTime : 2022-02-18 10:45:06 + * @FilePath : \\tms-obc-web\\src\\app\\shared\\components\\amap\\amap.service.ts + * Copyright (C) 2022 huzhenhong. All rights reserved. + */ import { Injectable } from '@angular/core'; import { Observable, Subject, throwError } from 'rxjs'; import AMapLoader from '@amap/amap-jsapi-loader'; @@ -16,18 +26,18 @@ export class AmapService { sub = new Subject(); currentSub = new Subject(); - //计算路径驾车最优路线的长度与所需时间 - drivingCompute(starts: any[], ends: any[]): Observable { + //计算路径驾车最优路线的长度与所需时间 + drivingCompute(starts: any[], ends: any[]): Observable { AMap.plugin('AMap.Driving', () => { let driving = new AMap.Driving({ // 驾车路线规划策略,AMap.DrivingPolicy.LEAST_TIME是最快捷模式 policy: AMap.DrivingPolicy.LEAST_TIME }); const points = starts.concat(ends).map(item => { - return { keyword: item.address, city: item.city }; + return { keyword: item.detailedAddress, city: item.city }; }); driving.search(points, (status: any, result: any) => { - const repData = { distance: (result.routes[0].distance / 1000).toFixed(2), time: (result.routes[0].time / 60 / 60).toFixed(2) }; + const repData = { distance: (result?.routes?.[0]?.distance / 1000).toFixed(2), time: (result?.routes?.[0]?.time / 60 / 60).toFixed(2) }; this.sub.next(repData); }); });