feat : show item by udi

This commit is contained in:
zeinab.ashrafi
2025-05-13 12:15:47 +03:30
parent fa7df1e500
commit 316c5507ba
3 changed files with 27 additions and 11 deletions
+3 -1
View File
@@ -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}`;
+6
View File
@@ -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',
+18 -10
View File
@@ -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(`<!DOCTYPE html>
<html>
<head>
${stylesHtml}
</head>
<body>
${prtHtml}
</body>
</html>`);
WinPrint.document.write(`<!DOCTYPE html><html><head>${stylesHtml}</head><body> ${prtHtml}</body></html>`);
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,