This commit is contained in:
wangshiming
2022-03-01 15:05:20 +08:00
parent 36937f229f
commit 73b1521523
4 changed files with 113 additions and 33 deletions

View File

@ -126,7 +126,6 @@
<sf #sf4 [schema]="schema4" [formData]="sf4data" [button]="'none'" [ui]="ui4">
<ng-template sf-template="freightPrice" let-i let-ui="ui">
<nz-input-group [nzAddOnAfter]="addOnAfterTemplate">
<!-- <input nz-input [ngModel]="i.value" (ngModelChange)="i.setValue($event)" placeholder="请输入" /> -->
<nz-input-number [ngModel]="i.value" (ngModelChange)="i.setValue($event)" [nzMin]="1" style="width: 100%"></nz-input-number>
</nz-input-group>
<ng-template #addOnAfterTemplate>

View File

@ -46,6 +46,13 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
startInfo: any = [];
endInfo: any = [];
PageStatus = '';
limitValues = {
maxMonth: 99,
maxWeight: 99999,
maxVolume: 99999,
maxTrainNumber: 99999,
maxFreight: 9999999
}
constructor(
private http: _HttpClient,
fb: FormBuilder,
@ -96,6 +103,7 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
this.initSF4();
this.initSF6();
this.initdata();
this.getLimitvalue();
}
initSF1() {
this.schema1 = {
@ -150,19 +158,19 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
ui: {
placeholder: '请输入',
format: 'yyyy-MM-dd HH:mm:ss',
disabledDate: (current: Date): boolean => {
validator: (val) => {
let d = new Date();
let year = d.getFullYear();
let month = d.getMonth();
let date = d.getDate();
let mydate = new Date(year, month + 3, date);
return differenceInCalendarDays(current, new Date()) < 0 || differenceInCalendarDays(current, mydate) > 0;
},
validator: (val) => {
if( new Date(val) <new Date()){
return [{ keyword: 'validTime', message: '有效期时间需大于当前时间' }];
}
return [];
let mydate = new Date(year, month + this.limitValues.maxMonth, date);
if (new Date(val) < new Date()) {
return [{ keyword: 'validTime', message: '有效期时间需大于当前时间' }];
}
if (new Date(val) > mydate) {
return [{ keyword: 'validTime2', message: `有效期最长为${this.limitValues.maxMonth}个月` }];
}
return [];
},
}
},
@ -649,7 +657,6 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
}
// 提交前确认,委托运输协议弹窗
submitConfirm(submitType?: any) {
// 校验规则
Object.keys(this.validateForm1.controls).forEach(key => {
this.validateForm1.controls[key].markAsDirty();
this.validateForm1.controls[key].updateValueAndValidity();
@ -657,11 +664,20 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
this.sf1.validator({ emitError: true });
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.sf1.valid || !this.sf3.valid || !this.sf4.valid ) {
this.service.msgSrv.warning('请完善必填项!');
return;
}
// 校验各个输入限定值
if (this.sf4.value.weight > this.limitValues.maxWeight || this.sf4.value.volume > this.limitValues.maxVolume || this.sf4.value.number > this.limitValues.maxTrainNumber) {
this.service.msgSrv.error(`当前货物核载信息已超出限定值【${this.limitValues.maxWeight}吨、${this.limitValues.maxVolume}方、${this.limitValues.maxTrainNumber}车】`);
return;
}
if (this.sf4.value.freightPrice > this.limitValues.maxFreight) {
this.service.msgSrv.error(`当前运费单价已超出限定值【${this.limitValues.maxFreight}元】`);
return;
}
const modalRef = this.modalService.create({
nzTitle: '运输协议',
@ -677,16 +693,21 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
}
// 确认提交
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();
}
// //装卸货信息
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 params: any = {
...this.sf1.value,
@ -1057,4 +1078,27 @@ export class SupplyManagementBulkPublishComponent implements OnInit {
});
}
}
getLimitvalue() {
const getlimitvaluesParms = [
this.service.limitKeys2.month,
this.service.limitKeys2.weight,
this.service.limitKeys2.volume,
this.service.limitKeys2.trainNumber,
this.service.limitKeys2.freight,
];
this.service.request(this.service.$api_findItemValueByItemKeys, getlimitvaluesParms).subscribe((res) => {
const maxMonth = res.filter((item: any) => item.itemKey === this.service.limitKeys2.month)[0].itemValue;
const maxWeight = res.filter((item: any) => item.itemKey === this.service.limitKeys2.weight)[0].itemValue;
const maxVolume = res.filter((item: any) => item.itemKey === this.service.limitKeys2.volume)[0].itemValue;
const maxTrainNumber = res.filter((item: any) => item.itemKey === this.service.limitKeys2.trainNumber)[0].itemValue;
const maxFreight = res.filter((item: any) => item.itemKey === this.service.limitKeys2.freight)[0].itemValue;
this.limitValues = {
maxMonth: Number(maxMonth),
maxWeight: Number(maxWeight),
maxVolume: Number(maxVolume),
maxTrainNumber: Number(maxTrainNumber),
maxFreight: Number(maxFreight)
}
})
}
}

View File

@ -41,6 +41,13 @@ export class SupplyManagementBulkReleasePublishComponent implements OnInit {
totalFees: any; // 总数信息
id = '';
type = 'add';
limitValues = {
maxMonth: 99,
maxWeight: 99999,
maxVolume: 99999,
maxTrainNumber: 99999,
maxFreight: 9999999
}
// // 单位
startInfo: any[] = [];
endInfo: any[] = [];
@ -80,6 +87,7 @@ export class SupplyManagementBulkReleasePublishComponent implements OnInit {
this.initSF3();
this.initSF4();
this.initSF6();
this.getLimitvalue();
this.startInfo = [
{
detailedAddress: '',
@ -173,19 +181,19 @@ export class SupplyManagementBulkReleasePublishComponent implements OnInit {
ui: {
placeholder: '请输入',
format: 'yyyy-MM-dd HH:mm:ss',
disabledDate: (current: Date): boolean => {
validator: (val) => {
let d = new Date();
let year = d.getFullYear();
let month = d.getMonth();
let date = d.getDate();
let mydate = new Date(year, month + 3, date);
return differenceInCalendarDays(current, new Date()) < 0 || differenceInCalendarDays(current, mydate) > 0;
},
validator: (val) => {
if( new Date(val) <new Date()){
return [{ keyword: 'validTime', message: '有效期时间需大于当前时间' }];
}
return [];
let mydate = new Date(year, month + this.limitValues.maxMonth, date);
if (new Date(val) < new Date()) {
return [{ keyword: 'validTime', message: '有效期时间需大于当前时间' }];
}
if (new Date(val) > mydate) {
return [{ keyword: 'validTime2', message: `有效期最长为${this.limitValues.maxMonth}个月` }];
}
return [];
},
}
},
@ -822,4 +830,27 @@ export class SupplyManagementBulkReleasePublishComponent implements OnInit {
});
}
}
getLimitvalue() {
const getlimitvaluesParms = [
this.service.limitKeys2.month,
this.service.limitKeys2.weight,
this.service.limitKeys2.volume,
this.service.limitKeys2.trainNumber,
this.service.limitKeys2.freight,
];
this.service.request(this.service.$api_findItemValueByItemKeys, getlimitvaluesParms).subscribe((res) => {
const maxMonth = res.filter((item: any) => item.itemKey === this.service.limitKeys2.month)[0].itemValue;
const maxWeight = res.filter((item: any) => item.itemKey === this.service.limitKeys2.weight)[0].itemValue;
const maxVolume = res.filter((item: any) => item.itemKey === this.service.limitKeys2.volume)[0].itemValue;
const maxTrainNumber = res.filter((item: any) => item.itemKey === this.service.limitKeys2.trainNumber)[0].itemValue;
const maxFreight = res.filter((item: any) => item.itemKey === this.service.limitKeys2.freight)[0].itemValue;
this.limitValues = {
maxMonth: Number(maxMonth),
maxWeight: Number(maxWeight),
maxVolume: Number(maxVolume),
maxTrainNumber: Number(maxTrainNumber),
maxFreight: Number(maxFreight)
}
})
}
}

View File

@ -146,7 +146,13 @@ export class SupplyManagementService extends BaseService {
intervalDays:'sys.config.goods.wholeUnloadingIntervalDays', //计划装、卸货时间间隔
maxTimes:'sys.config.goods.wholeLoadingMaxTimes', //整车-多装多卸地点上限
}
public limitKeys2 = {
month:'sys.config.goods.bulkEndMaxMonth', //大宗-截止时间上限
weight:'sys.config.goods.bulkMaxWeight', //大宗-重量上限
volume:'sys.config.goods.bulkMaxVolume', //大宗-体积上限
trainNumber:'sys.config.goods.bulkMaxTrainNumber', //大宗-车次上限
freight:'sys.config.goods.bulkMaxUnitFreight', //大宗-运费单价上限
}
// 根据ItemKey获取项值
public $api_findItemValueByItemKeys = '/api/mdc/pbc/sysConfigItem/findItemValueByItemKeys';
// 获取保价费信息