Add extra receipt image

This commit is contained in:
Amir
2023-01-24 14:52:19 +08:00
parent ccb0210bd0
commit 7650aac9be
+132 -24
View File
@@ -121,7 +121,12 @@
v-on:click="downloadPdf(list.kodcaw)"
v-if="list.status_payment_cawangan.status == 1"
/>
<div v-if="list.status_payment_cawangan.status == 1 || list.status_payment_cawangan.status == 9">
<div
v-if="
list.status_payment_cawangan.status == 1 ||
list.status_payment_cawangan.status == 9
"
>
<div
class="m-2"
v-if="
@@ -173,29 +178,68 @@
<div class="col-3">Cara Bayaran</div>
<div class="col-5 form-control">CDM</div>
</div>
<div v-if="list.status_payment_cawangan.status == 9">
<Button
class="p-button-sm mb-3"
label="Muat Naik Resit"
icon="pi pi-plus-circle"
iconPos="right"
@click="openModalFileUpload(list.kodcaw)"
/>
<Dialog
header="Muat Naik Resit Baharu"
v-model:visible="isDisplayFileUpload"
:breakpoints="{ '960px': '75vw', '640px': '90vw' }"
:style="{ width: '50vw' }"
:modal="true"
>
<div class="text-center m-2">
<input
class="form-control"
type="file"
accept="image/*"
v-on:change="selectPhoto"
/>
</div>
<template #footer>
<Button
class="p-button-sm p-button-secondary"
label="Kembali"
@click="closeModalFileUpload()"
/>
<Button
class="p-button-sm p-button-success"
label="Simpan"
icon="pi pi-check"
iconPos="right"
@click="addPhotoResit()"
/>
</template>
</Dialog>
</div>
<div class="overflow-x-auto">
<table class="table text-center table-bordered">
<tbody>
<tr class="table-light">
<td>Bil</td>
<td style="min-width: 180px">Gambar</td>
<td style="min-width: 180px">Masa Muat Naik</td>
</tr>
<tr
v-for="(receipt, index) in list
.status_payment_cawangan.file_resit"
v-bind:key="receipt"
>
<td>{{ index + 1 }}</td>
<td>
<receipt-image
v-bind:fileResitId="receipt.id"
></receipt-image>
</td>
<td>{{receipt.created_at}}</td>
</tr>
</tbody>
</table>
<table class="table text-center table-bordered">
<tbody>
<tr class="table-light">
<td>Bil</td>
<td style="min-width: 180px">Gambar</td>
<td style="min-width: 180px">Masa Muat Naik</td>
</tr>
<tr
v-for="(receipt, index) in list
.status_payment_cawangan.file_resit"
v-bind:key="receipt"
>
<td>{{ index + 1 }}</td>
<td>
<receipt-image
v-bind:fileResitId="receipt.id"
></receipt-image>
</td>
<td>{{ receipt.masa_upload }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
@@ -465,7 +509,7 @@ import html2canvas from "html2canvas";
import VueHtml2pdf from "vue-html2pdf";
import axios from "axios";
import ItemMasterImageModal from "../list/ItemMasterImageModal.vue";
import ReceiptImage from "../pay/ReceiptImage.vue"
import ReceiptImage from "../pay/ReceiptImage.vue";
export default {
components: {
@@ -486,6 +530,13 @@ export default {
isDisplay: false,
suratHak: "",
isSuccessHak: false,
isDisplayFileUpload: false,
formResit: {
user_id: localStorage.getItem("id"),
lelong_id: this.$route.params.lelongId,
gambarResit: "",
kodcaw: "",
},
};
},
created() {
@@ -541,6 +592,63 @@ export default {
this.theData = value;
this.reloadImageComponent += 1;
},
selectPhoto(e) {
console.log(e);
this.formResit.gambarResit = e.target.files[0];
},
addPhotoResit() {
var resitFormData = new FormData();
resitFormData.append("gambarResit", this.formResit.gambarResit);
resitFormData.append("lelong_id", this.formResit.lelong_id);
resitFormData.append("user_id", this.formResit.user_id);
resitFormData.append("kodcaw", this.formResit.kodcaw);
console.log(this.formResit);
axios
.post("/addPhotoResit", resitFormData, {
headers: {
Authorization: "Bearer " + localStorage.getItem("token"),
},
})
.then((response) => {
this.liveData();
this.isDisplayFileUpload = false;
if (response.data.success == true) {
this.$swal.fire({
icon: "success",
title: "Gambar Resit Berjaya Di Muat Naik",
confirmButtonColor: "#344871",
confirmButtonText: "OK",
allowOutsideClick: false,
allowEscapeKey: false,
});
this.componentKey += 1;
} else if (response.data.success == false) {
console.log(response);
this.$swal.fire({
toast: true,
icon: "error",
title: "Gagal! Sila refresh page semula.",
animation: false,
position: "bottom",
showConfirmButton: false,
timer: 5000,
timerProgressBar: true,
});
this.componentKey += 1;
}
})
.catch((error) => {
alert(error);
});
},
openModalFileUpload(e) {
this.isDisplayFileUpload = true;
this.formResit.kodcaw = e;
},
closeModalFileUpload() {
this.isDisplayFileUpload = false;
this.formResit.kodcaw = "";
},
downloadPdf(value) {
axios
.get("/resultInCawangan", {