fix : items & package & barcode modal & show-modal

This commit is contained in:
zeinab.ashrafi
2025-04-09 12:58:52 +03:30
parent 983d1659db
commit 1d77e7b000
18 changed files with 627 additions and 544 deletions
+63 -55
View File
@@ -61,25 +61,29 @@
{{ (item.user && item.user.medical_center) ? item.user.medical_center.name : '' }}
</td>
<td class="title font-weight-light">
{{item.user ? item.user.name : '' | text_20_letter}}
{{ item.user ? item.user.name : '' | text_20_letter }}
</td>
<td class="title font-weight-light">{{ item.description }}</td>
<td class="title font-weight-light">{{ item.status }}</td>
<td class="text-xs-right FlexBtn Height-MD-60 justify-self-end">
<v-tooltip bottom open-on-hover v-if="$hasRole('Admin|Supervisor')">
<template v-slot:activator="{ on, attrs }">
<v-btn :color="!['suspended', 'rejected'].includes(item.status) ? 'red' : 'green'"
class="mr-2" @click="changeStatus(item)" v-bind="attrs" v-on="on">
<v-icon class="white--text mr-1 caption">
fas {{!['suspended', 'rejected'].includes(item.status) ? 'fa-close' : 'fa-check'}}
</v-icon>
<span>
{{!['suspended', 'rejected'].includes(item.status) ? 'reject' : 'approve'}}
</span>
</v-btn>
</template>
<span>{{!['suspended', 'rejected'].includes(item.status) ? 'reject' : 'approve'}}</span>
</v-tooltip>
<template v-if="$hasRole('Admin|Supervisor')">
<v-tooltip v-for="status in getStatus(item)" :key="status.label" bottom
open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn :color="status.color" class="mr-2"
@click="changeStatus(item, status.status)" v-bind="attrs"
v-on="on">
<v-icon class="white--text mr-1 caption">fas {{
status.icon
}}
</v-icon>
<span>{{ status.label }}</span>
</v-btn>
</template>
<span>{{ status.label }}</span>
</v-tooltip>
</template>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="cyan" class="mr-2"
@@ -90,10 +94,11 @@
</template>
<span>Show</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<router-link class="LinkBtn"
v-if="$hasRole('Admin') || item.user_id == $store.state.user.id"
v-if="$hasRole('Admin|Supervisor') ||( item.user_id == $store.state.user.id && !['approved', 'rejected'].includes(item.status))"
:to="{ name: 'EditPackage', params: { package: item.id } }">
<v-btn v-bind="attrs" v-on="on" color="orange" class="mr-2">
<v-icon class="white--text mr-1 caption">fas fa-pen</v-icon>
@@ -103,12 +108,13 @@
</template>
<span>Edit</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="pink" class="WM-ActionButton mr-2"
@click="remove(item.id)"
v-if="$hasRole('Admin') || item.user_id == $store.state.user.id">
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
v-if="$hasRole('Admin|Supervisor') ||( item.user_id == $store.state.user.id && !['approved', 'rejected'].includes(item.status))">
<v-icon class="white--text mr-2 caption">fas fa-trash</v-icon>
<span>Remove</span>
</v-btn>
</template>
@@ -117,7 +123,7 @@
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn class="mr-2" v-bind="attrs" v-on="on" color="orange darken-1"
@click="generateBarcode(item, 'Package')">
@click="generateBarcode(item.id, 'Package')">
<v-icon class="white--text mr-1 caption">fas fa-barcode</v-icon>
<span>Generate Barcode</span>
</v-btn>
@@ -156,13 +162,13 @@ import toast from "@/services/global/toast.service";
export default {
data: () => ({
headers: [
{sortable: false, text: "Package ID", value: "Package ID"},
{sortable: false, text: "ID", value: "Package ID"},
{sortable: false, text: "Name", value: "name"},
{sortable: false, text: "Hospital", value: "Hospital"},
{sortable: false, text: "Owner", value: "User"},
{sortable: false, text: "Description", value: "description"},
{sortable: false, text: "Status", value: "status"},
{sortable: false, text: "Action", value: "action", align: "left"}
{sortable: false, text: "Action", value: "action", align: "center", width: '20%'}
],
filter: {
name: '',
@@ -200,9 +206,7 @@ export default {
this.loadMedicalCenters();
},
async show(testResultId) {
const result = await ApiService.get(
urls.showPackage(testResultId)
);
const result = await ApiService.get(urls.showPackage(testResultId));
if (result && result.status == 200) {
this.changeCurrentModal({
modal: "modal-package-show",
@@ -225,37 +229,13 @@ export default {
}
}
},
async generateBarcode(item, type) {
const code = item.udi;
if (code) {
const result = await ApiService.post(urls.Barcode(code, type));
if (result && result.status == 200) {
this.changeCurrentModal({
modal: "modal-barcode-barcode",
properties: {result}
});
}
} else {
toast.error('please first set UDI');
}
},
async changeStatus(item) {
const payload = {
status: ['suspended', 'rejected'].includes(item.status) ? 'approved' : 'rejected',
}
const result = await ApiService.post(
urls.changePackageStatus(item.id),
payload
);
if (result) {
for (const key in this.items) {
if (
this.items.hasOwnProperty(key) &&
this.items[key].id == item.id
) {
this.items[key].status = result.data.data.status;
}
}
async generateBarcode(id, type) {
const result = await ApiService.post(urls.Barcode(id, type));
if (result && result.status == 200) {
this.changeCurrentModal({
modal: "modal-barcode-barcode",
properties: {result}
});
}
},
async loadMedicalCenters() {
@@ -264,6 +244,34 @@ export default {
this.medicalCenters = result.data.data.MedicalCenters;
}
},
getStatus(item) {
if (item.status === 'pending') {
return [
{status: 'rejected', label: 'reject', color: 'red', icon: 'fa-close'},
{status: 'approved', label: 'approve', color: 'green', icon: 'fa-check'}
]
} else {
const nextStatus = item.status === 'rejected' ? 'approved' : 'rejected'
return [
{
status: nextStatus,
label: nextStatus === 'approved' ? 'approve' : 'reject',
color: nextStatus === 'approved' ? 'green' : 'red',
icon: nextStatus === 'approved' ? 'fa-check' : 'fa-close'
}
]
}
},
async changeStatus(item, status) {
const result = await ApiService.post(urls.changePackageStatus(item.id), {status})
if (result?.data?.data?.status) {
const newStatus = result.data.data.status
const target = this.items.find(i => i.id === item.id)
if (target) target.status = newStatus
}
}
},
computed: {
...mapGetters("modal", ["getModalResult"])