mirror of
https://git.meshkee.com/cssd/cssd-front.git
synced 2026-10-10 19:43:18 +03:30
330 lines
18 KiB
Vue
330 lines
18 KiB
Vue
<template>
|
|
<div class>
|
|
<v-container fluid>
|
|
<material-card class color="black" title="All Items" text>
|
|
<v-layout align-center wrap class="px-3">
|
|
<v-flex xs12 sm4 md4 lg2 xl1 class="WM-FlexCenter">
|
|
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
|
|
<v-text-field class="pt-3 pr-3" v-model="filter.item_id" label="Item ID"
|
|
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"/>
|
|
<v-text-field class="pt-3 pr-3" v-model="filter.name" label="Name" 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"/>
|
|
<v-text-field class="pt-3 pr-3" v-model="filter.user_name" label="Owner" color="black"/>
|
|
</v-flex>
|
|
<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="pt-3 pr-3" v-model="filter.medical_center_id" item-text="name"
|
|
item-value="id" label="Hospital" color="black" :items="medicalCenters"
|
|
:clearable="true"/>
|
|
</v-flex>
|
|
<v-flex xs12 sm3 md3 lg2 xl1 class="WM-FlexCenter">
|
|
<v-icon class="fas fa-sort-numeric-up mr-2 WM-Margin-B-8"/>
|
|
<v-text-field class="pt-3 pr-3" v-model="filter.size" label="Size" color="black"/>
|
|
</v-flex>
|
|
<v-flex xs12 sm3 md3 lg2 xl1 class="WM-FlexCenter">
|
|
<v-icon class="fa fa-align-left mr-2 WM-Margin-B-8"/>
|
|
<v-text-field class="pt-3 pr-3" v-model="filter.udi" label="UDI" color="black"/>
|
|
</v-flex>
|
|
<!--btn-->
|
|
<v-spacer/>
|
|
<v-flex xs12 sm6 md6 lg12 xl3 class="WM-Align-R">
|
|
<v-tooltip bottom open-on-hover>
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<v-btn v-bind="attrs" v-on="on"
|
|
color="WM-Tooltip-Btn WM-Outline-Btn WM-Border WM-Margin-BT-0 WM-Border-Black mr-2"
|
|
@click="load()">
|
|
<v-icon class="black--text caption">fas fa-search</v-icon>
|
|
</v-btn>
|
|
</template>
|
|
<span>Filter</span>
|
|
</v-tooltip>
|
|
|
|
<v-btn class="WM-Outline-Btn WM-Border mr-2 WM-Margin-BT-0 WM-Border-Black" @click="download()" style="padding: 10px 30px;">
|
|
<v-icon class="black--text mr-2 caption">fas fa-share-square</v-icon>
|
|
<span class="black--text">EXPORT</span>
|
|
</v-btn>
|
|
|
|
<router-link :to="{ name: 'AddItem' }">
|
|
<v-btn class="WM-CyanBlueGradient-BG WM-Margin-BT-0" style="padding:10px 30px">
|
|
<v-icon class="white--text mr-2 caption">fas fa-plus</v-icon>
|
|
<span class="white--text">Add</span>
|
|
</v-btn>
|
|
</router-link>
|
|
</v-flex>
|
|
</v-layout>
|
|
<v-layout class="px-3 my-3">
|
|
<v-divider/>
|
|
</v-layout>
|
|
<v-layout align-center wrap class="my-3 px-3">
|
|
<v-flex md12>
|
|
<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"/>
|
|
</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.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">
|
|
<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="`${status.font_color}--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="light-gray" class="mr-2"
|
|
@click="show(item.id)">
|
|
<v-icon class="black--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 }">
|
|
<v-btn class="mr-2" v-bind="attrs" v-on="on" color="light-gray"
|
|
@click="generateBarcode(item, 'Item')">
|
|
<v-icon class="black--text mr-2 caption">fas fa-barcode</v-icon>
|
|
<span class="CSSD-font">Generate Barcode</span>
|
|
</v-btn>
|
|
</template>
|
|
<span>Generate Barcode</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="light-gray"
|
|
v-if="$hasRole('Admin|Supervisor') || item.user_id == $store.state.user.id"
|
|
@click="transfer(item)">
|
|
<v-icon class="black--text mr-2 caption">fas fa-exchange-alt</v-icon>
|
|
<span class="CSSD-font">Transfer</span>
|
|
</v-btn>
|
|
</template>
|
|
<span>Transfer</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="black" 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="red" class="WM-ActionButton mr-2"
|
|
@click="removeModal(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>
|
|
</td>
|
|
</template>
|
|
</v-data-table>
|
|
</v-flex>
|
|
</v-layout>
|
|
<v-divider/>
|
|
<div class="text-xs-center" v-if="lastPage > 1">
|
|
<v-pagination color="black" v-model="currentPage" :length="lastPage"
|
|
:total-visible="6"/>
|
|
</div>
|
|
<v-layout row wrap align-center justify-center class="mt-3 px-3">
|
|
<router-link to="/dashboard">
|
|
<v-btn class="WM-NoShadow WM-Outline-Btn WM-Border WM-Border-Black ml-5">
|
|
<v-icon class="black--text mr-2 caption">fas fa-chevron-left</v-icon>
|
|
<span class="black--text CSSD-font">Back</span>
|
|
</v-btn>
|
|
</router-link>
|
|
</v-layout>
|
|
</material-card>
|
|
</v-container>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import {ApiService} from "@/services";
|
|
import {urls} from "@/config/urls";
|
|
import {mapMutations, mapGetters} from "vuex";
|
|
import toast from "@/services/global/toast.service";
|
|
|
|
export default {
|
|
metaInfo() {
|
|
return {
|
|
title: this.$route.meta.title,
|
|
meta: this.$route.meta.metaTags || []
|
|
}
|
|
},
|
|
data: () => ({
|
|
headers: [
|
|
// {sortable: true,text: "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", width: '10%'},
|
|
{sortable: false, text: "Action", value: "action", align: "center", width: '20%'}
|
|
],
|
|
filter: {
|
|
name: '',
|
|
size: '',
|
|
item_id: '',
|
|
medical_center_id: ''
|
|
},
|
|
items: [],
|
|
currentPage: 1,
|
|
lastPage: 1,
|
|
medicalCenters: []
|
|
|
|
}),
|
|
created() {
|
|
this.load();
|
|
},
|
|
methods: {
|
|
...mapMutations("modal", ["changeCurrentModal", "closeModal"]),
|
|
async load(page = 1) {
|
|
let filter = '?';
|
|
for (const key in this.filter) {
|
|
if (this.filter.hasOwnProperty(key)) {
|
|
filter += `${key}=${this.filter[key]}&`;
|
|
}
|
|
}
|
|
filter += (page) ? `page=${page}` : `page=1`;
|
|
const result = await ApiService.get(urls.listItem(filter));
|
|
if (result && result.status == 200) {
|
|
this.items = result.data.data;
|
|
this.currentPage = result.data.meta.current_page;
|
|
this.lastPage = result.data.meta.last_page;
|
|
}
|
|
this.loadMedicalCenters();
|
|
},
|
|
async generateBarcode(item, type = null) {
|
|
let code = item.udi;
|
|
if (code) {
|
|
const result = await ApiService.post(urls.Barcode(item.id, type));
|
|
if (result && result.status == 200) {
|
|
this.changeCurrentModal({
|
|
modal: "modal-barcode-barcode",
|
|
properties: {result, item},
|
|
});
|
|
}
|
|
} else {
|
|
toast.error('An error occurred while generating the barcode . please first set UDI');
|
|
}
|
|
},
|
|
async show(id) {
|
|
const result = await ApiService.get(urls.showItem(id));
|
|
if (result && result.status == 200) {
|
|
this.changeCurrentModal({
|
|
modal: "modal-item-show",
|
|
properties: {result},
|
|
});
|
|
}
|
|
},
|
|
async download() {
|
|
const result = await ApiService.get(urls.exportItems());
|
|
if (result && result.status == 200) {
|
|
window.open(result.data.data.url, '_blank');
|
|
}
|
|
},
|
|
removeModal(id) {
|
|
this.changeCurrentModal({
|
|
modal: "modal-user-confirmation",
|
|
properties: {width: '30'},
|
|
success: async () => {
|
|
const result = await ApiService.delete(urls.removeItem(id));
|
|
if (result && result.status == 200) {
|
|
for (const key in this.items) {
|
|
if (this.items.hasOwnProperty(key) && this.items[key].id == id) {
|
|
this.items.splice(key, 1);
|
|
}
|
|
}
|
|
}
|
|
this.closeModal();
|
|
},
|
|
});
|
|
},
|
|
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: 'approved', label: 'approve', color: 'cyan', font_color : 'white', icon: 'fa-check'},
|
|
{status: 'rejected', label: 'reject', color: 'light-gray',font_color : 'black', icon: 'fa-close'},
|
|
]
|
|
} else {
|
|
const nextStatus = item.status === 'rejected' ? 'approved' : 'rejected'
|
|
return [
|
|
{
|
|
status: nextStatus,
|
|
label: nextStatus === 'approved' ? 'approve' : 'reject',
|
|
color: nextStatus === 'approved' ? 'cyan' : 'light-gray',
|
|
font_color: nextStatus === 'approved' ? 'white' : 'black',
|
|
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
|
|
}
|
|
},
|
|
async transfer(data) {
|
|
this.changeCurrentModal({
|
|
modal: "modal-user-list",
|
|
properties: {data},
|
|
});
|
|
},
|
|
},
|
|
watch: {
|
|
currentPage(page) {
|
|
this.load(page);
|
|
},
|
|
}
|
|
};
|
|
</script>
|