预实现效果截图:
需要将两段日期存入到同一字段内,需要用到split()方法
在编辑模态框中初始化时,将endDate(起始时间和截止时间)拆分
ngOnInit(): void {
let dateArray = this.record.endDate.split(' -- ');
this.startDate = dateArray[0];
this.enddDate = dateArray[1];
}
分别将前后两个日期存入startDate和enddDate
编辑保存
save() {
let reqJson = {};
Object.assign(reqJson, {endDate:Utils.commonDateFormat('yyyy-MM-dd',this.startDate)+ ' -- ' +Utils.commonDateFormat('yyyy-MM-dd',this.enddDate)});
});
}