transfer project in github
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<div>
|
||||
<CustomSubHeader>
|
||||
<CBreadcrumb class="border-0 mb-0">{{ title }}</CBreadcrumb>
|
||||
<CButton size="sm" color="success" :to="{name: 'admin-branch-party-sets-set',params:{set: 'new'}}" class="mr-auto">
|
||||
افزودن</CButton>
|
||||
</CustomSubHeader>
|
||||
|
||||
<CCard>
|
||||
<CCardHeader>
|
||||
<slot name="header">
|
||||
<i class="fal fa-bars"></i>
|
||||
<span>{{ list_title }}</span>
|
||||
</slot>
|
||||
</CCardHeader>
|
||||
<CCardBody>
|
||||
<el-table
|
||||
:data="partySets.docs"
|
||||
style="width: 100%">
|
||||
<el-table-column
|
||||
type="index"
|
||||
label="#">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="عکس"
|
||||
width="">
|
||||
<template slot-scope="scope">
|
||||
<img v-if="scope.row.image" :src="scope.row.image" alt="" style="width: 100px;">
|
||||
<i v-else class="fal fa-image-polaroid" style="font-size: 115px;"></i>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="title"
|
||||
label="عنوان"
|
||||
width="">
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="قیمت"
|
||||
width="">
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.price">{{ scope.row.price.toLocaleString() + ' ريال ' }}</span>
|
||||
<span v-else class="text-danger">بدون قیمت</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="وضعیت"
|
||||
width="">
|
||||
<template slot-scope="scope">
|
||||
<span class="text-success" v-if="scope.row.active">فعال</span>
|
||||
<span class="text-danger" v-else>غیر فعال</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="ویرایش"
|
||||
width="110"
|
||||
align="center">
|
||||
<template slot-scope="scope">
|
||||
<CButton color="danger" variant="outline" :key="scope.row._id + Math.random()" @click="remove(scope.row._id)">
|
||||
<i class="far fa-trash-alt"></i>
|
||||
</CButton>
|
||||
<CButton color="success" variant="outline" :key="scope.row._id"
|
||||
:to="{name: 'admin-branch-party-sets-set',params: {set: scope.row._id}}">
|
||||
<i class="far fa-eye"></i>
|
||||
</CButton>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
</el-table>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
<CCard class="col" v-if="partySets.totalDocs>20">
|
||||
<CRow alignHorizontal="center" style="padding : 10px">
|
||||
<el-pagination :hide-on-single-page="true" layout="prev, pager, next" :page-size="partySets.limit"
|
||||
@current-change="handleCurrentChange" :current-page.sync="partySets.page" :total="partySets.totalDocs">
|
||||
</el-pagination>
|
||||
</CRow>
|
||||
</CCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
title: 'لیست منوهای ویژه مهمانی',
|
||||
list_title: 'لیست',
|
||||
partySets: 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-party-sets",
|
||||
query: {
|
||||
page: page
|
||||
}
|
||||
});
|
||||
// }
|
||||
},
|
||||
remove(id) {
|
||||
this.$confirm('این مورد حذف شود؟', 'هشدار', {
|
||||
confirmButtonText: 'بله',
|
||||
cancelButtonText: 'لغو',
|
||||
type: 'warning'
|
||||
}).then(async () => {
|
||||
this.$axios.delete(`/api/admin/partySet/${id}`)
|
||||
.then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: 'منو با موفقیت حذف شد'
|
||||
})
|
||||
this.partySets.docs = this.partySets.docs.filter(item => item._id !== id)
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.status === 401) {
|
||||
return this.$message({
|
||||
type: 'error',
|
||||
message: 'لطفا دوباره وارد سیستم شوید.'
|
||||
})
|
||||
}
|
||||
if (err.response.status === 403) {
|
||||
return this.$message({
|
||||
type: 'error',
|
||||
message: err.response.data.message
|
||||
})
|
||||
} else console.log(err.response.data)
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'warning',
|
||||
message: 'عملیات لغو شد'
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.title
|
||||
}
|
||||
},
|
||||
layout: 'admin',
|
||||
async asyncData({$axios, query, error}) {
|
||||
try {
|
||||
const partySets = await $axios.get(`/api/admin/partySets?page=${query.page || 1}`)
|
||||
return {
|
||||
partySets: partySets.data
|
||||
}
|
||||
} catch (e) {
|
||||
if (e?.response?.status === 401) {
|
||||
error({
|
||||
status: 401,
|
||||
message: 'شما اجازه دسترسی به این صفحه را ندارید لطفا دوباره وارد شوید'
|
||||
})
|
||||
} else {
|
||||
error({
|
||||
status: 500,
|
||||
message: "مشکلی در گرفتن اطلاعات بوجود آمده است",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user