no message

This commit is contained in:
setthawutttty 2023-08-24 11:47:56 +07:00
parent ab32df6dc9
commit dbcf1f0106
2 changed files with 69 additions and 31 deletions

View file

@ -1,14 +1,17 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import type { QTableProps } from "quasar";
import { useQuasar } from "quasar";
import { useCounterMixin } from '@/stores/mixin'
import http from "@/plugins/http";
import config from "@/app.config";
const mixin = useCounterMixin()
const { success, messageError,hideLoader,dialogConfirm } = mixin
const fileUpload = ref<any>(null);
const reason = ref<string>("");
const documentTitle = ref<string>("");
const $q = useQuasar();
const filterKeyword = ref<string>("");
const filterDoc = ref<any>(null);
@ -48,21 +51,12 @@ const colums2 = ref<QTableProps["columns"]>([
sortable: true,
},
]);
const rows2 = ref<any>([
{
no: "1",
fileName: "test1",
annotation: "ทดสอบ",
file: "",
},
{
no: "2",
fileName: "test2",
annotation: "ทดสอบ",
file: "",
},
]);
const rows2 = ref<any>([]);
interface TypeData {
fileName:string
annotation:string
}
const props = defineProps({
roundId: {
type: String,
@ -74,7 +68,45 @@ const getRequest = async () => {
.get(config.API.requestDocNote(props.roundId as string))
.then((res:any) =>{
console.log(res)
const data = res.data.result
console.log(data)
data.map((item:TypeData) =>{
rows2.value.push({
fileName:item.fileName,
annotation:item.annotation
})
}
)
console.log(rows2.value)
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
});
}
const putRequest = () => {
const dataAppend = new FormData()
dataAppend.append("Name",documentTitle.value)
dataAppend.append("Reason",reason.value)
dataAppend.append("File",fileUpload.value)
http
.put(config.API.requestDocNote(props.roundId as string),dataAppend)
.then((res) => {
success($q, "บันทึกข้อมูลสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
documentTitle.value = "";
reason.value = "";
fileUpload.value = null;
getRequest();
hideLoader();
});
}
onMounted(async() => {
console.log(props.roundId);
@ -91,7 +123,7 @@ const pagination = ref({
rowsPerPage: 10,
});
const save = () => {
props.saveData()
dialogConfirm($q,()=>putRequest())
}
</script>
<template>
@ -203,7 +235,7 @@ props.saveData()
{{ props.row.fileName }}
</q-td>
<q-td key="annotation" :props="props">
{{ props.row.annotation }}
{{ props.row.annotation !== undefined ? props.row.annotation:"-"}}
</q-td>
<q-td auto-width>
<q-btn