Add
This commit is contained in:
+2
-1
@@ -14,10 +14,11 @@ import {
|
|||||||
PanatechStockAreaId
|
PanatechStockAreaId
|
||||||
} from './server/_env'
|
} from './server/_env'
|
||||||
import { serverMiddleware } from './server/index'
|
import { serverMiddleware } from './server/index'
|
||||||
|
import { rs } from './server/plugins/resHeader'
|
||||||
|
|
||||||
const serverMiddlewareArray = []
|
const serverMiddlewareArray = []
|
||||||
if (isProduction) serverMiddlewareArray.push(serverMiddleware)
|
if (isProduction) serverMiddlewareArray.push(serverMiddleware)
|
||||||
|
serverMiddlewareArray.push(rs)
|
||||||
export default {
|
export default {
|
||||||
// Global page headers (https://go.nuxtjs.dev/config-head)
|
// Global page headers (https://go.nuxtjs.dev/config-head)
|
||||||
head: {
|
head: {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
@@ -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>
|
||||||
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const Brand = require("../models/Brand");
|
const Brand = require("../models/Brand");
|
||||||
const { checkValidations } = require("../plugins/HelperFunctions")
|
const { checkValidations } = require("../plugins/controllersHelperFunctions")
|
||||||
const { body, validationResult } = require('express-validator')
|
const { body, validationResult } = require('express-validator')
|
||||||
const { _sr } = require("../plugins/resServer")
|
const { _sr } = require("../plugins/serverResponses")
|
||||||
|
|
||||||
|
|
||||||
//@desc Create a brand
|
//@desc Create a brand
|
||||||
|
|||||||
Reference in New Issue
Block a user