This commit is contained in:
wangshiming
2022-02-28 16:24:04 +08:00
parent 756bed1e72
commit 545b867fc1
3 changed files with 262 additions and 357 deletions

View File

@ -33,10 +33,10 @@
</nz-input-group> </nz-input-group>
<span *ngIf="idx !== 0" [ngClass]="idx == 0 ? 'hides' : ''" style="padding: 0 10px" <span *ngIf="idx !== 0" [ngClass]="idx == 0 ? 'hides' : ''" style="padding: 0 10px"
><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subStartInfo($event, idx, data.id)"></i ><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subStartInfo($event, idx)"></i
></span> ></span>
<span *ngIf="idx == 0" style="visibility:hidden;padding: 0 10px" <span *ngIf="idx == 0" style="visibility:hidden;padding: 0 10px"
><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subStartInfo($event, idx, data.id)"></i ><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subStartInfo($event, idx)"></i
></span> ></span>
</div> </div>
</nz-form-control> </nz-form-control>
@ -69,7 +69,7 @@
</nz-form-item> </nz-form-item>
</div> </div>
<div style="display: flex; justify-content: center"> <div style="display: flex; justify-content: center">
<button nz-button nzType="primary" (click)="addStartInfo($event)"> <button nz-button nzType="primary" (click)="addStartInfo()">
<i nz-icon nzType="plus"></i> <i nz-icon nzType="plus"></i>
添加装货地 添加装货地
</button> </button>
@ -98,7 +98,7 @@
</nz-input-group> </nz-input-group>
<span *ngIf="idx !== 0" style="padding: 0 10px"><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subEndInfo($event, idx)"></i></span> <span *ngIf="idx !== 0" style="padding: 0 10px"><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subEndInfo($event, idx)"></i></span>
<span *ngIf="idx == 0" style="visibility:hidden;padding: 0 10px" <span *ngIf="idx == 0" style="visibility:hidden;padding: 0 10px"
><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subStartInfo($event, idx, data.id)"></i ><i nz-icon nzType="minus-circle" nzTheme="outline" style="color: #d9001b" (click)="subStartInfo($event, idx)"></i
></span> ></span>
</div> </div>
</nz-form-control> </nz-form-control>
@ -131,7 +131,7 @@
</nz-form-item> </nz-form-item>
</div> </div>
<div style="display: flex; justify-content: center"> <div style="display: flex; justify-content: center">
<button nz-button nzType="primary" (click)="addEndInfo($event)"> <button nz-button nzType="primary" (click)="addEndInfo()">
<i nz-icon nzType="plus"></i> <i nz-icon nzType="plus"></i>
添加卸货地 添加卸货地
</button> </button>
@ -144,12 +144,11 @@
<nz-form-label [nzSpan]="5" nzRequired>装货时间</nz-form-label> <nz-form-label [nzSpan]="5" nzRequired>装货时间</nz-form-label>
<nz-form-control [nzErrorTip]="'请输入装货时间'"> <nz-form-control [nzErrorTip]="'请输入装货时间'">
<nz-date-picker <nz-date-picker
nzShowTime nzShowTime
nzFormat="yyyy-MM-dd HH:mm:ss" nzFormat="yyyy-MM-dd HH:mm:ss"
[ngModel]="loadingTime" formControlName="loadingTime"
(ngModelChange)="changeLO($event)" [nzDisabledDate]="disabledDateStart"
[ngModelOptions]="{ standalone: true }" ></nz-date-picker>
></nz-date-picker>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
@ -158,13 +157,7 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="5" nzRequired>卸货时间</nz-form-label> <nz-form-label [nzSpan]="5" nzRequired>卸货时间</nz-form-label>
<nz-form-control [nzErrorTip]="'请输入卸货时间'"> <nz-form-control [nzErrorTip]="'请输入卸货时间'">
<nz-date-picker <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="unloadingTime"></nz-date-picker>
nzShowTime
nzFormat="yyyy-MM-dd HH:mm:ss"
[ngModel]="unloadingTime"
(ngModelChange)="changeUn($event)"
[ngModelOptions]="{ standalone: true }"
></nz-date-picker>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
@ -172,55 +165,56 @@
<ng-template #endInconTemp1><i nz-icon nzType="global"></i></ng-template> <ng-template #endInconTemp1><i nz-icon nzType="global"></i></ng-template>
</form> </form>
</nz-card> </nz-card>
<nz-card> <nz-card>
<div class="card-title">货物信息</div> <div class="card-title">货物信息</div>
<div nz-row> <div nz-row>
<div nz-col nzSpan="24"> <div nz-col nzSpan="16">
<sf #sf3 [schema]="schema3" [formData]="sf3data" [button]="'none'" [ui]="ui3"></sf> <sf #sf3 [schema]="schema3" [button]="'none'" [ui]="ui3" [formData]="sf3data"></sf>
<sf #sf4 [schema]="schema4" [formData]="sf4data" [button]="'none'" [ui]="ui4">
<ng-template sf-template="weight" let-i let-ui="ui">
<nz-input-group [nzAddOnAfter]="''">
<input
nz-input
type="number"
[ngModel]="i.value"
min="0"
step="0.01"
(ngModelChange)="i.setValue($event)"
placeholder="总重量,必填"
/>
</nz-input-group>
</ng-template>
<ng-template sf-template="volume" let-i let-ui="ui">
<nz-input-group [nzAddOnAfter]="''">
<input
nz-input
type="number"
[ngModel]="i.value"
min="0"
step="0.01"
(ngModelChange)="i.setValue($event)"
placeholder="总体积"
/>
</nz-input-group>
</ng-template>
<ng-template sf-template="number" let-i let-ui="ui">
<nz-input-group [nzAddOnAfter]="''">
<input
nz-input
type="number"
[ngModel]="i.value"
min="0"
step="0.01"
(ngModelChange)="i.setValue($event)"
placeholder="总车次"
/>
</nz-input-group>
</ng-template>
</sf>
</div> </div>
</div> </div>
<sf #sf4 [schema]="schema4" [button]="'none'" [ui]="ui4" [formData]="sf4data">
<ng-template sf-template="weight" let-i let-ui="ui">
<nz-input-group [nzAddOnAfter]="''">
<input
nz-input
type="number"
[ngModel]="i.value"
min="0"
step="0.01"
(ngModelChange)="i.setValue($event)"
placeholder="总重量,必填"
oninput="if(value>99999)value=99999;if(value<0)value=0"
/>
</nz-input-group>
</ng-template>
<ng-template sf-template="volume" let-i let-ui="ui">
<nz-input-group [nzAddOnAfter]="''">
<input
nz-input
type="number"
[ngModel]="i.value"
min="0"
step="0.01"
(ngModelChange)="i.setValue($event)"
placeholder="体积"
oninput="if(value>99999)value=99999;if(value<0)value=0"
/>
</nz-input-group>
</ng-template>
<ng-template sf-template="number" let-i let-ui="ui">
<nz-input-group [nzAddOnAfter]="''">
<input
nz-input
type="number"
[ngModel]="i.value"
min="0"
(ngModelChange)="i.setValue($event)"
placeholder="车次"
oninput="if(value>99999)value=99999;if(value<0)value=0"
/>
</nz-input-group>
</ng-template>
</sf>
</nz-card> </nz-card>
<nz-card> <nz-card>

View File

@ -1,6 +1,6 @@
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { debounceTime } from 'rxjs/operators';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms'; import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
import format from 'date-fns/format'; import format from 'date-fns/format';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
@ -17,7 +17,6 @@ import {
import { _HttpClient } from '@delon/theme'; import { _HttpClient } from '@delon/theme';
import { AmapPoiPickerComponent, AmapService, EACacheService, ShipperBaseService } from '@shared'; import { AmapPoiPickerComponent, AmapService, EACacheService, ShipperBaseService } from '@shared';
import { NzModalService } from 'ng-zorro-antd/modal'; import { NzModalService } from 'ng-zorro-antd/modal';
import { type } from 'os';
import { of } from 'rxjs'; import { of } from 'rxjs';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { SupplyManagementService } from '../../services/supply-management.service'; import { SupplyManagementService } from '../../services/supply-management.service';
@ -39,8 +38,8 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
limitValues = { limitValues = {
maxWeight: 99999, maxWeight: 99999,
maxVolume: 99999, maxVolume: 99999,
maxPiece: 99999, maxPiece: 99999
} };
sf1data: any; // 货源单设置回显 sf1data: any; // 货源单设置回显
sf3data: any; // 货源单设置回显 sf3data: any; // 货源单设置回显
sf4data: any; // 货源单设置回显 sf4data: any; // 货源单设置回显
@ -72,8 +71,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
public service: SupplyManagementService, public service: SupplyManagementService,
private amapService: AmapService, private amapService: AmapService,
public shipperSrv: ShipperBaseService, public shipperSrv: ShipperBaseService,
private eaCacheSrv: EACacheService, private eaCacheSrv: EACacheService
) { ) {
this.validateForm1 = fb.group({ this.validateForm1 = fb.group({
loadingTime: [null, [Validators.required]], loadingTime: [null, [Validators.required]],
@ -112,15 +110,14 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
@ViewChild('sf7', { static: false }) sf7!: SFComponent; @ViewChild('sf7', { static: false }) sf7!: SFComponent;
schema7: SFSchema = {}; schema7: SFSchema = {};
ui7!: SFUISchema; ui7!: SFUISchema;
formatterRmb = (value: number): string =>{ formatterRmb = (value: number): string => {
if(value){ if (value) {
let value2 = Number(value).toLocaleString(undefined,{'minimumFractionDigits':2,'maximumFractionDigits':2}); let value2 = Number(value).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });
return `${value2}`; return `${value2}`;
} }
return `¥ 0.00` return `¥ 0.00`;
};
} ; parserRmb = (value: string): string => value.replace('¥ ', '').replace(',', '');
parserRmb = (value: string): string => value.replace('¥ ', '').replace(',','');
// 页面初始化 // 页面初始化
ngOnInit(): void { ngOnInit(): void {
if (this.route.snapshot?.queryParams?.sta === '1') { if (this.route.snapshot?.queryParams?.sta === '1') {
@ -343,13 +340,13 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
ui: { ui: {
widget: 'select', widget: 'select',
mode: 'multiple', mode: 'multiple',
maxMultipleCount:3, maxMultipleCount: 3,
placeholder: '请选择车型', placeholder: '请选择车型',
errors: { required: '请选择车型' }, errors: { required: '请选择车型' },
asyncData: () => this.service.getDictOptions({ dictKey: 'car:model' }), asyncData: () => this.service.getDictOptions({ dictKey: 'car:model' }),
change:(tag:any , org:any)=>{ change: (tag: any, org: any) => {
if(tag.includes("999")){ if (tag.includes('999')) {
this.sf4.setValue('/carModel',["999"]); this.sf4.setValue('/carModel', ['999']);
} }
} }
} }
@ -360,17 +357,17 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
ui: { ui: {
widget: 'select', widget: 'select',
mode: 'multiple', mode: 'multiple',
maxMultipleCount:3, maxMultipleCount: 3,
placeholder: '请选择车长', placeholder: '请选择车长',
errors: { required: '请选择车长' }, errors: { required: '请选择车长' },
asyncData: () => this.service.getDictOptions({ dictKey: 'car:length' }), asyncData: () => this.service.getDictOptions({ dictKey: 'car:length' }),
change:(tag:any , org:any)=>{ change: (tag: any, org: any) => {
if(tag.includes("999")){ if (tag.includes('999')) {
this.sf4.setValue('/carModel',["999"]); this.sf4.setValue('/carModel', ['999']);
} }
} }
} }
}, }
}, },
required: ['weight', 'carModel', 'carLength'] required: ['weight', 'carModel', 'carLength']
}; };
@ -410,7 +407,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
map((res: any) => { map((res: any) => {
return [...res]; return [...res];
}) })
) );
}, },
change: (tag: any, org: any) => { change: (tag: any, org: any) => {
this.getInsurersPrice(tag); this.getInsurersPrice(tag);
@ -514,7 +511,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
* 自定义校验数据 * 自定义校验数据
* @param val * @param val
*/ */
customValidator(val: number) { customValidator(val: number) {
if (this.isEmpty(val)) { if (this.isEmpty(val)) {
return [{ keyword: 'required', message: '不能为空' }]; return [{ keyword: 'required', message: '不能为空' }];
} else { } else {
@ -715,14 +712,17 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
resourcetype: '1' resourcetype: '1'
}; };
this.service.request(this.service.$api_getCalculatedSurcharge, params).subscribe(res => { this.service.request(this.service.$api_getCalculatedSurcharge, params).subscribe(res => {
console.log('999') console.log('999');
console.log(this.envCache) console.log(this.envCache);
if (res) { if (res) {
this.sf7.setValue('/appendFee', res.surcharge); this.sf7.setValue('/appendFee', res.surcharge);
this.sf7.setValue('/subtotal', subtotal); this.sf7.setValue('/subtotal', subtotal);
this.sf7.setValue('/total', subtotal + res.surcharge); this.sf7.setValue('/total', subtotal + res.surcharge);
this.service this.service
.request(this.service.$api_getAdditionalRate + `?shipperId=${this.envCache?.enterpriseId}&enterpriseInfoId=${this?.enterpriseProjectIds}&resourcetype='1'`) .request(
this.service.$api_getAdditionalRate +
`?shipperId=${this.envCache?.enterpriseId}&enterpriseInfoId=${this?.enterpriseProjectIds}&resourcetype='1'`
)
.subscribe(res => { .subscribe(res => {
if (res) { if (res) {
this.currentRate = res.rate * 100; this.currentRate = res.rate * 100;
@ -733,8 +733,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
} }
}); });
} }
// 添加 删除发货卸货地址 addStartInfo() {
addStartInfo(_event: any) {
if (this.startInfo.length < 5) { if (this.startInfo.length < 5) {
const controlId = this.startInfo.length; const controlId = this.startInfo.length;
this.startInfo.push({ this.startInfo.push({
@ -746,23 +745,19 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
province: '', province: '',
city: '', city: '',
area: '', area: '',
type: 1 type: '1'
}); });
this.validateForm1.addControl(`loadAddress${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`loadAddress${controlId}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`loadName${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`loadName${controlId}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`loadPhone${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`loadPhone${controlId}`, new FormControl(null, [Validators.required, Validators.pattern('^[0-9]*$')]));
} }
} }
getLimitvalue() { getLimitvalue() {
// 货物核载信息最大值 // 货物核载信息最大值
// 货物运输费(小计)最大值 // 货物运输费(小计)最大值
const getlimitvaluesParms = [ const getlimitvaluesParms = [this.service.limitKeys.weight, this.service.limitKeys.volume, this.service.limitKeys.piece];
this.service.limitKeys.weight, this.service.request(this.service.$api_findItemValueByItemKeys, getlimitvaluesParms).subscribe(res => {
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 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 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; const maxPiece = res.filter((item: any) => item.itemKey === this.service.limitKeys.piece)[0].itemValue;
@ -770,25 +765,17 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
maxWeight: Number(maxWeight), maxWeight: Number(maxWeight),
maxVolume: Number(maxVolume), maxVolume: Number(maxVolume),
maxPiece: Number(maxPiece) maxPiece: Number(maxPiece)
} };
}) });
} }
// 添加 删除发货卸货地址 subStartInfo(event: any, index: number) {
subStartInfo(event: any, index: number, id?: any) {
console.log(event, index, id);
if (id) {
this.service.request(this.service.$api_delete_Wholedeletebatch, [id]).subscribe(res => {
console.log(res);
});
}
this.startInfo.splice(index, 1); this.startInfo.splice(index, 1);
this.validateForm1.removeControl(`loadAddress${index}`); this.validateForm1.removeControl(`loadAddress${index}`);
this.validateForm1.removeControl(`loadName${index}`); this.validateForm1.removeControl(`loadName${index}`);
this.validateForm1.removeControl(`loadPhone${index}`); this.validateForm1.removeControl(`loadPhone${index}`);
} }
// 添加 删除发货卸货地址 addEndInfo() {
addEndInfo(_event: any) { if (this.endInfo.length < 5) {
if (this.addEndInfo.length < 5) {
const controlId = this.endInfo.length; const controlId = this.endInfo.length;
this.endInfo.push({ this.endInfo.push({
detailedAddress: '', detailedAddress: '',
@ -799,21 +786,17 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
province: '', province: '',
city: '', city: '',
area: '', area: '',
type: 2 type: '2'
}); });
this.validateForm1.addControl(`unloadAddress${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`unloadAddress${controlId}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`unloadPhone${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(
`unloadPhone${controlId}`,
new FormControl(null, [Validators.required, Validators.pattern('^[0-9]*$')])
);
} }
} }
// 添加 删除发货卸货地址 subEndInfo(event: any, index: number) {
subEndInfo(event: any, index: number, id?: any) {
if (id) {
this.service.request(this.service.$api_delete_Wholedeletebatch, [id]).subscribe(res => {
console.log(res);
});
}
console.log(event, index, id);
this.endInfo.splice(index, 1); this.endInfo.splice(index, 1);
this.validateForm1.removeControl(`unloadAddress${index}`); this.validateForm1.removeControl(`unloadAddress${index}`);
this.validateForm1.removeControl(`unloadName${index}`); this.validateForm1.removeControl(`unloadName${index}`);
@ -878,88 +861,71 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
nzComponentParams: { type: 'onecar', resourceObj, change: change } nzComponentParams: { type: 'onecar', resourceObj, change: change }
}); });
} }
// // 提交前确认,委托运输协议弹窗 // 提交前确认,委托运输协议弹窗
// submitConfirm(submitType?: any) { submitConfirm(submitType?: string) {
// Object.keys(this.validateForm1.controls).forEach(key => { Object.keys(this.validateForm1.controls).forEach(key => {
// this.validateForm1.controls[key].markAsDirty(); this.validateForm1.controls[key].markAsDirty();
// this.validateForm1.controls[key].updateValueAndValidity(); this.validateForm1.controls[key].updateValueAndValidity();
// }); });
// this.sf1.validator({ emitError: true }); this.sf3.validator({ emitError: true });
// this.sf3.validator({ emitError: true }); this.sf4.validator({ emitError: true });
// this.sf4.validator({ emitError: true }); this.sf5.validator({ emitError: true });
// this.sf6.validator({ emitError: true }); this.sf6.validator({ emitError: true });
// this.sf7.validator({ emitError: true }); this.sf7.validator({ emitError: true });
// console.log(this.sf1.valid); console.log(this.validateForm1.invalid)
// if (this.validateForm1.invalid || !this.sf3.valid || !this.sf1.valid || !this.sf4.valid || !this.sf6.valid || !this.sf7.valid) { console.log(this.sf4.valid)
// return; console.log(this.sf5.valid)
// } console.log(this.sf6.valid)
console.log(this.sf7.valid)
// const modalRef = this.modalService.create({ if (this.validateForm1.invalid || !this.sf3.valid || !this.sf4.valid || !this.sf5.valid || !this.sf6.valid || !this.sf7.valid) {
// nzTitle: '运输协议', this.service.msgSrv.warning('请完善必填项!');
// nzContent: TranAgreementComponent, return;
// 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);
}
})
} }
// 提交前协议弹窗 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) { agreementConfirm(submitType?: string) {
const modalRef = this.modalService.create({ const modalRef = this.modalService.create({
nzTitle: '运输协议', nzTitle: '运输协议',
@ -975,92 +941,60 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
} }
// 提交 // 提交
submit(submitType?: string): void { submit(submitType?: string): void {
//装卸货信息 //装卸货信息
const LoadingList = this.startInfo.concat(this.endInfo); const LoadingList = this.startInfo.concat(this.endInfo);
// 货物信息 // 货物信息
const sf3Values = { ...this.sf3.value }; const sf3Values = { ...this.sf3.value };
if (sf3Values.goodsTypeName === '其它') { if (sf3Values.goodsTypeName === '其它') {
sf3Values.goodsName = sf3Values.goodsName1; sf3Values.goodsName = sf3Values.goodsName1;
delete 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(',')
} }
]; if (this.sf4.value.carModel.includes('999')) {
// 运费信息 this.sf4.value.carModel = ['999'];
const expenseList = [ }
{ expenseCode: 'PRE', expenseName: '预付', price: this.sf7.value.prePay || 0, id: this.sf7data?.prePayId || '' }, if (this.sf4.value.carLength.includes('999')) {
{ expenseCode: 'RECE', expenseName: '到付', price: this.sf7.value.toPay || 0, id: this.sf7data?.toPayId || '' }, this.sf4.value.carLength = ['999'];
{ expenseCode: 'BACK', expenseName: '回单付', price: this.sf7.value.receiptPay || 0, id: this.sf7data?.receiptPayId || '' } }
]; 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 || 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都删除 // 从“再下一单”过来将所有的子参数内的id都删除
if (this.PageStatus = '整车下一单') { if ((this.PageStatus = '整车下一单')) {
LoadingList.forEach((ele: any) => { LoadingList.forEach((ele: any) => {
delete ele.id; delete ele.id;
}); });
goodsInfoList.forEach((ele: any) => { goodsInfoVOList.forEach((ele: any) => {
delete ele.id; delete ele.id;
}); });
expenseList.forEach((ele: any) => { expenseList.forEach((ele: any) => {
delete ele.id; delete ele.id;
}); });
} }
const params = {
// if (typeof this.unloadingTime !== 'string') { id: '',
// var c = new Date(this.unloadingTime); ...this.sf1.value,
// this.unloadingTime = unLoadingPlaceDTOList: LoadingList,
// c.getFullYear() + unloadingTime: format(this.validateForm1.value.unloadingTime, 'yyyy-MM-dd HH:mm:ss'),
// '-' + loadingTime: format(this.validateForm1.value.loadingTime, 'yyyy-MM-dd HH:mm:ss'),
// this.addPreZero(c.getMonth() + 1) + goodsInfoDTOList: goodsInfoVOList,
// '-' + ...this.sf5.value,
// this.addPreZero(c.getDate()) + ...this.sf6.value,
// ' ' + expenseDTOList: expenseList,
// this.addPreZero(c.getHours()) + paymentDays: this.sf7.value.paymentDays
// ':' + };
// 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 = { // const params: any = {
// ...this.sf1.value, // ...this.sf1.value,
// ...this.sf5.value, // ...this.sf5.value,
@ -1259,14 +1193,14 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`unloadPhone${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) { if (this.startInfo?.[0]?.area && this.endInfo?.[0]?.area) {
this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => { this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => {
this.totalDistance = res.distance; this.totalDistance = res.distance;
this.totalTime = res.time; this.totalTime = res.time;
}); });
} }
}); });
this.sf3data = { this.sf3data = {
@ -1279,26 +1213,27 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
this.sf3data.goodsName1 = res?.goodsInfoVOList[0]?.goodsName || ''; this.sf3data.goodsName1 = res?.goodsInfoVOList[0]?.goodsName || '';
} }
this.changeGoodsType(this.sf3data.goodsTypeId, { label: this.sf3data.goodsTypeName, value: this.sf3data.goodsTypeId }); this.changeGoodsType(this.sf3data.goodsTypeId, { label: this.sf3data.goodsTypeName, value: this.sf3data.goodsTypeId });
this.sf4data = {
weight: res?.goodsInfoVOList[0]?.weight,
volume: res?.goodsInfoVOList[0]?.volume,
vehicleDemand: res?.goodsInfoVOList[0]?.vehicleDemand,
carLength: res?.goodsInfoVOList[0]?.carLength?.split(','),
carModel: res?.goodsInfoVOList[0]?.carModel?.split(',') || '',
number: res?.goodsInfoVOList[0]?.number,
goodsTypeName: res?.goodsInfoVOList[0]?.goodsTypeName,
modifyUserId: res?.goodsInfoVOList[0]?.modifyUserId,
resourceId: res?.goodsInfoVOList[0]?.resourceId,
rule: res?.goodsInfoVOList[0]?.rule,
settlementBasis: res?.goodsInfoVOList[0]?.settlementBasis
};
if (res?.loadingTime) { if (res?.loadingTime) {
this.loadingTime = res?.loadingTime; this.loadingTime = res?.loadingTime;
} }
if (res?.unloadingTime) { if (res?.unloadingTime) {
this.unloadingTime = res?.unloadingTime; this.unloadingTime = res?.unloadingTime;
} }
this.validateForm1.patchValue(
{
loadingTime: new Date(Date.parse(res.loadingTime.replace(/-/g, '/'))),
unloadingTime: new Date(Date.parse(res.unloadingTime.replace(/-/g, '/')))
},
{ onlySelf: true }
);
this.sf4data = {
weight: res?.goodsInfoVOList[0]?.weight || '',
volume: res?.goodsInfoVOList[0]?.volume || '',
number: res?.goodsInfoVOList[0]?.number || '',
carModel: res?.goodsInfoVOList[0]?.carModel?.split(',') || [],
carLength: res?.goodsInfoVOList[0]?.carLength?.split(',') || []
};
if (this.PageStatus === '整车修改') { if (this.PageStatus === '整车修改') {
this.sf4data.id = res?.goodsInfoVOList[0]?.id; this.sf4data.id = res?.goodsInfoVOList[0]?.id;
} }
@ -1374,56 +1309,29 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
default: default:
break; break;
} }
// 计算里程,时间 // 计算里程,时间
if (this.startInfo[0]?.area && this.endInfo[0]?.area) { if (this.startInfo[0]?.area && this.endInfo[0]?.area) {
this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => { this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe(res => {
this.totalDistance = res.distance; this.totalDistance = res.distance;
this.totalTime = res.time; this.totalTime = res.time;
this.getInsurersPrice(); //计算保费金额 this.getInsurersPrice(); //计算保费金额
}); });
} }
} }
}); });
} }
changeUn(event: Date) { // 不可选择的时间
console.log(event) disabledDateStart = (current: Date): boolean => {
this.unloadingTime = event; return differenceInCalendarDays(new Date(), current) > 0;
if(typeof this.loadingTime === 'string') { };
var a = new Date(this.loadingTime)
if ( a > this.unloadingTime?.getTime() ) {
this.service.msgSrv.error('卸货时间不能小于装货时间!');
this.unloadingTime = '';
}
} else {
if ( this.loadingTime?.getTime() > this.unloadingTime?.getTime() ) {
this.service.msgSrv.error('卸货时间不能小于装货时间!');
this.unloadingTime = '';
}
}
}
changeLO(event: Date) {
this.loadingTime = event;
if(typeof this.unloadingTime === 'string') {
var a = new Date(this.unloadingTime)
if ( a.getTime()< this.loadingTime?.getTime()) {
this.service.msgSrv.error('装货时间不能大于卸货时间!');
this.loadingTime = '';
}
} else {
if ( this.unloadingTime?.getTime()< this.loadingTime?.getTime()) {
this.service.msgSrv.error('装货时间不能大于卸货时间!');
this.loadingTime = '';
}
}
}
// 装卸货地址互换 // 装卸货地址互换
swapAddress(){ swapAddress() {
this.startInfo.forEach((element:any, index:any) => { this.startInfo.forEach((element: any, index: any) => {
this.validateForm1.removeControl(`loadAddress${index}`); this.validateForm1.removeControl(`loadAddress${index}`);
this.validateForm1.removeControl(`loadName${index}`); this.validateForm1.removeControl(`loadName${index}`);
this.validateForm1.removeControl(`loadPhone${index}`); this.validateForm1.removeControl(`loadPhone${index}`);
}); });
this.endInfo.forEach((element:any, index:any) => { this.endInfo.forEach((element: any, index: any) => {
this.validateForm1.removeControl(`unloadAddress${index}`); this.validateForm1.removeControl(`unloadAddress${index}`);
this.validateForm1.removeControl(`unloadName${index}`); this.validateForm1.removeControl(`unloadName${index}`);
this.validateForm1.removeControl(`unloadPhone${index}`); this.validateForm1.removeControl(`unloadPhone${index}`);
@ -1433,13 +1341,13 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
this.startInfo = this.endInfo; this.startInfo = this.endInfo;
this.endInfo = item; this.endInfo = item;
this.startInfo.forEach((element:any,index:any) => { this.startInfo.forEach((element: any, index: any) => {
element.type = '1'; element.type = '1';
this.validateForm1.addControl(`loadAddress${index}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`loadAddress${index}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`loadName${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.validateForm1.addControl(`loadPhone${index}`, new FormControl(null, [Validators.required, Validators.pattern('^[0-9]*$')]));
}); });
this.endInfo.forEach((element:any,index:any) => { this.endInfo.forEach((element: any, index: any) => {
element.type = '2'; element.type = '2';
this.validateForm1.addControl(`unloadAddress${index}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`unloadAddress${index}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`unloadName${index}`, new FormControl(null, Validators.required)); this.validateForm1.addControl(`unloadName${index}`, new FormControl(null, Validators.required));
@ -1457,7 +1365,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
// 计算保价费金额 // 计算保价费金额
getInsurersPrice(insuranceType = this.sf5.value.insuranceType) { getInsurersPrice(insuranceType = this.sf5.value.insuranceType) {
if (this.sf5.value.goodsValue >= 50000 && this.totalDistance > 0) { if (this.sf5.value.goodsValue >= 50000 && this.totalDistance > 0) {
const params = { const params = {
insuranceType, insuranceType,
goodsValue: this.sf5.value.goodsValue, goodsValue: this.sf5.value.goodsValue,
@ -1474,5 +1381,4 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}); });
} }
} }
} }

View File

@ -158,7 +158,12 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="3" nzRequired>装货时间</nz-form-label> <nz-form-label [nzSpan]="3" nzRequired>装货时间</nz-form-label>
<nz-form-control [nzErrorTip]="'请输入装货时间'"> <nz-form-control [nzErrorTip]="'请输入装货时间'">
<nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="loadingTime" name="loadingTime"></nz-date-picker> <nz-date-picker
nzShowTime
nzFormat="yyyy-MM-dd HH:mm:ss"
formControlName="loadingTime"
[nzDisabledDate]="disabledDateStart"
></nz-date-picker>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>
@ -167,7 +172,7 @@
<nz-form-item> <nz-form-item>
<nz-form-label [nzSpan]="3" nzRequired>卸货时间</nz-form-label> <nz-form-label [nzSpan]="3" nzRequired>卸货时间</nz-form-label>
<nz-form-control [nzErrorTip]="'请输入卸货时间'"> <nz-form-control [nzErrorTip]="'请输入卸货时间'">
<nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="unloadingTime" name="unloadingTime"></nz-date-picker> <nz-date-picker nzShowTime nzFormat="yyyy-MM-dd HH:mm:ss" formControlName="unloadingTime"></nz-date-picker>
</nz-form-control> </nz-form-control>
</nz-form-item> </nz-form-item>
</div> </div>