อัปโหลด ลบ ไฟล์
This commit is contained in:
parent
3e60af46be
commit
dba49467eb
1 changed files with 102 additions and 11 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, defineProps } from "vue";
|
import { ref, defineProps,onMounted } from "vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
|
|
@ -9,9 +9,13 @@ import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsSt
|
||||||
const store = useSalaryListSDataStore();
|
const store = useSalaryListSDataStore();
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
|
|
||||||
|
const modalRecommend = ref<boolean>(false);
|
||||||
|
const titleRecommend = ref<string>("");
|
||||||
|
const listFile = ref<any>([])
|
||||||
const $q = useQuasar(); //ใช้ noti quasar
|
const $q = useQuasar(); //ใช้ noti quasar
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { messageError, dialogConfirm, showLoader, hideLoader, success } = mixin;
|
const { messageError, dialogConfirm, showLoader, hideLoader, success,dialogRemove } = mixin;
|
||||||
const type = ref<string>("");
|
const type = ref<string>("");
|
||||||
const sendStep = ref<number>(1);
|
const sendStep = ref<number>(1);
|
||||||
const fileUpload = ref<any>(null);
|
const fileUpload = ref<any>(null);
|
||||||
|
|
@ -53,7 +57,7 @@ async function uploadFile(event: any) {
|
||||||
res.data[key]?.fileName !== undefined &&
|
res.data[key]?.fileName !== undefined &&
|
||||||
res.data[key]?.fileName !== ""
|
res.data[key]?.fileName !== ""
|
||||||
);
|
);
|
||||||
foundKey && uploadfile(res.data[foundKey]?.uploadUrl, fileUpload);
|
foundKey && uploadfile(res.data[foundKey]?.uploadUrl, fileUpload.value);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -100,13 +104,14 @@ function getListFile() {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
listFile.value = res.data
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
})
|
})
|
||||||
.finally(() => {});
|
.finally(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveReccommend(reason: string) {
|
function saveReccommend(reason: string) {
|
||||||
dialogConfirm(
|
dialogConfirm(
|
||||||
$q,
|
$q,
|
||||||
|
|
@ -168,18 +173,71 @@ function sendToDirector(msg: string, type: string) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const modalRecommend = ref<boolean>(false);
|
function downloadFile(fileName: string) {
|
||||||
const titleRecommend = ref<string>("");
|
showLoader();
|
||||||
|
http
|
||||||
|
.get(
|
||||||
|
config.API.subFileByFileName(
|
||||||
|
"ระบบเงินเดือน",
|
||||||
|
"เลื่อนเงินเดือน",
|
||||||
|
props.periodId ? props.periodId : "",
|
||||||
|
props.rootId ? props.rootId : "",
|
||||||
|
fileName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data.downloadUrl;
|
||||||
|
window.open(data, "_blank");
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteFile(fileName: string) {
|
||||||
|
dialogRemove($q, () => {
|
||||||
|
showLoader();
|
||||||
|
http
|
||||||
|
.delete(
|
||||||
|
config.API.subFileByFileName(
|
||||||
|
"ระบบเงินเดือน",
|
||||||
|
"เลื่อนเงินเดือน",
|
||||||
|
props.periodId ? props.periodId : "",
|
||||||
|
props.rootId ? props.rootId : "",
|
||||||
|
fileName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
success($q, "ลบไฟล์สำเร็จ");
|
||||||
|
setTimeout(() => {
|
||||||
|
getListFile();
|
||||||
|
hideLoader();
|
||||||
|
}, 1000);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(async () => {});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function sendAndRecommend(title: string, typeOrder: string) {
|
function sendAndRecommend(title: string, typeOrder: string) {
|
||||||
modalRecommend.value = true;
|
modalRecommend.value = true;
|
||||||
titleRecommend.value = title;
|
titleRecommend.value = title;
|
||||||
type.value = typeOrder;
|
type.value = typeOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(()=>{
|
||||||
|
getListFile()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="row col-12 q-pa-md">
|
<div class="row col-12 q-pa-md">
|
||||||
<q-toolbar>
|
<q-toolbar class="q-pa-none">
|
||||||
<q-file
|
<q-file
|
||||||
v-if="store.statusQuota == 'PENDING'"
|
v-if="store.statusQuota == 'PENDING'"
|
||||||
bg-color="white"
|
bg-color="white"
|
||||||
|
|
@ -284,15 +342,48 @@ function sendAndRecommend(title: string, typeOrder: string) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</q-toolbar>
|
</q-toolbar>
|
||||||
<div class="col-12">
|
<div class="col-6" v-if="listFile.length !== 0">
|
||||||
asdasd
|
<q-card bordered style="border: 1px solid #d6dee1">
|
||||||
<q-card bordered class="row" style="border: 1px solid #d6dee1">
|
|
||||||
<div class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md">
|
<div class="col-12 text-weight-medium bg-grey-1 q-py-sm q-px-md">
|
||||||
รายการเอกสาร
|
รายการเอกสาร
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12"><q-separator /></div>
|
<q-list bordered separator>
|
||||||
|
<q-item clickable v-ripple v-for="item in listFile">
|
||||||
|
<q-item-section>{{ item.fileName }}</q-item-section>
|
||||||
|
<q-item-section avatar>
|
||||||
|
<div class="row">
|
||||||
|
<div>
|
||||||
|
<q-btn
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
size="12px"
|
||||||
|
color="blue"
|
||||||
|
icon="mdi-download-outline"
|
||||||
|
@click="downloadFile(item.fileName)"
|
||||||
|
>
|
||||||
|
<q-tooltip>ดาวน์โหลดเอกสาร</q-tooltip>
|
||||||
|
</q-btn>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<q-btn
|
||||||
|
dense
|
||||||
|
flat
|
||||||
|
round
|
||||||
|
size="12px"
|
||||||
|
color="red"
|
||||||
|
icon="mdi-delete-outline"
|
||||||
|
@click="deleteFile(item.fileName)"
|
||||||
|
><q-tooltip>ลบเอกสาร</q-tooltip></q-btn
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<DialogPopupReason
|
<DialogPopupReason
|
||||||
v-model:modal="modalRecommend"
|
v-model:modal="modalRecommend"
|
||||||
:title="titleRecommend"
|
:title="titleRecommend"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue