From 316c5507bab52fbc26995c0c977455ecea91366f Mon Sep 17 00:00:00 2001 From: "zeinab.ashrafi" Date: Tue, 13 May 2025 12:15:47 +0330 Subject: [PATCH] feat : show item by udi --- resources/js/show/config/urls.js | 4 +++- resources/js/show/router/paths.js | 6 +++++ resources/js/show/views/Item/ShowItem.vue | 28 +++++++++++++++-------- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/resources/js/show/config/urls.js b/resources/js/show/config/urls.js index e3e2b1e9..c7607b39 100644 --- a/resources/js/show/config/urls.js +++ b/resources/js/show/config/urls.js @@ -5,7 +5,9 @@ const urls = { showItem: function(id) { // return `/ShowItem/${id}`; return `/api/show-item/${id}`; - + }, + showItemByUdi: function(udi) { + return `/api/show-item/udi/${udi}`; }, showPackage: function(id) { return `/api/show-package/${id}`; diff --git a/resources/js/show/router/paths.js b/resources/js/show/router/paths.js index 27c9509b..ce36e961 100644 --- a/resources/js/show/router/paths.js +++ b/resources/js/show/router/paths.js @@ -19,6 +19,12 @@ export default [ view: 'Item/ShowItem', meta: {public: true} }, + { + path: '/Show/UDI/:udi', + name: 'ShowItem', + view: 'Item/ShowItem', + meta: {public: true} + }, { path: '/Show/Package/:package', name: 'ShowPackage', diff --git a/resources/js/show/views/Item/ShowItem.vue b/resources/js/show/views/Item/ShowItem.vue index ee3003fa..f5e7f914 100644 --- a/resources/js/show/views/Item/ShowItem.vue +++ b/resources/js/show/views/Item/ShowItem.vue @@ -148,7 +148,7 @@ export default { }, computed: { imagesOnly() { - return this.data.files && this.data.files.length? this.data.files.filter(file => file.file_type !== 'document') : []; + return this.data.files && this.data.files.length ? this.data.files.filter(file => file.file_type !== 'document') : []; }, }, methods: { @@ -166,6 +166,20 @@ export default { console.error("Error loading data:", error); } }, + async loadByUdi(udi) { + try { + const result = await axios.get(urls.showItemByUdi(udi)); + if (result.status == 200) { + this.data = result.data.data; + if (this.data) { + this.generateBarcode(this.data); + this.MedicalCenter = this.data.user.medical_center.name; + } + } + } catch (error) { + console.error("Error loading data:", error); + } + }, async generateBarcode(item) { let code = item.udi; if (code) { @@ -202,15 +216,7 @@ export default { "left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0" ); - WinPrint.document.write(` - - - ${stylesHtml} - - - ${prtHtml} - - `); + WinPrint.document.write(`${stylesHtml} ${prtHtml}`); WinPrint.document.close(); WinPrint.focus(); @@ -228,6 +234,8 @@ export default { created() { if (this.$route.params.item) { this.load(this.$route.params.item); + } else if (this.$route.params.udi) { + this.loadByUdi(this.$route.params.udi); } this.lightboxImages = this.imagesOnly && this.imagesOnly.length ? this.imagesOnly.map(file => ({ src: file.thumbnail,