Commit 16d9fa3e by DESKTOP-HF0LVOG\myhr

Update หน้าต่างการเบิกอุปกรณ์และตารางรายการแสดงสถานะ

parent 3b3c8056
import { CategoryModel } from "./itemDetail.model";
export class Equirment {
eqId: number;
eqName: string;
......@@ -15,19 +17,19 @@ export class Equirment {
}
export interface SearchEquirmentModel {
sdate: string;
edate: string;
stime: string;
etime: string;
sDate: string;
eDate: string;
sTime: string;
eTime: string;
}
export class SearchEquirmentModel {
constructor(init?: SearchEquirmentModel) {
Object.assign(this, init);
this.sdate = '',
this.edate = '',
this.stime = '',
this.etime = '';
this.sDate = '',
this.eDate = '',
this.sTime = '',
this.eTime = '';
}
}
......
interface itemDetail {
id?: number;
catagory: string;
type: string;
detail: string;
name: string;
sdate: string;
edate: string;
stime: string;
etime: string;
status: string;
quantity: string;
remark: string;
import { Equirment } from "./equirment.model";
export class itemDetail {
Id?: number;
equirment : Equirment;
userName: string;
sDate: string;
eDate: string;
sTime: {
hour: number;
minute: number;
second: number;
};
eTime: {
hour: number;
minute: number;
second: number;
};
eStatus: string;
Quantity: string;
Remark: string;
constructor(init?: itemDetail) {
Object.assign(this, init);
this.Id = 1;
this.equirment = this.equirment;
this.userName = '';
this.sDate = '';
this.eDate = '';
this.eStatus = '';
this.Quantity = '';
this.Remark = '';
}
}
export interface SearchitemDetailModel {
sDate: string;
eDate: string;
sTime: string;
eTime: string;
}
export class SearchitemDetailModel {
constructor(init?: SearchitemDetailModel) {
Object.assign(this, init);
this.sDate = '',
this.eDate = '',
this.sTime = '',
this.eTime = '';
}
}
interface CategoryModel {
export class CategoryModel {
id: number;
name: string;
}
......
import { Component, OnInit } from '@angular/core';
import { NgbDate, NgbCalendar, NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
import { itemDetail } from 'src/app/models/itemDetail.model';
@Component({
selector: 'app-admin-pending',
......@@ -40,34 +41,7 @@ export class AdminPendingComponent implements OnInit {
closeResult = '';
item: itemDetail[] = [
{
catagory: 'string',
type: 'string',
detail: 'Moniter',
name: 'a',
sdate: '2021-11-25',
edate: '2021-11-25',
stime: '12.00',
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
},
{
catagory: 'string',
type: 'string',
detail: 'Mouse',
name: 'b',
sdate: '2021-11-25',
edate: '2021-11-25',
stime: '12.00',
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
}
];
item: itemDetail[] = [];
collectionSize = this.item.length;
hoveredDate: NgbDate | null = null;
......
......@@ -20,7 +20,7 @@
<div class="card-body">
<button class="btn btn-lg btn-outline-primary"
(click)="open(contentroom)">เพิ่มรายการ</button>
(click)="Ropen(contentroom)">เพิ่มรายการ</button>
<div class="row">
<div class="col-sm-3" *ngFor="let item of listRoomModel">
......@@ -38,8 +38,7 @@
<div class="text-center">
<div class="d-grid gap-2 a-md-flex justify-content-md-end ">
<button class="btn btn-sm btn-outline-primary"
(click)="open(Room)">จอง</button>
<button class="btn btn-sm btn-primary" type="button">ยกเลิก</button>
(click)="Ropen(Room)">จอง</button>
</div>
</div>
</div>
......@@ -128,7 +127,7 @@
</ng-template>
<button class="btn btn-lg btn-outline-primary"
(click)="open(contentequirment)">เพิ่มรายการ</button>
(click)="Eopen(contentequirment)">เพิ่มรายการ</button>
<div class="row">
<div class="col-sm-3" *ngFor="let item of listEquirmentModel">
......@@ -147,8 +146,7 @@
<div class="text-center">
<div class="d-grid gap-2 a-md-flex justify-content-md-end">
<button class="btn btn-sm btn-outline-primary"
(click)="open(lend)">เบิก</button>
<button class="btn btn-sm btn-primary" type="button">ยกเลิก</button>
(click)="bookEquir(lend,item)">เบิก</button>
</div>
</div>
</div>
......@@ -255,13 +253,13 @@
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">ชื่อห้อง</label>
<input readonly class="form-control" type="text" value="{{item.rName}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">รายละเอียด</label>
<input readonly class="form-control" type="text" value="{{item.rDecs}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class="row">
......@@ -307,15 +305,15 @@
<div class=" col-md-12">
<div class="card">
<div class=" card-header">
<h5 class=" title">Lend Equirment</h5>
<h5 class=" title">เบิกอุปกรณ์</h5>
</div>
<div class=" card-body">
<form>
<div class=" row">
<div class=" col-sm-12 mb-1">
<div class=" form-group">
<label> ชื่อผู้จอง </label>
<input class=" form-control" placeholder="" type="text" value="" />
<label> ชื่อผู้เบิก </label>
<input class=" form-control" placeholder="" type="text" value="" [(ngModel)]="modelitemDetail.userName"/>
</div>
</div>
</div>
......@@ -330,40 +328,40 @@
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">ชื่ออุปกรณ์</label>
<input readonly class="form-control" type="text" value="{{item.rName}}">
<input readonly class="form-control" type="text" [value]="modelitemDetail.equirment.eqName" >
</div>
</div>
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">รายละเอียดอุปกรณ์</label>
<input readonly class="form-control" type="text" value="{{item.rDecs}}">
<input readonly class="form-control" type="text" [value]="modelitemDetail.equirment.eqDesc">
</div>
</div>
<div class="row">
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">วันที่เริ่มต้น</label>
<input type="date" class="form-control" value="">
<input type="date" class="form-control" value="" [(ngModel)]="modelitemDetail.sDate">
</div>
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">วันที่สิ้นสุด</label>
<input type="date" class="form-control" value="">
<input type="date" class="form-control" value="" [(ngModel)]="modelitemDetail.eDate">
</div>
</div>
<div class="row">
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่เริ่มต้น</label>
<ngb-timepicker [(ngModel)]="stime"></ngb-timepicker>
<ngb-timepicker [(ngModel)]="modelitemDetail.sTime"></ngb-timepicker>
</div>
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่สิ้นสุด</label>
<ngb-timepicker [(ngModel)]="etime"></ngb-timepicker>
<ngb-timepicker [(ngModel)]="modelitemDetail.eTime"></ngb-timepicker>
</div>
</div>
<div class=" row">
<div class=" col-sm-6 mb-1">
<label for="changequantity">จำนวน</label>
<input id="changequantity" type="number" class="form-control form-control-sm"
[(ngModel)]="quantity" />
[(ngModel)]="modelitemDetail.Quantity" />
</div>
</div>
<div class=" row">
......@@ -371,14 +369,14 @@
<div class=" form-group">
<label> หมายเหตุ </label>
<textarea class="form-control" id="exampleFormControlTextarea1" rows="3"
placeholder="......"></textarea>
placeholder="......" [(ngModel)]="modelitemDetail.Remark"></textarea>
</div>
</div>
</div>
</form>
</div>
<div class=" card-footer">
<button class=" btn btn-fill btn-danger" type="submit">Save</button>
<button class=" btn btn-fill btn-danger" type="submit" (click)="saveLend()">Save</button>
<button class=" btn btn-fill btn-danger" type="close">Cancel</button>
</div>
</div>
......
import { Component, OnInit } from '@angular/core';
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
import { Equirment } from 'src/app/models/equirment.model';
import { itemDetail } from 'src/app/models/itemDetail.model';
import { Room } from 'src/app/models/rooms.model';
import { EquirmentService } from 'src/app/service/equirment.service';
import { itemDetailService } from 'src/app/service/item-detail.service';
import { RoomService } from 'src/app/service/room.service';
......@@ -21,9 +23,12 @@ export class EquipmentComponent implements OnInit {
listEquirmentModel: Equirment[] = [];
listRoomModel: Room[] = [];
collectionSize = this.listEquirmentModel.length;
modelEquirment = new Equirment();
modelRoom = new Room();
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService) {
modelitemDetail = new itemDetail();
constructor(private modalService: NgbModal, private equirmentService: EquirmentService, private roomService: RoomService, private itemDetailService : itemDetailService) {
}
......@@ -32,6 +37,7 @@ export class EquipmentComponent implements OnInit {
this.listRoomModel = this.roomService.getListRoom();
}
Eopen(contentequirment) {
this.modelEquirment = new Equirment();
this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
......@@ -41,6 +47,20 @@ export class EquipmentComponent implements OnInit {
});
}
book(contentequirment,item : Equirment) {
this.modelitemDetail = new itemDetail();
this.modelitemDetail.equirment = item ;
console.log("item",this.modelitemDetail);
this.modalService.open(contentequirment, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
this.closeResult = `Closed with: ${result}`;
}, (reason) => {
this.closeResult = `Dismissed ${this.getDismissReason(reason)}`;
});
}
Ropen(contentroom) {
this.modelRoom = new Room();
this.modalService.open(contentroom, { ariaLabelledBy: 'modal-basic-title' }).result.then((result) => {
......@@ -86,5 +106,12 @@ export class EquipmentComponent implements OnInit {
this.ngOnInit();
}
saveLend() {
this.itemDetailService.additemDetail(this.modelitemDetail);
this.modalService.dismissAll();
this.ngOnInit();
console.log(this.itemDetailService);
}
}
import { Component, OnInit } from '@angular/core';
import { itemDetail } from 'src/app/models/itemDetail.model';
@Component({
selector: 'app-lend-page',
......@@ -7,36 +8,7 @@ import { Component, OnInit } from '@angular/core';
})
export class LendPageComponent implements OnInit {
item: itemDetail[] = [
{
catagory: 'string',
type: 'string',
detail: 'Moniter',
name: 'a',
sdate: '2021-11-25',
edate: '2021-11-25',
stime: '12.00',
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
},
{
catagory: 'string',
type: 'string',
detail: 'Mouse',
name: 'b',
sdate: '2021-11-25',
edate: '2021-11-25',
stime: '12.00',
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
}
];
item: itemDetail[] = [];
collectionSize = this.item.length;
constructor() { }
......
......@@ -77,24 +77,24 @@
<tr>
<th scope="col">#</th>
<th scope="col">หมวดหมู่</th>
<th scope="col">ประเภท</th>
<th scope="col">ชื่ออุปกรณ์</th>
<th scope="col">รายละเอียด</th>
<th scope="col">ชื่อ</th>
<th scope="col">ชื่อผู้เบิก</th>
<th scope="col">วันที่เริ่มต้น</th>
<th scope="col">วันที่สิ้นสุด</th>
<th scope="col">สถานะ</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let country of countries">
<th scope="row">{{ country.id }}</th>
<td>{{ country.catagory }}</td>
<td>{{ country.type }}</td>
<td>{{ country.detail }}</td>
<td>{{ country.name }}</td>
<td>{{ country.sdate | date:'dd-MM-yyyy' }} {{ country.stime }}</td>
<td>{{ country.edate | date:'dd-MM-yyyy' }} {{ country.etime }}</td>
<td>{{ country.status }}</td>
<tr *ngFor="let item of listitemDetail">
<th scope="row">{{ item.Id }}</th>
<td>{{ item.equirment.eqType }}</td>
<td>{{ item.equirment.eqName }}</td>
<td>{{ item.equirment.eqDesc }}</td>
<td>{{ item.userName }}</td>
<td>{{ item.sDate | date:'dd-MM-yyyy' }} {{ item.sTime.hour }}:{{ item.sTime.minute }}</td>
<td>{{ item.eDate | date:'dd-MM-yyyy' }} {{ item.eTime.hour }}:{{ item.eTime.minute }}</td>
<td>{{ item.eStatus }}</td>
<div class="col-auto align-self-sm-center">
<button type="button" class="btn btn-info btn-sm btn-circle "
style="line-height: 0px" (click)="open(Room)"><i class="fa fa-search"></i> </button>
......@@ -144,16 +144,15 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let country of countries">
<th scope="row">{{ country.id }}</th>
<td>{{ country.catagory }}</td>
<td>{{ country.type }}</td>
<td>{{ country.detail }}</td>
<td>{{ country.name }}</td>
<td>{{ country.sdate | date:'dd-MM-yyyy' }} {{ country.stime }}</td>
<td>{{ country.edate | date:'dd-MM-yyyy' }} {{ country.etime }}</td>
<td>{{ country.quantity }}</td>
<td>{{ country.status }}</td>
<tr *ngFor="let item of listitemDetail">
<th scope="row">{{ item.Id }}</th>
<td>{{ item.Catagory }}</td>
<td>{{ item.Type }}</td>
<td>{{ item.Detail }}</td>
<td>{{ item.userName }}</td>
<td>{{ item.sDate | date:'dd-MM-yyyy' }} {{ item.sTime.hour }}:{{ item.sTime.minute }}</td>
<td>{{ item.eDate | date:'dd-MM-yyyy' }} {{ item.eTime.hour }}:{{ item.eTime.minute }}</td>
<td>{{ item.eStatus }}</td>
<div class="col-auto align-self-sm-center">
<button type="button" class="btn btn-info btn-sm btn-circle "
style="line-height: 0px" (click)="open(lend)"><i class="fa fa-search"></i> </button>
......@@ -211,13 +210,13 @@
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">ชื่อห้อง</label>
<input readonly class="form-control" type="text" value="{{item.rname}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">รายละเอียด</label>
<input readonly class="form-control" type="text" value="{{item.rdecs}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class="row">
......@@ -233,11 +232,11 @@
<div class="row">
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่เริ่มต้น</label>
<input readonly class="form-control" type="text" value="{{country.stime}}">
<input readonly class="form-control" type="text" value="">
</div>
<div class="col-6 mb-1">
<label [readonly] for="exampleFormControlSelect1">เวลาที่สิ้นสุด</label>
<input readonly class="form-control" type="text" value="{{country.etime}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class=" row">
......@@ -282,13 +281,13 @@
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">ชื่ออุปกรณ์</label>
<input readonly class="form-control" type="text" value="{{item.rname}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class="row">
<div class="col-sm-12 mb-1">
<label for="exampleFormControlSelect1">รายละเอียดอุปกรณ์</label>
<input readonly class="form-control" type="text" value="{{item.rdecs}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class="row">
......@@ -304,11 +303,11 @@
<div class="row">
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่เริ่มต้น</label>
<input readonly class="form-control" type="text" value="{{country.stime}}">
<input readonly class="form-control" type="text" value="">
</div>
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่สิ้นสุด</label>
<input readonly class="form-control" type="text" value="{{country.etime}}">
<input readonly class="form-control" type="text" value="">
</div>
</div>
<div class=" row">
......
import { Component, OnInit } from '@angular/core';
import { NgbDate, NgbCalendar, NgbDateParserFormatter } from '@ng-bootstrap/ng-bootstrap';
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
import { itemDetail } from 'src/app/models/itemDetail.model';
import { itemDetailService } from 'src/app/service/item-detail.service';
@Component({
selector: 'app-pending',
......@@ -39,48 +41,22 @@ export class PendingComponent implements OnInit {
closeResult = '';
item : itemDetail[] = [
{
catagory: 'string',
type: 'string',
detail: 'Moniter',
name: 'a',
sdate: '2021-11-25',
edate: '2021-11-25',
stime: '12.00',
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
},
{
catagory: 'string',
type: 'string',
detail: 'Mouse',
name: 'b',
sdate: '2021-11-25',
edate: '2021-11-25',
stime: '12.00',
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
}
];
collectionSize = this.item.length;
listitemDetail : itemDetail[] = [];
collectionSize = this.listitemDetail.length;
hoveredDate: NgbDate | null = null;
fromDate: NgbDate | null;
toDate: NgbDate | null;
constructor(private calendar: NgbCalendar, public formatter: NgbDateParserFormatter , private modalService: NgbModal) {
constructor(private calendar: NgbCalendar, public formatter: NgbDateParserFormatter, private modalService: NgbModal, private itemDetailService: itemDetailService) {
this.fromDate = calendar.getToday();
this.toDate = calendar.getNext(calendar.getToday(), 'd', 10);
this.refreshitemDetail();
}
refreshitemDetail() {
this.item = this.item
this.listitemDetail = this.listitemDetail
.map((item, i) => ({ id: i + 1, ...item }))
.slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
}
......@@ -131,7 +107,9 @@ export class PendingComponent implements OnInit {
return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
}
ngOnInit(): void {
ngOnInit() {
this.listitemDetail = this.itemDetailService.getListitemDetail();
console.log(this.listitemDetail);
}
}
......
......@@ -58,7 +58,7 @@ export class EquirmentService {
}
searchListEquirment(searchModel: SearchEquirmentModel) {
this.http.get(this.url + '&startDate=' + searchModel.sdate.split("-")[2] + '-' + searchModel.sdate.split("-")[1] + '-' + searchModel.sdate.split("-")[0] + '&endDate=' + searchModel.edate.split("-")[2] + '-' + searchModel.edate.split("-")[1] + '-' + searchModel.edate.split("-")[0] + '&startTime=' + searchModel.stime + ':00' + '&endTime=' + searchModel.etime + ':00').subscribe((response: any) => {
this.http.get(this.url + '&startDate=' + searchModel.sDate.split("-")[2] + '-' + searchModel.sDate.split("-")[1] + '-' + searchModel.sDate.split("-")[0] + '&endDate=' + searchModel.eDate.split("-")[2] + '-' + searchModel.eDate.split("-")[1] + '-' + searchModel.eDate.split("-")[0] + '&startTime=' + searchModel.sTime + ':00' + '&endTime=' + searchModel.eTime + ':00').subscribe((response: any) => {
console.log(response);
this.listEquirment = response;
}, error => {
......
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { itemDetail, SearchitemDetailModel } from '../models/itemDetail.model';
@Injectable({ providedIn: 'root' })
export class itemDetailService {
constructor(private http: HttpClient) { }
url: string;
listitemDetail: itemDetail[] = [
{
Id : 1,
equirment : {
eqId: 2,
eqName: "เมาส์",
eqDesc: "...",
eqType: "it",
eqPic: "assets/img/mou.jpg"
},
userName: 'เกม',
sDate: '10/12/2560',
eDate: '10/11/2561',
sTime: {
hour: 22,
minute: 30,
second: 0
},
eTime: {
hour: 22,
minute: 30,
second: 0
},
eStatus: 'รอการอนุมัติ',
Quantity: '1',
Remark: 'test',
},
{
Id : 2,
equirment : {
eqId: 3,
eqName: "โน๊ตบุ๊ค",
eqDesc: "หน้าจอขนาด 20 นิ้ว",
eqType: "it",
eqPic: "assets/img/notebook.jpg"
},
userName: 'แป๊ะ',
sDate: '',
eDate: '',
sTime: {
hour: 22,
minute: 30,
second: 0
},
eTime: {
hour: 22,
minute: 30,
second: 0
},
eStatus: 'รอการอนุมัติ',
Quantity: '1',
Remark: 'test',
},
]
additemDetail(model: itemDetail) {
console.log(this.listitemDetail);
this.listitemDetail.push(model);
}
getListitemDetail() {
return this.listitemDetail;
}
// getListitemDetail() {
// this.http.get(this.url).subscribe((response: any) => {
// console.log(response);
// this.listitemDetail = response.content;
// }, error => {
// console.log(error)
// // alert("ไม่สามารถดึงข้อมูลห้องประชุมได้ เนื่องจาก :\n" + error.message)
// })
// }
searchListitemDetail(searchModel: SearchitemDetailModel) {
this.http.get(this.url + '&startDate=' + searchModel.sDate.split("-")[2] + '-' + searchModel.sDate.split("-")[1] + '-' + searchModel.sDate.split("-")[0] + '&endDate=' + searchModel.eDate.split("-")[2] + '-' + searchModel.eDate.split("-")[1] + '-' + searchModel.eDate.split("-")[0] + '&startTime=' + searchModel.sTime + ':00' + '&endTime=' + searchModel.eTime + ':00').subscribe((response: any) => {
console.log(response);
this.listitemDetail = response;
}, error => {
console.log(error)
alert("ไม่สามารถค้นหาอุปกรณ์ที่ว่างได้ เนื่องจาก :\n" + error.message)
})
}
// addEquirment(EquirmentModel: Equirment) {
// this.http.post(this.url, EquirmentModel).subscribe(response => {
// console.log(response);
// })
// }
deleteitemDetail(itemDetailModel: itemDetail) {
this.http.delete(this.url + "/" + itemDetailModel.Id).subscribe(response => {
console.log(response);
this.getListitemDetail()
alert("ลบข้อมูลอุปกรณ์สำเร็จ")
})
}
updateitemDetail(itemDetailModel: itemDetail) {
this.http.put(this.url + "/" +itemDetailModel.Id, itemDetailModel).subscribe(response => {
console.log(response);
alert("อัพเดทข้อมูลอุปกรณ์สำเร็จ")
})
}
itemDetailModel(eqId: string) {
}
}
\ No newline at end of file
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Room, SearchRoomModel } from '../models/rooms.model';
import { itemDetail } from '../models/itemDetail.model';
@Injectable({ providedIn: 'root' })
......@@ -46,7 +47,6 @@ export class RoomService {
addRoom(model: Room) {
this.listRoomModel.push(model);
}
getListRoom() {
......
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