From 51417debf424722b583ecf224ae71d0cd0d0cdae Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Thu, 29 Feb 2024 10:23:42 +0700 Subject: [PATCH] upfile popup --- .../components/SalaryChart/DialogFormMain.vue | 647 ++++++------------ .../components/SalaryChart/DialogUpload.vue | 387 +++++++++++ src/modules/13_salary/views/salaryChart.vue | 27 +- 3 files changed, 638 insertions(+), 423 deletions(-) diff --git a/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue b/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue index ab5e01f6a..0c955d58d 100644 --- a/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue +++ b/src/modules/13_salary/components/SalaryChart/DialogFormMain.vue @@ -237,78 +237,8 @@ function createSalary() { }); } -async function uploadDocumentFile() { - const fileName = documentFile.value.name.replace(/\.(xlsx|docx|pdf)$/, ""); - showLoader(); - const formData = new FormData(); - formData.append("file", documentFile.value); - const body = { - replace: false, - fileList: { - fileName: fileName, - }, - }; - await http - .post(config.API.salaryChartFile(salaryId.value), body) - .then((res) => { - console.log(res); - const foundKey: any = Object.keys(res.data).find( - (key) => - res.data[key]?.fileName !== undefined && - res.data[key]?.fileName !== "" - ); - const link = res.data[foundKey]?.uploadUrl; - fileUpLoad(link); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} -/** - * function อัปโหลดไฟล์ - * @param url link อัปโหลด - */ -function fileUpLoad(url: string) { - axios - .put(url, documentFile.value, { - headers: { "Content-Type": documentFile.value?.type }, - onUploadProgress: (e) => console.log(e), - }) - .then(() => { - success($q, "อัปโหลดไฟล์สำเร็จ"); - documentFile.value = null; - fetchDocumentFile(salaryId.value); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => {}); -} -function onClickDeleteFile(fileName: string) { - dialogRemove($q, async () => { - showLoader(); - await http - .delete(config.API.salaryChartDelFile(salaryId.value, fileName)) - .then(() => { - setTimeout(() => { - fetchDocumentFile(salaryId.value); - success($q, "ลบไฟล์สำเร็จ"); - }, 1000); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - setTimeout(() => { - hideLoader(); - }, 1000); - }); - }); -} + /** function checkEndDate*/ function checkEndDate() { @@ -319,20 +249,6 @@ function checkEndDate() { } } -async function onClickDonwload(fileName: string) { - showLoader(); - await http - .get(config.API.salaryChartDelFile(salaryId.value, fileName)) - .then((res) => { - const data = res.data; - downloadFile(data.downloadUrl, data.fileType, fileName); - }) - .catch((err) => { - messageError($q, err); - hideLoader(); - }); -} - /** * function เรียกไฟล์ PDF * @param url link PDF @@ -370,351 +286,242 @@ async function downloadFile(url: string, type: string, fileName: string) {
- +
-
-
- -
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ - ข้อมูลผังบัญชีเงินเดือน -
-
-
-
- -
- -
- -
- -
- -
- -
- -
- -
- -
- -
- - - - - -
- -
- - - - - -
- -
- - - - - -
- -
+ + + +
- + +
+ + + + + +
+ +
+ + + + + +
+ +
+ +
+
+ +
+ + บันทึกข้อมูล + +
diff --git a/src/modules/13_salary/components/SalaryChart/DialogUpload.vue b/src/modules/13_salary/components/SalaryChart/DialogUpload.vue index e69de29bb..dffb98a71 100644 --- a/src/modules/13_salary/components/SalaryChart/DialogUpload.vue +++ b/src/modules/13_salary/components/SalaryChart/DialogUpload.vue @@ -0,0 +1,387 @@ + + + + + diff --git a/src/modules/13_salary/views/salaryChart.vue b/src/modules/13_salary/views/salaryChart.vue index 2c57a3d1c..ca827071c 100644 --- a/src/modules/13_salary/views/salaryChart.vue +++ b/src/modules/13_salary/views/salaryChart.vue @@ -13,7 +13,7 @@ import type { } from "@/modules/13_salary/interface/index/Main"; import type { Salary } from "@/modules/13_salary/interface/response/Main"; import type { FormQuerySalary } from "@/modules/13_salary/interface/request/Main"; - +import DialogFormUpload from '@/modules/13_salary/components/SalaryChart/DialogUpload.vue' import DialogFormMain from "@/modules/13_salary/components/SalaryChart/DialogFormMain.vue"; /** importStore*/ @@ -33,7 +33,8 @@ const { /** modalDialog*/ const modalDialogFormMain = ref(false); - +const modalUpload = ref(false); +const rowId = ref('') /** Table*/ const rows = ref([]); const columns = ref([ @@ -99,6 +100,12 @@ const itemMenu = ref([ color: "edit", type: "edit", }, + { + label: "อัปโหลดเอกสารอ้างอิง", + icon: "mdi-upload", + color: "teal", + type: "upload", + }, { label: "อัตราเงินเดือน", icon: "mdi-format-list-bulleted-triangle", @@ -203,6 +210,12 @@ async function onClickDelete(id: string) { }); } +async function onClickUpload(type: string,id: string) { + modalUpload.value = true + typeAction.value = type; + rowId.value = id +} + onMounted(async () => { await fetchListSalaly(); }); @@ -320,7 +333,7 @@ async function filterFn(page: number) { size="12px" > - + +