From e5683c7f2b0fd22e36f5bfbc300b3784d1cd2be1 Mon Sep 17 00:00:00 2001 From: Jarinya Date: Tue, 23 Apr 2024 18:57:44 +0700 Subject: [PATCH] update edit / login / responsive --- .vscode/settings.json | 3 + public/index.html | 2 +- public/logo.png | Bin 0 -> 6541 bytes src/App.vue | 51 +- src/assets/Group 195.png | Bin 0 -> 35535 bytes src/assets/Group 196.png | Bin 0 -> 3284 bytes src/assets/Group 197.png | Bin 0 -> 2418 bytes src/assets/Group 198.png | Bin 0 -> 1421 bytes src/assets/Group 199.png | Bin 0 -> 1240 bytes src/components/HeaderHome.vue | 15 +- src/components/Section2Green.vue | 17 +- src/components/Section3Base.vue | 2 +- src/components/Section7GreenTab.vue | 4 +- src/components/Section8Base.vue | 22 +- src/components/check/CheckList.vue | 7 +- src/components/check/QuestionList.vue | 87 +- src/components/edit/FormMainEdit.vue | 33 + src/components/edit/FormSteperEdit.vue | 1057 ++++++++++++++++++++++++ src/components/form/FormSteper.vue | 144 +++- src/components/search/SearchMain.vue | 78 +- src/config.js | 2 +- src/router/index.js | 16 + src/store/index.js | 26 +- src/views/CheckDetail.vue | 259 ++++++ src/views/LoginForm.vue | 134 +++ src/views/ProfileUser.vue | 13 + 26 files changed, 1884 insertions(+), 88 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 public/logo.png create mode 100644 src/assets/Group 195.png create mode 100644 src/assets/Group 196.png create mode 100644 src/assets/Group 197.png create mode 100644 src/assets/Group 198.png create mode 100644 src/assets/Group 199.png create mode 100644 src/components/edit/FormMainEdit.vue create mode 100644 src/components/edit/FormSteperEdit.vue create mode 100644 src/views/CheckDetail.vue create mode 100644 src/views/LoginForm.vue create mode 100644 src/views/ProfileUser.vue diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..367d206 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "nuxt.isNuxtApp": false +} \ No newline at end of file diff --git a/public/index.html b/public/index.html index 6910ef8..68ffc7d 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ - + <%= htmlWebpackPlugin.options.title %> diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..bda12e7b5db852b9f10b599ea12eb15d1acdddb5 GIT binary patch literal 6541 zcmb`M=n*Tn(p?vMuQR6|KT|^_neu}ow={>yOU&Mq(edam=p&GheA(R)9k;D`foyr3IB5se&vw=0zXJy z&w}_rfrwux;^44o>S?N3ggKo!l7!J~tzvribom9;Rq@`nap95ZMI-R!^B7{dK9bgo z3V)x7z-*7S)CvlY)hAD;e-sx#JdB9u(N{g^iWaoyBKa8ogKDBI_LEPR-m}H40U7E~ z1*Zk4B?ejJuMfk+XcsJ(E#dZXYq;eyUc7!=RrH*%2SRWQ00E*B^YebgN{;NW~71SQCE9P&Rrw?byKe z=+at%(z|`81dY$a^o1lvzV;Cg;g-Y1F{YHfkA*Vk>{K$y4dX$hHch(QtF?`NAY2jc zC>7`$&+B1`-(&_yXu>OLnn~R51Uxx&m+=`RyxWk$C_jtIEaUgPJPiX6ZfaM&@1D4& z6wec3o?;gDX)ciW#F<-(T*RO6BWuih`KcfwlNr)~B}E5!G0eI@(1*!1B6NCa`<(7u zmaS`N%ldvMmq!i<-qB$cI7G-L^{=Vvdjw%02)H31Mh2s$QDHgwT&yY0bGH zs0@rw)wJ!@QygPrbTSBscU)BDjB&l)r6|67O>5o%U-QV}oQ zAGvd@^PB7mc*N!#G^_LTljM^`$$W}8=iMh?Rxb5ap##UQldhtSjP~Yk!eYV-KBN@7 z`aM)A)V7^JfECA0!WZrsJZsC%CGm%~ZS`49Br@HSA?_E*R;(fL#6)T%GS&A*ar5$KfCY*6PP~25j9m+S}e7~_Ac9k z{By*EFqY!dH~np%d5E#uFg2TF;B({tpXoOdaL^I9>+7%aXr+?SWzu1-y!?IUtXsPcmE zKq30U<9O9pvW2IkZ@z=F{S}G$uRHF;{4gJ%wVdwa$=rB#)dGVV7j8QfNeQc1(RKgKi%z+ch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l&0A%*zpJxwfrU`w_AfHVzV>3N=} z*Kp6l(QCF-GEg8U1OfWpuU@#x@;bMW99`s3jn(H)J0r!XfL^7mz0GzcJ^-al%rI4M zy(HtOcJtm>E~H1V&z90S zyNj!HT*TwdVZA<;(-_(M$cMg~UCCcgpDn78jTRZ{JbyNfQbepfLR6XMJzf_vbDxg! z=m$59)w-TcbxgqBNcb&e(yGQ|oE4k5EM%7Rg!ks7LReL4T z+&JX}=EQMl5`WacI5OW; -
+
+ + - Sign In - Get Started + {{ getUsername }} + Logout + Log In + + Get Started
@@ -31,17 +37,40 @@ import { client } from "./utils/trpc"; client.info.getAllZones.query({}).then(console.log); // import MainVote from "./components/MainVote.vue"; - +import { mapGetters } from "vuex"; export default { name: "App", - + computed: { + ...mapGetters(["getUsername"]), + }, components: { // MainVote, }, data: () => ({ - // + username: "", }), + methods: { + logout() { + localStorage.clear(); + // location.reload(); + this.$store.commit("setUsername", ""); + this.$router.push("/"); + }, + }, + mounted() { + // this.$emitter.on("loginUser", (val) => { + // console.log("user", val); + // if (val) { + // this.username = localStorage.getItem("username"); + // } + // }); + this.username = localStorage.getItem("username"); + if(this.getUsername==""){ + this.$store.commit("setUsername", this.username); + } + + }, }; diff --git a/src/components/Section3Base.vue b/src/components/Section3Base.vue index 42a5eba..2ef4187 100644 --- a/src/components/Section3Base.vue +++ b/src/components/Section3Base.vue @@ -7,7 +7,7 @@ โดยมีคุณสมบัติดังนี้
เช็คคุณสมบัติกันเลย !
- + ตรวจสอบคุณสมบัติการเป็น สว. diff --git a/src/components/Section7GreenTab.vue b/src/components/Section7GreenTab.vue index 98b5f12..40a47f6 100644 --- a/src/components/Section7GreenTab.vue +++ b/src/components/Section7GreenTab.vue @@ -1,7 +1,7 @@ diff --git a/src/components/edit/FormMainEdit.vue b/src/components/edit/FormMainEdit.vue new file mode 100644 index 0000000..b17d161 --- /dev/null +++ b/src/components/edit/FormMainEdit.vue @@ -0,0 +1,33 @@ + + + diff --git a/src/components/edit/FormSteperEdit.vue b/src/components/edit/FormSteperEdit.vue new file mode 100644 index 0000000..81da8bb --- /dev/null +++ b/src/components/edit/FormSteperEdit.vue @@ -0,0 +1,1057 @@ + + + diff --git a/src/components/form/FormSteper.vue b/src/components/form/FormSteper.vue index b0a4024..e8e9e89 100644 --- a/src/components/form/FormSteper.vue +++ b/src/components/form/FormSteper.vue @@ -34,7 +34,7 @@ - + @@ -99,7 +100,7 @@ > - + @@ -387,6 +389,25 @@ bg-color="#F2EBD1" v-model="payload.vision" > + +
+ Previous + + + next +
+
@@ -427,6 +448,7 @@ label="โทรศัพท์" v-model="payload.public_phone" :rules="rules.tel" + class="d-none" > @@ -522,9 +544,9 @@ - + // import Provinces from "./provinces.json"; // import Districts from "./districts.json"; + import { client } from "@/utils/trpc"; +import { createFormData } from "@/utils/fileUpload"; import validateThaiID from "thai-id-validator"; // client.info.getAllGroups.query({}).then(console.log); export default { @@ -563,13 +587,14 @@ export default { ? "next" : undefined; }, - // isIdCardValid() { - // return this.$refs.form.validate(); - // }, - // // ถ้าเลขบัตรประชาชนไม่ถูกต้องให้ปุ่ม Next ถูก disable - // isNextDisabled() { - // return !this.isIdCardValid; - // } + checkOpt1() { + let dataOption = [...this.option1, ...this.option2]; + const filteredItems = dataOption.filter( + (item) => item.choice !== null && item.choice !== undefined + ); + + return { count: dataOption.length, checkcount: filteredItems.length }; + }, }, data() { @@ -580,6 +605,12 @@ export default { form3: false, form4: false, rules: { + files: [ + (files) => + !files || + !files.some((file) => file.size > 3_097_152) || + "Avatar size should be less than 3 MB!", + ], // ^[a-zA-Z0-9?><;,{}[\]\-_+=!@#$%\^&*|']*$ space: (v) => /^[^ ]+$/.test(v) || "must not contain spaces.", username: (v) => @@ -621,6 +652,7 @@ export default { (parseInt(v) == v && v.length == 13 && validateThaiID(v)) || "Invalid ID card number", ], + age: [(v) => parseInt(v) >= 40 || "Age must be over 40"], email: [ (value) => { const pattern = @@ -660,6 +692,7 @@ export default { url: null, image: null, + file: null, province: null, district: null, districtItems: [], @@ -730,6 +763,40 @@ export default { }; }, methods: { + onFileChanged(event) { + const file = event.target.files[0]; + this.file = file; + if (this.file && this.file !== null) { + const reader = new FileReader(); + reader.onload = (event) => { + console.log(event.target.result); + this.url = event.target.result; + }; + reader.readAsDataURL(this.file); + console.log(); + } else { + this.url = null; + } + }, + + async uploadImage() { + if (!this.file) { + return; + } + let request = await client.user.requestChangeImage.mutate({ + imageName: this.file.name, + contentType: this.file.type, + }); + let formData = createFormData(request, this.file); + await fetch(request.postURL, { + method: "POST", + body: formData, + }).then(() => { + client.user.confirmChangeImage.mutate(); + alert("บันทึกข้อมูลสำเร็จ"); + }); + console.log("done"); + }, submit() { let dataOption = [...this.option1, ...this.option2]; const filterOpt = dataOption.map((item) => { @@ -745,10 +812,10 @@ export default { // console.log("opppp", filterOpt, filterOpt2); // let payload = { - // firstName: "ธรรมนูญ", + // firstName: "ธรรมนูญ2", // lastName: "สังขวรรณ", // title: "", - // cid: "1189900247580", + // cid: "3180600024176", // age: 60, // phone: "0819444825", // public_phone: "0819444885", @@ -772,18 +839,53 @@ export default { // // }, // // ], // }; - + // console.log("this.payload", this.payload); client.user.createUser .mutate(this.payload) .then((data) => { console.log("data", data); - alert("บันทึกข้อมูลสำเร็จ"); - this.$router.push("/upload"); + + localStorage.setItem("token", data.token); + if (this.file) { + this.uploadImage(); + } else { + alert("บันทึกข้อมูลสำเร็จ"); + } + this.getUser(); + // this.$router.push("/upload"); // this.provinceItems = data; }) .catch((error) => { - alert("ไม่สามารถอัปโหลดข้อมูลได้"); + alert("ไม่สามารถบันทึกข้อมูลได้: " + error.message); + console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); + }); + }, + login(payload) { + client.user.login + .mutate(payload) + .then((data) => { + console.log("data", data); + + localStorage.setItem("token", data.token); + this.$router.push("/"); + }) + .catch((error) => { + alert("ไม่สามารถบันทึกข้อมูลได้: " + error.message); + console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); + }); + }, + getUser() { + client.user.getSelf + .mutate({}) + .then((data) => { + this.login({ cid: data.cid, phone: data.phone }); + localStorage.setItem("username", data.firstName); + this.$store.commit("setUsername", data.firstName); + // this.$store.dispatch('setLocalStorageValue',data.firstName) + }) + .catch((error) => { + alert("ไม่สามารถโหลดข้อมูลได้"); console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); }); }, @@ -802,12 +904,6 @@ export default { } }, filterData() { - // กรองข้อมูลอันที่สองโดยใช้ข้อมูลจากอันแรก - // if (this.province && this.province.provinceCode) { - // this.districtItems = [...Districts].filter( - // (item) => item.provinceCode === this.province.provinceCode - // ); - // } this.payload.zone = null; client.info.getAllZones .query({ provice_id: this.payload.province }) diff --git a/src/components/search/SearchMain.vue b/src/components/search/SearchMain.vue index f4251b6..43a88cd 100644 --- a/src/components/search/SearchMain.vue +++ b/src/components/search/SearchMain.vue @@ -10,7 +10,7 @@
ค้นหาผู้สมัครสว.
- + - + - + - + ค้นหา @@ -79,12 +79,15 @@ > ไม่พบข้อมูล + +
@@ -113,6 +116,7 @@ export default { items: [], group: null, offset: 0, + count:0, }; }, methods: { @@ -125,10 +129,13 @@ export default { // this.offset = (this.page - 1) * 10; let data = { offset: offset, - limit: 10, + limit: 10, // group: this.group, // zone: this.district, }; + if (this.province) { + data.province = this.province; + } if (this.group) { data.group = this.group; } @@ -160,6 +167,59 @@ export default { console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); }); }, + searchUserApi(offset) { + this.show = false; + this.load = true; + if (offset == 0) { + this.page = 1; + } + // this.offset = (this.page - 1) * 10; + let data = { + offset: offset, + limit: 10, + // group: this.group, + // zone: this.district, + }; + if (this.province) { + data.province = this.province; + } + if (this.group) { + data.group = this.group; + } + if (this.district) { + data.zone = this.district; + } + + console.log(data); + client.user.getAllUserCount + .query(data) + .then((rs) => { + this.count = rs; + }) + .catch((error) => { + alert("ไม่สามารถโหลดข้อมูลได้"); + console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); + }); + + client.user.getAllUser + .query(data) + .then((rs) => { + this.result = rs; + console.log(rs); + this.load = false; + if (rs.length == 0) { + this.show = true; + } + + // this.districtItems = rs; + }) + .catch((error) => { + this.load = false; + + alert("ไม่สามารถโหลดข้อมูลได้"); + console.error("เกิดข้อผิดพลาดในการโหลดข้อมูล:", error); + }); + }, filterData() { // กรองข้อมูลอันที่สองโดยใช้ข้อมูลจากอันแรก this.district = null; diff --git a/src/config.js b/src/config.js index 53492b2..7b781ca 100644 --- a/src/config.js +++ b/src/config.js @@ -1,4 +1,4 @@ export const CONFIG = { - // api_url: "http://178.128.18.156:3000", + // api_url: "http://178.128.18.156:3000", api_url: process.env.VUE_APP_API_URL || "http://localhost:3000", }; diff --git a/src/router/index.js b/src/router/index.js index 6c22073..cdc5949 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -5,12 +5,20 @@ import QuestionList from "@/views/QuestionList.vue"; import RegisterForm from "@/views/RegisterForm.vue"; import SearchUser from "@/views/SearchUser.vue"; import UploadImage from "@/views/UploadImage.vue"; +import LoginForm from "@/views/LoginForm.vue"; +import ProfileUser from "@/views/ProfileUser.vue"; +import CheckDetail from "@/views/CheckDetail.vue"; const routes = [ { path: "/", name: "HomePage", component: HomePage, }, + { + path: "/login", + name: "LoginForm", + component: LoginForm, + }, { path: "/check", component: CheckSurvey, @@ -31,6 +39,14 @@ const routes = [ path: "/upload", component: UploadImage, }, + { + path: "/profile", + component: ProfileUser, + }, + { + path: "/detail", + component: CheckDetail, + }, ]; const router = createRouter({ diff --git a/src/store/index.js b/src/store/index.js index 2a25fb0..6727218 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,11 +1,27 @@ import { createStore } from "vuex"; export default createStore({ - state: {}, - getters: {}, - mutations: {}, - actions: { - + state: { + username:"" }, + getters: { + getUsername: (state) => { + return state.username + }, + }, + mutations: { + setUsername: (state, payload) => { + state.username = payload; + }, + }, + actions: { + setLocalStorageValue(data) { + localStorage.setItem("username", data); + }, + // getLocalStorageValue() { + // const username = localStorage.getItem("username"); + // // ทำสิ่งที่คุณต้องการกับค่าที่ได้จาก Local Storage + // }, + }, modules: {}, }); diff --git a/src/views/CheckDetail.vue b/src/views/CheckDetail.vue new file mode 100644 index 0000000..243dd1b --- /dev/null +++ b/src/views/CheckDetail.vue @@ -0,0 +1,259 @@ + + + diff --git a/src/views/LoginForm.vue b/src/views/LoginForm.vue new file mode 100644 index 0000000..d5dd157 --- /dev/null +++ b/src/views/LoginForm.vue @@ -0,0 +1,134 @@ + + diff --git a/src/views/ProfileUser.vue b/src/views/ProfileUser.vue new file mode 100644 index 0000000..1bf7f3b --- /dev/null +++ b/src/views/ProfileUser.vue @@ -0,0 +1,13 @@ + + + + \ No newline at end of file