Commit 12cd07db by DESKTOP-HF0LVOG\myhr

Update Validator หน้าอุปกรณ์ และ admin

parent 591bb041
...@@ -52,15 +52,11 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -52,15 +52,11 @@ export class AdminEquirmentComponent implements OnInit {
rDesc: new FormControl('') rDesc: new FormControl('')
}); });
myFormRoom: FormGroup;
myFormEquir: FormGroup;
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService, private RoomDetailService: RoomDetailService constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService, private RoomDetailService: RoomDetailService
, private fb: FormBuilder) { , private fb: FormBuilder) {
console.log()
this.RoomForm = this.fb.group({
rName: ["",],
rType: ["",],
rDesc: ["",]
});
this.RoomForm.valueChanges.subscribe(console.log);
} }
ngOnInit() { ngOnInit() {
...@@ -68,6 +64,34 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -68,6 +64,34 @@ export class AdminEquirmentComponent implements OnInit {
this.listRoomModel = this.roomService.getListRoom(); this.listRoomModel = this.roomService.getListRoom();
this.collectionSizeListRoom = this.listRoomModel.length this.collectionSizeListRoom = this.listRoomModel.length
console.log("listRoom", this.listRoomModel) console.log("listRoom", this.listRoomModel)
this.myFormRoom = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
rTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
rName : new FormControl('',[Validators.required]),
rDesc : new FormControl('',[Validators.required]),
rType : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Remark : new FormControl()
});
this.myFormEquir = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
eTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
eqName : new FormControl('',[Validators.required]),
eqDesc : new FormControl('',[Validators.required]),
eqType : new FormControl('',[Validators.required]),
eqPic : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Quantity : new FormControl('',[Validators.required]),
Remark : new FormControl('',[Validators.required]),
})
} }
bookEquir(editLend, item: Equirment) { bookEquir(editLend, item: Equirment) {
...@@ -168,20 +192,18 @@ export class AdminEquirmentComponent implements OnInit { ...@@ -168,20 +192,18 @@ export class AdminEquirmentComponent implements OnInit {
}); });
} }
openItemDetail(content: string, item: ItemDetail) { openItemDetail(contentequirment) {
this.modelItemDetail = item; this.modelEquirment = new Equirment();
console.log(item); this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`; this.closeResult = `Closed with: ${result}`;
}, (reason) => { }, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`; this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
}); });
} }
openRoomDetail(content: string, item: RoomDetail) { openRoomDetail(contentroom) {
this.modelRoomDetail = item; this.modelRoom = new MyRoom();
console.log(item); this.modalService.open(contentroom, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.modalService.open(content, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`; this.closeResult = `Closed with: ${result}`;
}, (reason) => { }, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`; this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
......
...@@ -9,6 +9,7 @@ import { RoomDetailService } from 'src/app/service/room-detail.service'; ...@@ -9,6 +9,7 @@ import { RoomDetailService } from 'src/app/service/room-detail.service';
import { MyRoom, Room } from 'src/app/models/rooms.model'; import { MyRoom, Room } from 'src/app/models/rooms.model';
import { EquirmentService } from 'src/app/service/equirment.service'; import { EquirmentService } from 'src/app/service/equirment.service';
import { RoomService } from 'src/app/service/room.service'; import { RoomService } from 'src/app/service/room.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
@Component({ @Component({
selector: 'app-admin-pending', selector: 'app-admin-pending',
...@@ -185,11 +186,42 @@ export class AdminPendingComponent implements OnInit { ...@@ -185,11 +186,42 @@ export class AdminPendingComponent implements OnInit {
return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue; return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
} }
myFormRoom: FormGroup;
myFormEquir: FormGroup;
ngOnInit(): void { ngOnInit(): void {
this.listitemDetail = this.ItemDetailService.getListItemDetail(); this.listitemDetail = this.ItemDetailService.getListItemDetail();
this.listroomDetail = this.RoomDetailService.getListRoomDetail(); this.listroomDetail = this.RoomDetailService.getListRoomDetail();
this.collectionSizeListRoom = this.listitemDetail.length; this.collectionSizeListRoom = this.listitemDetail.length;
console.log(this.listitemDetail); console.log(this.listitemDetail);
this.myFormRoom = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
rTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
rName : new FormControl('',[Validators.required]),
rDesc : new FormControl('',[Validators.required]),
rType : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Remark : new FormControl()
});
this.myFormEquir = new FormGroup({
userNameForm : new FormControl('',[Validators.required]),
eTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]),
eqName : new FormControl('',[Validators.required]),
eqDesc : new FormControl('',[Validators.required]),
eqType : new FormControl('',[Validators.required]),
eqPic : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]),
eTime : new FormControl('',[Validators.required]),
Quantity : new FormControl('',[Validators.required]),
Remark : new FormControl('',[Validators.required]),
})
} }
saveEquirment() { saveEquirment() {
......
...@@ -131,43 +131,54 @@ ...@@ -131,43 +131,54 @@
<h5 class=" title">Add Equirment</h5> <h5 class=" title">Add Equirment</h5>
</div> </div>
<div class=" card-body"> <div class=" card-body">
<form [formGroup]="myFormEquir" class="needs-validation">
<div class=" row"> <div class=" row">
<div class=" col-md-12"> <div class=" col-md-12">
<div class=" form-group"> <div class=" form-group">
<label> ชื่อ </label> <label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelEquirment.eqName" <input class=" form-control" placeholder="" type="text"
value="" /> [(ngModel)]="modelEquirment.eqName" value="" formControlName="eqName" />
<div style="color: red;" *ngIf="myFormEquir.controls.eqName.status=='INVALID'">
Invalid
Equirment Name.</div>
</div>
</div> </div>
</div> </div>
</div> <div class=" row">
<div class=" row"> <div class=" col-md-6 mb-2">
<div class=" col-md-6 mb-2"> <div class=" form-group">
<div class=" form-group"> <label> หมวดหมู่ </label>
<label> หมวดหมู่ </label> <br>
<br> <select class="form-select" aria-label="Default select example"
<select class="form-select" aria-label="Default select example" [(ngModel)]="modelEquirment.eqType" formControlName="eqType">
[(ngModel)]="modelEquirment.eqType"> <option selected>เลือกหมวดหมู่</option>
<option selected>เลือกหมวดหมู่</option> <option value="4">IT</option>
<option value="4">IT</option> <option value="5">Company</option>
<option value="5">Company</option> </select>
</select> <div style="color: red;" *ngIf="myFormEquir.controls.eqType.status=='INVALID'">
Invalid
Equirment Type.</div>
</div>
</div> </div>
</div> </div>
</div> <div class=" row">
<div class=" row"> <div class=" col-md-12">
<div class=" col-md-12"> <div class=" form-group">
<div class=" form-group"> <label> รายละเอียด</label>
<label> รายละเอียด</label> <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="......" [(ngModel)]="modelEquirment.eqDesc"
placeholder="......" [(ngModel)]="modelEquirment.eqDesc"></textarea> formControlName="eqDesc"></textarea>
<div style="color: red;" *ngIf="myFormEquir.controls.eqDesc.status=='INVALID'">
Invalid
Equirment Desc.</div>
</div>
</div> </div>
</div> </div>
</div> <label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label>
<label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label> <input type="file" class="form-control-file" id="exampleFormControlFile" formControlName="eqPic">
<input type="file" class="form-control-file" id="exampleFormControlFile"> </form>
</div> </div>
<div class=" card-footer"> <div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit" (click)="saveEquirment()">Save</button> <button class=" btn btn-fill btn-danger" type="submit" (click)="saveEquirment()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel" <button class=" btn btn-fill btn-danger" type="cancel"
...@@ -181,42 +192,54 @@ ...@@ -181,42 +192,54 @@
<div class=" col-md-12" style="padding: 0; "> <div class=" col-md-12" style="padding: 0; ">
<div class="card" style="margin: 0; "> <div class="card" style="margin: 0; ">
<div class=" card-header"> <div class=" card-header">
<h5 class=" title">Add Equirment</h5> <h5 class=" title">เพิ่มรายการ</h5>
</div> </div>
<div class=" card-body"> <div class=" card-body">
<div class=" row"> <form [formGroup]="myFormRoom" class="needs-validation">
<div class=" col-md-12"> <div class=" row">
<div class=" form-group"> <div class=" col-md-12">
<label> ชื่อ </label> <div class=" form-group">
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelRoom.rName"> <label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelRoom.rName"
formControlName="rName">
<div style="color: red;" *ngIf="myFormRoom.controls.rName.status=='INVALID'">
Invalid
Name.</div>
</div>
</div> </div>
</div> </div>
</div> <div class=" row">
<div class=" row"> <div class=" col-md-6 mb-2">
<div class=" col-md-6 mb-2"> <div class=" form-group">
<div class=" form-group"> <label> ประเภท </label>
<label> ประเภท </label> <br>
<br> <select class="form-select" aria-label="Default select example"
<select class="form-select" aria-label="Default select example" [(ngModel)]="modelRoom.rType" formControlName="rType">
[(ngModel)]="modelRoom.rType"> <option value="1">ห้อง</option>
<option selected>เลือกประเภท</option> <option value="2">รถ</option>
<option value="1">ห้อง</option> </select>
<option value="2">รถ</option> <div style="color: red;" *ngIf="myFormRoom.controls.rType.status=='INVALID'">
</select> Invalid
Type.</div>
</div>
</div> </div>
</div> </div>
</div> <div class=" row">
<div class=" row"> <div class=" col-md-12">
<div class=" col-md-12"> <div class=" form-group">
<div class=" form-group"> <label> รายละเอียด</label>
<label> รายละเอียด</label> <textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3" placeholder="......" [(ngModel)]="modelRoom.rDesc"
placeholder="......" [(ngModel)]="modelRoom.rDesc"></textarea> formControlName="rDesc"></textarea>
<div style="color: red;" *ngIf="myFormRoom.controls.rDesc.status=='INVALID'">
Invalid
Desc.</div>
</div>
</div> </div>
</div> </div>
</div> <label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label>
<label for="exampleFormControlFile">แนบไฟล์รูปภาพ</label> <input type="file" class="form-control-file" id="exampleFormControlFile">
<input type="file" class="form-control-file" id="exampleFormControlFile"> </form>
</div> </div>
<div class=" card-footer"> <div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit" (click)="saveRoom()">Save</button> <button class=" btn btn-fill btn-danger" type="submit" (click)="saveRoom()">Save</button>
......
...@@ -59,8 +59,9 @@ export class EquipmentComponent implements OnInit { ...@@ -59,8 +59,9 @@ export class EquipmentComponent implements OnInit {
userNameForm : new FormControl('',[Validators.required]), userNameForm : new FormControl('',[Validators.required]),
rTelephone : new FormControl('',[Validators.required]), rTelephone : new FormControl('',[Validators.required]),
email : new FormControl('',[Validators.required, Validators.email]), email : new FormControl('',[Validators.required, Validators.email]),
rName : new FormControl(), rName : new FormControl('',[Validators.required]),
rDesc : new FormControl(), rDesc : new FormControl('',[Validators.required]),
rType : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]), sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]), eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]), sTime : new FormControl('',[Validators.required]),
...@@ -73,6 +74,8 @@ export class EquipmentComponent implements OnInit { ...@@ -73,6 +74,8 @@ export class EquipmentComponent implements OnInit {
email : new FormControl('',[Validators.required, Validators.email]), email : new FormControl('',[Validators.required, Validators.email]),
eqName : new FormControl('',[Validators.required]), eqName : new FormControl('',[Validators.required]),
eqDesc : new FormControl('',[Validators.required]), eqDesc : new FormControl('',[Validators.required]),
eqType : new FormControl('',[Validators.required]),
eqPic : new FormControl('',[Validators.required]),
sDate : new FormControl('',[Validators.required]), sDate : new FormControl('',[Validators.required]),
eDate : new FormControl('',[Validators.required]), eDate : new FormControl('',[Validators.required]),
sTime : new FormControl('',[Validators.required]), sTime : new FormControl('',[Validators.required]),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment