api Order step 4
This commit is contained in:
parent
fc3d4bb409
commit
04f79de4c1
2 changed files with 88 additions and 21 deletions
|
|
@ -286,14 +286,14 @@
|
||||||
unelevated
|
unelevated
|
||||||
label="ออกคำสั่ง"
|
label="ออกคำสั่ง"
|
||||||
:color="validateForm() ? 'public' : 'grey'"
|
:color="validateForm() ? 'public' : 'grey'"
|
||||||
:disable="!validateForm()"
|
:disable="statusOrder == 'N'"
|
||||||
/>
|
/>
|
||||||
<q-btn
|
<q-btn
|
||||||
class="text-dark"
|
class="text-dark"
|
||||||
unelevated
|
unelevated
|
||||||
label="ส่งไปลงนาม"
|
label="ส่งไปลงนาม"
|
||||||
color="grey"
|
color="grey"
|
||||||
disable
|
:disable="statusOrder == 'N'"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -422,16 +422,28 @@ import { VuePDF, usePDF } from "@tato30/vue-pdf";
|
||||||
import type { PDFDocumentLoadingTask } from "pdfjs-dist/types/src/display/api";
|
import type { PDFDocumentLoadingTask } from "pdfjs-dist/types/src/display/api";
|
||||||
import type { QForm } from "quasar";
|
import type { QForm } from "quasar";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
|
import { useQuasar } from "quasar";
|
||||||
import { useRoute } from "vue-router";
|
import { useRoute } from "vue-router";
|
||||||
import http from "@/plugins/http";
|
import http from "@/plugins/http";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
||||||
const mixin = useCounterMixin();
|
const mixin = useCounterMixin();
|
||||||
const { date2Thai } = mixin;
|
const { date2Thai, messageError, showLoader, hideLoader } = mixin;
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const $q = useQuasar();
|
||||||
|
|
||||||
const orderId_params = route.params.orderid;
|
const orderId_params = route.params.orderid;
|
||||||
const dialog = ref<boolean>(false);
|
const dialog = ref<boolean>(false);
|
||||||
|
const splitterModel = ref<number>(70);
|
||||||
|
const tab = ref<string>("main");
|
||||||
|
|
||||||
|
const order = ref<string>("");
|
||||||
|
const years = ref<number>(new Date().getDate());
|
||||||
|
const date = ref<Date>(new Date());
|
||||||
|
const fileOrder = ref<any>(null);
|
||||||
|
const fileTailer = ref<any>(null);
|
||||||
|
|
||||||
|
const statusOrder = ref<string>();
|
||||||
|
|
||||||
// onUnmounted(() => {
|
// onUnmounted(() => {
|
||||||
// window.removeEventListener("resize", (e: any) => {
|
// window.removeEventListener("resize", (e: any) => {
|
||||||
|
|
@ -440,13 +452,12 @@ const dialog = ref<boolean>(false);
|
||||||
// });
|
// });
|
||||||
const orderId = ref<string>("");
|
const orderId = ref<string>("");
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
console.log(orderId_params);
|
|
||||||
if (orderId_params !== undefined) {
|
if (orderId_params !== undefined) {
|
||||||
orderId.value == orderId_params.toString();
|
orderId.value = orderId_params.toString();
|
||||||
|
fetchAttachment(orderId.value);
|
||||||
|
fecthstatusOrder(orderId.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchAttachment(orderId.value);
|
|
||||||
|
|
||||||
// window.addEventListener("resize", (e: any) => {
|
// window.addEventListener("resize", (e: any) => {
|
||||||
// myEventHandler(e);
|
// myEventHandler(e);
|
||||||
// });
|
// });
|
||||||
|
|
@ -460,11 +471,34 @@ onMounted(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchAttachment = async (orderId: string) => {
|
const fetchAttachment = async (orderId: string) => {
|
||||||
console.log(123);
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(config.API.attachmentOrder("08db94be-f7c6-43e2-83eb-3c5cef3a91c7"))
|
.get(config.API.attachmentOrder(orderId))
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res);
|
let response = res.data.result;
|
||||||
|
console.log(response);
|
||||||
|
order.value = response.orderNo;
|
||||||
|
years.value = Number(response.orderYear);
|
||||||
|
if (response.date !== undefined) {
|
||||||
|
date.value = response.date;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
messageError($q, e);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const fecthstatusOrder = async (orderId: string) => {
|
||||||
|
await http
|
||||||
|
.get(config.API.orderReady(orderId))
|
||||||
|
.then((res) => {
|
||||||
|
let status = res.data.result;
|
||||||
|
statusOrder.value = status.result;
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -496,15 +530,6 @@ const props = defineProps({
|
||||||
const next = () => props.next();
|
const next = () => props.next();
|
||||||
const previous = () => props.previous();
|
const previous = () => props.previous();
|
||||||
|
|
||||||
const splitterModel = ref<number>(70);
|
|
||||||
const tab = ref<string>("main");
|
|
||||||
const fileOrder = ref<any>(null);
|
|
||||||
const fileTailer = ref<any>(null);
|
|
||||||
|
|
||||||
const order = ref<string>("");
|
|
||||||
const years = ref<number>(new Date().getFullYear());
|
|
||||||
const date = ref<Date>(new Date());
|
|
||||||
|
|
||||||
const onchangePage = (val: any) => {
|
const onchangePage = (val: any) => {
|
||||||
// console.log(val);
|
// console.log(val);
|
||||||
if (vuePDFRef !== null) {
|
if (vuePDFRef !== null) {
|
||||||
|
|
@ -513,14 +538,57 @@ const onchangePage = (val: any) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = () => {
|
const save = () => {
|
||||||
|
// putOrderData();
|
||||||
if (myForm.value !== null) {
|
if (myForm.value !== null) {
|
||||||
myForm.value!.validate().then((success: Boolean) => {
|
myForm.value!.validate().then((success: Boolean) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
// yay, models are correct
|
// yay, models are correct
|
||||||
|
$q.dialog({
|
||||||
|
title: "ยืนยันการบันทึกข้อมูล",
|
||||||
|
message: "ต้องการบันทึกข้อมูลนี้ใช่หรือไม่?",
|
||||||
|
cancel: {
|
||||||
|
flat: true,
|
||||||
|
color: "negative",
|
||||||
|
},
|
||||||
|
persistent: true,
|
||||||
|
})
|
||||||
|
.onOk(async () => {
|
||||||
|
await putOrderData();
|
||||||
|
await postfileOrder();
|
||||||
|
await postfileTailer();
|
||||||
|
})
|
||||||
|
.onCancel(() => {})
|
||||||
|
.onDismiss(() => {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const putOrderData = async () => {
|
||||||
|
const orderData = {
|
||||||
|
orderNo: order.value,
|
||||||
|
orderYear: years.value.toString(),
|
||||||
|
signDate: date.value,
|
||||||
|
};
|
||||||
|
await http
|
||||||
|
.put(config.API.attachmentOrder(orderId.value), orderData)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const postfileOrder = async () => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("File", fileOrder.value);
|
||||||
|
await http.post(config.API.attachmentOrderId(orderId.value), formData);
|
||||||
|
};
|
||||||
|
const postfileTailer = async () => {
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("File", fileTailer.value);
|
||||||
|
await http.post(config.API.attachmentOrderId(orderId.value), formData);
|
||||||
|
};
|
||||||
|
|
||||||
const validateForm = () => {
|
const validateForm = () => {
|
||||||
return (
|
return (
|
||||||
|
|
@ -529,14 +597,12 @@ const validateForm = () => {
|
||||||
order.value.trim() !== ""
|
order.value.trim() !== ""
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getClass = (val: boolean) => {
|
const getClass = (val: boolean) => {
|
||||||
return {
|
return {
|
||||||
"card-header-active q-px-lg q-py-md cursor-pointer": val,
|
"card-header-active q-px-lg q-py-md cursor-pointer": val,
|
||||||
"card-header q-px-lg q-py-md cursor-pointer": !val,
|
"card-header q-px-lg q-py-md cursor-pointer": !val,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const setTab = (val: string) => {
|
const setTab = (val: string) => {
|
||||||
tab.value = val;
|
tab.value = val;
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,7 @@ const fecthlistRecevice = async () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// const nextPage = (id:string) => {
|
// const nextPage = (id:string) => {
|
||||||
// router.push("/retirement/resign/"+id);
|
// router.push("/retirement/resign/"+id);
|
||||||
// };
|
// };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue