车辆对接

This commit is contained in:
wangshiming
2022-01-11 17:08:39 +08:00
parent 0dde51a145
commit 347cb109af
6 changed files with 894 additions and 981 deletions

View File

@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import {
SFComponent,
@ -13,15 +13,13 @@ import {
import { _HttpClient } from '@delon/theme';
import { AmapPoiPickerComponent, AmapService, ShipperBaseService } from '@shared';
import { NzModalService } from 'ng-zorro-antd/modal';
import { PublishGoodsChooseFamifiarComponent } from '../choose-famifiar/choose-famifiar.component';
import { of } from 'rxjs';
import { map } from 'rxjs/operators';
import { SupplyManagementService } from '../../services/supply-management.service';
import { debug } from 'console';
import { SupplyManagementVehicleAssignedCarComponent } from '../assigned-car/assigned-car.component';
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 { map } from 'rxjs/operators';
import { of } from 'rxjs';
import { TranAgreementComponent } from '../tran-agreement/tran-agreement.component';
import { SupplyManagementVehicleAssignedCarComponent } from '../assigned-car/assigned-car.component';
@Component({
selector: 'app-publish-goods-onecar-publish',
templateUrl: './onecar-publish.component.html',
@ -29,7 +27,6 @@ import { SupplyManagementVehicleAssignedCarComponent } from '../assigned-car/ass
})
export class SupplyManagementOnecarPublishComponent implements OnInit {
validateForm1: FormGroup;
newTempchecked = false; //是否存入新模板
sf1data: any; // 货源单设置回显
sf3data: any; // 货源单设置回显
sf4data: any; // 货源单设置回显
@ -43,17 +40,11 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
totalDistance = 0.0; //总里程
totalTime = 0.0; //路程总时间
currentRate = 0; //实时计算的费率
npp = false;
id = this.route.snapshot.params.id;
// // 单位
unit1 = '吨';
unit2 = '方';
unit3 = '保价费金额';
startInfo: any = [];
endInfo: any = [];
startInfo: any = []; // 发货地数据
endInfo: any = []; // 卸货地数据
PageStatus = '';
dataList: any;
enterpriseProjectIds: any;
constructor(
private http: _HttpClient,
@ -97,16 +88,12 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
@ViewChild('sf7', { static: false }) sf7!: SFComponent;
schema7: SFSchema = {};
ui7!: SFUISchema;
// 页面初始化
ngOnInit(): void {
if (this.route.snapshot?.queryParams?.sta === '1') {
console.log('修改');
this.PageStatus = '整车修改';
} else if (this.route.snapshot?.queryParams?.sta === '2') {
this.PageStatus = '整车下一单';
} else if (this.route.snapshot?.queryParams?.sta === '3') {
this.PageStatus = '大宗修改';
} else if (this.route.snapshot?.queryParams?.sta === '4') {
this.PageStatus = '大宗下一单';
}
this.initSF1();
this.initSF3();
@ -116,7 +103,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
this.initSF7();
this.initdata();
}
initSF1() {
this.schema1 = {
properties: {
@ -141,7 +127,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
},
change: (q: any) => {
this.getRegionCode(q);
},
}
} as SFSelectWidgetSchema
},
enterpriseProjectId: {
@ -149,7 +135,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
title: '项目',
ui: {
widget: 'select',
placeholder: '请选择',
placeholder: '请选择'
} as SFSelectWidgetSchema
},
enterpriseInfoName: {
@ -172,8 +158,8 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
title: '手机号',
maxLength: 30,
ui: {
hidden: true,
placeholder: '请输入'
hidden: true,
placeholder: '请输入'
}
},
dispatchName: {
@ -193,18 +179,18 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
placeholder: '请选择',
allowClear: true,
optionalHelp: '选择调度员,司机直接联系调度员 ; 不选择,司机直接联系您',
change: (value: any, data: any) => {
if(data.label) {
const dat = data.label.split('/')
this.sf1.setValue('/dispatchName', dat[0]);
this.sf1.setValue('/dispatchPhone', dat[1]);
change: (_value: any, data: any) => {
if (data.label) {
const dat = data.label.split('/');
this.sf1.setValue('/dispatchName', dat[0]);
this.sf1.setValue('/dispatchPhone', dat[1]);
}
},
asyncData: () => this.shipperSrv.getStaffList2()
} as SFSelectWidgetSchema
}
},
required: ['shipperAppUserId','enterpriseProjectId','dispatchId']
required: ['shipperAppUserId', 'enterpriseProjectId', 'dispatchId']
};
this.ui1 = {
'*': {
@ -251,7 +237,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
widget: 'select',
placeholder: '请选择',
errors: { required: '请填写货物名称' },
change: (value: any, data: any) => {
change: (_value: any, data: any) => {
this.sf3.setValue('/goodsName', data.label);
},
visibleIf: {
@ -364,30 +350,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
};
}
// 获取城市列表
getRegionCode(regionCode: any) {
console.log(regionCode);
return this.service
.request(this.service.$api_get_enterprise_project, { id: regionCode })
.pipe(
map(res =>
res.map((item: any) => ({
label: item.projectName,
value: item.id
}))
)
)
.subscribe(res => {
this.sf1.getProperty('/enterpriseProjectId')!.schema.enum = res;
this.sf1.getProperty('/enterpriseProjectId')!.widget.reset(res);
console.log('12345645454545454=============')
console.log(this.enterpriseProjectIds)
console.log(res)
if(this.enterpriseProjectIds) {
this.sf1.setValue('/enterpriseProjectId', this.enterpriseProjectIds);
}
});
}
initSF5() {
this.schema5 = {
properties: {
@ -409,7 +372,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
};
}
initSF6() {
this.schema6 = {
properties: {
@ -504,7 +466,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
} as SFTextareaWidgetSchema
}
},
required: ['stateReceipt', 'receiptType', 'receiptAddressId',]
required: ['stateReceipt', 'receiptType', 'receiptAddressId']
};
this.ui6 = {
'*': {
@ -513,15 +475,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
};
}
changeValue() {
this.totalFees =
Number(this.sf7?.value?.appendFee) +
Number(this.sf7?.value?.oilCardPay) +
Number(this.sf7?.value?.prePay) +
Number(this.sf7?.value?.receiptPay) +
Number(this.sf7?.value?.toPay);
console.log(this.totalFees);
}
initSF7() {
this.schema7 = {
properties: {
@ -532,7 +485,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
default: 0,
ui: {
prefix: '¥',
change: args => this.payChange()
change: _args => this.payChange()
} as SFNumberWidgetSchema
},
toPay: {
@ -540,21 +493,21 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
title: '到付',
minimum: 0,
default: 0,
ui: { prefix: '¥', change: args => this.payChange() } as SFNumberWidgetSchema
ui: { prefix: '¥', change: _args => this.payChange() } as SFNumberWidgetSchema
},
oilCardPay: {
type: 'number',
title: '油卡',
minimum: 0,
default: 0,
ui: { prefix: '¥', change: args => this.payChange() } as SFNumberWidgetSchema
ui: { prefix: '¥', change: _args => this.payChange() } as SFNumberWidgetSchema
},
receiptPay: {
type: 'number',
title: '回单付',
minimum: 0,
default: 0,
ui: { prefix: '¥', change: args => this.payChange() } as SFNumberWidgetSchema
ui: { prefix: '¥', change: _args => this.payChange() } as SFNumberWidgetSchema
},
subtotal: { type: 'number', title: '小计', default: 0, ui: { widget: 'custom' } as SFNumberWidgetSchema },
appendFee: { type: 'number', title: '附加费', default: 0, ui: { widget: 'custom' } as SFNumberWidgetSchema },
@ -578,38 +531,74 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
};
}
payChange(value?: any) {
let subtotal: any ={}
let oilCardPay: any ={}
if(value) {
subtotal = (value.prePay +value.toPay + value.oilCardPay + value.receiptPay) || 0;
oilCardPay = value.oilCardPay || 0;
} else {
subtotal = (this.sf7.value.prePay + this.sf7.value.toPay + this.sf7.value.oilCardPay + this.sf7.value.receiptPay) || 0;
oilCardPay = this.sf7.value.oilCardPay || 0;
}
console.log(this.sf7.value)
this.service.request(this.service.$api_getCalculatedSurcharge + `?totalFreight=${subtotal}&fuelCardAmount=${oilCardPay}`).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);
// 获取城市列表
getRegionCode(regionCode: any) {
console.log(regionCode);
return this.service
.request(this.service.$api_get_enterprise_project, { id: regionCode })
.pipe(
map(res =>
res.map((item: any) => ({
label: item.projectName,
value: item.id
}))
)
)
.subscribe(res => {
this.sf1.getProperty('/enterpriseProjectId')!.schema.enum = res;
this.sf1.getProperty('/enterpriseProjectId')!.widget.reset(res);
console.log('12345645454545454=============');
console.log(this.enterpriseProjectIds);
console.log(res);
if (this.enterpriseProjectIds) {
this.sf1.setValue('/enterpriseProjectId', this.enterpriseProjectIds);
}
});
} else {
this.service.msgSrv.error(res.msg);
}
});
}
changeValue() {
this.totalFees =
Number(this.sf7?.value?.appendFee) +
Number(this.sf7?.value?.oilCardPay) +
Number(this.sf7?.value?.prePay) +
Number(this.sf7?.value?.receiptPay) +
Number(this.sf7?.value?.toPay);
console.log(this.totalFees);
}
payChange(value?: any) {
let subtotal: any = {};
let oilCardPay: any = {};
if (value) {
subtotal = value.prePay + value.toPay + value.oilCardPay + value.receiptPay || 0;
oilCardPay = value.oilCardPay || 0;
} else {
subtotal = this.sf7.value.prePay + this.sf7.value.toPay + this.sf7.value.oilCardPay + this.sf7.value.receiptPay || 0;
oilCardPay = this.sf7.value.oilCardPay || 0;
}
console.log(this.sf7.value);
addStartInfo(event: any) {
this.service
.request(this.service.$api_getCalculatedSurcharge + `?totalFreight=${subtotal}&fuelCardAmount=${oilCardPay}`)
.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);
}
});
}
// 添加 删除发货卸货地址
addStartInfo(_event: any) {
if (this.startInfo.length < 5) {
const controlId = this.startInfo.length;
this.startInfo.push({
@ -628,6 +617,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
this.validateForm1.addControl(`loadPhone${controlId}`, new FormControl(null, Validators.required));
}
}
// 添加 删除发货卸货地址
subStartInfo(event: any, index: number, id?: any) {
console.log(event, index, id);
if (id) {
@ -640,6 +630,39 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
this.validateForm1.removeControl(`loadName${index}`);
this.validateForm1.removeControl(`loadPhone${index}`);
}
// 添加 删除发货卸货地址
addEndInfo(_event: any) {
if (this.addEndInfo.length < 5) {
const controlId = this.endInfo.length;
this.endInfo.push({
detailedAddress: '',
appUserName: '',
contractTelephone: '',
latitude: '',
longitude: '',
province: '',
city: '',
area: '',
type: 2
});
this.validateForm1.addControl(`unloadAddress${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));
}
}
// 添加 删除发货卸货地址
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.validateForm1.removeControl(`unloadAddress${index}`);
this.validateForm1.removeControl(`unloadName${index}`);
this.validateForm1.removeControl(`unloadPhone${index}`);
}
changeGoodsType(value: string, data: any) {
if (data.label === '其它') return;
const params = {
@ -660,50 +683,17 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
if (res) {
this.sf3.getProperty('/goodsNameId')!.schema.enum = res;
this.sf3.getProperty('/goodsNameId')!.widget?.reset(res);
if(this.sf3data.goodsNameId){
this.sf3.setValue('/goodsNameId',this.sf3data.goodsNameId);
if (this.sf3data.goodsNameId) {
this.sf3.setValue('/goodsNameId', this.sf3data.goodsNameId);
}
} else {
this.service.msgSrv.error(res.msg);
}
});
}
addEndInfo(event: any) {
if (this.addEndInfo.length < 5) {
const controlId = this.endInfo.length;
this.endInfo.push({
detailedAddress: '',
appUserName: '',
contractTelephone: '',
latitude: '',
longitude: '',
province: '',
city: '',
area: '',
type: 2
});
this.validateForm1.addControl(`unloadAddress${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));
}
}
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.validateForm1.removeControl(`unloadAddress${index}`);
this.validateForm1.removeControl(`unloadName${index}`);
this.validateForm1.removeControl(`unloadPhone${index}`);
}
//指派熟车
chooseFamifiar(item: any) {
console.log('999')
//指派熟车
chooseFamifiar(item: any) {
console.log('999');
const modalRef = this.modalService.create({
nzTitle: '指派熟车',
nzContent: SupplyManagementVehicleAssignedCarComponent,
@ -713,7 +703,6 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
url: this.service.$api_save_assign_whole,
params: item,
type: 'next'
},
nzFooter: null
});
@ -723,31 +712,32 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
});
}
// 打开下单完成页面
openFinishPage(resourceObj: any = null) {
this.modalService.create({
nzTitle: '',
nzContent: PublishSuccessComponent,
nzWidth: 900,
nzFooter: null,
nzComponentParams: { type: 'onecar', resourceObj }
});
}
// 提交前确认,委托运输协议弹窗
submitConfirm(submitType?: any) {
const modalRef = this.modalService.create({
nzTitle: '运输协议',
nzContent: TranAgreementComponent,
nzWidth: 900,
nzFooter: null,
nzComponentParams: { type: 'next' }
});
modalRef.afterClose.subscribe(result => {
if (result) {
this.submit(submitType);
}
});
}
// 打开下单完成页面
openFinishPage(resourceObj: any = null) {
this.modalService.create({
nzTitle: '',
nzContent: PublishSuccessComponent,
nzWidth: 900,
nzFooter: null,
nzComponentParams: { type: 'onecar', resourceObj }
});
}
// 提交前确认,委托运输协议弹窗
submitConfirm(submitType?: any) {
const modalRef = this.modalService.create({
nzTitle: '运输协议',
nzContent: TranAgreementComponent,
nzWidth: 900,
nzFooter: null,
nzComponentParams: { type: 'next' }
});
modalRef.afterClose.subscribe(result => {
if (result) {
this.submit(submitType);
}
});
}
// 提交
submit(submitType?: string): void {
Object.keys(this.validateForm1.controls).forEach(key => {
this.validateForm1.controls[key].markAsDirty();
@ -758,8 +748,8 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
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) {
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;
}
if (typeof this.validateForm1.value.unloadingTime !== 'string') {
@ -814,7 +804,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
totalFees: this.totalFees
};
console.log(params);
if(submitType) {
if (submitType) {
if (submitType == 'assign') {
this.chooseFamifiar(params);
return;
@ -833,6 +823,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
return num;
}
}
// 下单成功提示弹窗
requests(url: any, params: any) {
this.service.request(url, params).subscribe((res: any) => {
if (res) {
@ -889,21 +880,18 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
});
}
// 返回上一页
goBack() {
window.history.go(-1);
}
// 初始化信息
// 初始化赋值信息
initdata() {
this.service.request(`${this.service.$api_get_getCompleteVehicleDetail}`, { id: this.id }).subscribe(res => {
this.dataR(res);
});
}
asds(i: any) {
console.log(i);
}
// 初始化信息
// 初始化赋值信息函数
dataR(res: any) {
// this.dataList = res;
if (res?.shipperAppUserName) {
const List: any = [];
this.service.request(this.service.$api_enterpriceList, { enterpriseName: res?.shipperAppUserName }).subscribe(rs => {
@ -918,8 +906,8 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
});
}
if(res?.enterpriseProjectId) {
this.enterpriseProjectIds = res.enterpriseProjectId
if (res?.enterpriseProjectId) {
this.enterpriseProjectIds = res.enterpriseProjectId;
}
this.sf1data = {
enterpriseInfoName: res?.enterpriseInfoName,
@ -1002,7 +990,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
goodsTypeId: res?.goodsInfoVOList[0]?.goodsTypeId || '',
goodsTypeName: res?.goodsInfoVOList[0]?.goodsTypeName || '',
goodsNameId: res?.goodsInfoVOList[0]?.goodsNameId || '',
goodsName: res?.goodsInfoVOList[0]?.goodsName || '',
goodsName: res?.goodsInfoVOList[0]?.goodsName || ''
};
if (this.sf3data.goodsTypeName === '其它') {
this.sf3data.goodsName1 = res?.goodsInfoVOList[0]?.goodsName || '';
@ -1049,9 +1037,9 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
area: res?.supplementaryInformationVO?.area || '',
phon: res?.supplementaryInformationVO?.phon || '',
address: res?.supplementaryInformationVO?.address || '',
remarks: res?.supplementaryInformationVO?.remarks || '',
remarks: res?.supplementaryInformationVO?.remarks || ''
};
// if (this.PageStatus === '整车修改') {
// if (this.PageStatus === '整车修改') {
// this.sf6data.id = res?.supplementaryInformationVO?.id
// }
this.sf7data = {
@ -1066,6 +1054,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
};
this.payChange(this.sf7data);
}
// 选择收回单地址
backBillChange() {
const modalRef = this.modalService.create({
nzTitle: '选择收回单地址',
@ -1083,9 +1072,7 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
});
}
choose(){
window.history.go(-1);
}
// 选择地址
chooseAddress(index: number, type: string) {
const modalRef = this.modalService.create({
nzTitle: '选择地址',
@ -1093,8 +1080,8 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
nzWidth: 900,
nzComponentParams: { spuStatus: '1' },
nzOnOk: item => {
console.log(item)
console.log(type)
console.log(item);
console.log(type);
const data = item.seleteData;
if (JSON.stringify(data) === '{}') return;
switch (type) {
@ -1130,5 +1117,4 @@ export class SupplyManagementOnecarPublishComponent implements OnInit {
}
});
}
}