เพิ่ม api download แก้บัคต่างๆ ฟอร์มลา

This commit is contained in:
AnandaTon 2023-12-25 18:13:36 +07:00
parent fd4f6038b2
commit 4d9be43479
4 changed files with 44 additions and 5 deletions

View file

@ -301,8 +301,8 @@ function resetEndDate(type: string) {
borderless
:enableTimePicker="false"
week-start="0"
:readonly="isReadOnly"
@update:model-value="FetchCheck()"
:readonly="!formDataSick.leaveStartDate"
@update:model-value="FetchCheck(), isReadOnly"
:min-date="formDataSick.leaveStartDate"
>
<template #year="{ year }">
@ -319,7 +319,7 @@ function resetEndDate(type: string) {
for="leaveEndDateRef"
hide-bottom-space
bg-color="white"
:readonly="isReadOnly"
:readonly="!formDataSick.leaveStartDate"
:class="inputEdit(isReadOnly)"
:model-value="formDataSick.leaveEndDate != null ? date2Thai(formDataSick.leaveEndDate) : null"
:label="`${'ลาถึงวันที่'}`"

View file

@ -7,6 +7,7 @@ import { useLeaveStore } from "@/modules/05_leave/store"
import http from "@/plugins/http"
import config from "@/app.config"
import { useRouter } from "vue-router"
import genReport from "@/plugins/genreport"
/** Use */
const dataStore = useLeaveStore()
@ -106,6 +107,24 @@ const onSubmit = async () => {
)
}
//download function
async function onClickDownloadFile(id: string, fileName: string) {
// showLoader();
await http
.get(config.API.leaveReport(id))
.then(async res => {
console.log(res)
const data = res.data.result
await genReport(data, fileName)
})
.catch(err => {
messageError($q, err)
})
.finally(() => {
// hideLoader();
})
}
/**
* check าลาไดไหม จาก api
* @param formData
@ -350,7 +369,7 @@ async function saveFormData() {
<div class="col-12 col-sm-4 col-md-4 q-my-sm offset-sm-1 offset-md-2">
<div class="column q-mx-xs">
<div class="q-pl-sm text-weight-bold text-dark text-center">ดาวนโหลด</div>
<q-btn color="primary" icon="download" label="ดาวน์โหลดแบบฟอร์ม" />
<q-btn color="primary" icon="download" label="ดาวน์โหลดแบบฟอร์ม" @click="onClickDownloadFile(formDataWorkInternational.typeId, 'dataStore.typeId')" />
</div>
</div>
<div class="col-10 col-sm-5 col-md-4 q-my-sm">

View file

@ -7,6 +7,7 @@ import { useLeaveStore } from "@/modules/05_leave/store"
import http from "@/plugins/http"
import config from "@/app.config"
import { useRouter } from "vue-router"
import genReport from "@/plugins/genreport"
/** Use */
const dataStore = useLeaveStore()
@ -115,6 +116,24 @@ async function FetchCheck() {
})
}
//download function
async function onClickDownloadFile(id: string, fileName: string) {
// showLoader();
await http
.get(config.API.leaveReport(id))
.then(async res => {
console.log(res)
const data = res.data.result
await genReport(data, fileName)
})
.catch(err => {
messageError($q, err)
})
.finally(() => {
// hideLoader();
})
}
/**
* งชนบนทกขอมลจาก formdata งไปท Api
*/
@ -294,7 +313,7 @@ async function saveFormData() {
<div class="col-12 col-sm-4 col-md-4 q-my-sm offset-sm-1 offset-md-2">
<div class="column q-mx-xs">
<div class="q-pl-sm text-weight-bold text-dark text-center">ดาวนโหลด</div>
<q-btn color="primary" icon="download" label="ดาวน์โหลดแบบฟอร์ม" />
<q-btn color="primary" icon="download" label="ดาวน์โหลดแบบฟอร์ม" @click="onClickDownloadFile(formDataRehabilitation.typeId, ' dataStore.typeId')" />
</div>
</div>
<div class="col-10 col-sm-5 col-md-4 q-my-sm">