This commit is contained in:
Swift
2024-02-08 16:15:59 +03:30
parent 1c3751b5a0
commit 3f39241b05
4 changed files with 200 additions and 3 deletions
+52
View File
@@ -0,0 +1,52 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0">برند ها</CBreadcrumb>
<CButton size="sm" color="primary" class="mr-auto" :to="{ name: 'admin-brands' }">برگشت به صفحه قبل</CButton>
<CButton v-if="$route.params.item === 'new'" size="sm" color="success" style="margin-right: 10px" @click="add"
>افزودن</CButton
>
<CButton v-else size="sm" color="success" style="margin-right: 10px" @click="update">بروزرسانی</CButton>
</CustomSubHeader>
<CRow>
</CRow>
</div>
</template>
<script>
export default {
name: 'AddminBrandsItem',
layout: 'admin',
async asyncData({ $axios, params, error }) {
try {
const data = {}
if (params.admin !== 'new') {
const brand = await $axios.get(`/api/admin/brand/${params.item}`)
data.brand = brand.data
}
return data
} catch (e) {
error({ status: 404, message: 'Page not found' })
}
},
data() {
return {
brand: {
},
validation: {},
}
},
head() {
return {
title: "برندها"
}
},
methods: {
}
}
</script>
+144
View File
@@ -0,0 +1,144 @@
<template>
<div>
<CustomSubHeader>
<CBreadcrumb class="border-0 mb-0"> برندها </CBreadcrumb>
<CButton size="sm" color="success" :to="{ name: 'admin-brands-item', params: { item: 'new' } }" class="mr-auto"
>افزودن</CButton
>
</CustomSubHeader>
<CCard>
<CCardHeader>
<slot name="header">
<CIcon name="cil-grid" />
برندها
</slot>
</CCardHeader>
<CCardBody>
<el-table :data="brands" style="width: 100%">
<el-table-column type="index" label="#"> </el-table-column>
<el-table-column width="80">
<template slot-scope="scope">
<img width="60" :src="config.apiAsanMarket + scope.row.logo">
</template>
</el-table-column>
<el-table-column prop="title" label="نام" width="">
</el-table-column>
<el-table-column label="توضیحات" width="">
<template slot-scope="scope">
<span class="singleLineTxt" :title="scope.row.national"> {{ scope.row.description }} </span>
</template>
</el-table-column>
<el-table-column label="لینک" width="">
<template slot-scope="scope">
<span class="singleLineTxt" :title="scope.row.national"> {{ scope.row.link }} </span>
</template>
</el-table-column>
<el-table-column label="نمایش" width="110" align="center">
<template slot-scope="scope">
<CButton
:key="scope.row._id"
color="success"
variant="outline"
:to="{ name: 'admin-brands-item', params: { item: scope.row._id } }"
>
<i class="fal fa-eye"></i>
</CButton>
<CButton
:key="scope.row._id"
color="danger"
variant="outline"
@click="deleteBrands(scope.row._id)"
>
<i class="fal fa-trash"></i>
</CButton>
</template>
</el-table-column>
</el-table>
</CCardBody>
</CCard>
</div>
</template>
<script>
export default {
name: 'AdminBrandsList',
layout: 'admin',
async asyncData({ $axios, error }) {
},
data() {
return {
brands:null
}
},
computed: {
config() {
return this.$config
}
},
beforeMount(){
this.$axios.get('/api/public//brand').then(res=>{
this.brands = res.data
console.log(res.data)
}).catch(err=>{
console.log(err)
})
},
methods: {
deleteBrands(id){
this.$confirm('این برند حذف شود؟', 'هشدار', {
confirmButtonText: 'بله',
cancelButtonText: 'لغو',
type: 'warning'
})
.then(() => {
this.$axios
.delete(`/api/admin/brand/${id}`)
.then(response => {
this.brands = this.brans.filter(item => item._id !== id)
this.$message({
type: 'success',
message: 'برند حذف شد'
})
})
.catch(err => {
this.$message({
type: 'error',
message: err.response.data.message
})
})
})
.catch(() => {
this.$message({
type: 'warning',
message: 'عملیات لغو شد'
})
})
}
}
}
</script>