Merge branch 'develop' into devTee

# Conflicts:
#	src/api/12_evaluatePersonal/api.evaluate.ts
This commit is contained in:
setthawutttty 2023-12-22 18:21:51 +07:00
commit 5c7001a2b5
10 changed files with 150 additions and 102 deletions

View file

@ -1,7 +1,8 @@
<script setup lang="ts">
import { ref, reactive, watch } from "vue";
import { ref, reactive, watch, onMounted } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { useRoute } from "vue-router";
import type {
FormData,
FormRef,
@ -9,7 +10,8 @@ import type {
} from "@/modules/12_evaluatePersonal/interface/index/meeting";
import http from "@/plugins/http";
import config from "@/app.config";
const route = useRoute();
const id = ref<string>(route.params.id as string);
const $q = useQuasar();
const mixin = useCounterMixin();
const {
@ -42,10 +44,11 @@ const emit = defineEmits(["formDataReturn"]);
*/
//
const idCard = ref<string>("");
const file = ref<any>();
const fileOj = reactive<FileOj[]>([]);
const formData = reactive<FormData>({
id: "",
rounded: "",
dateMeeting: "",
dateMeetingStart: null,
@ -53,7 +56,7 @@ const formData = reactive<FormData>({
consider: "",
period: "",
title: "",
file: fileOj,
// file: fileOj,
});
/**
@ -63,6 +66,7 @@ const formData = reactive<FormData>({
*/
watch(props.data, async () => {
// console.log("data==>", props.data)
formData.id = props.data.id;
formData.rounded = props.data.rounded;
formData.dateMeetingStart = props.data.dateMeetingStart;
formData.dateMeetingEnd = props.data.dateMeetingEnd;
@ -71,45 +75,6 @@ watch(props.data, async () => {
formData.title = props.data.title;
});
// /**
// *
// */
// function addEmployee() {
// if (idCard.value.length === 13) {
// console.log("idCard===>", idCard.value);
// showLoader();
// http
// .post(config.API.profileSearchPersonal(), {
// fieldName: "idcard",
// keyword: idCard.value,
// })
// .then((res) => {
// const dataApi = res.data.result;
// if (dataApi.length > 0) {
// const dataList = dataApi[0];
// formData.rounded = dataList.rounded;
// formData.dateMeeting = dataList.dateMeeting;
// formData.consider = dataList.consider;
// formData.period = dataList.period;
// } else {
// dialogMessageNotify($q, "");
// }
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// hideLoader();
// });
// }
// if (idCard.value.length !== 13) {
// hideLoader();
// dialogMessageNotify($q, " 13 ");
// } else {
// console.log("nodata");
// }
// }
/**
* ตรวจสอบขอมลกอนสงไปย api
*/
@ -146,29 +111,85 @@ function onValidate() {
}
}
function uploadFile() {
// const Data = new FormData();
// Data.append("file", formData.file);
// showLoader();
// http
// .put(config.API.appealUpLoadFile(formData.id), Data)
// .then((res) => {
// console.log(res);
// success($q, "");
// props.getData();
// // router.push(`/discipline/complaints`);
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// hideLoader();
// formData.file = null;
// });
}
const fileData = ref<any>([]);
/**
* งคาจาก api
*/
const fetchDataFile = async () => {
if (id.value != undefined) {
showLoader();
await http
.get(config.API.meetingFilebyId("การประชุม", id.value))
.then((res) => {
// const dataFile = res.data.result;
const dataFile = res.data;
fileData.value = dataFile;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
};
function downloadFile(link: string) {
window.open(link, "_blank");
/**
* function download
*/
const fileDataDownload = ref<any>([]);
const fetchDataFileDownload = async (pathName: string) => {
console.log(fileData.value[0].fileName);
if (id.value !== undefined) {
showLoader();
console.log(fileData.value[0].fileName);
await http
.get(config.API.meetingFileDowloadbyId("การประชุม", id.value, pathName))
.then((res) => {
const dataFile = res.data;
fileDataDownload.value = dataFile;
window.open(fileDataDownload.value.downloadUrl);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
};
/**
* addFiles
*/
function uploadFile() {
fetchDataFile();
if (file) {
const fileList = [
{
fileName: file.value.name,
metadata: {
tag: "value",
},
},
];
const requestBody = {
replace: false,
fileList: fileList,
};
showLoader();
http
.post(config.API.meetingFilebyId("การประชุม", id.value), requestBody)
.then((res) => {})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
file.value = null;
setTimeout(() => fetchDataFile(), 500);
});
}
}
function deleteFile(id: string) {
@ -179,19 +200,19 @@ function deleteFile(id: string) {
* นย ลบ ไฟล
* @param id id file
*/
function confirmDelete(id: string) {
// showLoader();
// http
// .delete(config.API.appealDeleteFile(formData.id, id))
// .then((res) => {
// success($q, ``);
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// props.getData();
// });
function confirmDelete(fileName: string) {
showLoader();
http
.delete(config.API.meetingFileDowloadbyId("การประชุม", id.value, fileName))
.then((res) => {
success($q, `ลบไฟล์สำเร็จ`);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
setTimeout(() => fetchDataFile(), 1000);
});
}
//checkDate
@ -211,6 +232,12 @@ function inputEdit(val: boolean) {
"full-width cursor-pointer inputgreen": !val,
};
}
/**Hook */
onMounted(() => {
setTimeout(() => fetchDataFile(), 500);
// fetchDataFileDownload();
});
</script>
<template>
<form @submit.prevent.stop="onValidate">
@ -342,7 +369,7 @@ function inputEdit(val: boolean) {
:rules="[(val: string) => !!val || `${'กรุณากรอกระยะเวลาในการแก้ไขผลงาน'}`]"
/>
</div>
<div class="col-sm-12 col-md-12">
<div class="col-sm-12 col-md-12" v-if="id">
<q-card bordered class="row col-12" style="border: 1px solid #d6dee1">
<div class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md">
ปโหลดไฟลเอกสารหลกฐาน
@ -354,7 +381,7 @@ function inputEdit(val: boolean) {
class="col-11"
outlined
dense
v-model="formData.file"
v-model="file"
@added="uploadFile"
label="ไฟล์เอกสารหลักฐาน"
hide-bottom-space
@ -369,22 +396,22 @@ function inputEdit(val: boolean) {
<div class="col-1 self-center text-center">
<q-btn
v-if="formData.file && isReadonly"
size="14px"
flat
round
dense
color="add"
icon="mdi-upload"
v-if="file"
@click="uploadFile"
><q-tooltip>ปโหลดไฟล</q-tooltip></q-btn
>
</div>
</div>
<div v-if="formData.file.length > 0" class="col-12 q-pa-sm row">
<div class="col-12 q-pa-sm row" v-if="fileData.length > 0">
<!-- v-if="file.length > 0" v-else -->
<q-list
v-for="data in formData.file"
v-for="data in fileData"
:key="data.id"
class="full-width"
bordered
@ -400,7 +427,7 @@ function inputEdit(val: boolean) {
dense
color="blue"
icon="mdi-download"
@click="downloadFile(data.pathName)"
@click="fetchDataFileDownload(data.fileName)"
><q-tooltip>ดาวนโหลดไฟล</q-tooltip></q-btn
>
<q-btn
@ -411,7 +438,7 @@ function inputEdit(val: boolean) {
color="red"
class="q-ml-sm"
icon="mdi-delete-outline"
@click="deleteFile(data.id)"
@click="deleteFile(data.fileName)"
><q-tooltip>ลบไฟล</q-tooltip></q-btn
>
</q-item>

View file

@ -13,7 +13,14 @@ interface MainList {
date: string;
}
interface ArrayFileList {
id: string;
pathName: string;
fileName: string;
}
interface FormData {
id: string;
rounded: string;
dateMeeting: string;
dateMeetingStart: Date | null;
@ -21,7 +28,7 @@ interface FormData {
consider: string;
period: string;
title: string;
file: FileOj[];
// file: FileOj[];
}
interface FileOj {
@ -38,4 +45,11 @@ interface FormRef {
period: object | null;
[key: string]: any;
}
export type { DataResponseList, MainList, FormData, FormRef, FileOj };
export type {
DataResponseList,
MainList,
FormData,
FormRef,
FileOj,
ArrayFileList,
};