车辆接口更新

This commit is contained in:
wangshiming
2022-01-19 15:13:45 +08:00
parent 51a7014b2c
commit 175e48816a
8 changed files with 370 additions and 242 deletions

View File

@ -40,7 +40,7 @@
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
<div class="align-center">
<div style="display: flex;">
<nz-form-control [nzErrorTip]="'请输入联系人姓名'">
<input
nz-input
@ -92,7 +92,7 @@
</nz-form-item>
<nz-form-item>
<nz-form-label [nzSpan]="4" nzRequired>联系人</nz-form-label>
<div class="align-center">
<div style="display: flex;">
<nz-form-control [nzErrorTip]="'请输入联系人姓名'">
<input
nz-input
@ -240,8 +240,8 @@
<nz-card>
<div class="align-center">
<!-- <button nz-button nzType="primary" (click)="chooseFamifiar()">生成二维码</button> -->
<button nz-button nzType="primary" style="margin-left: 48px" (click)="submit('assign')">指派熟车</button>
<button nz-button nzType="primary" style="margin-left: 48px" (click)="submitConfirm('assign')">指派熟车</button>
<!-- <button nz-button nzType="primary" (click)="choose()">取消</button> -->
<button nz-button nzType="primary" style="margin-left: 48px" (click)="submit('publish')">司机抢单</button>
<button nz-button nzType="primary" style="margin-left: 48px" (click)="submitConfirm('publish')">司机抢单</button>
</div>
</nz-card>

View File

@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormGroup,Validators,FormControl } from '@angular/forms';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import {
SFComponent,
@ -14,17 +14,18 @@ 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 { SupplyManagementService} from '../../services/supply-management.service';
import { SupplyManagementService } from '../../services/supply-management.service';
import { map } from 'rxjs/operators';
import { of } from 'rxjs';
import { PublishSuccessComponent } from '../onecar-publish/publish-success/publish-success.component';
import { PublishAddressListComponent } from '../onecar-publish/address-list/address-list.component';
import { TranAgreementComponent } from '../tran-agreement/tran-agreement.component';
@Component({
selector: 'app-publish-goods-bulk-publish',
templateUrl: './bulk-publish.component.html',
styleUrls: ['./bulk-publish.component.less']
})
export class SupplyManagementBulkPublishComponent implements OnInit {
export class SupplyManagementBulkPublishComponent implements OnInit {
validateForm1: FormGroup;
sf1data: any; // 货源单设置回显
sf3data: any; // 货源单设置回显
@ -38,7 +39,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
totalTime = 0.0; //路程总时间
currentGoodsTypeName: any;
enterpriseProjectIds: any;
id = this.route.snapshot.params.id; // 传参id
id = this.route.snapshot.params.id; // 传参id
// // 单位
startInfo: any = [];
endInfo: any = [];
@ -51,16 +52,15 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
private modalService: NzModalService,
public service: SupplyManagementService,
private amapService: AmapService,
public shipperSrv: ShipperBaseService,) {
public shipperSrv: ShipperBaseService
) {
this.validateForm1 = fb.group({
createTime: [null, []],
modifyTime: [null, []],
loadAddress0: [null, [Validators.required]],
loadName0: [null, [Validators.required]],
loadPhone0: [null, [Validators.required]],
loadPhone0: [null, [Validators.required, Validators.pattern('^[0-9]*$')]],
unloadAddress0: [null, [Validators.required]],
unloadName0: [null, [Validators.required]],
unloadPhone0: [null, [Validators.required]]
unloadPhone0: [null, [Validators.required, Validators.pattern('^[0-9]*$')]]
});
}
@ViewChild('sf1', { static: false }) sf1!: SFComponent;
@ -84,11 +84,11 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
ui7!: SFUISchema;
// 初始化
ngOnInit(): void {
if(this.route.snapshot?.queryParams?.sta === '3') {
if (this.route.snapshot?.queryParams?.sta === '3') {
this.PageStatus = '大宗修改';
} else if(this.route.snapshot?.queryParams?.sta === '4') {
} else if (this.route.snapshot?.queryParams?.sta === '4') {
this.PageStatus = '大宗下一单';
}
}
this.initSF1();
this.initSF3();
this.initSF4();
@ -110,27 +110,27 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
onSearch: (q: any) => {
if (!!q) {
return this.service
.request(this.service.$api_enterpriceList, { enterpriseName: q})
.pipe(map((res) => (res as any[]).map((i) => ({ label: i.enterpriseName, value: i.id } as SFSchemaEnum))))
.request(this.service.$api_enterpriceList, { enterpriseName: q })
.pipe(map(res => (res as any[]).map(i => ({ label: i.enterpriseName, value: i.id } as SFSchemaEnum))))
.toPromise();
} else {
return of([]);
}
},
change: (q: any) => {
this.getRegionCode(q)
this.getRegionCode(q);
},
visibleIf: {
_$expand: (value: boolean) => value,
},
} as SFSelectWidgetSchema,
},
_$expand: (value: boolean) => value
}
} as SFSelectWidgetSchema
},
enterpriseProjectId: {
type: 'string',
title: '项目',
ui: {
widget: 'select',
placeholder: '请选择',
placeholder: '请选择'
} as SFSelectWidgetSchema
},
enterpriseInfoName: {
@ -138,7 +138,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
title: '网络货运人',
ui: {
widget: 'text'
},
}
},
deadlineTime: {
title: '截至日期',
@ -154,8 +154,8 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
title: '手机号',
maxLength: 30,
ui: {
hidden: true,
placeholder: '请输入'
hidden: true,
placeholder: '请输入'
}
},
dispatchName: {
@ -175,10 +175,10 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
placeholder: '请选择',
allowClear: true,
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]);
if (data.label) {
const dat = data.label.split('/');
this.sf1.setValue('/dispatchName', dat[0]);
this.sf1.setValue('/dispatchPhone', dat[1]);
}
},
optionalHelp: '选择调度员,司机直接联系调度员 ; 不选择,司机直接联系您',
@ -186,7 +186,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
} as SFSelectWidgetSchema
}
},
required: ['shipperAppUserId', 'enterpriseProjectId','enterpriseInfoId', 'deadlineTime', ]
required: ['shipperAppUserId', 'enterpriseProjectId', 'enterpriseInfoId', 'deadlineTime']
};
this.ui1 = {
'*': {
@ -497,7 +497,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
} as SFTextareaWidgetSchema
}
},
required: ['paymentDays','stateReceipt']
required: ['paymentDays', 'stateReceipt']
};
this.ui7 = {
'*': {
@ -507,27 +507,32 @@ export class SupplyManagementBulkPublishComponent 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)
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);
}
// 获取城市列表
getRegionCode(regionCode: any) {
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
}))
)
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);
if(this.enterpriseProjectIds) {
this.sf1.setValue('/enterpriseProjectId', this.enterpriseProjectIds);
}
});
)
.subscribe(res => {
this.sf1.getProperty('/enterpriseProjectId')!.schema.enum = res;
this.sf1.getProperty('/enterpriseProjectId')!.widget.reset(res);
if (this.enterpriseProjectIds) {
this.sf1.setValue('/enterpriseProjectId', this.enterpriseProjectIds);
}
});
}
addStartInfo(event: any) {
if (this.startInfo.length < 5) {
@ -548,10 +553,9 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
this.validateForm1.addControl(`loadPhone${controlId}`, new FormControl(null, Validators.required));
}
}
subStartInfo(event: any, index: number, id?:any) {
if(id) {
this.service.request(this.service.$api_delete_Wholedeletebatch, [id]).subscribe((res) => {
})
subStartInfo(event: any, index: number, id?: any) {
if (id) {
this.service.request(this.service.$api_delete_Wholedeletebatch, [id]).subscribe(res => {});
}
this.startInfo.splice(index, 1);
this.validateForm1.removeControl(`loadAddress${index}`);
@ -577,13 +581,12 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
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) => {
})
subEndInfo(event: any, index: number, id?: any) {
if (id) {
this.service.request(this.service.$api_delete_Wholedeletebatch, [id]).subscribe(res => {});
}
this.endInfo.splice(index, 1);
this.validateForm1.removeControl(`unloadAddress${index}`);
this.validateForm1.removeControl(`unloadAddress${index}`);
this.validateForm1.removeControl(`unloadName${index}`);
this.validateForm1.removeControl(`unloadPhone${index}`);
}
@ -596,7 +599,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
submitParams: item,
submitUrl: this.service.$api_save_bulk_assign
},
nzWidth: 1300,
nzWidth: 1300
});
modalRef.afterClose.subscribe(result => {
if (result) {
@ -606,16 +609,16 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
}
// 打开下单完成页面
openFinishPage(resourceObj: any = null) {
this.modalService.create({
nzTitle: '',
nzContent: PublishSuccessComponent,
nzWidth: 900,
nzFooter: null,
nzComponentParams: { type: 'bulk' }
});
this.modalService.create({
nzTitle: '',
nzContent: PublishSuccessComponent,
nzWidth: 900,
nzFooter: null,
nzComponentParams: { type: 'bulk' }
});
}
// 确认提交
submit(submitType?: string): void {
// 提交前确认,委托运输协议弹窗
submitConfirm(submitType?: any) {
// 校验规则
Object.keys(this.validateForm1.controls).forEach(key => {
this.validateForm1.controls[key].markAsDirty();
@ -625,40 +628,58 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
this.sf3.validator({ emitError: true });
this.sf4.validator({ emitError: true });
this.sf7.validator({ emitError: true });
if (this.validateForm1.invalid || !this.sf3.valid || !this.sf1.valid|| !this.sf4.valid || !this.sf7.valid) {
if (this.validateForm1.invalid || !this.sf3.valid || !this.sf1.valid || !this.sf4.valid || !this.sf7.valid) {
return;
}
if(typeof(this.validateForm1.value.modifyTime) !== 'string' ) {
var c = new Date(this.validateForm1.value.modifyTime);
this.validateForm1.value.modifyTime = c.getFullYear() + '-' + (c.getMonth() + 1) + '-' + c.getDate() + ' ' + c.getHours() + ':' + c.getMinutes() + ':' + c.getSeconds()
const modalRef = this.modalService.create({
nzTitle: '运输协议',
nzContent: TranAgreementComponent,
nzWidth: 900,
nzFooter: null
});
modalRef.afterClose.subscribe(result => {
if (result) {
this.submit(submitType);
}
});
}
// 确认提交
submit(submitType?: string): void {
if (typeof this.validateForm1.value.modifyTime !== 'string') {
var c = new Date(this.validateForm1.value.modifyTime);
this.validateForm1.value.modifyTime =
c.getFullYear() + '-' + (c.getMonth() + 1) + '-' + c.getDate() + ' ' + c.getHours() + ':' + c.getMinutes() + ':' + c.getSeconds();
}
if(typeof(this.validateForm1.value.createTime) !== 'string' ) {
var c = new Date(this.validateForm1.value.createTime);
this.validateForm1.value.createTime = c.getFullYear() + '-' + (c.getMonth() + 1) + '-' + c.getDate() + ' ' + c.getHours() + ':' + c.getMinutes() + ':' + c.getSeconds()
if (typeof this.validateForm1.value.createTime !== 'string') {
var c = new Date(this.validateForm1.value.createTime);
this.validateForm1.value.createTime =
c.getFullYear() + '-' + (c.getMonth() + 1) + '-' + c.getDate() + ' ' + c.getHours() + ':' + c.getMinutes() + ':' + c.getSeconds();
}
const params: any = {
...this.sf1.value,
...this.sf7.value,
unLoadingPlaceDTOList: [...this.startInfo, ...this.endInfo,],
unLoadingPlaceDTOList: [...this.startInfo, ...this.endInfo],
goodsInfoDTOList: [
{
...this.sf4.value, ...this.sf3.value,
maxWeight: this.sf4.value.maxWeight.join(','),
maxCube: this.sf4.value.maxCube.join(',')
}
{
...this.sf4.value,
...this.sf3.value,
maxWeight: this.sf4.value.maxWeight.join(','),
maxCube: this.sf4.value.maxCube.join(',')
}
]
}
params.freightPrice = this.totalFees
if(submitType) {
};
params.freightPrice = this.totalFees;
if (submitType) {
if (submitType == 'assign') {
this.chooseFamifiar(params);
return;
}
}
if(this.PageStatus === '大宗修改') {
if (this.PageStatus === '大宗修改') {
this.requests(this.service.$api_set_bulkModify, params, 1);
} else if(this.PageStatus === '大宗下一单') {
} else if (this.PageStatus === '大宗下一单') {
this.requests(this.service.$api_set_saveAnotherBulkOrder, params, 2);
}
}
@ -695,8 +716,8 @@ export class SupplyManagementBulkPublishComponent 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);
}
}
});
@ -713,64 +734,64 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
this.sf7.setValue('/receiptAddressId', data.id);
this.sf7.setValue('/receiptUserName', data.contactName);
this.sf7.setValue('/phon', data.contactTelephone);
this.sf7.setValue('/area', `${data.province}-${data.city}-${data.area}`)
this.sf7.setValue('/area', `${data.province}-${data.city}-${data.area}`);
this.sf7.setValue('/address', data.detailedAddress);
}
});
}
// 打开地图
// 打开地图
openMap(type: string, index: number) {
const modalRef = this.modalService.create({
nzTitle: '',
nzContent: AmapPoiPickerComponent,
nzWidth: 900,
nzOnOk: item => {
const poi = item.poi;
const locList = poi.location.toString().split(',');
switch (type) {
case 'start':
this.startInfo[index].detailedAddress = poi.district + poi.name;
this.startInfo[index].longitude = locList[0];
this.startInfo[index].latitude = locList[1];
this.startInfo[index].province = poi.cityInfo.province;
this.startInfo[index].city = poi.cityInfo.city;
this.startInfo[index].area = poi.cityInfo.district;
this.startInfo[index].address = poi.name;
break;
case 'end':
this.endInfo[index].detailedAddress = poi.district + poi.name;
this.endInfo[index].longitude = locList[0];
this.endInfo[index].latitude = locList[1];
this.endInfo[index].province = poi.cityInfo.province;
this.endInfo[index].city = poi.cityInfo.city;
this.endInfo[index].area = poi.cityInfo.district;
this.endInfo[index].address = poi.name;
break;
default:
break;
}
const modalRef = this.modalService.create({
nzTitle: '',
nzContent: AmapPoiPickerComponent,
nzWidth: 900,
nzOnOk: item => {
const poi = item.poi;
const locList = poi.location.toString().split(',');
switch (type) {
case 'start':
this.startInfo[index].detailedAddress = poi.district + poi.name;
this.startInfo[index].longitude = locList[0];
this.startInfo[index].latitude = locList[1];
this.startInfo[index].province = poi.cityInfo.province;
this.startInfo[index].city = poi.cityInfo.city;
this.startInfo[index].area = poi.cityInfo.district;
this.startInfo[index].address = poi.name;
break;
case 'end':
this.endInfo[index].detailedAddress = poi.district + poi.name;
this.endInfo[index].longitude = locList[0];
this.endInfo[index].latitude = locList[1];
this.endInfo[index].province = poi.cityInfo.province;
this.endInfo[index].city = poi.cityInfo.city;
this.endInfo[index].area = poi.cityInfo.district;
this.endInfo[index].address = poi.name;
break;
default:
break;
}
if (this.startInfo[0]?.area && this.endInfo[0]?.area) {
this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe((res: any) => {
this.totalDistance = res.distance;
this.totalTime = res.time;
});
if (this.startInfo[0]?.area && this.endInfo[0]?.area) {
this.amapService.drivingCompute([...this.startInfo], [...this.endInfo]).subscribe((res: any) => {
this.totalDistance = res.distance;
this.totalTime = res.time;
});
}
}
}
});
}
});
}
goBack() {
window.history.go(-1);
}
// 初始化信息
initdata() {
this.service.request(`${this.service.$api_get_getBulkDetail}`, {id:this.id}).subscribe((res) => {
this.dataR(res);
})
this.service.request(`${this.service.$api_get_getBulkDetail}`, { id: this.id }).subscribe(res => {
this.dataR(res);
});
}
// 初始化信息
dataR (res: any) {
dataR(res: any) {
// 注:区分编辑和下一单 区别是初始化的时候加不加ID
if (res?.shipperAppUserName) {
const List: any = [];
@ -786,26 +807,26 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
}
});
}
if(res?.enterpriseProjectId) {
this.enterpriseProjectIds = res.enterpriseProjectId
if (res?.enterpriseProjectId) {
this.enterpriseProjectIds = res.enterpriseProjectId;
}
this.sf1data = {
dispatchPhone: res?.dispatchPhone,
dispatchName: res?.dispatchName,
// shipperAppUserName: res?.shipperAppUserName || '',
enterpriseProjectId: res?.enterpriseProjectId || '',
enterpriseInfoName: res?.enterpriseInfoName || '',
externalResourceCode: res?.externalResourceCode || '',
dispatchId: res?.dispatchId || '',
deadlineTime: res?.deadlineTime || '',
}
if(this.PageStatus === '大宗修改') {
enterpriseProjectId: res?.enterpriseProjectId || '',
enterpriseInfoName: res?.enterpriseInfoName || '',
externalResourceCode: res?.externalResourceCode || '',
dispatchId: res?.dispatchId || '',
deadlineTime: res?.deadlineTime || ''
};
if (this.PageStatus === '大宗修改') {
this.sf1data.id = res?.id;
}
res?.unLoadingPlaceVOList.forEach((element: any) => {
if(element.type === 1 || element.type === '1') {
if (element.type === 1 || element.type === '1') {
const controlId = this.startInfo.length;
if(this.PageStatus === '大宗修改') {
if (this.PageStatus === '大宗修改') {
this.startInfo.push({
detailedAddress: element.detailedAddress,
appUserName: element.appUserName,
@ -817,7 +838,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
area: element.area,
type: element.type,
id: element.id
})
});
} else {
this.startInfo.push({
detailedAddress: element.detailedAddress,
@ -828,19 +849,19 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
province: element.province,
city: element.city,
area: element.area,
type: element.type,
})
type: element.type
});
}
if(element.createTime) {
this.creatTime = element?.createTime
this.modifyTime = element?.modifyTime
if (element.createTime) {
this.creatTime = element?.createTime;
this.modifyTime = element?.modifyTime;
}
this.validateForm1.addControl(`loadAddress${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));
} else if(element.type === 2 || element.type === '2') {
} else if (element.type === 2 || element.type === '2') {
const controlId = this.endInfo.length;
if( this.PageStatus === '大宗修改') {
if (this.PageStatus === '大宗修改') {
this.endInfo.push({
detailedAddress: element?.detailedAddress,
appUserName: element?.appUserName,
@ -852,7 +873,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
area: element.area,
type: element.type,
id: element.id
})
});
} else {
this.endInfo.push({
detailedAddress: element?.detailedAddress,
@ -864,7 +885,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
city: element.city,
area: element.area,
type: element.type
})
});
}
this.validateForm1.addControl(`unloadAddress${controlId}`, new FormControl(null, Validators.required));
this.validateForm1.addControl(`unloadName${controlId}`, new FormControl(null, Validators.required));
@ -875,7 +896,7 @@ export class SupplyManagementBulkPublishComponent 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 || '';
@ -892,11 +913,10 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
number: res?.goodsInfoVOList[0]?.number || '',
maxWeight: res?.goodsInfoVOList[0]?.maxWeight?.split(',') || '',
maxCube: res?.goodsInfoVOList[0]?.maxCube?.split(',') || ''
}
if(this.PageStatus === '大宗修改') {
};
if (this.PageStatus === '大宗修改') {
this.sf4data.id = res?.goodsInfoVOList[0]?.id;
}
}
this.totalFees = res?.freightPrice || '0';
this.sf7data = {
stateReceipt: res?.supplementaryInformationVO?.stateReceipt,
@ -911,7 +931,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
};
}
// 回退
choose(){
choose() {
window.history.go(-1);
}
// 选择地址