แบบ สอบถาม

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-10-10 11:16:52 +07:00
parent d3ddfc38d7
commit 736bd7eb6a
4 changed files with 861 additions and 469 deletions

View file

@ -8,4 +8,6 @@ export default {
resingByid: (id: string) => `${retirementResign}/resign/${id}`, resingByid: (id: string) => `${retirementResign}/resign/${id}`,
questionnaireByid: (id: string) => `${retirementResign}/resign/questionnaire/${id}`, questionnaireByid: (id: string) => `${retirementResign}/resign/questionnaire/${id}`,
listquestionnaire: () => `${retirementResign}/resign/questionnaire`, listquestionnaire: () => `${retirementResign}/resign/questionnaire`,
// คำถาม
questionList: () => `${retirementResign}/resign/questionnaire/question`
} }

View file

@ -0,0 +1,29 @@
interface QuestionDescription {
question1Desc: string;
question2Desc: string;
question3Desc: string;
question4Desc: string;
question5Desc: string;
question6Desc: string;
question7Desc: string;
question8Desc: string;
question9Desc: string;
question10Desc: string;
[key: string]: string;
}
interface OptionQuestions {
label: string;
value: number;
}
interface OptionQuestions2 {
label: string;
value: boolean;
}
export type {
QuestionDescription,
OptionQuestions,
OptionQuestions2
};

View file

@ -1,127 +1,240 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue" import { ref, reactive, onMounted } from "vue";
import { useQuasar } from "quasar" import { useQuasar } from "quasar";
import { useRouter, useRoute } from "vue-router" import { useRouter, useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin" import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http" import http from "@/plugins/http";
import config from "@/app.config" import config from "@/app.config";
const route = useRoute() import type {
const router = useRouter() QuestionDescription,
const $q = useQuasar() OptionQuestions,
const mixin = useCounterMixin() OptionQuestions2,
const { success, messageError, notifyError } = mixin } from "@/modules/03_retire/interface/request/Main";
const dataId = ref<any>(route.params.id.toString())
const exitFactor = ref<any>([]) const route = useRoute();
const reasonWork = ref<any>([]) const router = useRouter();
const adjust = ref<any>([]) const $q = useQuasar();
const timeThink = ref<any>() const mixin = useCounterMixin();
const realReason = ref<any>("") const { success, messageError, notifyError, showLoader, hideLoader } = mixin;
const notExitFactor = ref<any>("") const dataId = ref<any>(route.params.id.toString());
const haveJob = ref<any>()
const suggestFriends = ref<any>()
const futureWork = ref<any>()
const suggestion = ref<any>("")
const reasonWorkOther = ref("") const exitFactor = ref<any>([]);
const reasonWork_option = ref<any>([ const reasonWork = ref<any>([]);
{ label: "ความมั่นคงในการทำงาน ", value: 0 }, const adjust = ref<any>([]);
{ label: "สิทธิประโยชน์/สวัสดิการ", value: 1 }, const timeThink = ref<any>();
{ label: "อัตราเงินเดือน ", value: 2 }, const realReason = ref<any>("");
{ label: "ลักษณะงาน ", value: 3 }, const notExitFactor = ref<any>("");
{ label: "วัฒนธรรมการทำงานของข้าราชการ ", value: 4 }, const haveJob = ref<any>();
{ label: "นโยบายของหน่วยงาน ", value: 5 }, const suggestFriends = ref<any>();
{ label: "ระบบการทำงาน", value: 6 }, const futureWork = ref<any>();
{ label: "สมดุลชีวิตการทำงาน ", value: 7 }, const suggestion = ref<any>("");
{ label: "บรรยากาศในการทำงาน ", value: 8 },
{ label: "การพัฒนาในสายอาชีพ ", value: 9 },
{ label: "โอกาสความก้าวหน้า ", value: 10 },
{ label: "การได้รับการยอมรับจากสังคม ", value: 11 },
{ label: "อื่น ๆ (ระบุ) ", value: 12 },
])
const exitFactorOther = ref("")
const exitFactor_option = ref<any>([
{ label: "อัตราเงินเดือน ", value: 0 },
{ label: "สวัสดิการ", value: 1 },
{ label: "ลักษณะงาน ", value: 2 },
{ label: "ระบบการทำงาน ", value: 3 },
{ label: "ระบบสนับสนุนการปฏิบัติงาน ", value: 4 },
{ label: "การมอบหมายงานที่ชัดเจนและเหมาะสม ", value: 5 },
{ label: "การบริหารงานของผู้บังคับบัญชา", value: 6 },
{ label: "การทำงานเป็นทีมกับเพื่อนร่วมงาน ", value: 7 },
{ label: "ระบบบริหารงานภายในหน่วยงาน ", value: 8 },
{ label: "บรรยากาศในการทำงาน ", value: 9 },
{ label: "การปฏิบัติอย่างเป็นธรรม ", value: 10 },
{ label: "การยอมรับความแตกต่างหลากหลาย ", value: 11 },
{ label: "การดูแลและให้ความช่วยเหลือในช่วงเริ่มต้นปฏิบัติงาน ", value: 12 },
{ label: "การพัฒนาอย่างเป็นระบบและต่อเนื่อง ", value: 13 },
{ label: "โอกาสความก้าวหน้า ", value: 14 },
{ label: "อื่น ๆ (ระบุ) ", value: 15 },
])
const suggestFriendsReason = ref("")
const suggestFriends_option = ref<any>([
{ label: "แนะนำ ", value: 0 },
{ label: "ไม่แนะนำ (ระบุ)", value: 1 },
])
const timeThink_option = ref<any>([
{ label: "น้อยกว่า 2 สัปดาห์ ", value: 0 },
{ label: "1 เดือน - 3 เดือน", value: 1 },
{ label: "3 เดือน - 6 เดือน ", value: 2 },
{ label: "6 เดือนขึ้นไป ", value: 3 },
])
const haveJobReason = ref<any>("")
const haveJob_option = ref<any>([
{ label: "มี (ระบุ)", value: 0 },
{ label: "ไม่มี", value: 1 },
])
const futureWorkReason = ref<any>("")
const futureWork_option = ref<any>([
{ label: "อยาก ", value: 0 },
{ label: "ไม่อยาก (ระบุ)", value: 1 },
])
const adjustOther = ref("")
const adjust_option = ref<any>([
{ label: "อัตราเงินเดือน ", value: 0 },
{ label: "สวัสดิการ", value: 1 },
{ label: "ลักษณะงาน ", value: 2 },
{ label: "ระบบการทำงาน ", value: 3 },
{ label: "ระบบสนับสนุนการปฏิบัติงาน ", value: 4 },
{ label: "การมอบหมายงานที่ชัดเจนและเหมาะสม ", value: 5 },
{ label: "การบริหารงานของผู้บังคับบัญชา", value: 6 },
{ label: "การทำงานเป็นทีมกับเพื่อนร่วมงาน ", value: 7 },
{ label: "ระบบบริหารงานภายในหน่วยงาน ", value: 8 },
{ label: "บรรยากาศในการทำงาน ", value: 9 },
{ label: "การปฏิบัติอย่างเป็นธรรม ", value: 10 },
{ label: "การยอมรับความแตกต่างหลากหลาย ", value: 11 },
{ label: "การดูแลและให้ความช่วยเหลือในช่วงเริ่มต้นปฏิบัติงาน ", value: 12 },
{ label: "การพัฒนาอย่างเป็นระบบและต่อเนื่อง ", value: 13 },
{ label: "โอกาสความก้าวหน้า ", value: 14 },
{ label: "อื่น ๆ (ระบุ) ", value: 15 },
])
const reasonWorkOther = ref("");
// const reasonWork_option = ref<any>([
// { label: " ", value: 0 },
// { label: "/", value: 1 },
// { label: " ", value: 2 },
// { label: " ", value: 3 },
// { label: " ", value: 4 },
// { label: " ", value: 5 },
// { label: "", value: 6 },
// { label: " ", value: 7 },
// { label: " ", value: 8 },
// { label: " ", value: 9 },
// { label: " ", value: 10 },
// { label: " ", value: 11 },
// { label: " () ", value: 12 },
// ]);
const exitFactorOther = ref("");
// const exitFactor_option = ref<any>([
// { label: " ", value: 0 },
// { label: "", value: 1 },
// { label: " ", value: 2 },
// { label: " ", value: 3 },
// { label: " ", value: 4 },
// { label: " ", value: 5 },
// { label: "", value: 6 },
// { label: " ", value: 7 },
// { label: " ", value: 8 },
// { label: " ", value: 9 },
// { label: " ", value: 10 },
// { label: " ", value: 11 },
// { label: " ", value: 12 },
// { label: " ", value: 13 },
// { label: " ", value: 14 },
// { label: " () ", value: 15 },
// ]);
const suggestFriendsReason = ref("");
// const suggestFriends_option = ref<any>([
// { label: " ", value: 0 },
// { label: " ()", value: 1 },
// ]);
// const timeThink_option = ref<any>([
// { label: " 2 ", value: 0 },
// { label: "1 - 3 ", value: 1 },
// { label: "3 - 6 ", value: 2 },
// { label: "6 ", value: 3 },
// ]);
const haveJobReason = ref<any>("");
// const haveJob_option = ref<any>([
// { label: " ()", value: 0 },
// { label: "", value: 1 },
// ]);
const futureWorkReason = ref<any>("");
// const futureWork_option = ref<any>([
// { label: "", value: 0 },
// { label: " ()", value: 1 },
// ]);
const adjustOther = ref("");
// const adjust_option = ref<any>([
// { label: " ", value: 0 },
// { label: "", value: 1 },
// { label: " ", value: 2 },
// { label: " ", value: 3 },
// { label: " ", value: 4 },
// { label: " ", value: 5 },
// { label: "", value: 6 },
// { label: " ", value: 7 },
// { label: " ", value: 8 },
// { label: " ", value: 9 },
// { label: " ", value: 10 },
// { label: " ", value: 11 },
// { label: " ", value: 12 },
// { label: " ", value: 13 },
// { label: " ", value: 14 },
// { label: " () ", value: 15 },
// ]);
//
onMounted(async () => {
showLoader();
await fecthQuestion();
});
//
//
const questionDesc = ref<QuestionDescription>({
question1Desc: "",
question2Desc: "",
question3Desc: "",
question4Desc: "",
question5Desc: "",
question6Desc: "",
question7Desc: "",
question8Desc: "",
question9Desc: "",
question10Desc: "",
});
const question1Answer = ref<OptionQuestions[]>([]);
const question2Answer = ref<OptionQuestions[]>([]);
const question3Answer = ref<OptionQuestions[]>([]);
const question4Answer = ref<OptionQuestions[]>([]);
const question7Answer = ref<OptionQuestions2[]>([]);
const question8Answer = ref<OptionQuestions2[]>([]);
const question9Answer = ref<OptionQuestions2[]>([]);
async function fecthQuestion() {
await http
.get(config.API.questionList())
.then((res) => {
const data = res.data.result;
question1Answer.value = [];
question3Answer.value = [];
question4Answer.value = [];
//
for (let i = 1; i <= 10; i++) {
const questionKey = `question${i}Desc`;
questionDesc.value[questionKey] = `${i}. ${data[questionKey]}`;
}
//
const Answer1 = data.question1Answer.map((e: any, index: number) => ({
label: e,
value: index,
}));
question1Answer.value = Answer1;
question1Answer.value.push({
label: "อื่น ๆ (ระบุ)",
value: Answer1.length,
});
question2Answer.value = data.question2Answer.map(
(e: any, index: number) => ({
label: e,
value: index,
})
);
const Answer3 = data.question3Answer.map((e: any, index: number) => ({
label: e,
value: index,
}));
question3Answer.value = Answer3;
question3Answer.value.push({
label: "อื่น ๆ (ระบุ)",
value: Answer3.length,
});
const Answer4 = data.question4Answer.map((e: any, index: number) => ({
label: e,
value: index,
}));
question4Answer.value = Answer4;
question4Answer.value.push({
label: "อื่น ๆ (ระบุ)",
value: Answer4.length,
});
question7Answer.value = data.question7Answer.map(
(e: any, index: number) => ({
label: e,
value: index,
})
);
question8Answer.value = data.question8Answer.map(
(e: any, index: number) => ({
label: e,
value: index,
})
);
question9Answer.value = data.question9Answer.map(
(e: any, index: number) => ({
label: e,
value: index,
})
);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
// //
const saveForm = () => { const saveForm = () => {
let hasError = false let hasError = false;
if ( if (
reasonWork.value.length === 0 || reasonWork.value.length === 0 ||
(reasonWork.value.filter((x: any) => x == 12).length > 0 && (reasonWorkOther.value == null || reasonWorkOther.value == "")) || (reasonWork.value.filter((x: any) => x == 12).length > 0 &&
(reasonWorkOther.value == null || reasonWorkOther.value == "")) ||
timeThink.value.length === 0 || timeThink.value.length === 0 ||
exitFactor.value.length === 0 || exitFactor.value.length === 0 ||
(exitFactor.value.filter((x: any) => x == 15).length > 0 && (exitFactorOther.value == null || exitFactorOther.value == "")) || (exitFactor.value.filter((x: any) => x == 15).length > 0 &&
(exitFactorOther.value == null || exitFactorOther.value == "")) ||
adjust.value.length === 0 || adjust.value.length === 0 ||
(adjust.value.filter((x: any) => x == 15).length > 0 && (adjustOther.value == null || adjustOther.value == "")) || (adjust.value.filter((x: any) => x == 15).length > 0 &&
(adjustOther.value == null || adjustOther.value == "")) ||
realReason.value.length < 1 || realReason.value.length < 1 ||
notExitFactor.value.length < 1 || notExitFactor.value.length < 1 ||
haveJob.value.length === 0 || haveJob.value.length === 0 ||
(haveJob.value === 0 && (haveJobReason.value == null || haveJobReason.value == "")) || (haveJob.value === 0 &&
(haveJobReason.value == null || haveJobReason.value == "")) ||
suggestFriends.value.length === 0 || suggestFriends.value.length === 0 ||
(suggestFriends.value === 1 && (suggestFriendsReason.value == null || suggestFriendsReason.value == "")) || (suggestFriends.value === 1 &&
(suggestFriendsReason.value == null ||
suggestFriendsReason.value == "")) ||
futureWork.value.length === 0 || futureWork.value.length === 0 ||
(futureWork.value === 1 && (futureWorkReason.value == null || futureWorkReason.value == "")) || (futureWork.value === 1 &&
(futureWorkReason.value == null || futureWorkReason.value == "")) ||
suggestion.value.length < 1 suggestion.value.length < 1
) { ) {
hasError = true hasError = true;
} else { } else {
$q.dialog({ $q.dialog({
title: "ยืนยันข้อมูลแบบสอบถาม", title: "ยืนยันข้อมูลแบบสอบถาม",
@ -133,15 +246,15 @@ const saveForm = () => {
persistent: true, persistent: true,
}) })
.onOk(async () => { .onOk(async () => {
createResult() createResult();
}) })
.onCancel(() => {}) .onCancel(() => {})
.onDismiss(() => {}) .onDismiss(() => {});
} }
if (hasError === true) { if (hasError === true) {
notifyError($q, "กรุณากรอกข้อมูลให้ครบ") notifyError($q, "กรุณากรอกข้อมูลให้ครบ");
} }
} };
const createResult = async () => { const createResult = async () => {
const data = { const data = {
@ -162,40 +275,65 @@ const createResult = async () => {
FutureWork: futureWork.value, FutureWork: futureWork.value,
FutureWorkReason: futureWorkReason.value, FutureWorkReason: futureWorkReason.value,
Suggestion: suggestion.value, Suggestion: suggestion.value,
} };
await http await http
.post(config.API.listquestionnaire(), data) .post(config.API.listquestionnaire(), data)
.then((res: any) => { .then(() => {
success($q, "บันทึกข้อมูลสำเร็จ") success($q, "บันทึกข้อมูลสำเร็จ");
router.push(`/retire`) router.push(`/retire`);
}) })
.catch((e: any) => { .catch((e: any) => {
messageError($q, e) messageError($q, e);
}) });
} };
</script> </script>
<template> <template>
<div class="col-12 row justify-center"> <div class="col-12 row justify-center">
<div class="col-xs-12 col-sm-12 col-md-11"> <div class="col-xs-12 col-sm-12 col-md-11">
<div class="toptitle text-white col-12 row items-center"> <div class="toptitle text-white col-12 row items-center">
<q-btn icon="mdi-arrow-left" unelevated round dense flat color="primary" class="q-mr-sm" @click="router.push(`/retire`)" /> <q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="router.push(`/retire`)"
/>
</div> </div>
<div class="col-12"> <div class="col-12">
<q-card bordered> <q-card bordered>
<div class="col-12 row q-col-gutter-md q-pa-md"> <div class="col-12 row q-col-gutter-md q-pa-md">
<div class="col-xs-12 col-sm-12"> <div class="col-xs-12 col-sm-12">
<q-card bordered flat> <q-card bordered flat>
<div class="q-pa-xs bg-white-2 row items-center q-py-sm q-px-md justify-center text-bold">เราไดบแบบฟอรมของคณแล กรณาตอบแบบสอบถาม</div> <div
<div class="q-pa-xs bg-grey-2 row items-center q-py-sm q-px-md justify-center text-bold">แบบสอบถาม</div> class="q-pa-xs bg-white-2 row items-center q-py-sm q-px-md justify-center text-bold"
>
เราไดบแบบฟอรมของคณแล กรณาตอบแบบสอบถาม
</div>
<div
class="q-pa-xs bg-grey-2 row items-center q-py-sm q-px-md justify-center text-bold"
>
แบบสอบถาม
</div>
<q-separator /> <q-separator />
<div class="col-12 row q-pa-sm q-col-gutter-sm"> <div class="col-12 row q-pa-sm q-col-gutter-sm">
<div class="col-12 text-top0 items-center">1. เหตใดทานจงตดสนใจรวมงานกบกรงเทพมหานคร (เลอกไดมากกว 1 )</div> <div class="col-12 text-top0 items-center">
<q-option-group :options="reasonWork_option" type="checkbox" v-model="reasonWork" /> <!-- 1. เหตใดทานจงตดสนใจรวมงานกบกรงเทพมหานคร
(เลอกไดมากกว 1 ) -->
{{ questionDesc.question1Desc }}
</div>
<q-option-group
:options="question1Answer"
type="checkbox"
v-model="reasonWork"
/>
<div class="col-12 text-top0 items-center"> <div class="col-12 text-top0 items-center">
<q-item-label> <q-item-label>
<q-input <q-input
v-if="reasonWork.includes(12)" v-if="reasonWork.includes(question1Answer.length - 1)"
v-model="reasonWorkOther" v-model="reasonWorkOther"
label="กรอกอื่นๆ" label="กรอกอื่นๆ"
dense dense
@ -205,19 +343,38 @@ const createResult = async () => {
hide-bottom-space hide-bottom-space
outlined outlined
class="bg-white" class="bg-white"
:rules="[val => (val && val.length > 0) || 'กรุณากรอกข้อความ']" :rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อความ',
]"
/> />
</q-item-label> </q-item-label>
</div> </div>
<div class="col-12 text-top0 items-center">2. สำหรบการลาออกในครงน านไดดทบทวนอยางจรงจงเปนระยะเวลานานเทาใด</div> <div class="col-12 text-top0 items-center">
<q-option-group :options="timeThink_option" type="radio" v-model="timeThink" /> <!-- 2. สำหรบการลาออกในครงน
านไดดทบทวนอยางจรงจงเปนระยะเวลานานเทาใด -->
{{ questionDesc.question2Desc }}
</div>
<q-option-group
:options="question2Answer"
type="radio"
v-model="timeThink"
/>
<div class="col-12 text-top0 items-center">3. จจยใดททำใหานตดสนใจลาออกจากราชการ (เลอกไดมากกว 1 )</div> <div class="col-12 text-top0 items-center">
<q-option-group :options="exitFactor_option" type="checkbox" v-model="exitFactor" /> <!-- 3. จจยใดททำใหานตดสนใจลาออกจากราชการ
(เลอกไดมากกว 1 ) -->
{{ questionDesc.question3Desc }}
</div>
<q-option-group
:options="question3Answer"
type="checkbox"
v-model="exitFactor"
/>
<div class="col-12 text-top0 items-center"> <div class="col-12 text-top0 items-center">
<q-item-label> <q-item-label>
<q-input <q-input
v-if="exitFactor.includes(15)" v-if="exitFactor.includes(question3Answer.length - 1)"
v-model="exitFactorOther" v-model="exitFactorOther"
label="กรอกอื่นๆ" label="กรอกอื่นๆ"
dense dense
@ -227,19 +384,28 @@ const createResult = async () => {
hide-bottom-space hide-bottom-space
outlined outlined
class="bg-white" class="bg-white"
:rules="[val => (val && val.length > 0) || 'กรุณากรอกข้อความ']" :rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อความ',
]"
/> />
</q-item-label> </q-item-label>
</div> </div>
<div class="col-12 text-top0 items-center">4. อะไรคอสงทานเหนวาควรปรบปร (เลอกไดมากกว 1 )</div> <div class="col-12 text-top0 items-center">
{{ questionDesc.question4Desc }}
</div>
<q-list> <q-list>
<q-option-group :options="adjust_option" type="checkbox" v-model="adjust" /> <q-option-group
:options="question4Answer"
type="checkbox"
v-model="adjust"
/>
</q-list> </q-list>
<div class="col-12 text-top0 items-center"> <div class="col-12 text-top0 items-center">
<q-item-label> <q-item-label>
<q-input <q-input
v-if="adjust.includes(15)" v-if="adjust.includes(question4Answer.length - 1)"
v-model="adjustOther" v-model="adjustOther"
label="กรอกอื่นๆ" label="กรอกอื่นๆ"
dense dense
@ -249,21 +415,54 @@ const createResult = async () => {
hide-bottom-space hide-bottom-space
outlined outlined
class="bg-white" class="bg-white"
:rules="[val => (val && val.length > 0) || 'กรุณากรอกข้อความ']" :rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อความ',
]"
/> />
</q-item-label> </q-item-label>
</div> </div>
<div class="col-12 text-top0 items-center">5. โปรดระบสาเหตแทจร ทำใหานตดสนใจลาออกจากการปฏราชการกบกรงเทพมหานคร ?</div> <div class="col-12 text-top0 items-center">
<q-input class="col-12" dense outlined v-model="realReason" label=" " type="textarea" /> <!-- 5. โปรดระบสาเหตแทจร
ทำใหานตดสนใจลาออกจากการปฏราชการกบกรงเทพมหานคร
<div class="col-12 text-top0 items-center">6. จจยใดทจะชวยทำใหานเปลยนใจ ไมอยากลาออกจากการปฏราชการกบกรงเทพมหานคร</div> ? -->
<q-input class="col-12" dense outlined v-model="notExitFactor" label=" " type="textarea" /> {{ questionDesc.question5Desc }}
</div>
<q-input
class="col-12"
dense
outlined
v-model="realReason"
label=" "
type="textarea"
/>
<div class="col-12 text-top0 items-center"> <div class="col-12 text-top0 items-center">
7. านมงานใหมหรอไม าม (โปรดระบ อบรทเอกชน/หนวยงานภาคร) และอะไรคอสงททำงานใหมใหบทาน <!-- 6. จจยใดทจะชวยทำใหานเปลยนใจ
งทานรกวาเปนทาพอใจมากกวาการปฏราชการกบกรงเทพมหานคร ไมอยากลาออกจากการปฏราชการกบกรงเทพมหานคร -->
{{ questionDesc.question6Desc }}
</div> </div>
<q-option-group :options="haveJob_option" type="radio" v-model="haveJob" /> <q-input
class="col-12"
dense
outlined
v-model="notExitFactor"
label=" "
type="textarea"
/>
<div class="col-12 text-top0 items-center">
<!-- 7. านมงานใหมหรอไม าม (โปรดระบ
อบรทเอกชน/หนวยงานภาคร)
และอะไรคอสงททำงานใหมใหบทาน
งทานรกวาเปนทาพอใจมากกวาการปฏราชการกบกรงเทพมหานคร -->
{{ questionDesc.question7Desc }}
</div>
<q-option-group
:options="question7Answer"
type="radio"
v-model="haveJob"
/>
<div class="col-12 text-top0 items-center"> <div class="col-12 text-top0 items-center">
<q-item-label> <q-item-label>
<q-input <q-input
@ -277,12 +476,23 @@ const createResult = async () => {
hide-bottom-space hide-bottom-space
outlined outlined
class="bg-white" class="bg-white"
:rules="[val => (val && val.length > 0) || 'กรุณากรอกข้อความ']" :rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อความ',
]"
/> />
</q-item-label> </q-item-label>
</div> </div>
<div class="col-12 text-top0 items-center">8. านจะแนะนำเพอนใหมารวมงานกบกรงเทพมหานครหรอไม (าไม โปรดระบเหตผล)</div> <div class="col-12 text-top0 items-center">
<q-option-group :options="suggestFriends_option" type="radio" v-model="suggestFriends" /> <!-- 8. านจะแนะนำเพอนใหมารวมงานกบกรงเทพมหานครหรอไม
(าไม โปรดระบเหตผล) -->
{{ questionDesc.question8Desc }}
</div>
<q-option-group
:options="question8Answer"
type="radio"
v-model="suggestFriends"
/>
<div class="col-12 text-top0 items-center"> <div class="col-12 text-top0 items-center">
<q-item-label> <q-item-label>
<q-input <q-input
@ -296,12 +506,24 @@ const createResult = async () => {
hide-bottom-space hide-bottom-space
outlined outlined
class="bg-white" class="bg-white"
:rules="[val => (val && val.length > 0) || 'กรุณากรอกข้อความ']" :rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อความ',
]"
/> />
</q-item-label> </q-item-label>
</div> </div>
<div class="col-12 text-top0 items-center">9. หากทานมโอกาสในอนาคต านอยากกลบมารวมงานกบกรงเทพมหานครหรอไม (าไม โปรดระบเหตผล)</div> <div class="col-12 text-top0 items-center">
<q-option-group :options="futureWork_option" type="radio" v-model="futureWork" /> <!-- 9. หากทานมโอกาสในอนาคต
านอยากกลบมารวมงานกบกรงเทพมหานครหรอไม (าไม
โปรดระบเหตผล) -->
{{ questionDesc.question9Desc }}
</div>
<q-option-group
:options="question9Answer"
type="radio"
v-model="futureWork"
/>
<div class="col-12 text-top0 items-center"> <div class="col-12 text-top0 items-center">
<q-item-label> <q-item-label>
<q-input <q-input
@ -315,13 +537,26 @@ const createResult = async () => {
hide-bottom-space hide-bottom-space
outlined outlined
class="bg-white" class="bg-white"
:rules="[val => (val && val.length > 0) || 'กรุณากรอกข้อความ']" :rules="[
(val) =>
(val && val.length > 0) || 'กรุณากรอกข้อความ',
]"
/> />
</q-item-label> </q-item-label>
</div> </div>
<div class="col-12 text-top0 items-center">10. ความคดเหนและขอเสนอแนะอ </div> <div class="col-12 text-top0 items-center">
<q-input class="col-12" dense outlined v-model="suggestion" label=" " type="textarea" /> <!-- 10. ความคดเหนและขอเสนอแนะอ -->
{{ questionDesc.question10Desc }}
</div>
<q-input
class="col-12"
dense
outlined
v-model="suggestion"
label=" "
type="textarea"
/>
<q-separator /> <q-separator />
</div> </div>
@ -330,7 +565,14 @@ const createResult = async () => {
</div> </div>
<div class="row col-12 q-pa-sm"> <div class="row col-12 q-pa-sm">
<q-space /> <q-space />
<q-btn unelevated dense class="q-px-md items-center" color="primary" label="บันทึกข้อมูลแบบสอบถาม" @click="saveForm" /> <q-btn
unelevated
dense
class="q-px-md items-center"
color="primary"
label="บันทึกข้อมูลแบบสอบถาม"
@click="saveForm"
/>
</div> </div>
</q-card> </q-card>
</div> </div>

View file

@ -1,7 +1,7 @@
<template> <template>
<div class="col-12 row justify-center"> <div class="col-12 row justify-center">
<div class="col-xs-12 col-sm-12 col-md-11 "> <div class="col-xs-12 col-sm-12 col-md-11">
<q-card flat class="row col-12 cardNone" > <q-card flat class="row col-12 cardNone">
<div :class="getClass(checkIn)"> <div :class="getClass(checkIn)">
<div class="col-2"> <div class="col-2">
<q-btn <q-btn
@ -26,8 +26,8 @@
dense dense
flat flat
color="white" color="white"
:label="$q.screen.gt.xs ? 'ประวัติการลงเวลา': ''" :label="$q.screen.gt.xs ? 'ประวัติการลงเวลา' : ''"
:class="$q.screen.gt.xs ? 'q-px-sm': ''" :class="$q.screen.gt.xs ? 'q-px-sm' : ''"
@click="router.push('/check-in/history')" @click="router.push('/check-in/history')"
/> />
</div> </div>
@ -78,9 +78,8 @@
<div class="q-pa-md text-weight-medium text-grey-8"> <div class="q-pa-md text-weight-medium text-grey-8">
นทใกลเคยง นทใกลเคยง
<span class="q-px-sm">:</span> <span class="q-px-sm">:</span>
{{location}} {{ location }}
</div> </div>
</q-card> </q-card>
</div> </div>
<div class="col-12 col-sm-4"> <div class="col-12 col-sm-4">
@ -94,7 +93,7 @@
<div class="column col-12" v-if="!camera"> <div class="column col-12" v-if="!camera">
<div class="text-center"> <div class="text-center">
<q-icon <q-icon
name="mdi-image-off-outline" name="mdi-camera"
size="100px" size="100px"
color="blue-grey-3" color="blue-grey-3"
/> />
@ -103,35 +102,99 @@
ไมปภาพ ไมปภาพ
</div> --> </div> -->
</div> </div>
<div v-else>
<div v-if="hasPhoto">
<video
ref="video"
autoplay
:style="{
width: videoWidth + 'px',
height: videoHeight + 'px',
}"
></video>
<canvas
ref="canvas"
:width="videoWidth"
:height="videoHeight"
></canvas>
</div>
<div v-else class="q-mt-sm">
<q-img <q-img
v-else :src="img"
src="@/assets/camera.jpg" :style="{
:style=" width: videoWidth + 'px',
$q.screen.gt.xs ? 'height: 350px;' : 'height: 220px;' height: videoHeight + 'px',
" }"
> class="q-mt-lg"
</q-img> ></q-img>
<!-- <div class="absolute-bottom-right q-ma-md"> <canvas
ref="canvas"
:width="canvasWidth"
:height="canvasHeight"
:style="{
width: videoWidth + 'px',
height: videoHeight + 'px',
}"
></canvas>
</div>
<div class="absolute-bottom-right q-ma-md">
<q-btn <q-btn
round round
push push
icon="mdi-camera" icon="mdi-camera"
size="md" size="md"
color="positive" color="positive"
@click="photo()" @click="capturePhoto"
/> />
</div> --> </div>
</div>
</q-card> </q-card>
</div> </div>
<div class="col-12 q-mb-md"> <div class="col-12 q-mb-md">
<q-card bordered flat :class="$q.screen.gt.xs ? 'q-px-md q-py-sm row items-center shadow-0': 'q-pa-md row items-center shadow-0'"> <q-card
bordered
flat
:class="
$q.screen.gt.xs
? 'q-px-md q-py-sm row items-center shadow-0'
: 'q-pa-md row items-center shadow-0'
"
>
<div class="text-weight-bold">สถานททำงาน</div> <div class="text-weight-bold">สถานททำงาน</div>
<div :class="$q.screen.gt.xs ? 'row q-gutter-md q-pl-md col-sm-6 col-md-3': 'column col-12'"> <div
<q-radio v-model="workplace" checked-icon="task_alt" unchecked-icon="panorama_fish_eye" val="in-place" label="ในสถานที่" /> :class="
<q-radio v-model="workplace" checked-icon="task_alt" unchecked-icon="panorama_fish_eye" val="off-site" label="นอกสถานที่" /> $q.screen.gt.xs
? 'row q-gutter-md q-pl-md col-sm-6 col-md-3'
: 'column col-12'
"
>
<q-radio
v-model="workplace"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="in-place"
label="ในสถานที่"
/>
<q-radio
v-model="workplace"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="off-site"
label="นอกสถานที่"
/>
</div> </div>
<div class="col-xs-12 col-sm-6 col-md-4"> <div class="col-xs-12 col-sm-6 col-md-4">
<q-select v-if="workplace == 'off-site'" dense class="q-ml-md" outlined v-model="model" :options="options" prefix="ระบุสถานที่ :" /> <q-select
v-if="workplace == 'off-site'"
dense
class="q-ml-md"
outlined
v-model="model"
:options="options"
prefix="ระบุสถานที่ :"
/>
</div> </div>
</q-card> </q-card>
</div> </div>
@ -144,8 +207,8 @@
</div> </div>
<div class="col-12 q-pa-md"> <div class="col-12 q-pa-md">
<q-btn <q-btn
:label="checkIn == true ? 'ลงเวลาเข้างาน': 'ลงเวลาออกงาน'" :label="checkIn == true ? 'ลงเวลาเข้างาน' : 'ลงเวลาออกงาน'"
:color="checkIn == true ? 'primary': 'red-9'" :color="checkIn == true ? 'primary' : 'red-9'"
push push
size="14px" size="14px"
:class="$q.screen.gt.xs ? 'q-px-md' : 'full-width'" :class="$q.screen.gt.xs ? 'q-px-md' : 'full-width'"
@ -167,9 +230,7 @@
</div> </div>
<q-card-section class="row col-12 justify-center"> <q-card-section class="row col-12 justify-center">
<div class="bg-grey-2 rounded-borders q-pa-md col-11"> <div class="bg-grey-2 rounded-borders q-pa-md col-11">
<div <div class="col-12 text-subtitle1 text-center text-weight-medium">
class="col-12 text-subtitle1 text-center text-weight-medium"
>
{{ Thai }} {{ Thai }}
</div> </div>
<div class="row col-12 justify-center q-pt-sm"> <div class="row col-12 justify-center q-pt-sm">
@ -180,13 +241,21 @@
</div> </div>
</div> </div>
<div class="col-12 text-center row q-pt-md"> <div class="col-12 text-center row q-pt-md">
<div class="col-12 text-subtitle1 text-weight-medium text-secondary">{{location}}</div> <div class="col-12 text-subtitle1 text-weight-medium text-secondary">
{{ location }}
</div>
<div class="col-12 text-grey-7">{{ coordinates }}</div> <div class="col-12 text-grey-7">{{ coordinates }}</div>
</div> </div>
</q-card-section> </q-card-section>
<q-card-actions align="center" class="q-mb-md row"> <q-card-actions align="center" class="q-mb-md row">
<q-btn class="col-xs-11 col-sm-6" push label="ตกลง" color="secondary" v-close-popup /> <q-btn
class="col-xs-11 col-sm-6"
push
label="ตกลง"
color="secondary"
v-close-popup
/>
</q-card-actions> </q-card-actions>
</q-card> </q-card>
</q-dialog> </q-dialog>
@ -200,21 +269,24 @@ import { useRouter } from "vue-router";
import moment, { Moment } from "moment"; import moment, { Moment } from "moment";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
const mixin = useCounterMixin(); const mixin = useCounterMixin();
const { const { dateThai } = mixin;
dateThai,
} = mixin;
// import mapCheckin from "../componenst/mapCheck.vue"; // import mapCheckin from "../componenst/mapCheck.vue";
const router = useRouter(); const router = useRouter();
const $q = useQuasar(); const $q = useQuasar();
const dateNow = ref(new Date()); const dateNow = ref(new Date());
const Thai = ref(dateThai(dateNow.value)) const Thai = ref(dateThai(dateNow.value));
const location = ref('สำนักงาน ก.ก'); const location = ref("สำนักงาน ก.ก");
const coordinates = ref('13° 43 45” N 100° 31 26” E'); const coordinates = ref("13° 43 45” N 100° 31 26” E");
const workplace = ref('in-place'); const workplace = ref("in-place");
const model = ref(null); const model = ref(null);
const options = ref(['ปฏิบัติงานที่บ้าน', 'ลืมลงเวลาปฏิบัติงาน', 'ไปประชุม/อบรม/สัมมนา/ปฏิบัติงานที่บ้านนอกสถานที่', 'ขออนุญาตออกนอกสถานที่']); const options = ref([
"ปฏิบัติงานที่บ้าน",
"ลืมลงเวลาปฏิบัติงาน",
"ไปประชุม/อบรม/สัมมนา/ปฏิบัติงานที่บ้านนอกสถานที่",
"ขออนุญาตออกนอกสถานที่",
]);
const checkIn = ref(true); // () true 2 () false const checkIn = ref(true); // () true 2 () false
@ -223,10 +295,57 @@ const dialogTime = ref(false);
const photo = () => { const photo = () => {
camera.value = true; camera.value = true;
camera.value && setupCamera();
}; };
const confirm = () => { const confirm = () => {
dialogTime.value = true; dialogTime.value = true;
}; };
const mediaStream = ref<MediaStream | null>(null);
const video = ref<HTMLVideoElement | null>(null);
const canvas = ref<HTMLCanvasElement | null>(null);
const hasPhoto = ref<boolean>(true);
const img = ref<any>();
const videoWidth = ref<number>(335);
const videoHeight = ref<number>(350);
const canvasWidth = ref<number>(335);
const canvasHeight = ref<number>(350);
function capturePhoto() {
const videoElement = video.value;
const canvasElement = canvas.value;
if (!videoElement || !canvasElement) {
console.error("Video or Canvas element not available");
return;
}
const context = canvasElement.getContext("2d");
if (!context) {
console.error("Canvas context not available");
return;
}
context.drawImage(videoElement, 0, 0, 335, 270);
//
const dataURL = canvasElement.toDataURL(".image/.png");
img.value = dataURL;
console.log(img.value);
if (mediaStream.value) {
mediaStream.value.getTracks().forEach((track) => track.stop());
videoElement.srcObject = null;
hasPhoto.value = false;
}
}
const setupCamera = async () => {
try {
const stream = await navigator.mediaDevices.getUserMedia({ video: true });
if (video.value) {
video.value.srcObject = stream;
}
mediaStream.value = stream;
} catch (error) {
console.error("Error accessing camera:", error);
}
};
// var date = Date.now(); // var date = Date.now();
// let formattedH = moment(date).format("HH"); // let formattedH = moment(date).format("HH");
@ -262,7 +381,7 @@ const getClass = (val: boolean) => {
</script> </script>
<style> <style>
.q-card.cardImg:hover{ .q-card.cardImg:hover {
border: 1px solid #02A998 !important; border: 1px solid #02a998 !important;
} }
</style> </style>