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
+141 -40
View File
@@ -5,25 +5,31 @@
<v-layout align-center wrap class="my-3 px-5">
<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="getFilters.item_id" @input="updateFilter('item_id', getFilters.item_id)" label="Item ID" color="black"/>
<v-text-field class="py-3 pr-3" v-model="getFilters.item_id"
@input="updateFilter('item_id', getFilters.item_id)" label="Item ID"
color="black"/>
</v-flex>
<v-flex xs12 sm4 md4 lg2 xl2 class="WM-FlexCenter pl-3">
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"/>
<v-text-field class="py-3 pr-3" v-model="getFilters.name" @input="updateFilter('name', getFilters.name)" label="Name" color="black"/>
<v-text-field class="py-3 pr-3" v-model="getFilters.name"
@input="updateFilter('name', getFilters.name)" label="Name" color="black"/>
</v-flex>
<v-flex xs12 sm4 md4 lg2 xl2 class="WM-FlexCenter pl-3" 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="getFilters.medical_center_id" item-text="name"
item-value="id" @input="updateFilter('medical_center_id', getFilters.medical_center_id)"
item-value="id"
@input="updateFilter('medical_center_id', getFilters.medical_center_id)"
label="Hospital" color="black" :items="medicalCenters" :clearable="true"/>
</v-flex>
<v-flex xs12 sm4 md4 lg2 xl2 class="WM-FlexCenter pl-3">
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
<v-text-field class="py-3 pr-3" v-model="getFilters.size" @input="updateFilter('size', getFilters.size)" label="Size" color="black"/>
<v-text-field class="py-3 pr-3" v-model="getFilters.size"
@input="updateFilter('size', getFilters.size)" label="Size" color="black"/>
</v-flex>
<v-flex xs12 sm4 md4 lg2 xl2 class="WM-FlexCenter pl3">
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"/>
<v-text-field class="py-3 pr-3" v-model="getFilters.udi" @input="updateFilter('udi', getFilters.udi)" label="UDI" color="black"/>
<v-text-field class="py-3 pr-3" v-model="getFilters.udi"
@input="updateFilter('udi', getFilters.udi)" label="UDI" color="black"/>
</v-flex>
<v-spacer/>
<v-flex class xs12 sm6 md6 lg2 xl1>
@@ -55,19 +61,63 @@
<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.udi }}</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">
<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="showItem(item.id)">
@click="show(item.id)">
<v-icon class="white--text mr-1 caption">fas fa-eye</v-icon>
<span>Show</span>
</v-btn>
</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|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>
</v-btn>
</router-link>
</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|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>
<span>Remove</span>
</v-tooltip>
<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"
@@ -88,17 +138,8 @@
</template>
<span>Transfer</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
<v-btn v-bind="attrs" v-on="on" color="red" class="WM-ActionButton mr-2"
@click="removeItem(item.id)" v-if="$hasRole('Admin|Supervisor')">
<v-icon class="white--text mr-2 caption">fas fa-trash</v-icon>
<span>Remove</span>
</v-btn>
</template>
<span>Remove</span>
</v-tooltip>
</td>
</template>
</v-data-table>
</v-flex>
@@ -129,11 +170,13 @@ export default {
data: () => ({
headers: [
// {sortable: true,text: "ID",value: "id"},
{sortable: false, text: "Item ID", value: "id" },
{sortable: false, text: "ID", value: "id"},
{sortable: false, text: "Name", value: "name"},
{sortable: false, text: "Owner", value: "User"},
{sortable: false, text: "UDI", value: "udi"},
{sortable: false, text: "Size", value: "size"},
{sortable: false, text: "Action", value: "action", align: "left",width:'20%'}
{sortable: false, text: "Status", value: "status", width: '10%'},
{sortable: false, text: "Action", value: "action", align: "center", width: '20%'}
],
filter: {
name: '',
@@ -148,42 +191,100 @@ export default {
this.loadMyItem();
},
computed: {
...mapGetters('myItems', ["getFilters",'getMyItems','getCurrentPage','getLastPage']),
items(){ return this.getMyItems;},
currentPage(){ return this.getCurrentPage;},
lastPage(){ return this.getLastPage;},
...mapGetters('myItems', ["getFilters", 'getMyItems', 'getCurrentPage', 'getLastPage']),
items() {
return this.getMyItems;
},
currentPage() {
return this.getCurrentPage;
},
lastPage() {
return this.getLastPage;
},
},
methods: {
...mapMutations('myItems',["SET_FILTER"]),
...mapMutations('myItems', ["SET_FILTER"]),
...mapMutations("modal", ["changeCurrentModal"]),
...mapActions('myItems', ['loadMyItem', 'removeItem', 'showItem', 'generateBarcode']),
onFilterClick() {
this.loadMyItem();
},
updateFilter(key, value) {
this.SET_FILTER({ key, value });
this.SET_FILTER({key, value});
},
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');
}
},
async transfer(data) {
this.changeCurrentModal({
modal: "modal-user-list",
properties: {data},
});
},
async generateBarcode(item, type = null) {
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)
);
if (result && result.status == 200) {
this.changeCurrentModal({
modal: "modal-item-show",
properties: {result},
});
}
},
async remove(testResultId) {
const result = await ApiService.delete(
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.splice(key, 1);
}
}
}
},
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: {