嘿,如何处理多个用户编辑相同的信息?例如使用两个浏览器/用户来编辑患者。两个浏览器应开始编辑过程。一个更改并保存,另一个浏览器更改为不同的值并尝试保存(但应拒绝) 我该如何实现?
我的html文件文件
<ng-template #content>
<form
role="form"
#createPatientForm="ngForm"
(ngSubmit)="onLogin(createPatientForm.value)"
novalidate>
<div class="modal-body" *ngIf="!editMode || !confirm">
<div class="form-content">
<div class="form-group">
<div class="row">
<div id="fName" class="col-8">
<label for="firstName">First Name*</label>
<input
#fName="ngModel"
type="text"
[(ngModel)]="patient.FirstName"
name="firstName"
class="form-control input-underline input-lg"
[ngClass]="{ invalid: !fName.valid && fName.touched }"
id="firstName"
autocomplete="off"
minlength="2"
maxlength="20"
required
/>
</div>
<div *ngIf="!fName.valid && fName.touched" class="error">
<div *ngIf="fName.errors.required">First Name is required. </div>
<div *ngIf="fName.errors.minlength">Minimum of 2 characters.</div>
</div>
<div *ngIf="!mName.valid && mName.touched" class="error">
<div *ngIf="mName.errors.pattern">
Numbers not allowed for initials.
</div>
<div *ngIf="mName.errors.minlength">Minimum of 2 characters.</div>
</div>
</div>
<div class="form-group">
<label for="lastName">Last Name*</label>
<input
#lName="ngModel"
type="text"
[(ngModel)]="patient.LastName"
name="lastName"
class="form-control input-underline input-lg"
[ngClass]="{ invalid: !lName.valid && lName.touched }"
id="lastName"
autocomplete="off"
minlength="2"
maxlength="50"
inputName
required
/>
<div *ngIf="!lName.valid && lName.touched" class="error">
<div *ngIf="lName.errors.required">Last Name is required.</div>
<div *ngIf="lName.errors.minlength">Minimum of 2 characters.</div>
</div>
</div>
<div class="col-6">
<label for="Gender">Gender*</label>
<select
#gender="ngModel"
[(ngModel)]="patient.Gender"
[class.text-dimmed]="!patient.Gender"
name="gender"
id="Gender"
class="form-control input-underline input-lg"
[ngClass]="{ invalid: gender.value === null && gender.touched }"
required
>
<option [ngValue]="null">Select</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
<div *ngIf="gender.value === null && gender.touched">
<div class="error">Gender required.</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="patientEmail">Email</label>
<input
type="email"
#email="ngModel"
[(ngModel)]="patient.Email"
name="patientEmail"
class="form-control input-underline input-lg"
[ngClass]="{ invalid: !email.valid && email.touched }"
id="patientEmail"
minlength="5"
maxlength="100"
pattern="^(?!.*(?:''|\.\.))[\w-\.\']{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,3}$"
/>
<div class="error" *ngIf="!email.valid && email.touched">
<div *ngIf="email.errors.pattern">
Please enter a valid email address.
</div>
<div *ngIf="email.errors.minlength">
minimum of 5 characters required.
</div>
</div>
</div>
<div class="hint-section">
<p class="address-header text-center">
* Required
</p>
</div>
</div>
</div>
<div class="modal-footer">
<span (click)="cancel()" class="clickable">CANCEL</span>
<button
[disabled]="
checkFormValidity(createPatientForm) || !createPatientForm.form.valid
"
type="button"
class="btn square-btn"
(click)="editMode && confirm ? setConfirm() : createUpdatePatient()"
>
{{ editMode && confirm ? "YES" : "NEXT" }}
</button>
</div>
这是我的Ts文件
createUpdatePatient() {
this.duplicateFinderService.confirmDuplicatePatient(
this.dateOfBirth,
this.patient,
this.mode,
this.patientId
);
this.router.navigate(["../additional-details"], {
relativeTo: this.route
});
}
其他详细信息ts文件
update() {
this.requestPending = true;
this.patientService.updatePatientProfile(this.patient).subscribe(
() => {
this.store.dispatch(
new SetPatientAction(this.patient, this.utilService)
);
this.requestPending = false;
if (this.isAdminEdit) {
this.router.navigate(["../billing"], { relativeTo: this.route });
} else {
this.router.navigate(["../"], { relativeTo: this.route });
}
},
error => {
this.requestPending = false;
}
);
}
计费明细
update() {
this.requestPending = true;
this.patientService.updatePatientBilling(this.patient).subscribe(() => {
this.requestPending = false;
this.store.dispatch(new SetPatientAction(this.patient, this.utilService));
this.cancel();
});
}
我可以在前端实现吗?谢谢
答案 0 :(得分:0)
您可以基于userId实现它。跟踪每个用户ID并根据该ID进行更改