Commit 3fad6518 by DESKTOP-HF0LVOG\myhr

Add model กับ service หน้า equirment

parent bc39d93f
export class Equirment {
eqid: number;
eqName: string;
eqdesc: string;
eqtype: string;
eqpic: string;
constructor(init?: Equirment){
Object.assign(this, init);
this.eqid = 0;
this.eqName = '';
this.eqdesc = '';
this.eqtype = '';
this.eqpic = '';
}
}
export interface SearchEquirmentModel {
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 = '';
}
}
interface RoomModel {
rid: number;
rname: string;
rdesc: string;
rpic: string;
}
interface EquirmentModel {
id: number;
name: string;
desc: string;
type?: CategoryModel;
pic: string;
}
interface CategoryModel {
id: number;
name: string;
}
interface Country {
interface itemDetail {
id?: number;
catagory: string;
type: string;
......@@ -30,4 +10,11 @@ interface Country {
etime: string;
status: string;
quantity: string;
}
\ No newline at end of file
remark: string;
}
interface CategoryModel {
id: number;
name: string;
}
export class Room {
rid: number;
rname: string;
title: string;
rpic: string;
roomLimit: number;
rdesc: string;
constructor(init?: Room) {
Object.assign(this, init);
this.rid = 0;
this.rname = '';
this.title = '';
this.rpic = '';
this.roomLimit = 0;
this.rdesc = '';
}
}
export interface SearchRoomModel {
sdate: string;
edate: string;
stime: string;
etime: string;
roomlimit: number;
}
export class SearchRoomModel {
constructor(init?: SearchRoomModel) {
Object.assign(this, init);
this.sdate = '',
this.edate = '',
this.stime = '',
this.etime = '',
this.roomlimit = 0;
}
}
\ No newline at end of file
import { Room } from "./rooms.model";
interface TransectionRoom{
id: number ;
employeeId : string ;
remark : string ;
room : RoomModel;
room : Room;
}
\ No newline at end of file
......@@ -40,7 +40,7 @@ export class AdminPendingComponent implements OnInit {
closeResult = '';
countries: Country[] = [
item: itemDetail[] = [
{
catagory: 'string',
type: 'string',
......@@ -52,6 +52,7 @@ export class AdminPendingComponent implements OnInit {
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
},
{
catagory: 'string',
......@@ -64,10 +65,11 @@ export class AdminPendingComponent implements OnInit {
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
}
];
collectionSize = this.countries.length;
collectionSize = this.item.length;
hoveredDate: NgbDate | null = null;
fromDate: NgbDate | null;
toDate: NgbDate | null;
......@@ -75,11 +77,11 @@ export class AdminPendingComponent implements OnInit {
constructor(private calendar: NgbCalendar, public formatter: NgbDateParserFormatter , private modalService: NgbModal) {
this.fromDate = calendar.getToday();
this.toDate = calendar.getNext(calendar.getToday(), 'd', 10);
this.refreshCountries();
this.refreshitemDetail();
}
refreshCountries() {
this.countries = this.countries
refreshitemDetail() {
this.item = this.item
.map((country, i) => ({ id: i + 1, ...country }))
.slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
}
......
......@@ -83,7 +83,7 @@
<div class=" col-md-12">
<div class=" form-group">
<label> ชื่อ </label>
<input class=" form-control" placeholder="" type="text"
<input class=" form-control" placeholder="" type="text" [(ngModel)]="modelEquirment.eqName"
value="" />
</div>
</div>
......@@ -118,7 +118,7 @@
</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)="saveEquirment()">Save</button>
<button class=" btn btn-fill btn-danger" type="cancel">Cancel</button>
</div>
</div>
......@@ -137,9 +137,9 @@
width: 200px;" [src]="item.pic" class="nav justify-content-center"
alt="...">
<br>
<p class="text-left">ชื่อ : {{item.name}}</p>
<p class="text-left">รายละเอียด : {{item.desc}}</p>
<p class="text-left">ประเภท : {{item.type}}</p>
<p class="text-left">ชื่อ : {{item.eqname}}</p>
<p class="text-left">รายละเอียด : {{item.eqdesc}}</p>
<p class="text-left">ประเภท : {{item.eqtype}}</p>
</div>
<div class="text-center">
......@@ -275,11 +275,11 @@
<div class="row">
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่เริ่มต้น</label>
<ngb-timepicker [(ngModel)]="time"></ngb-timepicker>
<ngb-timepicker [(ngModel)]="stime"></ngb-timepicker>
</div>
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่สิ้นสุด</label>
<ngb-timepicker [(ngModel)]="time"></ngb-timepicker>
<ngb-timepicker [(ngModel)]="etime"></ngb-timepicker>
</div>
</div>
<div class=" row">
......@@ -350,11 +350,11 @@
<div class="row">
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่เริ่มต้น</label>
<ngb-timepicker [(ngModel)]="time"></ngb-timepicker>
<ngb-timepicker [(ngModel)]="stime"></ngb-timepicker>
</div>
<div class="col-6 mb-1">
<label for="exampleFormControlSelect1">เวลาที่สิ้นสุด</label>
<ngb-timepicker [(ngModel)]="time"></ngb-timepicker>
<ngb-timepicker [(ngModel)]="etime"></ngb-timepicker>
</div>
</div>
<div class=" row">
......
import { Component, OnInit } from '@angular/core';
import { NgbModal, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap';
import { Equirment } from 'src/app/models/equirment.model';
interface EquirmentModel {
id: number;
name: string;
desc: string;
type: string;
type?: CategoryModel;
pic: string;
}
interface RoomModel{
rid : number;
rname : string;
rdesc : string;
rpic : string;
}
@Component({
selector: 'app-equipment',
......@@ -27,93 +22,9 @@ export class EquipmentComponent implements OnInit {
closeResult = '';
listEquirment: EquirmentModel[] = [
{
id: 1,
name: "จอคอมพิวเตอร์",
desc: "หน้าจอขนาด 22 นิ้ว",
type: "it",
pic: "assets/img/mo1.jpg"
},
{
id: 2,
name: "เมาส์",
desc: "...",
type: "it",
pic: "assets/img/mou.jpg"
},
{
id: 3,
name: "โน๊ตบุ๊ค",
desc: "หน้าจอขนาด 20 นิ้ว",
type: "it",
pic: "assets/img/notebook.jpg"
},
{
id: 4,
name: "คีย์บอร์ด",
desc: "...",
type: "it",
pic: "assets/img/keyboard.png"
}
]
listRoomModel: RoomModel[] = [
{
rid: 1,
rname: "ห้องเดียว",
rdesc: "จำนวนคน 25 คน",
rpic: "assets/img/room.jpg"
},
{
rid: 2,
rname: "ห้องคู่",
rdesc: "จำนวนคน 50 คน",
rpic: "assets/img/room.jpg"
},
{
rid: 3,
rname: "ห้องรวม",
rdesc: "จำนวนคน 100 คน",
rpic: "assets/img/room.jpg"
},
{
rid: 4,
rname: "รถ",
rdesc: "รถบริษัท",
rpic: "assets/img/car.jpg"
},
]
countries: Country[] = [
{
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',
},
{
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',
}
];
collectionSize = this.listEquirment.length;
listEquirmentModel: Equirment[] = [];
collectionSize = this.listEquirmentModel.length;
modelEquirment = new Equirment();
constructor(private modalService: NgbModal) { }
ngOnInit(): void {
......@@ -137,7 +48,7 @@ export class EquipmentComponent implements OnInit {
}
}
refreshCountries() {
this.listEquirment = this.listEquirment
this.listEquirmentModel = this.listEquirmentModel
.map((item, i) => ({ id: i + 1, ...item }))
.slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
}
......@@ -145,5 +56,11 @@ export class EquipmentComponent implements OnInit {
NgbdTimepickerBasic() {
}
saveEquirment(){
console.log(this.modelEquirment);
}
}
......@@ -7,7 +7,7 @@ import { Component, OnInit } from '@angular/core';
})
export class LendPageComponent implements OnInit {
countries: Country[] = [
item: itemDetail[] = [
{
catagory: 'string',
......@@ -20,6 +20,7 @@ export class LendPageComponent implements OnInit {
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
},
{
......@@ -33,9 +34,10 @@ export class LendPageComponent implements OnInit {
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
}
];
collectionSize = this.countries.length;
collectionSize = this.item.length;
constructor() { }
......
......@@ -331,6 +331,4 @@
</div>
</div>
</div>
</ng-template>
</ng-template>
\ No newline at end of file
......@@ -39,7 +39,7 @@ export class PendingComponent implements OnInit {
closeResult = '';
countries: Country[] = [
item : itemDetail[] = [
{
catagory: 'string',
type: 'string',
......@@ -51,6 +51,7 @@ export class PendingComponent implements OnInit {
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
},
{
catagory: 'string',
......@@ -63,9 +64,10 @@ export class PendingComponent implements OnInit {
etime: '12.00',
status: 'waiting',
quantity : '1',
remark: '',
}
];
collectionSize = this.countries.length;
collectionSize = this.item.length;
hoveredDate: NgbDate | null = null;
fromDate: NgbDate | null;
......@@ -74,12 +76,12 @@ export class PendingComponent implements OnInit {
constructor(private calendar: NgbCalendar, public formatter: NgbDateParserFormatter , private modalService: NgbModal) {
this.fromDate = calendar.getToday();
this.toDate = calendar.getNext(calendar.getToday(), 'd', 10);
this.refreshCountries();
this.refreshitemDetail();
}
refreshCountries() {
this.countries = this.countries
.map((country, i) => ({ id: i + 1, ...country }))
refreshitemDetail() {
this.item = this.item
.map((item, i) => ({ id: i + 1, ...item }))
.slice((this.page - 1) * this.pageSize, (this.page - 1) * this.pageSize + this.pageSize);
}
......
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Equirment, SearchEquirmentModel } from '../models/equirment.model';
@Injectable({ providedIn: 'root' })
export class EquirmentService {
constructor(private http: HttpClient) { }
url: string;
listEquirment: Equirment[] = [
{
eqid: 1,
eqName: "จอคอมพิวเตอร์",
eqdesc: "หน้าจอขนาด 22 นิ้ว",
eqtype: "it",
eqpic: "assets/img/mo1.jpg"
},
{
eqid: 2,
eqName: "เมาส์",
eqdesc: "...",
eqtype: "it",
eqpic: "assets/img/mou.jpg"
},
{
eqid: 3,
eqName: "โน๊ตบุ๊ค",
eqdesc: "หน้าจอขนาด 20 นิ้ว",
eqtype: "it",
eqpic: "assets/img/notebook.jpg"
},
{
eqid: 4,
eqName: "คีย์บอร์ด",
eqdesc: "...",
eqtype: "it",
eqpic: "assets/img/keyboard.png"
}
]
listEquirmentModel: Equirment[] = [];
getListRoom() {
this.http.get(this.url).subscribe((response: any) => {
console.log(response);
this.listEquirmentModel = response.content;
}, error => {
console.log(error)
// alert("ไม่สามารถดึงข้อมูลห้องประชุมได้ เนื่องจาก :\n" + error.message)
})
}
searchListRoom(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) => {
console.log(response);
this.listEquirmentModel = response;
}, error => {
console.log(error)
alert("ไม่สามารถค้นหาอุปกรณ์ที่ว่างได้ เนื่องจาก :\n" + error.message)
})
}
addRoom(EquirmentModel: Equirment) {
this.http.post(this.url, EquirmentModel).subscribe(response => {
console.log(response);
})
}
deleteRoom(EquirmentModel: Equirment) {
this.http.delete(this.url + "/" + EquirmentModel.eqid).subscribe(response => {
console.log(response);
this.getListRoom()
alert("ลบข้อมูลอุปกรณ์สำเร็จ")
})
}
updateRoom(EquirmentModel: Equirment) {
this.http.put(this.url + "/" + EquirmentModel.eqid, EquirmentModel).subscribe(response => {
console.log(response);
alert("อัพเดทข้อมูลอุปกรณ์สำเร็จ")
})
}
EquirmentModel(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';
@Injectable({ providedIn: 'root' })
export class RoomService {
constructor(private http: HttpClient) { }
url: string;
listRoomModel: Room[] = [
{
rid: 1,
rname: "ห้องเดียว",
title: "string",
rpic: "assets/img/room.jpg",
roomLimit: 25,
rdesc: "จำนวนคน 25 คน",
},
{
rid: 2,
rname: "ห้องคู่",
title: "string",
rpic: "assets/img/room.jpg",
roomLimit: 50,
rdesc: "จำนวนคน 50 คน",
},
{
rid: 3,
rname: "ห้องรวม",
title: "string",
rpic: "assets/img/room.jpg",
roomLimit: 100,
rdesc: "จำนวนคน 100 คน",
},
]
listRoomSearch: Room[] = [];
getListRoom() {
this.http.get(this.url).subscribe((response: any) => {
console.log(response);
this.listRoomModel = response.content;
}, error => {
console.log(error)
// alert("ไม่สามารถดึงข้อมูลห้องประชุมได้ เนื่องจาก :\n" + error.message)
})
}
searchListRoom(searchModel: SearchRoomModel) {
this.http.get(this.url + '/limits?roomlimit='+searchModel.roomlimit+'&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.listRoomSearch = response;
}, error => {
console.log(error)
alert("ไม่สามารถค้นหาห้องประขุมที่ว่างได้ เนื่องจาก :\n" + error.message)
})
}
addRoom(roomModel: Room) {
this.http.post(this.url, roomModel).subscribe(response => {
console.log(response);
})
}
deleteRoom(roomModel: Room) {
this.http.delete(this.url + "/" + roomModel.rid).subscribe(response => {
console.log(response);
this.getListRoom()
alert("ลบข้อมูลห้องสำเร็จ")
})
}
updateRoom(roomModel: Room) {
this.http.put(this.url + "/" + roomModel.rid, roomModel).subscribe(response => {
console.log(response);
alert("อัพเดทข้อมูลห้องสำเร็จ")
})
}
roomModel(rid: string) {
}
}
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