fix bug
This commit is contained in:
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user