Merge branch 'develop' into nice_dev

# Conflicts:
#	src/api/11_discipline/api.discipline.ts
This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-11-27 17:34:51 +07:00
parent 73a0384fa8
commit eafbc65bf2
6 changed files with 104 additions and 28 deletions

View file

@ -1,7 +1,18 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar } from "quasar";
import type { FileLists } from "@/modules/11_discipline/interface/index/Main";
import { useCounterMixin } from "@/stores/mixin";
const $q = useQuasar();
const mixin = useCounterMixin();
const { showLoader, hideLoader, success, messageError } = mixin;
const fileRef = ref<Object | null>(null);
const file = ref<any>();
@ -28,32 +39,61 @@ const props = defineProps({
required: true,
default: "support",
},
type: {
type: String,
required: true,
},
fetchData: {
type: Function,
default: () => "",
},
});
/**
* ปโหลดหลกฐานสนบสนนขอกลาวหา
*/
function uploadFile() {
async function uploadFile() {
console.log("test");
// const Data = new FormData();
// Data.append("file", file.value);
// showLoader();
// http
// .put(config.API.complaintFileUpload(props.id), Data)
// .then((res) => {
// console.log(res);
// success($q, "");
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(async () => {
// hideLoader();
// });
const Data = new FormData();
Data.append("file", file.value);
showLoader();
await http
.put(config.API.disciplineDoc(props.type, props.id), Data)
.then(() => {
file.value = null;
success($q, "บันทึกข้อมูลสำเร็จ");
props.fetchData();
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
}
function removeFile(id: string) {
console.log(id);
async function removeFile(id: string) {
showLoader();
await http
.delete(config.API.disciplineByIdDoc(props.type, props.id, id))
.then(() => {
success($q, "ลบข้อมูลสำเร็จ");
props.fetchData();
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
}
/**
* เปดลงคไฟล
* @param link บมาเป https งค
*/
function downloadFile(link: string) {
window.open(link, "_blank");
}
</script>
@ -122,7 +162,7 @@ function removeFile(id: string) {
size="12px"
color="blue"
icon="mdi-download-outline"
@href="f.pathName"
@click="downloadFile(f.pathName)"
>
<q-tooltip>ดาวนโหลดเอกสาร</q-tooltip>
</q-btn>