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
+78 -71
View File
@@ -6,7 +6,7 @@
<v-flex xs12 sm4 md4 lg2 xl2 class="WM-FlexCenter">
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
<v-text-field class="py-3 pr-3" v-model="filter.item_id" label="Item ID"
color="black"/>
color="black"/>
</v-flex>
<v-flex xs12 sm4 md4 lg3 xl2 class="WM-FlexCenter">
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"/>
@@ -15,8 +15,8 @@
<v-flex xs12 sm4 md4 lg3 xl2 class="WM-FlexCenter" v-if="$hasRole('Admin')">
<v-icon class="fa fa-hospital-o mr-2 WM-Margin-B-8"/>
<v-autocomplete class="py-3 pr-3" v-model="filter.medical_center_id" item-text="name"
item-value="id" label="Hospital" color="black" :items="medicalCenters"
:clearable="true"/>
item-value="id" label="Hospital" color="black" :items="medicalCenters"
:clearable="true"/>
</v-flex>
<v-flex xs12 sm4 md4 lg2 xl2 class="WM-FlexCenter">
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
@@ -51,38 +51,42 @@
<v-data-table :headers="headers" :items="items" hide-actions>
<template slot="headerCell" slot-scope="{ header }">
<span class="subheading font-weight-light text-white text--darken-3"
v-text="header.text" />
v-text="header.text"/>
</template>
<template slot="items" slot-scope="{ item }">
<td class="title font-weight-light">{{ item.id }}</td>
<!-- <td class="title font-weight-light">{{ item.unique_id }}</td> -->
<td class="title font-weight-light">{{ item.name }}</td>
<td class="title font-weight-light">{{ item.user ? item.user.name : '' | text_20_letter }}</td>
<td class="title font-weight-light">{{ (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 }}
</td>
<td class="title font-weight-light">
{{ (item.user && item.user.medical_center) ? item.user.medical_center.name : '' }}
</td>
<td class="title font-weight-light">{{ item.udi | text_20_letter }}</td>
<td class="title font-weight-light">{{ item.size }}</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"
@click="show(item.id)">
@click="show(item.id)">
<v-icon class="white--text mr-1 caption">fas fa-eye</v-icon>
<span>Show</span>
</v-btn>
@@ -92,8 +96,8 @@
<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"
:to="{ name: 'EditItem', params: { Item: item.id } }">
v-if="$hasRole('Admin|Supervisor') ||( item.user_id == $store.state.user.id && !['approved', 'rejected'].includes(item.status))"
:to="{ name: 'EditItem', params: { Item: 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>
<span>Edit</span>
@@ -105,8 +109,8 @@
<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">
@click="remove(item.id)"
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>
@@ -116,7 +120,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, 'Item')">
@click="generateBarcode(item, 'Item')">
<v-icon class="white--text mr-2 caption">fas fa-barcode</v-icon>
<span class="CSSD-font">Generate Barcode</span>
</v-btn>
@@ -131,7 +135,7 @@
<v-divider/>
<div class="text-xs-center" v-if="lastPage > 1">
<v-pagination color="black" v-model="currentPage" :length="lastPage"
:total-visible="6"/>
:total-visible="6"/>
</div>
<v-layout row wrap align-center justify-center class="mt-3">
<router-link to="/dashboard">
@@ -147,23 +151,23 @@
</template>
<script>
import { ApiService } from "@/services";
import { urls } from "@/config/urls";
import { mapMutations, mapGetters } from "vuex";
import {ApiService} from "@/services";
import {urls} from "@/config/urls";
import {mapMutations, mapGetters} from "vuex";
import toast from "@/services/global/toast.service";
export default {
data: () => ({
headers: [
// {sortable: true,text: "ID",value: "id"},
{sortable: false, text: "Item ID", value: "id"},
{sortable: false, text: "ID", value: "id", width: '5%'},
{sortable: false, text: "Name", value: "name"},
{sortable: false, text: "Owner", value: "User"},
{sortable: false, text: "Hospital", value: "Hospital"},
{sortable: false, text: "UDI", value: "udi"},
{sortable: false, text: "Size", value: "size"},
{sortable: false, text: "Status", value: "status"},
{sortable: false, text: "Action", value: "action", align: "left"}
{sortable: false, text: "Status", value: "status", width: '10%'},
{sortable: false, text: "Action", value: "action", align: "center", width: '20%'}
],
filter: {
name: '',
@@ -191,7 +195,7 @@ export default {
}
filter += (page) ? `page=${page}` : `page=1`;
const result = await ApiService.get(
urls.listItem(filter)
urls.listItem(filter)
);
if (result && result.status == 200) {
this.items = result.data.data;
@@ -201,70 +205,73 @@ export default {
this.loadMedicalCenters();
},
async generateBarcode(item, type = null) {
let 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, item },
});
}
} else {
toast.error('please first set UDI');
const result = await ApiService.post(urls.Barcode(item.id, type));
if (result && result.status == 200) {
this.changeCurrentModal({
modal: "modal-barcode-barcode",
properties: {result, item},
});
}
},
async show(testResultId) {
const result = await ApiService.get(
urls.showItem(testResultId)
urls.showItem(testResultId)
);
if (result && result.status == 200) {
this.changeCurrentModal({
modal: "modal-item-show",
properties: { result },
properties: {result},
});
}
},
async remove(testResultId) {
const result = await ApiService.delete(
urls.removeItem(testResultId)
urls.removeItem(testResultId)
);
if (result && result.status == 200) {
for (const key in this.items) {
if (
this.items.hasOwnProperty(key) &&
this.items[key].id == testResultId
this.items.hasOwnProperty(key) &&
this.items[key].id == testResultId
) {
this.items.splice(key, 1);
}
}
}
},
async changeStatus(item) {
const payload = {
status: ['suspended', 'rejected'].includes(item.status) ? 'approved' : 'rejected',
}
const result = await ApiService.post(
urls.changeItemStatus(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 loadMedicalCenters() {
const result = await ApiService.get(urls.listFilterItemsTestResult);
if (result && result.status == 200) {
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.changeItemStatus(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
}
}
},
watch: {
currentPage(page) {