This commit is contained in:
sajjad talkhabi
2025-03-06 17:19:10 +03:30
parent ad39067d5a
commit 1c9a0d71a8
+21 -11
View File
@@ -52,7 +52,8 @@
<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" />
<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>
@@ -66,14 +67,18 @@
<td class="text-xs-right FlexBtn Height-MD-60">
<v-tooltip bottom open-on-hover v-if="$hasRole('Supervisor|Admin')">
<template v-slot:activator="{ on, attrs }">
<v-btn :color="item.status ? 'red' : 'green'" class="mr-2"
@click="changeStatus(item.id)" v-bind="attrs" v-on="on">
<v-icon class="white--text mr-1 caption">fas {{ item.status ? 'fa-close' :
'fa-check' }}</v-icon>
<span>{{ item.status ? 'reject' : 'approve' }}</span>
<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>{{ item.status ? 'reject' : 'approve' }}</span>
<span>{{ !['suspended', 'rejected'].includes(item.status) ? 'reject' : 'approve'
}}</span>
</v-tooltip>
<v-tooltip bottom open-on-hover>
<template v-slot:activator="{ on, attrs }">
@@ -126,7 +131,8 @@
</v-layout>
<v-divider></v-divider>
<div class="text-xs-center" v-if="lastPage > 1">
<v-pagination color="black" v-model="currentPage" :length="lastPage" :total-visible="6"></v-pagination>
<v-pagination color="black" v-model="currentPage" :length="lastPage"
:total-visible="6"></v-pagination>
</div>
<v-layout row wrap align-center justify-center class="mt-3">
<router-link to="/dashboard">
@@ -267,15 +273,19 @@ export default {
}
}
},
async changeStatus(id) {
async changeStatus(item) {
const payload = {
status: ['suspended', 'rejected'].includes(item.status) ? 'approved' : 'rejected',
}
const result = await ApiService.post(
urls.changeItemStatus(id)
urls.changeItemStatus(item.id),
payload
);
if (result) {
for (const key in this.items) {
if (
this.items.hasOwnProperty(key) &&
this.items[key].id == id
this.items[key].id == item.id
) {
this.items[key].status = result.data.data.status;
}