From 9ef2366f727f30c1ed5fbfb171b108d0c8cffb93 Mon Sep 17 00:00:00 2001 From: kamoa457 Date: Thu, 9 Nov 2023 12:31:29 +0700 Subject: [PATCH] update detail --- appserver/rooms.json | 75 ++++++++++------ appserver/server.js | 1 + webapp/src/views/Restroom/DetailRoomPage.vue | 93 +++++++++++--------- 3 files changed, 104 insertions(+), 65 deletions(-) diff --git a/appserver/rooms.json b/appserver/rooms.json index 844b08b..dab0cb7 100644 --- a/appserver/rooms.json +++ b/appserver/rooms.json @@ -10,7 +10,8 @@ "Affiliation": "ฝอ. 2", "typeRoom": "ช1", "roomconditions": "ปกติ", - "roomStatus": "unavailable" + "roomStatus": "unavailable", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c389c78-b2a3-4ea2-bca5-48521eb7e5db", @@ -23,7 +24,8 @@ "Affiliation": "ฝอ. 1", "typeRoom": "ช2", "roomconditions": "ปกติ", - "roomStatus": "return" + "roomStatus": "return", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c78-b2a3-4ea2-bca5-57521eb7e5db", @@ -36,7 +38,8 @@ "Affiliation": "ฝอ. 1", "typeRoom": "ช2", "roomconditions": "ปกติ", - "roomStatus": "unavailable" + "roomStatus": "unavailable", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c78-b2v3-4ea2-bca5-48521eb7e5db", @@ -49,7 +52,8 @@ "Affiliation": "ฝอ. 1", "typeRoom": "ช3", "roomconditions": "ปกติ", - "roomStatus": "special" + "roomStatus": "special", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c787c78-b2a3-4ea2-bca5-48521eb7e5db", @@ -62,7 +66,8 @@ "Affiliation": "ฝอ. 7", "typeRoom": "ช2", "roomconditions": "ชำรุด", - "roomStatus": "waiting" + "roomStatus": "waiting", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c78-q2a3-4ea2-bca5-48521eb7e5db", @@ -75,7 +80,8 @@ "Affiliation": "", "typeRoom": "ช2", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c36-b2a3-4ea2-bca5-48521eb7e5db", @@ -88,7 +94,8 @@ "Affiliation": "", "typeRoom": "ช1", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c41-b2a3-4ea2-bca5-48521eb7e5db", @@ -101,7 +108,8 @@ "Affiliation": "ฝอ. 1", "typeRoom": "ช3", "roomconditions": "ปกติ", - "roomStatus": "special" + "roomStatus": "special", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c99-b2a3-4ea2-bca5-48521eb7e5db", @@ -114,7 +122,8 @@ "Affiliation": "ฝอ. 7", "typeRoom": "ช2", "roomconditions": "ชำรุด", - "roomStatus": "waiting" + "roomStatus": "waiting", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c988c78-b2a3-4ea2-bca5-48521eb7e5db", @@ -127,7 +136,8 @@ "Affiliation": "", "typeRoom": "ช2", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c78-b2a3-4ea2-bca5-47821eb7e5db", @@ -147,7 +157,8 @@ "phone": "0325647845", "status": "โสด", "typeAffiliation": "ลูกจ้าง", - "typeRanks": "ลูกจ้าง" + "typeRanks": "ลูกจ้าง", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "id": "2c388c78-b2a3-4ea2-bca5-48981eb7e5db", @@ -167,7 +178,8 @@ "phone": "0325647845", "status": "โสด", "typeAffiliation": "บก.สนน.", - "typeRanks": "ประทวน" + "typeRanks": "ประทวน", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "8bc8b393-8ae2-4e65-9a35-32c0e76545b3", @@ -182,7 +194,8 @@ "Affiliation": "", "roomconditions": "ปกติ", "typeRoom": "ช1", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "8bc8b393-8ae2-4e65-9a35-32c0e76545b3", @@ -197,7 +210,8 @@ "Affiliation": "", "roomconditions": "ปกติ", "typeRoom": "ช1", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "8bc8b393-8ae2-4e65-9a35-32c0e76545b3", @@ -212,7 +226,8 @@ "Affiliation": "", "typeRoom": "ช2", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "8bc8b393-8ae2-4e65-9a35-32c0e76545b3", @@ -227,7 +242,8 @@ "Affiliation": "", "typeRoom": "ช1", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "8bc8b393-8ae2-4e65-9a35-32c0e76545b3", @@ -242,7 +258,8 @@ "Affiliation": "", "roomconditions": "ชำรุด", "typeRoom": "ช2", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "8bc8b393-8ae2-4e65-9a35-32c0e76545b3", @@ -264,7 +281,8 @@ "phone": "0325647845", "status": "สมรส", "typeAffiliation": "ลูกจ้าง", - "typeRanks": "ประทวน" + "typeRanks": "ประทวน", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "8bc8b393-8ae2-4e65-9a35-32c0e76545b3", @@ -279,7 +297,8 @@ "Affiliation": "", "typeRoom": "ช1", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "3ac5e496-89f8-44da-a666-4d910f9ba61c", @@ -294,7 +313,8 @@ "Affiliation": "", "typeRoom": "", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "3ac5e496-89f8-44da-a666-4d910f9ba61c", @@ -309,7 +329,8 @@ "Affiliation": "", "typeRoom": "", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "3ac5e496-89f8-44da-a666-4d910f9ba61c", @@ -324,7 +345,8 @@ "Affiliation": "", "typeRoom": "", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "3ac5e496-89f8-44da-a666-4d910f9ba61c", @@ -339,7 +361,8 @@ "Affiliation": "", "typeRoom": "", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "3ac5e496-89f8-44da-a666-4d910f9ba61c", @@ -354,7 +377,8 @@ "Affiliation": "", "typeRoom": "", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" }, { "buildingId": "3ac5e496-89f8-44da-a666-4d910f9ba61c", @@ -369,6 +393,7 @@ "Affiliation": "", "typeRoom": "", "roomconditions": "ปกติ", - "roomStatus": "free" + "roomStatus": "free", + "pickedBook": "2023-11-02T14:10:26.374Z" } ] \ No newline at end of file diff --git a/appserver/server.js b/appserver/server.js index 905da27..db5c855 100644 --- a/appserver/server.js +++ b/appserver/server.js @@ -170,6 +170,7 @@ app.put('/rooms/:id', (req, res) => { if (req.body.typeAffiliation) parsedData.typeAffiliation = req.body.typeAffiliation if (req.body.typeRanks) parsedData.typeRanks = req.body.typeRanks if (req.body.typeRoom) parsedData.typeRoom = req.body.typeRoom + if (req.body.pickedBook) parsedData.pickedBook = req.body.pickedBook if (req.body.roomconditions) parsedData.roomconditions = req.body.roomconditions filterdata.push(parsedData) fs.writeFile('./rooms.json', JSON.stringify(filterdata, null, 2), (err) => { diff --git a/webapp/src/views/Restroom/DetailRoomPage.vue b/webapp/src/views/Restroom/DetailRoomPage.vue index d18cb70..510fbfd 100644 --- a/webapp/src/views/Restroom/DetailRoomPage.vue +++ b/webapp/src/views/Restroom/DetailRoomPage.vue @@ -7,7 +7,6 @@ import MaterialButton from "@/components/MaterialButton.vue"; import Breadcrumbs from "@/examples/Breadcrumbs.vue"; import axios from "axios"; - export default { components: { MaterialInput, @@ -16,7 +15,7 @@ export default { }, setup() { return { - vueMkHeader + vueMkHeader, }; }, @@ -47,6 +46,8 @@ export default { data: "", queueList: [], queuefilter: [], + statusRoom: "", + dateApproved: "" }; }, created() { @@ -80,18 +81,31 @@ export default { try { axios.get(`http://localhost:3001/rooms/${id}`).then((res) => { this.data = res.data; - // console.log(this.data); - // if (this.data.typeRoom == "ช1") this.typeroom = "โสด"; - // if (this.data.typeRoom == "ช2") this.typeroom = "สมรส"; - // if (this.data.typeRoom == "ช3") this.typeroom = "ทั่วไป"; - this.typeroom = this.data.typeRoom - this.getAllqueue() + console.log(this.data); + this.dateApproved = this.convertDateTolocal(this.data.pickedBook) + this.typeroom = this.data.typeRoom; + if(this.data.affiliation) this.Affiliation = this.data.affiliation + if (this.data.roomStatus == "return") this.statusRoom = "ผ่อนผัน"; + if (this.data.roomStatus == "special") this.statusRoom = "กรณีพิเศษ"; + if (this.data.roomStatus == "waiting") this.statusRoom = "ชำรุด"; + if (this.data.roomStatus == "unavailable") this.statusRoom = "ไม่ว่าง"; + if (this.data.roomStatus == "free") this.statusRoom = "ว่าง"; + + + this.getAllqueue(); }); } catch (e) { console.error(e); } }, + convertDateTolocal(index){ + const date = new Date(index); + const formatter = new Intl.DateTimeFormat('en-US', { day: '2-digit', month: '2-digit', year: 'numeric' }); + const formattedDate = formatter.format(date) + return formattedDate + }, + getAllusersByid(id) { this.userId = id; try { @@ -119,7 +133,6 @@ export default { insurance: this.insurance, installments: this.installments, }; - console.log(body); await axios .post(`http://localhost:3001/history`, body, { headers: { @@ -128,9 +141,9 @@ export default { }, }) .then((res) => { - this.submitForm2() - this.submitForm3() - this.submitFormRoom() + this.submitForm2(); + this.submitForm3(); + this.submitFormRoom(); }) .catch((err) => { console.log(err); @@ -148,13 +161,12 @@ export default { installments: this.installments, }; - await axios - .post(`http://localhost:3001/report`, body, { - headers: { - "Access-Control-Allow-Origin": "*", - "Content-Type": "application/json", - }, - }) + await axios.post(`http://localhost:3001/report`, body, { + headers: { + "Access-Control-Allow-Origin": "*", + "Content-Type": "application/json", + }, + }); }, async submitForm3() { @@ -168,19 +180,18 @@ export default { installments: this.installments, }; - await axios - .put(`http://localhost:3001/queue/${this.userId}`, body, { - headers: { - "Access-Control-Allow-Origin": "*", - "Content-Type": "application/json", - }, - }) + await axios.put(`http://localhost:3001/queue/${this.userId}`, body, { + headers: { + "Access-Control-Allow-Origin": "*", + "Content-Type": "application/json", + }, + }); }, async submitFormRoom() { let body = { ...this.userByid, queue: "inroom", - roomStatus: 'unavailable', + roomStatus: "unavailable", contract: this.contract, checkintime: this.Checkintime, maintenance: this.Maintenance, @@ -262,21 +273,23 @@ export default {
รายละเอียดผู้เช่า
-

ชือ : ส.ต.ต. มานะ

-

สถานะห้อง : ไม่ว่าง

-

สังกัด : ฝอ. 1

-

เลขบัตรประชาชน : 123456123456

-

วันที่ได้รับอนุมัติ : 12/02/2564

+

+ ชือ : {{ data?.rank }} {{ data?.firstName }} +

+

สถานะห้อง : {{ statusRoom }}

+

สังกัด : {{ Affiliation }}

+

เลขบัตรประชาชน : {{ data?.idcard }}

+

วันที่ได้รับอนุมัติ : {{ dateApproved }}

-

ระยะเวลาที่เข้าพัก : 3 เดือน

+

ระยะเวลาที่เข้าพัก : {{ data?.Checkintime || 0 }} เดือน

-

นามสกุล : ถือดี

-

เบอร์โทร : 0972534887

-

เงินค่าประกัน : 12,000

-

งวดค่าประกัน : 5/10

-

จำนวนงวดค่าประกัน : 2,000

-

ยอดคงเหลือค่าประกัน : 6,000

+

นามสกุล : {{ data?.lastName }}

+

เบอร์โทร : {{ data?.phone }}

+

เงินค่าประกัน : {{ data?.Insurancecost }}

+

งวดค่าประกัน : {{ data?.installments }}

+ +
@@ -284,7 +297,7 @@ export default {
รายละเอียดห้องพัก

ประเภทห้องพัก : {{ data?.typeRoom }}

-

สภาพห้อง : {{ data?.Roomconditions }}

+

สภาพห้อง : {{ data?.roomconditions }}