Merge branch 'develop' into warunee-dev

This commit is contained in:
Warunee Tamkoo 2023-08-08 18:13:05 +07:00
commit 24381193d0
2 changed files with 63 additions and 20 deletions

View file

@ -62,6 +62,7 @@ export default {
typeOrder: () => `${order}/order/order-type`,
nextStep: (orderId: string) => `${order}/order/next/${orderId}`,
prevStep: (orderId: string) => `${order}/order/prev/${orderId}`,
executeOrder: (orderId: string) => `${order}/order/execute/${orderId}`,
createOrder: () => `${order}/order/detail`,

View file

@ -287,6 +287,7 @@
label="ออกคำสั่ง"
:color="validateForm() ? 'public' : 'grey'"
:disable="statusOrder == 'N'"
@click="clickExecute(orderId)"
/>
<q-btn
class="text-dark"
@ -417,7 +418,7 @@
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted, computed } from "vue";
import { ref, onMounted, onUnmounted, computed, watch } from "vue";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
import type { PDFDocumentLoadingTask } from "pdfjs-dist/types/src/display/api";
import type { QForm } from "quasar";
@ -443,38 +444,30 @@ const date = ref<Date>(new Date());
const fileOrder = ref<any>(null);
const fileTailer = ref<any>(null);
const OrderPDF = ref<string>("");
const TailerPDF = ref<string>("");
const statusOrder = ref<string>();
// onUnmounted(() => {
// window.removeEventListener("resize", (e: any) => {
// myEventHandler(e);
// });
// });
const orderId = ref<string>("");
const orderId = ref<string>(orderId_params.toString());
onMounted(async () => {
if (orderId_params !== undefined) {
orderId.value = orderId_params.toString();
if (orderId.value) {
fetchAttachment(orderId.value);
fecthstatusOrder(orderId.value);
}
// window.addEventListener("resize", (e: any) => {
// myEventHandler(e);
// });
// const pdfData = usePDF();
const pdfData = usePDF("/src/assets/05_modules.pdf");
setTimeout(() => {
pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value;
}, 1000);
// setTimeout(() => {
// pdfSrc.value = pdfData.pdf.value;
// numOfPages.value = pdfData.pages.value;
// }, 1000);
});
const fetchAttachment = async (orderId: string) => {
showLoader();
await http
.get(config.API.attachmentOrder(orderId))
.then((res) => {
.then(async (res) => {
let response = res.data.result;
console.log(response);
order.value = response.orderNo;
@ -482,6 +475,13 @@ const fetchAttachment = async (orderId: string) => {
if (response.date !== undefined) {
date.value = response.date;
}
if (response.orderFileUrl !== null) {
OrderPDF.value = response.orderFileUrl;
viewPDF(OrderPDF.value);
}
if (response.attachmentFileUrl !== null) {
TailerPDF.value = response.attachmentFileUrl;
}
})
.catch((e) => {
messageError($q, e);
@ -501,6 +501,24 @@ const fecthstatusOrder = async (orderId: string) => {
console.log(e);
});
};
const viewPDF = async (pdf: string) => {
const pdfData = await usePDF(`${pdf}`);
showLoader();
setTimeout(() => {
pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value;
hideLoader();
}, 1500);
};
watch(tab, () => {
console.log(tab.value);
if (tab.value === "main") {
viewPDF(OrderPDF.value);
}
if (tab.value === "second") {
viewPDF(TailerPDF.value);
}
});
// const myEventHandler = (e: any) => {
// console.log("e", e.target.innerWidth);
@ -538,7 +556,6 @@ const onchangePage = (val: any) => {
};
const save = () => {
// putOrderData();
if (myForm.value !== null) {
myForm.value!.validate().then((success: Boolean) => {
if (success) {
@ -556,6 +573,8 @@ const save = () => {
await putOrderData();
await postfileOrder();
await postfileTailer();
// await fetchAttachment(orderId.value);
// await fecthstatusOrder(orderId.value);
})
.onCancel(() => {})
.onDismiss(() => {});
@ -589,6 +608,29 @@ const postfileTailer = async () => {
formData.append("File", fileTailer.value);
await http.post(config.API.attachmentOrderId(orderId.value), formData);
};
const clickExecute = async (id: string) => {
$q.dialog({
title: "ยืนยันการออกคำสั่ง",
message: "ต้องการยืนยันการออกคำสั่งข้อมูลนี้ใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
})
.onOk(async () => {
await http
.put(config.API.executeOrder(id))
.then((res) => {
console.log(res);
})
.catch((e) => {
messageError($q, e);
});
})
.onCancel(() => {})
.onDismiss(() => {});
};
const validateForm = () => {
return (