From 0ec7e83d0d4108292a39fcb89fa26916702a7241 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 24 Nov 2023 16:39:55 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=A5=E0=B8=87=E0=B9=80=E0=B8=A7=E0=B8=A5=E0=B8=B2=E0=B8=81?= =?UTF-8?q?=E0=B8=A3=E0=B8=93=E0=B8=B5=E0=B8=9E=E0=B8=B4=E0=B9=80=E0=B8=A8?= =?UTF-8?q?=E0=B8=A9=20(USER)=20#32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/api.history.ts | 2 + src/components/FormTime.vue | 72 ++++++++++++++++++++++++------- src/components/PopUp.vue | 24 ++++++++--- src/components/ToolBar.vue | 30 +++++++------ src/interface/response/checkin.ts | 24 ++++++++++- src/stores/chekin.ts | 56 ++++++++++++------------ src/stores/mixin.ts | 32 ++++++++++++++ src/views/HistoryView.vue | 36 ++++++++++------ 8 files changed, 196 insertions(+), 80 deletions(-) diff --git a/src/api/api.history.ts b/src/api/api.history.ts index afca0e4..023dbab 100644 --- a/src/api/api.history.ts +++ b/src/api/api.history.ts @@ -1,6 +1,8 @@ import env from './index' const history = `${env.API_URI}/leave/check-in/history` +const TimeStamp = `${env.API_URI}/leave` export default { history: () => `${history}`, + createTimeStamp: () => `${TimeStamp}/user/edit`, } diff --git a/src/components/FormTime.vue b/src/components/FormTime.vue index d77ef68..1d7bf03 100644 --- a/src/components/FormTime.vue +++ b/src/components/FormTime.vue @@ -2,15 +2,19 @@ import { ref, watch, onMounted } from 'vue' import { useQuasar } from 'quasar' import moment from 'moment' +import http from '@/plugins/http' +import config from '@/app.config' + +import type { FormRef } from '@/interface/index/Main' +import type { FormTimeStemp } from '@/interface/response/checkin' // importStores import { useCounterMixin } from '@/stores/mixin' // importType -import type { FormRef } from '@/interface/index/Main' const $q = useQuasar() const mixin = useCounterMixin() -const { date2Thai, covertDateObject, dialogConfirm } = mixin +const { date2Thai, success, dialogConfirm } = mixin const props = defineProps({ dataById: { @@ -21,6 +25,10 @@ const props = defineProps({ type: Function, required: true, }, + fetcthDataTable: { + type: Function, + require: true, + }, }) const dataByIdVal = ref([]) @@ -30,13 +38,6 @@ const checkboxOut = ref(false) const reason = ref('') const statusAction = ref(false) -onMounted(() => { - updateClock() - dataByIdVal.value = props.dataById - if (dataByIdVal.value == null) { - statusAction.value = true - } -}) const dateNow = ref(new Date()) const timeNoew = ref('') @@ -55,7 +56,10 @@ const objectRef: FormRef = { reason: reasonRef, } const checkstatusBox = ref(false) + +/** function checkValidate*/ function onCkickSave() { + props.fetcthDataTable?.() const hasError = [] for (const key in objectRef) { if (Object.prototype.hasOwnProperty.call(objectRef, key)) { @@ -75,14 +79,50 @@ function onCkickSave() { ) ) { dialogConfirm($q, async () => { - console.log('save') - props.closePopup() + const data: FormTimeStemp = { + checkDate: date.value, + checkInEdit: checkboxIn.value, + checkOutEdit: checkboxOut.value, + description: reason.value, + } + createListTime(data) }) } else { console.log('ไม่ผ่าน ') } } +/** + * function เพิ่มลงเวลากรณีพิเศษ + * @param data body Request + */ +async function createListTime(data: FormTimeStemp) { + await http + .post(config.API.createTimeStamp(), data) + .then(() => { + success($q, 'บันทึกข้อมูลาำเร็จ') + }) + .catch((err) => { + console.log(err) + }) + .finally(() => { + props.fetcthDataTable?.() + props.closePopup?.() + }) +} + +/** Hook */ +onMounted(() => { + updateClock() + dataByIdVal.value = props.dataById + + if (dataByIdVal.value == null) { + statusAction.value = true + } else { + date.value = new Date(dataByIdVal.value.checkInDateTime) + } +}) + watch( [() => checkboxIn.value, () => checkboxOut.value], ([newCheckboxIn, newCheckboxOut]) => { @@ -116,7 +156,7 @@ watch(
- + >
@@ -159,7 +199,7 @@ watch(
-
{{ covertDateObject(dataByIdVal.date) }}
+
{{ dataByIdVal.checkInDate }}
@@ -199,7 +239,7 @@ watch( > กรุณาเลือก - + import { ref, watch } from 'vue' + import HeaderPopup from '@/components/HeaderPopup.vue' import FormTime from '@/components/FormTime.vue' @@ -20,24 +21,33 @@ const props = defineProps({ type: Object, default: null, }, + fetcthDataTable: { + type: Function, + require: true, + }, }) -// -ข้อมูล const data = ref() function clickClosePopup() { props.clickClose() } -watch(props, () => { - if (props.modal === true) { - data.value = props.dataById + +watch( + () => props.modal, + () => { + data.value = props.modal ? props.dataById : null } -}) +) diff --git a/src/components/ToolBar.vue b/src/components/ToolBar.vue index ccd6ad3..be36abc 100644 --- a/src/components/ToolBar.vue +++ b/src/components/ToolBar.vue @@ -1,16 +1,24 @@