From b9759239c49c308ac13d13032f7483308fb7ac6d Mon Sep 17 00:00:00 2001 From: shikha Date: Thu, 7 May 2020 15:40:31 +0530 Subject: [PATCH] shown invoice details and show file in noticeBoard --- src/pages/Account/invoice.vue | 253 +++++++++++++--------------------- src/pages/NoticeBoard/noticeBoard.vue | 117 ++++++++++++---- 2 files changed, 187 insertions(+), 183 deletions(-) diff --git a/src/pages/Account/invoice.vue b/src/pages/Account/invoice.vue index 14529a6..942aa79 100644 --- a/src/pages/Account/invoice.vue +++ b/src/pages/Account/invoice.vue @@ -149,7 +149,7 @@ @@ -186,14 +186,14 @@ @@ -201,38 +201,36 @@ - {{ invoiceData.subTotal }} - + {{ feeType.subTotal }} + - + @@ -242,10 +240,10 @@ Total: - {{ invoiceData.amount }} - {{ invoiceData.discount }} - {{ invoiceData.subTotal }} - {{ invoiceData.paidAmount }} + {{ feeType.amount }} + {{ feeType.discount }} + {{ feeType.subTotal }} + {{ feeType.paidAmount }} delete @@ -289,10 +287,10 @@ class="text-xs-center text-sm-center text-md-center text-lg-center" > - + @@ -300,7 +298,7 @@

- +

Student

@@ -312,7 +310,7 @@ - +
@@ -322,19 +320,9 @@ - + - @@ -359,7 +347,7 @@ @@ -371,7 +359,7 @@ color="open-dialog-button" dark class="right mt-3" - @click="save" + @click="add" >Add Payment @@ -392,34 +380,41 @@ # Fee Type Amount + Discount(%) Subtotal Paid Amount Action - {{ index + 1 }} - {{ feeType.feeTypeName }} + 1 + {{ feeType.feeTypeName }} + - {{ feeType.subTotal }} + {{ feeType.subTotal }} @@ -454,6 +450,7 @@ Total: {{ feeType.amount }} + {{ feeType.discount }} {{ feeType.subTotal }} {{ feeType.paidAmount }} @@ -480,55 +477,8 @@ cancel - - - Your search for "{{ search }}" found no results. - - + @@ -537,17 +487,19 @@ - - - - - - + + + + + + -
# DateWeaver Action
{{ index + 1 }}{{dates( editedItem.date) }}{{ editedItem.paymentMethod }}{{ editedItem.totalAmount }}{{ editedItem.discount}}
1{{dates( editedItem.date) }}{{ editedItem.paymentMethod }}{{ editedItem.totalAmount }}{{ editedItem.totalDiscount}} - +
--> + - + Your search for "{{ search }}" found no results. + Total: - {{ feeType.amount }} - {{ feeType.discount }} - {{ feeType.subTotal }} - {{ feeType.paidAmount }} + {{ feeType.amount }} + {{ feeType.discount }} + {{ feeType.subTotal }} + {{ feeType.paidAmount }} delete @@ -1024,7 +977,7 @@ export default { validEdit: true, isActive: true, newActive: false, - showFeeType: false, + showFeeType: true, addInvoiceDialog: false, editInvoiceDialog: false, paymentInvoiceDialog: false, @@ -1032,17 +985,8 @@ export default { details: [], feeTypes: [], invoiceData: [], - invoiceList: [ - { - studentId: { - name: "", - rollNo: "", - }, - classId: { - classNum: "" - } - } - ], + invoiceList: [], + editPayment: [{}], menu1: false, paymentMethods: ["Cash", "Cheque"], feeType: { @@ -1117,40 +1061,7 @@ export default { }, { text: "Action", value: "", sortable: false, align: "center" } ], - headersProfile: [ - { - text: "No", - align: "", - sortable: false, - value: "No" - }, - { - text: "Date", - value: "date", - sortable: false, - align: "center" - }, - { - text: "Paid By", - value: "paymentMethod", - sortable: false, - align: "center" - }, - { - text: "Payment Amount", - value: "paidAmount", - sortable: false, - align: "center" - }, - { text: "Weaver", value: "discount", sortable: false, align: "center" }, - // { - // text: "Fine", - // value: "fine", - // sortable: false, - // align: "center" - // }, - { text: "Action", value: "", sortable: false, align: "center" } - ], + studentId: { name: "" }, @@ -1185,18 +1096,23 @@ export default { return moment(date).format("MMMM DD, YYYY"); }, profile(item) { + // console.log("item", item); this.editedIndex = this.invoiceList.indexOf(item); this.editedItem = Object.assign({}, item); + // console.log("editedItem",this.editedItem); this.dialog1 = true; }, editItem(item) { this.editedIndex = this.invoiceList.indexOf(item); this.invoiceData = Object.assign({}, item); + // console.log("invoiceData", this.invoiceData); + this.feeTypeData = this.invoiceData.feeType; this.editInvoiceDialog = true; }, paymentItem(item) { this.editedIndex = this.invoiceList.indexOf(item); - this.invoiceList = Object.assign({}, item); + this.editPayment = Object.assign({}, item); + this.feeTypeData = this.editPayment.feeType; this.paymentInvoiceDialog = true; }, deleteItem(item) { @@ -1318,6 +1234,30 @@ export default { this.color = "red"; }); }, + add() { + var updatePayment = { + invoiceId: this.editPayment._id, + totalPaidAmount: this.editPayment.paidAmount + }; + http() + .put("/updateInvoice", updatePayment, { + headers: { + Authorization: "Bearer " + this.token + } + }) + .then(response => { + this.getInvoiceList(); + this.snackbar = true; + this.text = response.data.message; + this.color = "green"; + this.paymentInvoiceDialog = false; + }) + .catch(error => { + console.log("error", error); + this.snackbar = true; + this.color = "red"; + }); + }, clear() { this.$refs.form.reset(); }, @@ -1415,14 +1355,7 @@ export default { // this.$router.replace({ path: "/" }); }); }, - getPaymentDetails(feeTyp) { - let feeType = { - date: "", - paymentMethod: "", - totalAmount: "", - discount: "" - }; - }, + getAmmountDetails(feeTyp) { let feeType = { amount: "", diff --git a/src/pages/NoticeBoard/noticeBoard.vue b/src/pages/NoticeBoard/noticeBoard.vue index ebf1632..496ad50 100644 --- a/src/pages/NoticeBoard/noticeBoard.vue +++ b/src/pages/NoticeBoard/noticeBoard.vue @@ -200,6 +200,14 @@ {{ props.item.title}} + {{ props.item.fileType }} + + + @@ -377,6 +392,8 @@ export default { imageUrl: "", imageFile: "", upload: "", + loadingPdf: false, + titleRules: [v => !!v || " Title is required"], descriptionRules: [v => !!v || " Description is required"], headers: [ @@ -393,6 +410,12 @@ export default { value: "eventImageUrl" }, { text: "Title", value: "title", sortable: false, align: "center" }, + { + text: "File", + value: "eventImageUrl", + sortable: false, + align: "center" + }, { text: "Action", value: "", sortable: false, align: "center" } ], notices: [], @@ -407,29 +430,6 @@ export default { pickFile() { this.$refs.image.click(); }, - - onFilePicked(e) { - // console.log(e) - const files = e.target.files; - this.upload = e.target.files[0]; - console.log("thisupload==>", this.upload); - if (files[0] !== undefined) { - this.imageName = files[0].name; - if (this.imageName.lastIndexOf(".") <= 0) { - return; - } - const fr = new FileReader(); - fr.readAsDataURL(files[0]); - fr.addEventListener("load", () => { - this.imageUrl = fr.result; - this.imageFile = files[0]; // this is an image file that can be sent to server... - }); - } else { - this.imageName = ""; - this.imageFile = ""; - this.imageUrl = ""; - } - }, getNoticeDataList() { this.showLoader = true; var token = this.$store.state.token; @@ -476,21 +476,43 @@ export default { if ((this.snackbar = true)) { this.text = "Successfully delete Existing Notice Data"; } + this.snackbar = true; + this.color = "green"; this.getNoticeDataList(); }) .catch(error => { // console.log(error); + this.snackbar = true; + this.text = error.response.data.message; + this.color = "error"; }); }, close() { this.editNoticeBoardDialog = false; }, submit() { + var signatures = { + JVBERi0: "other", + iVBORw0KGgo: "image", + UEsDBBQ: "other", + "/": "image", + AAABAA: "image", + IywiV2hhdC: "other", + bmFtZSxl: "other" + }; + function detectMimeType(b64) { + for (var s in signatures) { + if (b64.indexOf(s) === 0) { + return signatures[s]; + } + } + } if (this.$refs.form.validate()) { if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); this.addNoticeBoard.upload = imageUrl; + this.addNoticeBoard.fileType = detectMimeType(imageUrl); } http() .post("/createEvent", this.addNoticeBoard) @@ -510,6 +532,27 @@ export default { }); } }, + onFilePicked(e) { + const files = e.target.files; + this.upload = e.target.files[0]; + if (files[0] !== undefined) { + this.imageName = files[0].name; + if (this.imageName.lastIndexOf(".") <= 0) { + return; + } + const fr = new FileReader(); + fr.readAsDataURL(files[0]); + fr.addEventListener("load", () => { + this.imageUrl = fr.result; + this.imageFile = files[0]; // this is an image file that can be sent to server... + this.imageData.imageUrl = URL.createObjectURL(this.imageFile); + }); + } else { + this.imageName = ""; + this.imageFile = ""; + this.imageUrl = ""; + } + }, clear() { this.$refs.form.reset(); this.imageUrl = ""; @@ -520,10 +563,26 @@ export default { title: this.editedItem.title, description: this.editedItem.description }; + var signatures = { + JVBERi0: "other", + iVBORw0KGgo: "image", + UEsDBBQ: "other", + "/": "image", + AAABAA: "image", + IywiV2hhdC: "other" + }; + function detectMimeType(b64) { + for (var s in signatures) { + if (b64.indexOf(s) === 0) { + return signatures[s]; + } + } + } if (this.imageUrl) { var str = this.imageUrl; const [baseUrl, imageUrl] = str.split(/,/); editNoticeBoard.upload = imageUrl; + editNoticeBoard.fileType = detectMimeType(imageUrl); } http() .put("/updateEvent", editNoticeBoard) @@ -545,6 +604,18 @@ export default { this.showSearch = false; this.show = true; this.search = ""; + }, + async generatePDF2Canvas(item) { + var dataType = ""; + var type = ""; + if (item.fileType == "image") { + dataType = "file.jpg"; + } else if (item.fileType == "other") { + dataType = "file.pdf"; + type = "application/pdf"; + } + var FileSaver = require("file-saver"); + FileSaver.saveAs(item.eventImageUrl, "image.jpg"); } }, mounted() { -- 2.0.0