fix bug
This commit is contained in:
@ -897,11 +897,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
|
||||
this.sf5.validator({ emitError: true });
|
||||
this.sf6.validator({ emitError: true });
|
||||
this.sf7.validator({ emitError: true });
|
||||
console.log(this.validateForm1.invalid)
|
||||
console.log(this.sf4.valid)
|
||||
console.log(this.sf5.valid)
|
||||
console.log(this.sf6.valid)
|
||||
console.log(this.sf7.valid)
|
||||
if (this.validateForm1.invalid || !this.sf3.valid || !this.sf4.valid || !this.sf5.valid || !this.sf6.valid || !this.sf7.valid) {
|
||||
this.service.msgSrv.warning('请完善必填项!');
|
||||
return;
|
||||
|
||||
@ -851,65 +851,137 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
|
||||
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.sf5.validator({ emitError: true });
|
||||
this.sf6.validator({ emitError: true });
|
||||
this.sf7.validator({ emitError: true });
|
||||
if (this.validateForm1.invalid || !this.sf1.valid || !this.sf3.valid || !this.sf4.valid || !this.sf6.valid || !this.sf7.valid) {
|
||||
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;
|
||||
}
|
||||
const num = (Number(this.validateForm1.value.unloadingTime) - Number(this.validateForm1.value.loadingTime))/(24*60*60*1000);
|
||||
if (num > this.limitValues.maxDays) {
|
||||
this.service.msgSrv.error(`当前计划装卸货时间间隔已超出限定值【${this.limitValues.maxDays}天】`);
|
||||
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 modalRef = this.modalService.create({
|
||||
nzTitle: '运输协议',
|
||||
nzContent: TranAgreementComponent,
|
||||
nzWidth: 900,
|
||||
nzFooter: null
|
||||
});
|
||||
modalRef.afterClose.subscribe(result => {
|
||||
if (result) {
|
||||
this.submit(submitType);
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 提交
|
||||
submit(submitType: string): void {
|
||||
//装卸货信息
|
||||
const LoadingList = this.startInfo.concat(this.endInfo);
|
||||
// 货物信息
|
||||
const goodsInfoList = [
|
||||
{
|
||||
...this.sf4.value,
|
||||
...this.sf3.value,
|
||||
carModel: this.sf4.value.carModel.join(','),
|
||||
carLength: this.sf4.value.carLength.join(',')
|
||||
}
|
||||
];
|
||||
// 提交前协议弹窗
|
||||
agreementConfirm(submitType?: string) {
|
||||
//装卸货信息
|
||||
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 goodsInfoVOList = [
|
||||
{
|
||||
...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, id: this.sf7data?.prePayId ? this.sf7data?.prePayId : '' },
|
||||
{ expenseCode: 'RECE', expenseName: '到付', price: this.sf7.value.toPay, id: this.sf7data?.toPayId ? this.sf7data?.toPayId : '' },
|
||||
{
|
||||
expenseCode: 'BACK',
|
||||
expenseName: '回单付',
|
||||
price: this.sf7.value.receiptPay,
|
||||
id: this.sf7data?.receiptPayId ? this.sf7data?.receiptPayId : ''
|
||||
}
|
||||
{ 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 || '' }
|
||||
];
|
||||
const params = {
|
||||
id: '',
|
||||
...this.sf1.value,
|
||||
unLoadingPlaceDTOList: 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'),
|
||||
goodsInfoDTOList: goodsInfoList,
|
||||
...this.sf5.value,
|
||||
...this.sf6.value,
|
||||
expenseDTOList: expenseList,
|
||||
paymentDays: this.sf7.value.paymentDays,
|
||||
insuranceType:this.sf55.value.insuranceType,
|
||||
};
|
||||
console.log(this.sf55?.value)
|
||||
// const params = {
|
||||
// id: '',
|
||||
// ...this.sf1.value,
|
||||
// unLoadingPlaceDTOList: 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'),
|
||||
// goodsInfoDTOList: goodsInfoList,
|
||||
// ...this.sf5.value,
|
||||
// ...this.sf6.value,
|
||||
// expenseDTOList: expenseList,
|
||||
// paymentDays: this.sf7.value?.paymentDays,
|
||||
// insuranceType:this.sf55?.value?.insuranceType,
|
||||
// };
|
||||
const params = {
|
||||
id: '',
|
||||
...this.sf1.value,
|
||||
unLoadingPlaceDTOList: 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'),
|
||||
goodsInfoDTOList: goodsInfoVOList,
|
||||
...this.sf5.value,
|
||||
...this.sf6.value,
|
||||
expenseDTOList: expenseList,
|
||||
paymentDays: this.sf7.value.paymentDays
|
||||
};
|
||||
console.log(params)
|
||||
const modalRef = this.modalService.create({
|
||||
nzTitle: '运输协议',
|
||||
nzContent: TranAgreementComponent,
|
||||
nzWidth: 900,
|
||||
nzFooter: null,
|
||||
nzComponentParams: {Object: params,}
|
||||
});
|
||||
modalRef.afterClose.subscribe(result => {
|
||||
if (result) {
|
||||
this.submit(submitType, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 提交
|
||||
submit(submitType?: string,params?: any): void {
|
||||
|
||||
|
||||
let reqUrl = this.service.$api_consignWhole;
|
||||
if (submitType) {
|
||||
@ -1069,65 +1141,44 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
|
||||
goBack() {
|
||||
window.history.go(-1);
|
||||
}
|
||||
// 装卸货地址互换
|
||||
swapAddress(){
|
||||
this.startInfo.forEach((element:any, index:any) => {
|
||||
this.validateForm1.removeControl(`loadAddress${index}`);
|
||||
this.validateForm1.removeControl(`loadName${index}`);
|
||||
this.validateForm1.removeControl(`loadPhone${index}`);
|
||||
});
|
||||
this.endInfo.forEach((element:any, index:any) => {
|
||||
this.validateForm1.removeControl(`unloadAddress${index}`);
|
||||
this.validateForm1.removeControl(`unloadName${index}`);
|
||||
this.validateForm1.removeControl(`unloadPhone${index}`);
|
||||
});
|
||||
|
||||
let item = this.startInfo;
|
||||
this.startInfo = this.endInfo;
|
||||
this.endInfo = item;
|
||||
|
||||
this.startInfo.forEach((element:any,index:any) => {
|
||||
element.type = '1';
|
||||
this.validateForm1.addControl(`loadAddress${index}`, new FormControl(null, Validators.required));
|
||||
this.validateForm1.addControl(`loadName${index}`, new FormControl(null, Validators.required));
|
||||
this.validateForm1.addControl(`loadPhone${index}`, new FormControl(null, [Validators.required, Validators.pattern('^[0-9]*$')]));
|
||||
});
|
||||
this.endInfo.forEach((element:any,index:any) => {
|
||||
element.type = '2';
|
||||
this.validateForm1.addControl(`unloadAddress${index}`, new FormControl(null, Validators.required));
|
||||
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) {
|
||||
// 装卸货地址互换
|
||||
swapAddress() {
|
||||
this.startInfo.forEach((element: any, index: any) => {
|
||||
this.validateForm1.removeControl(`loadAddress${index}`);
|
||||
this.validateForm1.removeControl(`loadName${index}`);
|
||||
this.validateForm1.removeControl(`loadPhone${index}`);
|
||||
});
|
||||
this.endInfo.forEach((element: any, index: any) => {
|
||||
this.validateForm1.removeControl(`unloadAddress${index}`);
|
||||
this.validateForm1.removeControl(`unloadName${index}`);
|
||||
this.validateForm1.removeControl(`unloadPhone${index}`);
|
||||
});
|
||||
|
||||
let item = this.startInfo;
|
||||
this.startInfo = this.endInfo;
|
||||
this.endInfo = item;
|
||||
|
||||
this.startInfo.forEach((element: any, index: any) => {
|
||||
element.type = '1';
|
||||
this.validateForm1.addControl(`loadAddress${index}`, new FormControl(null, Validators.required));
|
||||
this.validateForm1.addControl(`loadName${index}`, new FormControl(null, Validators.required));
|
||||
this.validateForm1.addControl(`loadPhone${index}`, new FormControl(null, [Validators.required, Validators.pattern('^[0-9]*$')]));
|
||||
});
|
||||
this.endInfo.forEach((element: any, index: any) => {
|
||||
element.type = '2';
|
||||
this.validateForm1.addControl(`unloadAddress${index}`, new FormControl(null, Validators.required));
|
||||
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 => {
|
||||
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){
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
// 计算保价费金额
|
||||
getInsurersPrice(insuranceType = this.sf5.value.insuranceType) {
|
||||
if (this.sf5.value.goodsValue >= 50000 && this.totalDistance > 0) {
|
||||
|
||||
Reference in New Issue
Block a user