所以这是我要测试的示例方法,我们有一个对话框,该方法在调用该方法时打开,并且当该对话框关闭时,我想将信息发布到数据库中并将信息保存在前面。结束。我真的不知道如何通过分支机构完成报道。
public addShift() {
const dialogRef = this.addShiftDialog.open(ShiftDialogComponent, {
height: '409px',
minHeight: '409px',
width: '560px',
minWidth: '560px',
disableClose: true,
data: {
shiftList: this.shiftsArray,
title: 'Add Shift',
infoRow: {
daysWeek: '1111111',
startTime: '08:00',
finishTime: '14:00',
duration: '6 hours',
typeShift: 'Regular',
comment: ''
}
}
});
dialogRef.afterClosed().subscribe(result => {
if (result) {
this.shiftService.postShift({
terminalUuid: '4fa6b12d-6e1e-4f68-8104-04ee91ced995',
typeShift: result.typeShift,
startTime: result.startTime + ':00',
finishTime: result.finishTime + ':00',
daysWeek: result.daysWeek,
comment: result.comment
}).subscribe((data: any) => {
result.uuid = data.payload.uuid;
result.daysWeek = this.shiftService.getCodeDaysWeek(result.daysWeek);
let times = this.shiftService.calculateTimes(result.startTime, result.finishTime);
result.startTime = times[0];
result.finishTime = times[1];
result.duration = times[2];
this.shiftsArray.push(result);
this.shiftTable.renderRows();
});
}
});