แก้ แสดง error
This commit is contained in:
parent
f732b87763
commit
95ebd013e4
1 changed files with 77 additions and 79 deletions
|
|
@ -17,12 +17,9 @@ const { dialogConfirm, success, showLoader, hideLoader, messageError } = mixin;
|
||||||
const commandId = defineModel<string>("commandId", { required: true }); // id คำสั่ง
|
const commandId = defineModel<string>("commandId", { required: true }); // id คำสั่ง
|
||||||
const type = defineModel<string>("type", { required: true }); // แยก tab
|
const type = defineModel<string>("type", { required: true }); // แยก tab
|
||||||
// รายละเอียดคำสั่ง
|
// รายละเอียดคำสั่ง
|
||||||
const dataTemplateDetail = defineModel<DataTemplateDetail>(
|
const dataTemplate = defineModel<DataTemplateDetail>("dataTemplateDetail", {
|
||||||
"dataTemplateDetail",
|
|
||||||
{
|
|
||||||
required: true,
|
required: true,
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
const documentFile = ref<File | null>(null); // file อัปโหลด
|
const documentFile = ref<File | null>(null); // file อัปโหลด
|
||||||
const isLoadPDF = ref<boolean>(false); // Loading display pdf
|
const isLoadPDF = ref<boolean>(false); // Loading display pdf
|
||||||
|
|
@ -57,11 +54,12 @@ const { fetchDataTemplate } = defineProps({
|
||||||
* @param dataTemple รายละเอียดคำสั่ง
|
* @param dataTemple รายละเอียดคำสั่ง
|
||||||
*/
|
*/
|
||||||
async function fetchDocumentTemplate(dataTemple: DataTemplateDetail) {
|
async function fetchDocumentTemplate(dataTemple: DataTemplateDetail) {
|
||||||
|
if (dataTemple) {
|
||||||
showLoader();
|
showLoader();
|
||||||
isLoadPDF.value = false;
|
isLoadPDF.value = false;
|
||||||
pdfSrc.value = undefined;
|
pdfSrc.value = undefined;
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
const reportName = await `${dataTemplateDetail.value.code}_${type.value}`;
|
const reportName = `${dataTemple.code}_${type.value}`;
|
||||||
const body = {
|
const body = {
|
||||||
template: reportName,
|
template: reportName,
|
||||||
reportName: `${typeFile.value}-report`,
|
reportName: `${typeFile.value}-report`,
|
||||||
|
|
@ -120,6 +118,7 @@ async function fetchDocumentTemplate(dataTemple: DataTemplateDetail) {
|
||||||
isLoadPDF.value = false;
|
isLoadPDF.value = false;
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -130,7 +129,7 @@ async function uploadTemplate() {
|
||||||
$q,
|
$q,
|
||||||
async () => {
|
async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
const reportName = await `${dataTemplateDetail.value.code}_${type.value}`;
|
const reportName = await `${dataTemplate.value.code}_${type.value}`;
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
config.API.reportTemplate +
|
config.API.reportTemplate +
|
||||||
|
|
@ -150,7 +149,7 @@ async function uploadTemplate() {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
|
|
||||||
// โหลดไฟล์ Template ที่แสดงในหน้า UI ใหม่
|
// โหลดไฟล์ Template ที่แสดงในหน้า UI ใหม่
|
||||||
fetchDocumentTemplate(dataTemplateDetail.value);
|
fetchDocumentTemplate(dataTemplate.value);
|
||||||
fetchDataTemplate(commandId.value);
|
fetchDataTemplate(commandId.value);
|
||||||
})
|
})
|
||||||
.catch(async (e) => {
|
.catch(async (e) => {
|
||||||
|
|
@ -170,8 +169,8 @@ async function uploadTemplate() {
|
||||||
*/
|
*/
|
||||||
async function downloadTemplate() {
|
async function downloadTemplate() {
|
||||||
const check = await (type.value == "cover"
|
const check = await (type.value == "cover"
|
||||||
? dataTemplateDetail.value.fileCover
|
? dataTemplate.value.fileCover
|
||||||
: dataTemplateDetail.value.fileAttachment);
|
: dataTemplate.value.fileAttachment);
|
||||||
await axios
|
await axios
|
||||||
.post(
|
.post(
|
||||||
config.API.reportTemplate + `/${typeFile.value}/download?folder=command`,
|
config.API.reportTemplate + `/${typeFile.value}/download?folder=command`,
|
||||||
|
|
@ -189,7 +188,7 @@ async function downloadTemplate() {
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
var a = document.createElement("a");
|
var a = document.createElement("a");
|
||||||
a.href = URL.createObjectURL(res.data);
|
a.href = URL.createObjectURL(res.data);
|
||||||
a.download = `${dataTemplateDetail.value.code}_${type.value}.${typeFile.value}`;
|
a.download = `${dataTemplate.value.code}_${type.value}.${typeFile.value}`;
|
||||||
a.click();
|
a.click();
|
||||||
hideLoader();
|
hideLoader();
|
||||||
})
|
})
|
||||||
|
|
@ -217,17 +216,16 @@ async function updateReportName(name: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// working on click command list
|
// working on click command list
|
||||||
watch(dataTemplateDetail, () => {
|
watch(
|
||||||
fetchDocumentTemplate(dataTemplateDetail.value);
|
() => dataTemplate.value,
|
||||||
});
|
async (newValue, oldValue) => {
|
||||||
|
await fetchDocumentTemplate(newValue);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// working on change tab
|
// working on change tab
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchDocumentTemplate(dataTemplateDetail.value);
|
fetchDocumentTemplate(dataTemplate.value);
|
||||||
});
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
fetchDocumentTemplate,
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue