This commit is contained in:
wangshiming
2022-02-28 15:55:57 +08:00
parent 03b1d6da82
commit 394aba4ba1
10 changed files with 689 additions and 361 deletions

View File

@ -2,6 +2,7 @@ import { Component, OnInit, ViewChild } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { cacheConf } from '@conf/cache.conf';
import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
import {
SFCheckboxWidgetSchema,
SFComponent,
@ -241,7 +242,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
ui: {
widget: 'select',
placeholder: '请选择',
errors: { required: '请选择货物类型' },
errors: { required: '请选择货物名称' },
asyncData: () =>
this.shipperSrv.loadConfigByKey('goods.name.config.type').pipe(
map((data: any) => {
@ -270,7 +271,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
widget: 'select',
placeholder: '请选择',
errors: { required: '请填写货物名称' },
change: (_value: any, data: any) => {
change: (value: any, data: any) => {
this.sf3.setValue('/goodsName', data.label);
},
visibleIf: {
@ -299,11 +300,11 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
}
}
},
required: ['goodsTypeId', 'goodsName', 'goodsNameId']
required: ['goodsTypeId', 'goodsName', 'goodsNameId', 'goodsName1']
};
this.ui3 = {
'*': {
spanLabelFixed: 90,
spanLabelFixed: 115,
grid: { span: 12 }
}
};
@ -317,7 +318,8 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
ui: {
widget: 'custom',
placeholder: '请输入',
errors: { required: '必填项' }
errors: { required: '必填项' },
validator: val => this.customValidator(val)
}
},
volume: {
@ -325,7 +327,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
title: '',
ui: {
widget: 'custom',
placeholder: '请输入'
placeholder: '请输入',
}
},
number: {
@ -333,7 +335,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
title: '',
ui: {
widget: 'custom',
placeholder: '请输入'
placeholder: '请输入',
}
},
carModel: {
@ -342,13 +344,13 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
ui: {
widget: 'select',
mode: 'multiple',
maxMultipleCount:3,
maxMultipleCount: 3,
placeholder: '请选择车型',
errors: { required: '请选择车型' },
asyncData: () => this.service.getDictOptions({ dictKey: 'car:model' }),
change:(tag:any , org:any)=>{
if(tag.includes("999")){
this.sf4.setValue('/carModel',["999"]);
change: (tag: any, org: any) => {
if (tag.includes('999')) {
this.sf4.setValue('/carModel', ['999']);
}
}
}
@ -359,43 +361,28 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
ui: {
widget: 'select',
mode: 'multiple',
maxMultipleCount:3,
maxMultipleCount: 3,
placeholder: '请选择车长',
errors: { required: '请选择车长' },
asyncData: () => this.service.getDictOptions({ dictKey: 'car:length' }),
change:(tag:any , org:any)=>{
if(tag.includes("999")){
this.sf4.setValue('/carModel',["999"]);
change: (tag: any, org: any) => {
if (tag.includes('999')) {
this.sf4.setValue('/carLength', ['999']);
}
}
}
},
}
},
required: ['weight', 'carModel', 'carLength']
};
this.ui4 = {
'*': {
spanLabelFixed: 90,
grid: { span: 24 }
},
$weight: {
grid: { lg: 8, md: 12, sm: 12, xs: 24 }
},
$volume: {
grid: { lg: 8, md: 12, sm: 12, xs: 24 }
},
$number: {
grid: { lg: 8, md: 12, sm: 12, xs: 24 }
},
$carModel: {
spanLabelFixed: 100,
grid: { span: 8 }
},
$carLength: {
spanLabelFixed: 115,
grid: { span: 8 }
}
};
}
initSF5() {
this.schema5 = {
properties: {
@ -403,8 +390,17 @@ export class SupplyManagementReleasePublishComponent 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'
},
@ -415,7 +411,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
readOnly: true,
ui: {
widget: 'checkbox',
visibleIf: { insuranceType: (value: string) => value === '0' }
visibleIf: { insuranceType: (value: string) => value === '1' }
} as SFCheckboxWidgetSchema,
default: ['车辆实时定位', '轨迹查询', '数据保护', '赠送基本险']
},
@ -426,7 +422,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
readOnly: true,
ui: {
widget: 'checkbox',
visibleIf: { insuranceType: (value: string) => value === '1' }
visibleIf: { insuranceType: (value: string) => value === '2' }
} as SFCheckboxWidgetSchema,
default: ['车辆实时定位', '轨迹查询', '数据保护', '专属技术服务', '赠送综合险']
},
@ -438,21 +434,22 @@ export class SupplyManagementReleasePublishComponent 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: {
@ -469,6 +466,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
title: '',
ui: {
widget: 'custom',
validator: val => this.customValidator(val),
visibleIf: { insuranceType: (value: string) => value !== '3' }
}
},
@ -478,26 +476,27 @@ export class SupplyManagementReleasePublishComponent 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 }
},
}
};
}
initSF6() {
this.schema6 = {
properties: {
@ -520,7 +519,7 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
ui: {
widget: 'dict-select',
params: { dictKey: 'receipt:type' },
containsAllLable: false,
containsAllLabel: false,
placeholder: '请选择',
errors: { required: '请选择' },
visibleIf: {
@ -528,58 +527,65 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
}
}
},
// receiptAddressId: {
// type: 'string',
// title: '选择地址',
// ui: {
// widget: 'custom',
// placeholder: '请点击选择回单地址',
// // validator: val => (this.sf6?.value?.receiptType === '2' ? [{ keyword: 'required', message: '请点击选择收回单地址' }] : []),
// visibleIf: {
// receiptType: value => value === '2'
// }
// },
// default: ''
// },
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: 50,
ui: {
visibleIf: {
receiptType: value => value === '2'
}
},
readOnly: true
},
remarks: {
type: 'string',
@ -592,15 +598,16 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
} as SFTextareaWidgetSchema
}
},
required: ['stateReceipt', 'receiptType', 'receiptUserName','receiptUserPhone','receiptAddressArea','receiptAddress']
required: ['stateReceipt', 'receiptType', 'receiptAddress']
};
this.ui6 = {
'*': {
spanLabelFixed: 90,
spanLabelFixed: 115,
grid: { span: 24 }
}
};
}
initSF7() {
this.schema7 = {
properties: {
@ -608,19 +615,19 @@ export class SupplyManagementReleasePublishComponent 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 },
@ -643,6 +650,29 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
}
};
}
// 不可选择的时间
disabledDateStart = (current: Date): boolean => {
return differenceInCalendarDays(new Date(), current) > 0;
};
/**
* 自定义校验数据
* @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() === '';
}
// 获取城市列表
getRegionCode(regionCode: any) {
console.log(regionCode);
@ -663,37 +693,35 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
}
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);
}
});
shipperId: this?.sf1.value?.shipperAppUserId,
enterpriseInfoId: this?.sf1.value?.enterpriseInfoName,
totalFreight: subtotal,
fuelCardAmount: oilCardPay,
resourcetype: '1'
};
this.service.request(this.service.$api_getCalculatedSurcharge, params).subscribe(res => {
console.log('999')
console.log(this?.sf1.value)
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?.sf1.value?.shipperAppUserId}&enterpriseInfoId=${this?.sf1.value?.enterpriseInfoName}&resourcetype='1'`)
.subscribe(res => {
if (res) {
this.currentRate = res.rate * 100;
}
});
} else {
this.service.msgSrv.error(res.msg);
}
});
}
// 添加 删除发货卸货地址
addStartInfo() {
@ -983,6 +1011,8 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
if (this.sf3data.goodsNameId) {
this.sf3.setValue('/goodsNameId', this.sf3data.goodsNameId);
}
} else {
this.service.msgSrv.error(res.msg);
}
});
}
@ -1049,28 +1079,24 @@ export class SupplyManagementReleasePublishComponent implements OnInit {
});
}
}
getInsurersPrice() {
console.log(this.sf5.value.goodsValue)
console.log(this.sf5.value.insuranceType)
if (this.sf5.value.goodsValue >= 50000) {
if(this.totalDistance <=0){
this.service.msgSrv.warning('当前装卸货距离为0无法计算保价费金额');
return;
// 计算保价费金额
getInsurersPrice(insuranceType = this.sf5.value.insuranceType) {
if (this.sf5.value.goodsValue >= 50000 && this.totalDistance > 0) {
const params = {
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);
this.sf5.setValue('/insuranceRate', res.insuranceRate);
} else {
this.sf5.setValue('/insurancePremium', null);
this.sf5.setValue('/insuranceRate', null);
}
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);
}
});
}
});
}
}
}