เพิ่มapi download เอกสาร

This commit is contained in:
setthawutttty 2023-09-11 17:16:35 +07:00
parent 0171aec669
commit dd27f0c835
2 changed files with 51 additions and 62 deletions

View file

@ -1,6 +1,9 @@
interface attachments {
name: string;
url: string;
}
interface ResponseInbox { interface ResponseInbox {
body: string; body: string;
createdAt: Date;
createdFullName: string; createdFullName: string;
createdUserId: string; createdUserId: string;
id: string; id: string;
@ -9,7 +12,7 @@ interface ResponseInbox {
lastUpdateUserId: string; lastUpdateUserId: string;
lastUpdatedAt: Date; lastUpdatedAt: Date;
openDate: Date | null; openDate: Date | null;
payload: string; payload: {attachments:attachments[]}
receiveDate: Date; receiveDate: Date;
receiverUserId: string; receiverUserId: string;
subject: string; subject: string;
@ -21,7 +24,7 @@ interface DataInbox {
subject: string; subject: string;
timereceive: Date; timereceive: Date;
body: string; body: string;
payload: string; payload: {attachments:attachments[]}
ratingModel: number; ratingModel: number;
} }

View file

@ -20,41 +20,15 @@ const {
success, success,
messageError, messageError,
date2Thai, date2Thai,
dialogRemove dialogRemove,
} = mixin; } = mixin;
const iteminbox = ref<any>([]); const iteminbox = ref<any>([]);
const splitterModel = ref<number>(30); const splitterModel = ref<number>(30);
const link = ref<string>("0"); const link = ref<string>("0");
const inboxList = ref<DataInbox[]>([ const inboxList = ref<DataInbox[]>([]);
// { const data = ref<DataInbox[]>([]);
// no: "1", const payLoadtext = ref<string>();
// sender: "",
// subject: "",
// timereceive: new Date(),
// body: " -",
// ratingModel: 0,
// },
// {
// no: "2",
// sender: "",
// subject: "",
// timereceive: new Date(),
// body: " -",
// ratingModel: 0,
// },
]);
const data = ref<DataInbox[]>([
// {
// no: "1",
// sender: "",
// subject: "",
// timereceive: new Date(),
// body: " -",
// ratingModel: 0,
// },
]);
const payLoadtext = ref<string>()
const btnReply = ref<boolean>(true); const btnReply = ref<boolean>(true);
const listpayload = ref<any>([]); const listpayload = ref<any>([]);
const listpayloadNolink = ref<any>([]); const listpayloadNolink = ref<any>([]);
@ -86,10 +60,10 @@ const getData = async () => {
await http await http
.get(config.API.msgInbox) .get(config.API.msgInbox)
.then((res: any) => { .then((res: any) => {
const response = res.data.result; const data = res.data.result;
console.log(response); console.log(data);
let list: DataInbox[] = []; let list: DataInbox[] = [];
response.map((e: ResponseInbox) => { data.map((e: ResponseInbox) => {
list.push({ list.push({
no: e.id ?? "", no: e.id ?? "",
sender: sender:
@ -104,7 +78,10 @@ const getData = async () => {
}); });
}); });
inboxList.value = list; inboxList.value = list;
}) console.log("🚀 ~ file: Dashboard.vue:82 ~ .then ~ inboxList:", inboxList.value)
}
)
.catch((e) => { .catch((e) => {
// messageError($q, e); // messageError($q, e);
}) })
@ -117,26 +94,29 @@ const selectInbox = (id: string) => {
link.value = id; link.value = id;
data.value = inboxList.value.filter((r) => r.no == id); data.value = inboxList.value.filter((r) => r.no == id);
}; };
const deleteData = (id:string) => { const deleteData = (id: string) => {
dialogRemove($q, () => removeData(id)) dialogRemove($q, () => removeData(id));
} };
// api // api
const removeData = async (id:string) => { const removeData = async (id: string) => {
console.log("delete=",id) console.log("delete=", id);
showLoader(); showLoader();
await http await http
.delete(config.API.msgInboxDelete(id)) .delete(config.API.msgInboxDelete(id))
.then((res) => { .then((res) => {
success($q, "ลบข้อมูลสำเร็จ"); success($q, "ลบข้อมูลสำเร็จ");
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {
getData() getData();
hideLoader() hideLoader();
}) });
};
const fileOpen = (url:string) => {
window.open(url, '_blank');
} }
</script> </script>
@ -170,6 +150,7 @@ await http
:key="contact.no" :key="contact.no"
class="q-pt-sm" class="q-pt-sm"
> >
<q-item <q-item
clickable clickable
v-ripple v-ripple
@ -199,7 +180,7 @@ await http
/> --> /> -->
<q-icon <q-icon
v-if="contact.payload !== null " v-if="contact.payload !== null"
class="q-mt-md" class="q-mt-md"
name="mdi-paperclip" name="mdi-paperclip"
color="grey-5" color="grey-5"
@ -306,14 +287,19 @@ await http
:style="$q.screen.gt.xs ? 'height: 64vh' : ''" :style="$q.screen.gt.xs ? 'height: 64vh' : ''"
>{{ d.body }}</q-card >{{ d.body }}</q-card
> >
<div :class="$q.screen.gt.xs ? 'absolute-bottom q-mb-md' : ''"> <div :class="$q.screen.gt.xs ? 'absolute-bottom q-mb-md' : ''">
<div class="row col-12 self-center q-px-md q-pt-md"> <div class="row col-12 self-center q-px-md q-pt-md">
<div v-if="d.payload !== ''" class="row self-center"> <q-btn v-if="d.payload !== null" color="primary" label="เอกสารแนบ" icon="mdi-paperclip" outline>
<q-icon name="mdi-paperclip" color="grey" size="xs" /> <q-menu transition-show="jump-down" transition-hide="jump-up" anchor="top middle" self="bottom middle">
<div class="text-grey-8 q-pl-sm text-weight-light"> <q-list style="min-width: 160px">
เอกสารแนบ <q-item clickable v-for="(link,num) in d.payload.attachments" :key="num" @click="fileOpen(link.url)">
</div> <q-item-section>{{ link.name }}</q-item-section>
</div> </q-item>
<q-separator />
</q-list>
</q-menu>
</q-btn>
<!-- <q-btn <!-- <q-btn
unelevated unelevated
size="12px" size="12px"