Commit 352a8acf by Chanachai

Update บันทึกclickได้

parent f90b9067
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
</div> </div>
<div class="card-footer"> <div class="card-footer">
<div class="d-grid gap-2 d-md-flex justify-content-md-center"> <div class="d-grid gap-2 d-md-flex justify-content-md-center">
<button type="button" class="btn btn-primary btn-sm " (click)="saveContact()">บันทึก</button> <button class="btn btn-primary btn-sm" type="submit" [disabled]="" (click)="saveContact()">บันทึก</button>
<button type="button" class="btn btn-primary btn-sm ">ยกเลิก</button> <button class="btn btn-primary btn-sm" type="cancel" (click)="model.dismiss('Cross click')">ยกเลิก</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -85,8 +85,9 @@ ...@@ -85,8 +85,9 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<ng-template #Alllist let-modal> <ng-template #Alllist let-modal>
<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">
...@@ -98,7 +99,7 @@ ...@@ -98,7 +99,7 @@
<div class=" form-group"> <div class=" form-group">
<label> ชื่อหัวข้อ </label> <label> ชื่อหัวข้อ </label>
<input readonly class=" form-control" placeholder="" type="text" <input readonly class=" form-control" placeholder="" type="text"
[(ngModel)]="modelContatc.ctHead" /> [(ngModel)]="modelContact.ctHead" />
</div> </div>
</div> </div>
</div> </div>
...@@ -107,7 +108,7 @@ ...@@ -107,7 +108,7 @@
<div class=" form-group"> <div class=" form-group">
<label> หน้าต่างที่มี BUG </label> <label> หน้าต่างที่มี BUG </label>
<input readonly class=" form-control" placeholder="" type="text" <input readonly class=" form-control" placeholder="" type="text"
[(ngModel)]="modelContatc.ctTab" /> [(ngModel)]="modelContact.ctTab" />
</div> </div>
</div> </div>
</div> </div>
...@@ -116,18 +117,17 @@ ...@@ -116,18 +117,17 @@
<div class=" form-group"> <div class=" form-group">
<label> ชื่อผู้แจ้ง </label> <label> ชื่อผู้แจ้ง </label>
<input readonly class=" form-control" placeholder="" type="text" <input readonly class=" form-control" placeholder="" type="text"
[(ngModel)]="modelContatc.ctName" /> [(ngModel)]="modelContact.ctName" />
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-sm-12 mb-1"> <div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">วันที่เริ่มต้น</label> <label for="exampleFormControlSelect1">วันที่แจ้ง</label>
<input readonly type="date" class="form-control" [(ngModel)]="sDate"> <input readonly type="date" class="form-control" [(ngModel)]="sDate">
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</ng-template> </ng-template>
</div> \ No newline at end of file
\ No newline at end of file
...@@ -10,7 +10,7 @@ const pages = ['หน้าหลัก','รายการอุปกรณ ...@@ -10,7 +10,7 @@ const pages = ['หน้าหลัก','รายการอุปกรณ
@Component({ @Component({
selector: 'app-contact-admin', selector: 'app-contact-admin',
templateUrl: './contact-admin.component.html', templateUrl:'./contact-admin.component.html',
styleUrls: ['./contact-admin.component.scss'] styleUrls: ['./contact-admin.component.scss']
}) })
export class ContactAdminComponent implements OnInit { export class ContactAdminComponent implements OnInit {
...@@ -28,7 +28,7 @@ export class ContactAdminComponent implements OnInit { ...@@ -28,7 +28,7 @@ export class ContactAdminComponent implements OnInit {
listContact: Contact[] = []; listContact: Contact[] = [];
modelcontact = new Contact(); modelContact = new Contact();
myFromContact : FormGroup; myFromContact : FormGroup;
...@@ -43,6 +43,7 @@ export class ContactAdminComponent implements OnInit { ...@@ -43,6 +43,7 @@ export class ContactAdminComponent implements OnInit {
ngOnInit(): void { ngOnInit(): void {
this.listContact = this.ContactService.getListContact(); this.listContact = this.ContactService.getListContact();
this.collectionSizeListRoom = this.listContact.length; this.collectionSizeListRoom = this.listContact.length;
this.collectionSize = this.listContact.length
} }
search: OperatorFunction<string, readonly string[]> = (text$: Observable<string>) => { search: OperatorFunction<string, readonly string[]> = (text$: Observable<string>) => {
...@@ -67,30 +68,32 @@ export class ContactAdminComponent implements OnInit { ...@@ -67,30 +68,32 @@ export class ContactAdminComponent implements OnInit {
} }
openContact(content : string ,item : Contact) { openContact(content : string ,item : Contact) {
this.modelcontact = item ; this.modelContact = item ;
let sDate = this.modelcontact.sDate.split('/') let sDate = this.modelContact.sDate.split('/')
this.sDate = sDate[0]+"-"+sDate[1]+"-"+sDate[2] this.sDate = sDate[0]+"-"+sDate[1]+"-"+sDate[2]
this.myFromContact = new FormGroup({ this.myFromContact = new FormGroup({
ctName: new FormControl(this.modelcontact.ctName, [Validators.required]), ctName: new FormControl(this.modelContact.ctName, [Validators.required]),
ctDesc: new FormControl(this.modelcontact.ctDesc, [Validators.required]), ctDesc: new FormControl(this.modelContact.ctDesc, [Validators.required]),
ctTab: new FormControl(this.modelcontact.ctTab, [Validators.required]), ctTab: new FormControl(this.modelContact.ctTab, [Validators.required]),
ctHead: new FormControl(this.modelcontact.ctHead, [Validators.required]), ctHead: new FormControl(this.modelContact.ctHead, [Validators.required]),
sDate: new FormControl(this.modelcontact.sDate, [Validators.required]), sDate: new FormControl(this.modelContact.sDate, [Validators.required]),
ctStatus: new FormControl(this.modelcontact.ctStatus) ctStatus: new FormControl(this.modelContact.ctStatus)
}); });
this.modalService.open(content, { 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)}`;
}); });
console.log("date",this.modelContact)
} }
saveContact() { saveContact() {
this.modelcontact.ctStatus = 0 ; this.modelContact.sDate = this.modelContact.sDate.split("-")[0]+"/"+this.modelContact.sDate.split("-")[1]+"/"+this.modelContact.sDate.split("-")[2];
console.log("save",this.modelcontact) this.modelContact.ctStatus = 0 ;
this.ContactService.addContact(this.modelcontact); console.log("save",this.modelContact)
this.ContactService.addContact(this.modelContact);
this.modalService.dismissAll(); this.modalService.dismissAll();
this.ngOnInit(); this.ngOnInit();
} }
......
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Contact } from "../models/contact.model"; import { Contact } from "../models/contact.model";
@Injectable({ providedIn: 'root' }) @Injectable({ providedIn: 'root' })
export class ContactService { export class ContactService {
constructor(private http: HttpClient) { }
url: string;
listContact: Contact[] = [ listContact: Contact[] = [
{ {
id: 1, id: 1,
......
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