diff --git a/src/app/routes/order-management/components/vehicle/vehicle.component.ts b/src/app/routes/order-management/components/vehicle/vehicle.component.ts index 5acae83a..42e4fd1a 100644 --- a/src/app/routes/order-management/components/vehicle/vehicle.component.ts +++ b/src/app/routes/order-management/components/vehicle/vehicle.component.ts @@ -12,6 +12,7 @@ import { VehicleFreightPeopleComponent } from '../../modal/vehicle/freight-peopl import { VehicleModifyCaptainComponent } from '../../modal/vehicle/modify-captain/modify-captain.component'; import { VehicleModifyRateComponent } from '../../modal/vehicle/modify-rate/modify-rate.component'; import { VehicleUpdateFreightComponent } from '../../modal/vehicle/update-freight/update-freight.component'; +import { OneCarOrderViewtrackComponent } from '../../modal/vehicle/view-track/view-track.component'; import { OrderManagementService } from '../../services/order-management.service'; @@ -458,8 +459,8 @@ resourceStatus: any; }, { text: '查看轨迹 ', - click: (_record) => this.cancellation(_record), - iif: item => item.billStatus == '4' || item.billStatus == '5' || item.billStatus == '2' || item.billStatus == '3', + click: (_record) => this.viewTrack(_record), + iif: item => item.billStatus !== '1' && item.billStatus !== '6', // acl: { ability: ['VEHICLE-LIST-view'] }, }, @@ -856,4 +857,22 @@ resourceStatus: any; } }); } + /** + *查看轨迹 + */ + viewTrack(item: any) { + const modalRef = this.modal.create({ + nzTitle: '查看轨迹', + nzContent: OneCarOrderViewtrackComponent, + nzWidth: 1200, + nzComponentParams: { + i: item, + }, + nzFooter: null + }); + modalRef.afterClose.subscribe((res: boolean) => { + if(res) { + } + }); + } } diff --git a/src/app/routes/order-management/modal/vehicle/cancel-confirm/cancel-confirm.component.ts b/src/app/routes/order-management/modal/vehicle/cancel-confirm/cancel-confirm.component.ts index 56e734b3..717ac457 100644 --- a/src/app/routes/order-management/modal/vehicle/cancel-confirm/cancel-confirm.component.ts +++ b/src/app/routes/order-management/modal/vehicle/cancel-confirm/cancel-confirm.component.ts @@ -4,7 +4,7 @@ * @Author : Shiming * @Date : 2022-02-22 13:53:29 * @LastEditors : Shiming - * @LastEditTime : 2022-02-22 15:51:53 + * @LastEditTime : 2022-02-28 15:12:10 * @FilePath : \\tms-obc-web\\src\\app\\routes\\order-management\\modal\\vehicle\\cancel-confirm\\cancel-confirm.component.ts * Copyright (C) 2022 huzhenhong. All rights reserved. */ @@ -75,6 +75,7 @@ export class OneCarOrderCancelConfirmComponent implements OnInit { initData() { let indexId = 0 let index = 0 + let indexSurcharge = 0 this.i?.mybidDetailInfo.forEach((ele: any) => { if(this.sts == 1) { // 大宗 @@ -83,25 +84,21 @@ export class OneCarOrderCancelConfirmComponent implements OnInit { } if (ele?.paymentStatusLabel == '已支付') { indexId += 1; + indexSurcharge += ele?.surcharge; } } else { // 整车 if (ele?.paymentStatusLabel == '已支付') { indexId += 1; index += ele?.price; + indexSurcharge += ele?.surcharge; } console.log(ele.expenseCode) } - if (ele.expenseCode == '"ATT"' || ele.expenseCode == 'ATT'){ - if(ele?.paymentStatusLabel == '已支付') { - this.ATTPrice = ele.price; - } else { - this.ATTPrice = 0; - } - } }); this.index = indexId this.List = index + this.ATTPrice = indexSurcharge console.log(this.index) console.log(this.List) } diff --git a/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.html b/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.html new file mode 100644 index 00000000..e897a9bf --- /dev/null +++ b/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.html @@ -0,0 +1,34 @@ + +
+ +
+
+ + +
+
+ +
+
+
+ + + + + + +
+ + diff --git a/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.less b/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.less new file mode 100644 index 00000000..14049ec8 --- /dev/null +++ b/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.less @@ -0,0 +1,11 @@ +:host { + ::ng-deep { + .mapBox { + iframe, canvas { + width: 400px !important; + } + } + + } + + } \ No newline at end of file diff --git a/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.ts b/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.ts new file mode 100644 index 00000000..dc25b3f4 --- /dev/null +++ b/src/app/routes/order-management/modal/vehicle/view-track/view-track.component.ts @@ -0,0 +1,98 @@ +/* + * @Description : + * @Version : 1.0 + * @Author : Shiming + * @Date : 2022-02-22 13:53:29 + * @LastEditors : Shiming + * @LastEditTime : 2022-02-28 14:37:42 + * @FilePath : \\tms-obc-web\\src\\app\\routes\\order-management\\modal\\vehicle\\view-track\\view-track.component.ts + * Copyright (C) 2022 huzhenhong. All rights reserved. + */ +import { Component, OnInit, ViewChild } from '@angular/core'; +import { STColumn } from '@delon/abc/st'; +import { + SFComponent, + SFCustomWidgetSchema, + SFNumberWidgetSchema, + SFRadioWidgetSchema, + SFSchema, + SFTextareaWidgetSchema, + SFUISchema +} from '@delon/form'; +import format from 'date-fns/format'; +import { _HttpClient } from '@delon/theme'; +import { NzMessageService } from 'ng-zorro-antd/message'; +import { NzModalRef, NzModalService } from 'ng-zorro-antd/modal'; +import { OrderManagementService } from '../../../services/order-management.service'; + + +@Component({ + selector: 'app-order-management-view-track', + styleUrls: ['./view-track.component.less'], + templateUrl: './view-track.component.html' +}) +export class OneCarOrderViewtrackComponent implements OnInit { + i: any; // 单行数据 + MapList: any; // 地图数据 + trajectory = 'car'; + addressItems: any[] = []; //打点地址数据组 + logColumns: STColumn[] = [ + { title: '款项', index: 'expenseCodeLabel' }, + { title: '小计(元)', render: 'price' }, + { title: '运输费(元)', render: 'price' }, + { title: '附加费(元)', render: 'surcharge' }, + { title: '支付时间', index: 'paymentTime' }, + { + title: '支付状态', + className: 'text-center', + index: 'paymentStatus', + type: 'badge', + width: '120px', + badge: { + '1': { text: '待申请', color: 'warning' }, + '2': { text: '已支付', color: 'success' }, + '3': { text: '已拒绝', color: 'warning' }, + '4': { text: '申请中', color: 'warning' } + } + } + ]; + constructor( + private modalRef: NzModalRef, + private modal: NzModalService, + private msgSrv: NzMessageService, + public service: OrderManagementService + ) {} + + ngOnInit(): void { + console.log(this.i); + this.MapInit(); + + } + // 获取轨迹 + MapInit() { + this.service.request(this.service.$api_get_getTrajectory, { id: this.i.id }).subscribe(res => { + if (res) { + const points = res.trackArray; + points?.forEach((item: any) => { + this.MapList.push({ + name: item.hgt, + lnglat: [Number((Number(item.lon) / 600000).toFixed(6)), Number((Number(item.lat) / 600000).toFixed(6))] + }); + }); + this.addressItems = res.parkArray; + if (this.addressItems && this.addressItems.length > 0) { + this.addressItems.forEach(item => { + item.parkBte = this.getLocalTime(item.parkBte); + item.parkEte = this.getLocalTime(item.parkEte); + }); + } + } + }); + } + close(value: boolean): void { + this.modalRef.close(false); + } + getLocalTime(time: any) { + return format(new Date(parseInt(time)), 'yyyy-MM-dd HH:mm:ss'); + } +} diff --git a/src/app/routes/order-management/order-management.module.ts b/src/app/routes/order-management/order-management.module.ts index 8d59ea15..b71b0fda 100644 --- a/src/app/routes/order-management/order-management.module.ts +++ b/src/app/routes/order-management/order-management.module.ts @@ -36,6 +36,7 @@ import { VehicleModifyRateComponent } from './modal/vehicle/modify-rate/modify-r import { VehicleSureArriveComponent } from './modal/vehicle/sure-arrive/sure-arrive.component'; import { VehicleSureDepartComponent } from './modal/vehicle/sure-depart/sure-depart.component'; import { VehicleUpdateFreightComponent } from './modal/vehicle/update-freight/update-freight.component'; +import { OneCarOrderViewtrackComponent } from './modal/vehicle/view-track/view-track.component'; import { OrderManagementRoutingModule } from './order-management-routing.module'; const COMPONENTS: Type[] = [ @@ -62,7 +63,8 @@ const COMPONENTS: Type[] = [ OrderManagementReceiptsAuditComponent, orderManagementVoucherViewComponent, OrderManagementComplianceAuditComponent, - OneCarOrderCancelConfirmComponent + OneCarOrderCancelConfirmComponent, + OneCarOrderViewtrackComponent ]; @NgModule({ 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 4b2384b3..c5399031 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 @@ -239,7 +239,7 @@ [nzMin]="50000" [nzMax]="3000000" [nzStep]="0.01" - (ngModelChange)="i.setValue($event);getInsurersPrice($event)" + (ngModelChange)="i.setValue($event);getInsurersPrice()" nzPlaceHolder="请输入50000-3000000之间数值" > @@ -353,7 +353,7 @@ acl [acl-ability]="['SUPPLY-VEHICLE-AMEND-submitChange']">提交修改 - 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 66f3d209..d02862b7 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 @@ -1,6 +1,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { debounceTime } from 'rxjs/operators'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; +import format from 'date-fns/format'; import { Subject } from 'rxjs'; import { ActivatedRoute, Router } from '@angular/router'; import { @@ -14,7 +15,7 @@ import { SFUISchema } from '@delon/form'; import { _HttpClient } from '@delon/theme'; -import { AmapPoiPickerComponent, AmapService, ShipperBaseService } from '@shared'; +import { AmapPoiPickerComponent, AmapService, EACacheService, ShipperBaseService } from '@shared'; import { NzModalService } from 'ng-zorro-antd/modal'; import { type } from 'os'; import { of } from 'rxjs'; @@ -24,13 +25,22 @@ import { SupplyManagementVehicleAssignedCarComponent } from '../assigned-car/ass import { TranAgreementComponent } from '../tran-agreement/tran-agreement.component'; import { PublishAddressListComponent } from './address-list/address-list.component'; import { PublishSuccessComponent } from './publish-success/publish-success.component'; +import { cacheConf } from '@conf/cache.conf'; + @Component({ selector: 'app-publish-goods-onecar-publish', templateUrl: './onecar-publish.component.html', styleUrls: ['./onecar-publish.component.less'] }) export class SupplyManagementOnecarPublishComponent implements OnInit { + // 环境信息 appId、tenantId + envInfo = this.eaCacheSrv.get(cacheConf.env); validateForm1: FormGroup; + limitValues = { + maxWeight: 99999, + maxVolume: 99999, + maxPiece: 99999, + } sf1data: any; // 货源单设置回显 sf3data: any; // 货源单设置回显 sf4data: any; // 货源单设置回显 @@ -61,18 +71,15 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { private modalService: NzModalService, public service: SupplyManagementService, private amapService: AmapService, - public shipperSrv: ShipperBaseService + public shipperSrv: ShipperBaseService, + private eaCacheSrv: EACacheService, + ) { this.validateForm1 = fb.group({ - loadAddress0: [null, [Validators.required]], - loadName0: [null, [Validators.required]], - loadPhone0: [null, [Validators.required, Validators.pattern('^[0-9]*$')]], - unloadAddress0: [null, [Validators.required]], - unloadName0: [null, [Validators.required]], - unloadPhone0: [null, [Validators.required, Validators.pattern('^[0-9]*$')]], - loadingTime: [null, []], - unloadingTime: [null, []] + loadingTime: [null, [Validators.required]], + unloadingTime: [null, [Validators.required]] }); + this.envCache = this.eaCacheSrv.get(cacheConf.env); } @ViewChild('sf1', { static: false }) sf1!: SFComponent; schema1: SFSchema = {}; @@ -127,8 +134,8 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { this.initSF5(); this.initSF6(); this.initSF7(); + this.getLimitvalue(); this.initdata(); - this.getInsurers() } initSF1() { this.schema1 = { @@ -397,8 +404,17 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { type: 'string', title: '增值服务套餐', ui: { - widget: 'dict-select', - params: { dictKey: 'bill:insurance:type' }, + widget: 'select', + asyncData: () => { + return this.service.request(this.service.$api_getDictValue, { dictKey: 'bill:insurance:type' }).pipe( + map((res: any) => { + return [...res]; + }) + ) + }, + change: (tag: any, org: any) => { + this.getInsurersPrice(tag); + } }, default: '3' }, @@ -409,7 +425,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { readOnly: true, ui: { widget: 'checkbox', - visibleIf: { insuranceType: (value: string) => value === '0' } + visibleIf: { insuranceType: (value: string) => value === '1' } } as SFCheckboxWidgetSchema, default: ['车辆实时定位', '轨迹查询', '数据保护', '赠送基本险'] }, @@ -420,7 +436,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { readOnly: true, ui: { widget: 'checkbox', - visibleIf: { insuranceType: (value: string) => value === '1' } + visibleIf: { insuranceType: (value: string) => value === '2' } } as SFCheckboxWidgetSchema, default: ['车辆实时定位', '轨迹查询', '数据保护', '专属技术服务', '赠送综合险'] }, @@ -432,21 +448,22 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { visibleIf: { insuranceType: (value: string) => value !== '3' } } }, - insurancePackagedGoods:{ + insurancePackagedGoods: { type: 'string', title: '货物包装', ui: { widget: 'dict-select', params: { dictKey: 'insure:packaged:goods' }, + containsAllLabel: false, visibleIf: { insuranceType: (value: string) => value !== '3' } } as SFSelectWidgetSchema }, - hidenField:{ + hidenField: { type: 'string', title: '', - default:' ', + default: ' ', ui: { - widget:'text' + widget: 'text' } }, goodsValue: { @@ -463,6 +480,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { title: '', ui: { widget: 'custom', + validator: val => this.customValidator(val), visibleIf: { insuranceType: (value: string) => value !== '3' } } }, @@ -472,26 +490,43 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { ui: { hidden: true } - }, + } }, - required: ['insurancePackagedGoods'] + required: ['insurancePackagedGoods', 'insurancePremium'] }; this.ui5 = { '*': { spanLabelFixed: 115, grid: { span: 12 } }, - $type1:{ + $type1: { grid: { span: 24 } }, - $type2:{ + $type2: { grid: { span: 24 } }, - $freeInsurance:{ + $freeInsurance: { grid: { span: 24 } - }, + } }; } + /** + * 自定义校验数据 + * @param val + */ + customValidator(val: number) { + if (this.isEmpty(val)) { + return [{ keyword: 'required', message: '不能为空' }]; + } else { + if (val <= 0) { + return [{ keyword: 'required', message: '数值需大于0' }]; + } + return []; + } + } + isEmpty(val: any) { + return val === undefined || val === null || val.toString().trim() === ''; + } initSF6() { this.schema6 = { properties: { @@ -522,45 +557,65 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { } } }, + receiptAddress: { + type: 'string', + title: '回单收件人信息', + ui: { + widget: 'custom', + placeholder: '请点击选择回单收件人信息', + // validator: val => (this.sf6?.value?.receiptType === '2' ? [{ keyword: 'required', message: '请点击选择收回单地址' }] : []), + visibleIf: { + receiptType: value => value === '2' + } + }, + default: '' + }, + receiptAddressId: { + type: 'string', + title: '', + ui: { + hidden: true + } + }, receiptUserName: { type: 'string', title: '联系人', - maxLength: 15, ui: { visibleIf: { receiptType: value => value === '2' } - } + }, + readOnly: true }, - receiptUserPhone: { + phon: { type: 'string', title: '联系电话', - maxLength: 11, ui: { visibleIf: { receiptType: value => value === '2' } - } + }, + readOnly: true }, - receiptAddressArea: { + area: { type: 'string', title: '所在地区', - maxLength: 30, ui: { visibleIf: { receiptType: value => value === '2' } - } + }, + readOnly: true }, - receiptAddress: { + address: { type: 'string', title: '详细地址', - maxLength: 30, ui: { visibleIf: { receiptType: value => value === '2' } - } + }, + readOnly: true }, remarks: { type: 'string', @@ -573,11 +628,11 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { } as SFTextareaWidgetSchema } }, - required: ['stateReceipt', 'receiptType', 'receiptUserName', 'receiptUserPhone', 'receiptAddressArea', 'receiptAddress'] + required: ['stateReceipt', 'receiptType', 'receiptAddress'] }; this.ui6 = { '*': { - spanLabelFixed: 90, + spanLabelFixed: 115, grid: { span: 24 } } }; @@ -590,19 +645,19 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { type: 'number', title: '预付', default: 0, - ui: {widget: 'custom'} + ui: { widget: 'custom' } }, toPay: { type: 'number', title: '到付', default: 0, - ui: { widget: 'custom'} + ui: { widget: 'custom' } }, receiptPay: { type: 'number', title: '回单付', default: 0, - ui: {widget: 'custom'} + ui: { widget: 'custom' } }, subtotal: { type: 'number', title: '小计', default: 0, ui: { widget: 'custom' } as SFNumberWidgetSchema }, appendFee: { type: 'number', title: '附加费', default: 0, ui: { widget: 'custom' } as SFNumberWidgetSchema }, @@ -646,47 +701,37 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { } }); } - changeValue() { - this.totalFees = - Number(this.sf7?.value?.appendFee) + - Number(this.sf7?.value?.prePay) + - Number(this.sf7?.value?.receiptPay) + - Number(this.sf7?.value?.toPay); - console.log(this.totalFees); - } payChange() { const prePay = this.sf7.value.prePay || 0; - const toPay = this.sf7.value.toPay || 0 + const toPay = this.sf7.value.toPay || 0; const receiptPay = this.sf7.value.receiptPay || 0; - // const oilCardPay = 0; + const oilCardPay = 0; const subtotal = prePay + toPay + receiptPay; const params = { shipperId: this.envCache?.enterpriseId, enterpriseInfoId: this.envCache?.networkTransporterId, - totalFreight:subtotal, - // fuelCardAmount:oilCardPay, - resourcetype:'1' - } - this.service - .request(this.service.$api_getCalculatedSurcharge,params) - .subscribe(res => { - if (res) { - this.sf7.setValue('/appendFee', res.surcharge); - this.sf7.setValue('/subtotal', subtotal); - this.sf7.setValue('/total', subtotal + res.surcharge); - this.service - .request(this.service.$api_getcalculatedServiceRate + `?invoiceAmount=${subtotal + res.surcharge}&totalFreight=${subtotal}`) - .subscribe(res => { - if (res) { - this.currentRate = res.rate * 100; - } else { - this.service.msgSrv.error(res.msg); - } - }); - } else { - this.service.msgSrv.error(res.msg); - } - }); + totalFreight: subtotal, + fuelCardAmount: oilCardPay, + resourcetype: '1' + }; + this.service.request(this.service.$api_getCalculatedSurcharge, params).subscribe(res => { + console.log('999') + console.log(this.envCache) + if (res) { + this.sf7.setValue('/appendFee', res.surcharge); + this.sf7.setValue('/subtotal', subtotal); + this.sf7.setValue('/total', subtotal + res.surcharge); + this.service + .request(this.service.$api_getAdditionalRate + `?shipperId=${this.envCache?.enterpriseId}&enterpriseInfoId=${this?.enterpriseProjectIds}&resourcetype='1'`) + .subscribe(res => { + if (res) { + this.currentRate = res.rate * 100; + } + }); + } else { + this.service.msgSrv.error(res.msg); + } + }); } // 添加 删除发货卸货地址 addStartInfo(_event: any) { @@ -708,6 +753,26 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { this.validateForm1.addControl(`loadPhone${controlId}`, new FormControl(null, Validators.required)); } } + + getLimitvalue() { + // 货物核载信息最大值 + // 货物运输费(小计)最大值 + const getlimitvaluesParms = [ + this.service.limitKeys.weight, + this.service.limitKeys.volume, + this.service.limitKeys.piece, + ]; + this.service.request(this.service.$api_findItemValueByItemKeys, getlimitvaluesParms).subscribe((res) => { + const maxWeight = res.filter((item: any) => item.itemKey === this.service.limitKeys.weight)[0].itemValue; + const maxVolume = res.filter((item: any) => item.itemKey === this.service.limitKeys.volume)[0].itemValue; + const maxPiece = res.filter((item: any) => item.itemKey === this.service.limitKeys.piece)[0].itemValue; + this.limitValues = { + maxWeight: Number(maxWeight), + maxVolume: Number(maxVolume), + maxPiece: Number(maxPiece) + } + }) + } // 添加 删除发货卸货地址 subStartInfo(event: any, index: number, id?: any) { console.log(event, index, id); @@ -773,10 +838,12 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { .subscribe(res => { if (res) { this.sf3.getProperty('/goodsNameId')!.schema.enum = res; - this.sf3.getProperty('/goodsNameId')!.widget?.reset(res); + this.sf3.getProperty('/goodsNameId')!.widget.reset(res); if (this.sf3data.goodsNameId) { this.sf3.setValue('/goodsNameId', this.sf3data.goodsNameId); } + } else { + this.service.msgSrv.error(res.msg); } }); } @@ -811,27 +878,94 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { nzComponentParams: { type: 'onecar', resourceObj, change: change } }); } - // 提交前确认,委托运输协议弹窗 - submitConfirm(submitType?: any) { - Object.keys(this.validateForm1.controls).forEach(key => { - this.validateForm1.controls[key].markAsDirty(); - this.validateForm1.controls[key].updateValueAndValidity(); - }); - this.sf1.validator({ emitError: true }); - this.sf3.validator({ emitError: true }); - this.sf4.validator({ emitError: true }); - this.sf6.validator({ emitError: true }); - this.sf7.validator({ emitError: true }); - console.log(this.sf1.valid); - if (this.validateForm1.invalid || !this.sf3.valid || !this.sf1.valid || !this.sf4.valid || !this.sf6.valid || !this.sf7.valid) { - return; - } + // // 提交前确认,委托运输协议弹窗 + // submitConfirm(submitType?: any) { + // Object.keys(this.validateForm1.controls).forEach(key => { + // this.validateForm1.controls[key].markAsDirty(); + // this.validateForm1.controls[key].updateValueAndValidity(); + // }); + // this.sf1.validator({ emitError: true }); + // this.sf3.validator({ emitError: true }); + // this.sf4.validator({ emitError: true }); + // this.sf6.validator({ emitError: true }); + // this.sf7.validator({ emitError: true }); + // console.log(this.sf1.valid); + // if (this.validateForm1.invalid || !this.sf3.valid || !this.sf1.valid || !this.sf4.valid || !this.sf6.valid || !this.sf7.valid) { + // return; + // } + // const modalRef = this.modalService.create({ + // nzTitle: '运输协议', + // nzContent: TranAgreementComponent, + // nzWidth: 900, + // nzFooter: null, + // }); + // modalRef.afterClose.subscribe(result => { + // if (result) { + // this.submit(submitType); + // } + // }); + // } + // 提交前确认,委托运输协议弹窗 + submitConfirm(submitType?: string) { + Object.keys(this.validateForm1.controls).forEach(key => { + this.validateForm1.controls[key].markAsDirty(); + this.validateForm1.controls[key].updateValueAndValidity(); + }); + this.sf3.validator({ emitError: true }); + this.sf4.validator({ emitError: true }); + this.sf5.validator({ emitError: true }); + this.sf6.validator({ emitError: true }); + this.sf7.validator({ emitError: true }); + if (this.validateForm1.invalid || !this.sf3.valid || !this.sf4.valid || !this.sf5.valid || !this.sf6.valid || !this.sf7.valid) { + this.service.msgSrv.warning('请完善必填项!'); + return; + } + if (this.validateForm1.value.loadingTime < new Date()) { + this.service.msgSrv.warning('装货时间必须大于当前时间!'); + return; + } + if (this.validateForm1.value.loadingTime > this.validateForm1.value.unloadingTime) { + this.service.msgSrv.warning('装货时间不能大于卸货时间!'); + return; + } + if (this.sf7.value.total <= 0) { + this.service.msgSrv.warning('总费用不能为0!'); + return; + } + + if (this.sf4.value.weight > this.limitValues.maxWeight || this.sf4.value.volume > this.limitValues.maxVolume || this.sf4.value.number > this.limitValues.maxPiece) { + this.service.msgSrv.error(`当前货物核载信息已超出限定值【${this.limitValues.maxWeight}吨、${this.limitValues.maxVolume}方、${this.limitValues.maxPiece}件】`); + return; + } + + const getFreightParms = { carLengthKeys: this.sf4.value.carLength, km: this.totalDistance }; + this.service.request(this.service.$api_getFreight, getFreightParms).subscribe((res) => { + if (this.sf7.value.subtotal > res.maxPrice) { + this.service.msgSrv.error(`运费过高,请调整录入`); + return; + } else if (this.sf7.value.subtotal > res.ewPrice) { + this.modalService.confirm({ + nzTitle: '', + nzContent: `您的录入的运费过高,可能会影响支付,请仔细确认`, + nzOkText: '继续', + nzCancelText: '取消', + nzOnOk: () => { + this.agreementConfirm(submitType); + }, + }); + } else { + this.agreementConfirm(submitType); + } + }) + } + // 提交前协议弹窗 + agreementConfirm(submitType?: string) { const modalRef = this.modalService.create({ nzTitle: '运输协议', nzContent: TranAgreementComponent, nzWidth: 900, - nzFooter: null, + nzFooter: null }); modalRef.afterClose.subscribe(result => { if (result) { @@ -841,73 +975,109 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { } // 提交 submit(submitType?: string): void { - Object.keys(this.validateForm1.controls).forEach(key => { - this.validateForm1.controls[key].markAsDirty(); - this.validateForm1.controls[key].updateValueAndValidity(); + //装卸货信息 + const LoadingList = this.startInfo.concat(this.endInfo); + + // 货物信息 + const sf3Values = { ...this.sf3.value }; + if (sf3Values.goodsTypeName === '其它') { + sf3Values.goodsName = sf3Values.goodsName1; + delete sf3Values.goodsName1; + } + if (this.sf4.value.carModel.includes('999')) { + this.sf4.value.carModel = ['999']; + } + if (this.sf4.value.carLength.includes('999')) { + this.sf4.value.carLength = ['999']; + } + const goodsInfoList = [ + { + ...sf3Values, + ...this.sf4.value, + carModel: this.sf4.value.carModel.join(','), + carLength: this.sf4.value.carLength.join(',') + } + ]; + // 运费信息 + const expenseList = [ + { expenseCode: 'PRE', expenseName: '预付', price: this.sf7.value.prePay || 0, id: this.sf7data?.prePayId || '' }, + { expenseCode: 'RECE', expenseName: '到付', price: this.sf7.value.toPay || 0, id: this.sf7data?.toPayId || '' }, + { expenseCode: 'BACK', expenseName: '回单付', price: this.sf7.value.receiptPay || 0, id: this.sf7data?.receiptPayId || '' } + ]; + + // 从“再下一单”过来,将所有的子参数内的id都删除 + if (this.PageStatus = '整车下一单') { + LoadingList.forEach((ele: any) => { + delete ele.id; }); - this.sf1.validator({ emitError: true }); - this.sf3.validator({ emitError: true }); - this.sf4.validator({ emitError: true }); - this.sf6.validator({ emitError: true }); - this.sf7.validator({ emitError: true }); - console.log(this.sf1.valid); - if (this.validateForm1.invalid || !this.sf3.valid || !this.sf1.valid || !this.sf4.valid || !this.sf6.valid || !this.sf7.valid) { - return; - } - console.log(this?.loadingTime); - console.log(this?.unloadingTime); - if (typeof this.unloadingTime !== 'string') { - var c = new Date(this.unloadingTime); - this.unloadingTime = - c.getFullYear() + - '-' + - this.addPreZero(c.getMonth() + 1) + - '-' + - this.addPreZero(c.getDate()) + - ' ' + - this.addPreZero(c.getHours()) + - ':' + - this.addPreZero(c.getMinutes()) + - ':' + - this.addPreZero(c.getSeconds()); - } - if (typeof this.loadingTime !== 'string') { - var c = new Date(this.loadingTime); - this.loadingTime = - c.getFullYear() + - '-' + - this.addPreZero(c.getMonth() + 1) + - '-' + - this.addPreZero(c.getDate()) + - ' ' + - this.addPreZero(c.getHours()) + - ':' + - this.addPreZero(c.getMinutes()) + - ':' + - this.addPreZero(c.getSeconds()); - } - console.log(this.loadingTime) - const params: any = { - ...this.sf1.value, - ...this.sf5.value, - ...this.sf6.value, - paymentDays: this.sf7.value.paymentDays, - loadingTime: this.loadingTime, - unloadingTime: this.unloadingTime, - unLoadingPlaceDTOList: [...this.startInfo, ...this.endInfo], - goodsInfoDTOList: [ - { - ...this.sf4.value, - ...this.sf3.value, - carModel: this.sf4.value.carModel.join(','), - carLength: this.sf4.value.carLength.join(',') - } - ] - }; - params.shippingInformationDTO = { - ...this.sf7.value, - totalFees: this.totalFees - }; + goodsInfoList.forEach((ele: any) => { + delete ele.id; + }); + expenseList.forEach((ele: any) => { + delete ele.id; + }); + } + + // if (typeof this.unloadingTime !== 'string') { + // var c = new Date(this.unloadingTime); + // this.unloadingTime = + // c.getFullYear() + + // '-' + + // this.addPreZero(c.getMonth() + 1) + + // '-' + + // this.addPreZero(c.getDate()) + + // ' ' + + // this.addPreZero(c.getHours()) + + // ':' + + // this.addPreZero(c.getMinutes()) + + // ':' + + // this.addPreZero(c.getSeconds()); + // } + // if (typeof this.loadingTime !== 'string') { + // var c = new Date(this.loadingTime); + // this.loadingTime = + // c.getFullYear() + + // '-' + + // this.addPreZero(c.getMonth() + 1) + + // '-' + + // this.addPreZero(c.getDate()) + + // ' ' + + // this.addPreZero(c.getHours()) + + // ':' + + // this.addPreZero(c.getMinutes()) + + // ':' + + // this.addPreZero(c.getSeconds()); + // } + + const params = { + id: '', + ...this.sf1.value, + unLoadingPlaceList: LoadingList, + unloadingTime: format(this.validateForm1.value.unloadingTime, 'yyyy-MM-dd HH:mm:ss'), + loadingTime: format(this.validateForm1.value.loadingTime, 'yyyy-MM-dd HH:mm:ss'), + goodsInfoList: goodsInfoList, + ...this.sf5.value, + ...this.sf6.value, + expenseDTOList: expenseList, + paymentDays: this.sf7.value.paymentDays, + }; + // const params: any = { + // ...this.sf1.value, + // ...this.sf5.value, + // ...this.sf6.value, + // paymentDays: this.sf7.value.paymentDays, + // loadingTime: this.loadingTime, + // unloadingTime: this.unloadingTime, + // unLoadingPlaceDTOList: [...this.startInfo, ...this.endInfo], + // goodsInfoDTOList: [ + // { + // ...this.sf4.value, + // ...this.sf3.value, + // carModel: this.sf4.value.carModel.join(','), + // carLength: this.sf4.value.carLength.join(',') + // } + // ] + // }; console.log(params); if (submitType) { if (submitType == 'assign') { @@ -979,6 +1149,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe((res: any) => { this.totalDistance = res.distance; this.totalTime = res.time; + this.getInsurersPrice(); // 计算保费金额 }); } } @@ -1203,6 +1374,14 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { default: break; } + // 计算里程,时间 + if (this.startInfo[0]?.area && this.endInfo[0]?.area) { + this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => { + this.totalDistance = res.distance; + this.totalTime = res.time; + this.getInsurersPrice(); //计算保费金额 + }); + } } }); } @@ -1271,78 +1450,29 @@ export class SupplyManagementOnecarPublishComponent implements OnInit { this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => { this.totalDistance = res.distance; this.totalTime = res.time; + this.getInsurersPrice(); //计算保费金额 }); } } - goodsValuesChange(value: any) { - console.log(value); - console.log(this.totalDistance); - - if(value >= 50000 && this.totalDistance > 0){ + // 计算保价费金额 + getInsurersPrice(insuranceType = this.sf5.value.insuranceType) { + if (this.sf5.value.goodsValue >= 50000 && this.totalDistance > 0) { + const params = { - goodsValue: value, - insuranceType: this.sf55.value.insuranceType, + insuranceType, + goodsValue: this.sf5.value.goodsValue, 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); - } + this.service.request(this.service.$api_getWholeInsuranceInfo, params).subscribe(res => { + if (res) { + this.sf5.setValue('/insurancePremium', res.insurancePremium); + this.sf5.setValue('/insuranceRate', res.insuranceRate); + } else { + this.sf5.setValue('/insurancePremium', null); + this.sf5.setValue('/insuranceRate', null); + } }); } } - getInsurersPrice($event?: any) { - console.log($event); - this.changeSub.next(`${$event}`); - - - } - getInsurers($event?: any) { - this.changeSub.pipe(debounceTime(500)).subscribe((res: any) => { - console.log(res) - if (res) { - console.log(res) - if(res > 3000000 ) { - console.log('1111') - this.sf5.getProperty('/goodsValue')!.widget.reset(3000000); - this.sf5.setValue('/goodsValue', 3000000); - this.service.msgSrv.error('请输入50000-3000000之间数值!') - } - if(res < 50000) { - // this.sf5.setValue('/goodsValue', 50000); - this.sf5.getProperty('/goodsValue')!.widget.reset(50000); - this.sf5.setValue('/goodsValue', 50000); - - console.log('2222') - this.service.msgSrv.error('请输入50000-3000000之间数值!') - } - if (this.sf5.value.goodsValue >= 50000) { - if(this.totalDistance <=0){ - this.service.msgSrv.warning('当前装卸货距离为0,无法计算保价费金额'); - return; - } - const params = { - goodsValue: this.sf5.value.goodsValue, - insuranceType: this.sf5.value.insuranceType, - km: this.totalDistance - }; - this.service.request(this.service.$api_getWholeInsuranceInfo, params).subscribe(res => { - if (res) { - this.sf5.setValue('/insurancePremium', res.insurancePremium); - this.sf5.setValue('/insuranceRate', res.insuranceRate); - } else { - this.sf5.setValue('/insurancePremium', null); - this.sf5.setValue('/insuranceRate', null); - } - }); - } - } - - }); - } } diff --git a/src/app/routes/supply-management/components/release-publish/release-publish.component.ts b/src/app/routes/supply-management/components/release-publish/release-publish.component.ts index df1da26e..9572bee4 100644 --- a/src/app/routes/supply-management/components/release-publish/release-publish.component.ts +++ b/src/app/routes/supply-management/components/release-publish/release-publish.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { ActivatedRoute, Router } from '@angular/router'; import { cacheConf } from '@conf/cache.conf'; +import differenceInCalendarDays from 'date-fns/differenceInCalendarDays'; import { SFCheckboxWidgetSchema, SFComponent, @@ -241,7 +242,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { ui: { widget: 'select', placeholder: '请选择', - errors: { required: '请选择货物类型' }, + errors: { required: '请选择货物名称' }, asyncData: () => this.shipperSrv.loadConfigByKey('goods.name.config.type').pipe( map((data: any) => { @@ -270,7 +271,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { widget: 'select', placeholder: '请选择', errors: { required: '请填写货物名称' }, - change: (_value: any, data: any) => { + change: (value: any, data: any) => { this.sf3.setValue('/goodsName', data.label); }, visibleIf: { @@ -299,11 +300,11 @@ export class SupplyManagementReleasePublishComponent implements OnInit { } } }, - required: ['goodsTypeId', 'goodsName', 'goodsNameId'] + required: ['goodsTypeId', 'goodsName', 'goodsNameId', 'goodsName1'] }; this.ui3 = { '*': { - spanLabelFixed: 90, + spanLabelFixed: 115, grid: { span: 12 } } }; @@ -317,7 +318,8 @@ export class SupplyManagementReleasePublishComponent implements OnInit { ui: { widget: 'custom', placeholder: '请输入', - errors: { required: '必填项' } + errors: { required: '必填项' }, + validator: val => this.customValidator(val) } }, volume: { @@ -325,7 +327,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { title: '', ui: { widget: 'custom', - placeholder: '请输入' + placeholder: '请输入', } }, number: { @@ -333,7 +335,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { title: '', ui: { widget: 'custom', - placeholder: '请输入' + placeholder: '请输入', } }, carModel: { @@ -342,13 +344,13 @@ export class SupplyManagementReleasePublishComponent implements OnInit { ui: { widget: 'select', mode: 'multiple', - maxMultipleCount:3, + maxMultipleCount: 3, placeholder: '请选择车型', errors: { required: '请选择车型' }, asyncData: () => this.service.getDictOptions({ dictKey: 'car:model' }), - change:(tag:any , org:any)=>{ - if(tag.includes("999")){ - this.sf4.setValue('/carModel',["999"]); + change: (tag: any, org: any) => { + if (tag.includes('999')) { + this.sf4.setValue('/carModel', ['999']); } } } @@ -359,43 +361,28 @@ export class SupplyManagementReleasePublishComponent implements OnInit { ui: { widget: 'select', mode: 'multiple', - maxMultipleCount:3, + maxMultipleCount: 3, placeholder: '请选择车长', errors: { required: '请选择车长' }, asyncData: () => this.service.getDictOptions({ dictKey: 'car:length' }), - change:(tag:any , org:any)=>{ - if(tag.includes("999")){ - this.sf4.setValue('/carModel',["999"]); + change: (tag: any, org: any) => { + if (tag.includes('999')) { + this.sf4.setValue('/carLength', ['999']); } } } - }, + } }, required: ['weight', 'carModel', 'carLength'] }; this.ui4 = { '*': { - spanLabelFixed: 90, - grid: { span: 24 } - }, - $weight: { - grid: { lg: 8, md: 12, sm: 12, xs: 24 } - }, - $volume: { - grid: { lg: 8, md: 12, sm: 12, xs: 24 } - }, - $number: { - grid: { lg: 8, md: 12, sm: 12, xs: 24 } - }, - $carModel: { - spanLabelFixed: 100, - grid: { span: 8 } - }, - $carLength: { + spanLabelFixed: 115, grid: { span: 8 } } }; } + initSF5() { this.schema5 = { properties: { @@ -403,8 +390,17 @@ export class SupplyManagementReleasePublishComponent implements OnInit { type: 'string', title: '增值服务套餐', ui: { - widget: 'dict-select', - params: { dictKey: 'bill:insurance:type' }, + widget: 'select', + asyncData: () => { + return this.service.request(this.service.$api_getDictValue, { dictKey: 'bill:insurance:type' }).pipe( + map((res: any) => { + return [...res]; + }) + ) + }, + change: (tag: any, org: any) => { + this.getInsurersPrice(tag); + } }, default: '3' }, @@ -415,7 +411,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { readOnly: true, ui: { widget: 'checkbox', - visibleIf: { insuranceType: (value: string) => value === '0' } + visibleIf: { insuranceType: (value: string) => value === '1' } } as SFCheckboxWidgetSchema, default: ['车辆实时定位', '轨迹查询', '数据保护', '赠送基本险'] }, @@ -426,7 +422,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { readOnly: true, ui: { widget: 'checkbox', - visibleIf: { insuranceType: (value: string) => value === '1' } + visibleIf: { insuranceType: (value: string) => value === '2' } } as SFCheckboxWidgetSchema, default: ['车辆实时定位', '轨迹查询', '数据保护', '专属技术服务', '赠送综合险'] }, @@ -438,21 +434,22 @@ export class SupplyManagementReleasePublishComponent implements OnInit { visibleIf: { insuranceType: (value: string) => value !== '3' } } }, - insurancePackagedGoods:{ + insurancePackagedGoods: { type: 'string', title: '货物包装', ui: { widget: 'dict-select', params: { dictKey: 'insure:packaged:goods' }, + containsAllLabel: false, visibleIf: { insuranceType: (value: string) => value !== '3' } } as SFSelectWidgetSchema }, - hidenField:{ + hidenField: { type: 'string', title: '', - default:' ', + default: ' ', ui: { - widget:'text' + widget: 'text' } }, goodsValue: { @@ -469,6 +466,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { title: '', ui: { widget: 'custom', + validator: val => this.customValidator(val), visibleIf: { insuranceType: (value: string) => value !== '3' } } }, @@ -478,26 +476,27 @@ export class SupplyManagementReleasePublishComponent implements OnInit { ui: { hidden: true } - }, + } }, - required: ['insurancePackagedGoods'] + required: ['insurancePackagedGoods', 'insurancePremium'] }; this.ui5 = { '*': { spanLabelFixed: 115, grid: { span: 12 } }, - $type1:{ + $type1: { grid: { span: 24 } }, - $type2:{ + $type2: { grid: { span: 24 } }, - $freeInsurance:{ + $freeInsurance: { grid: { span: 24 } - }, + } }; } + initSF6() { this.schema6 = { properties: { @@ -520,7 +519,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit { ui: { widget: 'dict-select', params: { dictKey: 'receipt:type' }, - containsAllLable: false, + containsAllLabel: false, placeholder: '请选择', errors: { required: '请选择' }, visibleIf: { @@ -528,58 +527,65 @@ export class SupplyManagementReleasePublishComponent implements OnInit { } } }, - // receiptAddressId: { - // type: 'string', - // title: '选择地址', - // ui: { - // widget: 'custom', - // placeholder: '请点击选择收回单地址', - // // validator: val => (this.sf6?.value?.receiptType === '2' ? [{ keyword: 'required', message: '请点击选择收回单地址' }] : []), - // visibleIf: { - // receiptType: value => value === '2' - // } - // }, - // default: '' - // }, + receiptAddress: { + type: 'string', + title: '回单收件人信息', + ui: { + widget: 'custom', + placeholder: '请点击选择回单收件人信息', + // validator: val => (this.sf6?.value?.receiptType === '2' ? [{ keyword: 'required', message: '请点击选择收回单地址' }] : []), + visibleIf: { + receiptType: value => value === '2' + } + }, + default: '' + }, + receiptAddressId: { + type: 'string', + title: '', + ui: { + hidden: true + } + }, receiptUserName: { type: 'string', title: '联系人', - maxLength: 15, ui: { visibleIf: { receiptType: value => value === '2' } }, + readOnly: true }, - receiptUserPhone: { + phon: { type: 'string', title: '联系电话', - maxLength: 11, ui: { visibleIf: { receiptType: value => value === '2' } }, + readOnly: true }, - receiptAddressArea: { + area: { type: 'string', title: '所在地区', - maxLength: 30, ui: { visibleIf: { receiptType: value => value === '2' } }, + readOnly: true }, - receiptAddress: { + address: { type: 'string', title: '详细地址', - maxLength: 50, ui: { visibleIf: { receiptType: value => value === '2' } }, + readOnly: true }, remarks: { type: 'string', @@ -592,15 +598,16 @@ export class SupplyManagementReleasePublishComponent implements OnInit { } as SFTextareaWidgetSchema } }, - required: ['stateReceipt', 'receiptType', 'receiptUserName','receiptUserPhone','receiptAddressArea','receiptAddress'] + required: ['stateReceipt', 'receiptType', 'receiptAddress'] }; this.ui6 = { '*': { - spanLabelFixed: 90, + spanLabelFixed: 115, grid: { span: 24 } } }; } + initSF7() { this.schema7 = { properties: { @@ -608,19 +615,19 @@ export class SupplyManagementReleasePublishComponent implements OnInit { type: 'number', title: '预付', default: 0, - ui: {widget: 'custom'} + ui: { widget: 'custom' } }, toPay: { type: 'number', title: '到付', default: 0, - ui: { widget: 'custom'} + ui: { widget: 'custom' } }, receiptPay: { type: 'number', title: '回单付', default: 0, - ui: {widget: 'custom'} + ui: { widget: 'custom' } }, subtotal: { type: 'number', title: '小计', default: 0, ui: { widget: 'custom' } as SFNumberWidgetSchema }, appendFee: { type: 'number', title: '附加费', default: 0, ui: { widget: 'custom' } as SFNumberWidgetSchema }, @@ -643,6 +650,29 @@ export class SupplyManagementReleasePublishComponent implements OnInit { } }; } + // 不可选择的时间 + disabledDateStart = (current: Date): boolean => { + return differenceInCalendarDays(new Date(), current) > 0; + }; + + /** + * 自定义校验数据 + * @param val + */ + customValidator(val: number) { + if (this.isEmpty(val)) { + return [{ keyword: 'required', message: '不能为空' }]; + } else { + if (val <= 0) { + return [{ keyword: 'required', message: '数值需大于0' }]; + } + return []; + } + } + + isEmpty(val: any) { + return val === undefined || val === null || val.toString().trim() === ''; + } // 获取城市列表 getRegionCode(regionCode: any) { console.log(regionCode); @@ -663,37 +693,35 @@ export class SupplyManagementReleasePublishComponent implements OnInit { } payChange() { const prePay = this.sf7.value.prePay || 0; - const toPay = this.sf7.value.toPay || 0 + const toPay = this.sf7.value.toPay || 0; const receiptPay = this.sf7.value.receiptPay || 0; - // const oilCardPay = 0; + const oilCardPay = 0; const subtotal = prePay + toPay + receiptPay; const params = { - shipperId: this.envCache?.enterpriseId, - enterpriseInfoId: this.envCache?.networkTransporterId, - totalFreight:subtotal, - // fuelCardAmount:oilCardPay, - resourcetype:'1' - } - this.service - .request(this.service.$api_getCalculatedSurcharge,params) - .subscribe(res => { - if (res) { - this.sf7.setValue('/appendFee', res.surcharge); - this.sf7.setValue('/subtotal', subtotal); - this.sf7.setValue('/total', subtotal + res.surcharge); - this.service - .request(this.service.$api_getcalculatedServiceRate + `?invoiceAmount=${subtotal + res.surcharge}&totalFreight=${subtotal}`) - .subscribe(res => { - if (res) { - this.currentRate = res.rate * 100; - } else { - this.service.msgSrv.error(res.msg); - } - }); - } else { - this.service.msgSrv.error(res.msg); - } - }); + shipperId: this?.sf1.value?.shipperAppUserId, + enterpriseInfoId: this?.sf1.value?.enterpriseInfoName, + totalFreight: subtotal, + fuelCardAmount: oilCardPay, + resourcetype: '1' + }; + this.service.request(this.service.$api_getCalculatedSurcharge, params).subscribe(res => { + console.log('999') + console.log(this?.sf1.value) + if (res) { + this.sf7.setValue('/appendFee', res.surcharge); + this.sf7.setValue('/subtotal', subtotal); + this.sf7.setValue('/total', subtotal + res.surcharge); + this.service + .request(this.service.$api_getAdditionalRate + `?shipperId=${this?.sf1.value?.shipperAppUserId}&enterpriseInfoId=${this?.sf1.value?.enterpriseInfoName}&resourcetype='1'`) + .subscribe(res => { + if (res) { + this.currentRate = res.rate * 100; + } + }); + } else { + this.service.msgSrv.error(res.msg); + } + }); } // 添加 删除发货卸货地址 addStartInfo() { @@ -983,6 +1011,8 @@ export class SupplyManagementReleasePublishComponent implements OnInit { if (this.sf3data.goodsNameId) { this.sf3.setValue('/goodsNameId', this.sf3data.goodsNameId); } + } else { + this.service.msgSrv.error(res.msg); } }); } @@ -1049,28 +1079,24 @@ export class SupplyManagementReleasePublishComponent implements OnInit { }); } } - getInsurersPrice() { - console.log(this.sf5.value.goodsValue) - console.log(this.sf5.value.insuranceType) - if (this.sf5.value.goodsValue >= 50000) { - if(this.totalDistance <=0){ - this.service.msgSrv.warning('当前装卸货距离为0,无法计算保价费金额'); - return; + // 计算保价费金额 + getInsurersPrice(insuranceType = this.sf5.value.insuranceType) { + if (this.sf5.value.goodsValue >= 50000 && this.totalDistance > 0) { + + const params = { + insuranceType, + goodsValue: this.sf5.value.goodsValue, + km: this.totalDistance + }; + this.service.request(this.service.$api_getWholeInsuranceInfo, params).subscribe(res => { + if (res) { + this.sf5.setValue('/insurancePremium', res.insurancePremium); + this.sf5.setValue('/insuranceRate', res.insuranceRate); + } else { + this.sf5.setValue('/insurancePremium', null); + this.sf5.setValue('/insuranceRate', null); } - const params = { - goodsValue: this.sf5.value.goodsValue, - insuranceType: this.sf5.value.insuranceType, - km: this.totalDistance - }; - this.service.request(this.service.$api_getWholeInsuranceInfo, params).subscribe(res => { - if (res) { - this.sf5.setValue('/insurancePremium', res.insurancePremium); - this.sf5.setValue('/insuranceRate', res.insuranceRate); - } else { - this.sf5.setValue('/insurancePremium', null); - this.sf5.setValue('/insuranceRate', 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 04ff9de7..dfde3bc3 100644 --- a/src/app/routes/supply-management/services/supply-management.service.ts +++ b/src/app/routes/supply-management/services/supply-management.service.ts @@ -4,7 +4,7 @@ * @Author : Shiming * @Date : 2021-12-03 11:10:14 * @LastEditors : Shiming - * @LastEditTime : 2022-02-28 11:31:44 + * @LastEditTime : 2022-02-28 15:22:19 * @FilePath : \\tms-obc-web\\src\\app\\routes\\supply-management\\services\\supply-management.service.ts * Copyright (C) 2022 huzhenhong. All rights reserved. */ @@ -54,6 +54,8 @@ export class SupplyManagementService extends BaseService { $api_getCalculatedSurcharge = `/api/sdc/expense/getCalculatedSurcharge`; // 整车计算附加费率 $api_getcalculatedServiceRate = `/api/sdc/expense/getAdditionalRate`; + // 整车计算附加费率 + $api_getAdditionalRate = `/api/sdc/expense/getAdditionalRate`; // 代发整车货源 $api_consignWhole = `/api/sdc/goodsResourceOperate/consignWhole`; // 代发大宗货源 @@ -111,8 +113,10 @@ export class SupplyManagementService extends BaseService { public $api_getOperationLogRecordsList = '/api/mdc/pbc/operationLogRecords/getOperationLogRecordsList'; // 获取数据字典 $api_getDictValue = `/api/mdc/pbc/dictItems/getDictValue`; - // 获取协议信息 - public $api_getAgreementInfoByType = '/api/mdc/pbc/agreementInfo/getAgreementInfoByType'; + // 获取协议信息 + public $api_getAgreementInfoByType = '/api/mdc/pbc/agreementInfo/getAgreementInfoByType'; + // 获取运价 + public $api_getFreight = '/api/mdc/cuc/freightConfig/getFreight'; /** * 获取车型、车长字典数据 * @returns @@ -132,6 +136,13 @@ export class SupplyManagementService extends BaseService { constructor(public injector: Injector) { super(injector); } + public limitKeys = { + weight: 'sys.config.goods.approvalCarMaxWeight', //整车-核载重量上限 + volume: 'sys.config.goods.approvalCarMaxVolume', //整车-核载体积上限 + piece: 'sys.config.goods.approvalCarMaxPiece' //整车-核载件数上限 + }; + // 根据ItemKey获取项值 + public $api_findItemValueByItemKeys = '/api/mdc/pbc/sysConfigItem/findItemValueByItemKeys'; // 获取保价费信息 public $api_getWholeInsuranceInfo = '/api/sdc/goodsResourceShipper/getWholeInsuranceInfo'; }