mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-12 18:31:06 +03:30
204 lines
6.0 KiB
Vue
204 lines
6.0 KiB
Vue
<template>
|
|
<v-container grid-list-xs>
|
|
<material-card
|
|
color="black"
|
|
title="Member List">
|
|
<v-layout align-center justify-center wrap class="px-5 mb-3">
|
|
<v-flex xs12 md3 sm3>
|
|
<v-text-field
|
|
class="pa-2"
|
|
color="black"
|
|
name="name"
|
|
label="Name"
|
|
></v-text-field>
|
|
</v-flex>
|
|
<v-flex xs12 md3 sm3>
|
|
<v-text-field
|
|
class="pa-2"
|
|
color="black"
|
|
name="date"
|
|
label="Date"
|
|
></v-text-field>
|
|
</v-flex>
|
|
<v-flex xs12 md3 sm3>
|
|
<v-text-field
|
|
class="pa-2"
|
|
color="black"
|
|
name="hospital"
|
|
label="Hospital"
|
|
></v-text-field>
|
|
</v-flex>
|
|
<v-flex xs12 md3 sm3>
|
|
<v-btn class="WM-CyanBlueGradient-BG" style="padding:10px 60px">
|
|
<v-icon class="white--text mr-2 caption">fas fa-search</v-icon>
|
|
<span class="white--text">Filter</span>
|
|
</v-btn>
|
|
</v-flex>
|
|
</v-layout>
|
|
<v-layout class="px-4 my-3">
|
|
<v-divider></v-divider>
|
|
</v-layout>
|
|
<v-layout align-center justify-center wrap class="px-5 my-2">
|
|
<v-flex xs12 md12 sm12>
|
|
<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="headline font-weight-light">{{item.name}}</td>
|
|
<td class="title font-weight-light">{{item.created_at}}</td>
|
|
<td class="title font-weight-light">
|
|
<span v-for="(role, key) in item.roles" :key="key">{{ role.name }}</span>
|
|
</td>
|
|
<td class="title font-weight-light">{{item.medical_center.name}}</td>
|
|
<td class="text-xs-right">
|
|
<v-btn
|
|
:color="item.status == 'Active' ? 'red' : 'green'"
|
|
@click="changeStatus(item.id)"
|
|
class="mr-2 WM-ActionButton"
|
|
>
|
|
<template v-if="item.status == 'Active'">
|
|
<v-icon class="white--text mr-2 caption">fas fa-user-tag</v-icon>
|
|
<span v-if="item.status == 'Active'">Susspended</span>
|
|
</template>
|
|
<template v-else>
|
|
<v-icon class="white--text mr-2 caption">fas fa-user-tag</v-icon>
|
|
<span>Active</span>
|
|
</template>
|
|
</v-btn>
|
|
<v-btn
|
|
color="orange darken-1"
|
|
@click="changeRoleModal(item)"
|
|
class="mr-2 WM-ActionButton"
|
|
>
|
|
<v-icon class="white--text mr-2 caption">fas fa-user-tag</v-icon>
|
|
<span>Role</span>
|
|
</v-btn>
|
|
<v-btn color="pink" class="WM-ActionButton" @click="remove(item.id)">
|
|
<v-icon class="white--text mr-2 caption">fas fa-times</v-icon>
|
|
<span>Remove</span>
|
|
</v-btn>
|
|
</td>
|
|
</template>
|
|
</v-data-table>
|
|
</v-flex>
|
|
</v-layout>
|
|
<v-layout class="px-4 my-3">
|
|
<v-divider></v-divider>
|
|
</v-layout>
|
|
<v-layout row wrap align-center justify-center class="mt-3">
|
|
<router-link :to="{name: '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">Back</span>
|
|
</v-btn>
|
|
</router-link>
|
|
</v-layout>
|
|
</material-card>
|
|
</v-container>
|
|
</template>
|
|
|
|
<script>
|
|
import { urls } from '@/config/urls'
|
|
import { ApiService } from '@/services'
|
|
import { mapMutations, mapGetters } from "vuex";
|
|
export default {
|
|
data: () => ({
|
|
headers : [
|
|
{
|
|
sortable : true,
|
|
text: 'Operator',
|
|
value: 'name'
|
|
},
|
|
{
|
|
sortable : false,
|
|
text: 'Date',
|
|
value: 'date'
|
|
},
|
|
{
|
|
sortable : false,
|
|
text: 'Role',
|
|
value: 'role'
|
|
},
|
|
{
|
|
sortable : true,
|
|
text: 'Hospital',
|
|
value: 'hospital'
|
|
},
|
|
{
|
|
sortable : false,
|
|
text: 'Action',
|
|
value: 'action',
|
|
align: 'right'
|
|
},
|
|
],
|
|
items: []
|
|
}),
|
|
created() {
|
|
this.load();
|
|
},
|
|
methods: {
|
|
async load() {
|
|
const result = await ApiService.get(urls.listOpertor );
|
|
if (result && result.status == 200) {
|
|
this.items = result.data.data.data;
|
|
} else {
|
|
this.$router.push({name:`Dashboard`});
|
|
}
|
|
},
|
|
async changeStatus(userId) {
|
|
const result = await ApiService.post(urls.changeStatusUser(userId));
|
|
if (result && result.status == 200) {
|
|
for (let user of this.items) {
|
|
if (user.id == userId) {
|
|
user.status = result.data.data.status;
|
|
}
|
|
}
|
|
} else {
|
|
this.$router.push({name:`Dashboard`});
|
|
}
|
|
},
|
|
...mapMutations("modal", ["changeCurrentModal"]),
|
|
changeRoleModal(user) {
|
|
this.changeCurrentModal({
|
|
modal: "modal-user-role",
|
|
properties: { user }
|
|
});
|
|
},
|
|
async remove(userId) {
|
|
const result = await ApiService.delete(urls.deleteUser(userId));
|
|
if (result && result.status == 200) {
|
|
for (const key in this.items) {
|
|
if (this.items.hasOwnProperty(key) && this.items[key].id == userId) {
|
|
this.items.splice(key, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters("modal", ["getModalResult"])
|
|
},
|
|
watch: {
|
|
getModalResult(user) {
|
|
for (const userList of this.items) {
|
|
if (userList.id == user.id) {
|
|
userList.roles = user.roles;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|