192 lines
5.2 KiB
Vue
192 lines
5.2 KiB
Vue
<template>
|
|
<div>
|
|
<CustomSubHeader>
|
|
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
|
|
<a :href="`/api/public/users/exportExel/${$auth.user._id}`" target="_blank" class="mr-auto">
|
|
<CButton size="sm" color="success">خروجی اکسل</CButton>
|
|
</a>
|
|
</CustomSubHeader>
|
|
|
|
<CCard>
|
|
<CCardHeader>
|
|
<slot name="header">
|
|
<i class="fal fa-bars"></i>
|
|
<span>{{ list_title }}</span>
|
|
</slot>
|
|
</CCardHeader>
|
|
<CCardBody>
|
|
<el-table
|
|
:data="customers.docs"
|
|
style="width: 100%">
|
|
<el-table-column
|
|
type="index"
|
|
label="#">
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
prop="first_name"
|
|
label="نام"
|
|
width="">
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
prop="last_name"
|
|
label="نام خانوادگی"
|
|
width="">
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
prop="mobile_number"
|
|
label="شماره موبایل"
|
|
width="">
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
prop="business_code"
|
|
label="کد مشتری"
|
|
width="">
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column
|
|
prop="score"
|
|
label="score"
|
|
width="">
|
|
</el-table-column>
|
|
|
|
<el-table-column
|
|
label="مشاهده"
|
|
width="70"
|
|
align="center">
|
|
<template slot-scope="scope">
|
|
<CButton color="success" variant="outline" :key="scope.row._id"
|
|
:to="{name: 'admin-branch-customers-profile',params: {profile: scope.row._id}}">
|
|
<i class="far fa-eye"></i>
|
|
</CButton>
|
|
</template>
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
</CCardBody>
|
|
</CCard>
|
|
<CCard class="col" v-if="customers.totalDocs>20">
|
|
<CRow alignHorizontal="center" style="padding : 10px">
|
|
<el-pagination :hide-on-single-page="true" layout="prev, pager, next" :page-size="customers.limit"
|
|
@current-change="handleCurrentChange" :current-page.sync="customers.page" :total="customers.totalDocs">
|
|
</el-pagination>
|
|
</CRow>
|
|
</CCard>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
title: 'لیست مشتریان',
|
|
list_title: 'لیست',
|
|
customers: null
|
|
}
|
|
},
|
|
computed: {
|
|
pageQuery() {
|
|
return this.$route.query.page;
|
|
}
|
|
},
|
|
watch:{
|
|
pageQuery(newPage, oldPage) {
|
|
this.$nuxt.refresh();
|
|
}
|
|
},
|
|
methods: {
|
|
handleCurrentChange(page) {
|
|
// if (!_.isEmpty(this.search)) {
|
|
// this.handleSearch(page);
|
|
// } else {
|
|
this.$router.push({
|
|
name: "admin-branch-customers",
|
|
query: {
|
|
page: page
|
|
}
|
|
});
|
|
// }
|
|
},
|
|
deleteUser(id) {
|
|
this.$confirm('کاربر حذف شود؟', 'هشدار', {
|
|
confirmButtonText: 'بله',
|
|
cancelButtonText: 'لغو',
|
|
type: 'warning'
|
|
}).then(async () => {
|
|
this.$axios.delete(`/api/admin/admin/${id}`)
|
|
.then(res => {
|
|
this.$message({
|
|
type: 'success',
|
|
message: 'کاربر با موفقیت حذف شد'
|
|
})
|
|
this.customers.docs = this.customers.docs.filter(item => item._id !== id)
|
|
})
|
|
.catch(err => {
|
|
if (err.response.status === 401) {
|
|
return this.$message({
|
|
type: 'error',
|
|
message: 'لطفا دوباره وارد سیستم شوید.'
|
|
})
|
|
}
|
|
console.log(err.response.data)
|
|
})
|
|
}).catch(() => {
|
|
this.$message({
|
|
type: 'warning',
|
|
message: 'عملیات لغو شد'
|
|
})
|
|
})
|
|
},
|
|
async createExel(){
|
|
try {
|
|
const createExel = await this.$axios.$get(`/api/admin/users/exportExel`);
|
|
|
|
console.log(createExel)
|
|
}catch (e) {
|
|
if (e?.response?.status === 401) {
|
|
this.$message({
|
|
type: 'warning',
|
|
message: 'شما اجازه دسترسی به این صفحه را ندارید لطفا دوباره وارد شوید'
|
|
})
|
|
} else {
|
|
this.$message({
|
|
type: 'warning',
|
|
message: 'مشکلی در گرفتن اطلاعات بوجود آمده است'
|
|
})
|
|
}
|
|
}
|
|
}
|
|
},
|
|
head() {
|
|
return {
|
|
title: this.title
|
|
}
|
|
},
|
|
layout: 'admin',
|
|
async asyncData({$axios,query, error, params}) {
|
|
try {
|
|
const customers = await $axios.get(`/api/admin/users/${params.branch}?page=${query.page || 1}`)
|
|
return {
|
|
customers: customers.data
|
|
}
|
|
} catch (e) {
|
|
if (e?.response?.status === 401) {
|
|
error({
|
|
status: 401,
|
|
message: 'شما اجازه دسترسی به این صفحه را ندارید لطفا دوباره وارد شوید'
|
|
})
|
|
} else {
|
|
error({
|
|
status: 500,
|
|
message: "مشکلی در گرفتن اطلاعات بوجود آمده است",
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|