award
This commit is contained in:
@@ -365,7 +365,7 @@
|
||||
<CSidebarNavItem
|
||||
v-if="hasPermission('gps')"
|
||||
name="جوایز"
|
||||
:to="{ name: 'admin-admins-admin', params: { admin: 'new' } }"
|
||||
:to="{ name: 'admin-gps-award' }"
|
||||
font-icon="fal fa-gift"
|
||||
:exact="false"
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog
|
||||
:title="dialogState === 1 ? 'به روزرسانی اطلاعات' : 'ساخت جایزه '"
|
||||
:visible.sync="centerDialogVisible"
|
||||
width="40%"
|
||||
center
|
||||
>
|
||||
<CRow>
|
||||
<CCol xl="12" class="my-3">
|
||||
<el-input v-model="award.title" placeholder="سر تیتر"></el-input>
|
||||
<p v-if="validation.title" class="errMsg">{{ validation.title.msg }}</p>
|
||||
|
||||
</CCol>
|
||||
<CCol xl="12" class="my-3">
|
||||
<el-input v-model="award.desc" type="textarea" :rows="3" placeholder="توضیحات"> </el-input>
|
||||
<p v-if="validation.desc" class="errMsg">{{ validation.desc.msg }}</p>
|
||||
|
||||
</CCol>
|
||||
<CCol xl="8" class="my-3">
|
||||
<persian-date-picker
|
||||
v-model="award.expireDate"
|
||||
display-format="jYYYY/jMM/jDD"
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="تاریخ را انتخاب کنید"
|
||||
color="#065495"
|
||||
/>
|
||||
<p v-if="validation.expireDate" class="errMsg">{{ validation.expireDate.msg }}</p>
|
||||
|
||||
</CCol>
|
||||
<CCol xl="4" class="my-3">
|
||||
<el-input-number v-model="award.score" controls-position="right" :min="1" :max="10000"></el-input-number>
|
||||
<p v-if="validation.score" class="errMsg">{{ validation.score.msg }}</p>
|
||||
|
||||
</CCol>
|
||||
</CRow>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="centerDialogVisible = false">بستن</el-button>
|
||||
<el-button type="primary" @click="post(dialogState, award)">تایید</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
|
||||
<CustomSubHeader>
|
||||
<CBreadcrumb class="border-0 mb-0"> جوایز</CBreadcrumb>
|
||||
<CButton size="sm" color="success" @click="showDialog(0, {})" class="mr-auto">افزودن</CButton>
|
||||
</CustomSubHeader>
|
||||
|
||||
<CRow>
|
||||
<CCol xl="6">
|
||||
<CCard>
|
||||
<CCardHeader>
|
||||
<slot name="header">
|
||||
<i class="fas fa-filter"></i>
|
||||
<b>فیلتر ها</b>
|
||||
</slot>
|
||||
</CCardHeader>
|
||||
|
||||
<CCardBody>
|
||||
<CRow>
|
||||
<CCol sm="12">
|
||||
<h4>جستجو در لیست:</h4>
|
||||
<el-input
|
||||
v-model="filterText"
|
||||
clearable
|
||||
placeholder=""
|
||||
style="display: inline-block; max-width: 500px; margin-top: 8px"
|
||||
></el-input>
|
||||
</CCol>
|
||||
</CRow>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</CCol>
|
||||
</CRow>
|
||||
|
||||
<CCard>
|
||||
<CCardHeader>
|
||||
<slot name="header">
|
||||
<CIcon name="cil-grid" />
|
||||
جوایز
|
||||
</slot>
|
||||
</CCardHeader>
|
||||
|
||||
<CCardBody>
|
||||
<el-table :data="filteredItems" style="width: 100%">
|
||||
<el-table-column type="index" label="#"> </el-table-column>
|
||||
|
||||
<el-table-column prop="score" label="امتیاز" width=""> </el-table-column>
|
||||
<el-table-column prop="title" label="سر تیتر" width=""> </el-table-column>
|
||||
<el-table-column prop="desc" label="توضیحات" width=""> </el-table-column>
|
||||
<el-table-column label="مهلت استفاده" width="">
|
||||
<template slot-scope="scope">
|
||||
{{ $jDate(scope.row.expireDate) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="تغییرات" width="110" align="center">
|
||||
<template slot-scope="scope">
|
||||
<CButton :key="scope.row._id" color="info" variant="outline" @click="showDialog(1, scope.row)">
|
||||
<i class="fa fa-pencil"></i>
|
||||
</CButton>
|
||||
<CButton :key="scope.row._id" color="danger" variant="outline" @click="deleteAward(scope.row._id)">
|
||||
<i class="fa fa-trash"></i>
|
||||
</CButton>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</CCardBody>
|
||||
</CCard>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'AdminGpsAwardList',
|
||||
layout: 'admin',
|
||||
async asyncData({ $axios, error, query }) {
|
||||
try {
|
||||
const { data } = await $axios.get('/api/admin/gps/award')
|
||||
|
||||
return {
|
||||
awards: data
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
awards: [],
|
||||
centerDialogVisible: false,
|
||||
award: {
|
||||
score: '',
|
||||
title: '',
|
||||
desc: '',
|
||||
expireDate: ''
|
||||
},
|
||||
filterText: '',
|
||||
dialogState: 0,
|
||||
validation: {}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
config() {
|
||||
return this.$config
|
||||
},
|
||||
filteredItems() {
|
||||
const filterText = this.filterText
|
||||
if (!this.filterText.length) return this.awards
|
||||
else {
|
||||
return this.awards.filter(item => {
|
||||
return item.score.includes(filterText) || item.title.includes(filterText) || item.desc.includes(filterText)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showDialog(state, data) {
|
||||
if (state === 1) {
|
||||
this.dialogState = 1
|
||||
this.award = data
|
||||
this.centerDialogVisible = true
|
||||
} else {
|
||||
this.dialogState = 0
|
||||
this.award = {
|
||||
score: '',
|
||||
title: '',
|
||||
desc: '',
|
||||
expireDate: ''
|
||||
}
|
||||
this.centerDialogVisible = true
|
||||
}
|
||||
},
|
||||
deleteAward(id){
|
||||
this.$axios.delete(`/api/admin/gps/award/${id}`).then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: res.data.msg
|
||||
})
|
||||
this.centerDialogVisible = false
|
||||
this.$nuxt.refresh()
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.data.status === 401) {
|
||||
return this.$message({
|
||||
type: 'warning',
|
||||
message: 'لطفا دوباره وارد حساب خود شوید'
|
||||
})
|
||||
}
|
||||
if (err.response.status === 422) this.validation = err.response.data.validation
|
||||
else {
|
||||
console.log(err)
|
||||
return this.$message({
|
||||
type: 'warning',
|
||||
message: err.response.data.msg
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
post(status, data) {
|
||||
console.log(data.expireDate);
|
||||
|
||||
if(status === 1){
|
||||
this.$axios.put(`/api/admin/gps/award/${data._id}`,data).then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: res.data.msg
|
||||
})
|
||||
|
||||
this.centerDialogVisible = false
|
||||
this.$nuxt.refresh()
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.data.status === 401) {
|
||||
return this.$message({
|
||||
type: 'warning',
|
||||
message: 'لطفا دوباره وارد حساب خود شوید'
|
||||
})
|
||||
}
|
||||
if (err.response.status === 422) this.validation = err.response.data.validation
|
||||
else {
|
||||
console.log(err)
|
||||
return this.$message({
|
||||
type: 'warning',
|
||||
message: err.response.data.msg
|
||||
})
|
||||
}
|
||||
})
|
||||
}else{
|
||||
this.$axios.post(`/api/admin/gps/award`,data).then(res => {
|
||||
this.$message({
|
||||
type: 'success',
|
||||
message: res.data.msg
|
||||
})
|
||||
this.centerDialogVisible = false
|
||||
this.$nuxt.refresh()
|
||||
})
|
||||
.catch(err => {
|
||||
if (err.response.data.status === 401) {
|
||||
return this.$message({
|
||||
type: 'warning',
|
||||
message: 'لطفا دوباره وارد حساب خود شوید'
|
||||
})
|
||||
}
|
||||
if (err.response.status === 422) this.validation = err.response.data.validation
|
||||
else {
|
||||
console.log(err)
|
||||
return this.$message({
|
||||
type: 'warning',
|
||||
message: err.response.data.msg
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.datePickerWrapper {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
|
||||
.vpd-input-group {
|
||||
@include borderRadius(3px);
|
||||
overflow: hidden;
|
||||
|
||||
input {
|
||||
&::placeholder {
|
||||
color: rgba(#000, 0.4);
|
||||
}
|
||||
}
|
||||
}
|
||||
.vpd-icon-btn {
|
||||
padding: 12px 10px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -24,8 +24,8 @@
|
||||
<p>
|
||||
برای اضافه کردن دستگاه جدید فقط کافی است فایل نمونه رو دانلود کنید و به ترتیب مقادیر رو وارد کنید .
|
||||
<br>
|
||||
برای آپدیت یک مقدار باید خروجی اکسل گرفته و نسبت به IMEI ثبت شد مقادیر ان را تغییر دهید و با پسوند XLSX خروجی گرفته و آپلود کرده
|
||||
</p>
|
||||
برای به روزرسانی یک دستگاه به صورت تکی یا عمده داخل فایل نمونه IMEI را قرار داده و مقادیر جدید آن را ثبت کنید و آپلود کنید
|
||||
</p>
|
||||
<a
|
||||
download
|
||||
target="_blank"
|
||||
|
||||
@@ -195,7 +195,10 @@ export default {
|
||||
if (!this.filterText.length) return filterUsersByType
|
||||
else {
|
||||
return this.requestsData.filter(item => {
|
||||
return item.IMEI.includes(filterText) || item.deviceId.model.includes(filterText)
|
||||
return item.userId.mobile_number.includes(filterText) ||
|
||||
item.userId.national_code.includes(filterText) ||
|
||||
item.userId.last_name.includes(filterText) ||
|
||||
item.userId.first_name.includes(filterText)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -7,8 +7,8 @@ const Award = require('../models/GPS.Award');
|
||||
module.exports.createAward = [
|
||||
[
|
||||
body('score').notEmpty().isInt().withMessage(_sr.fa.required.field),
|
||||
body('title').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('desc').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('title').notEmpty().isString().withMessage(_sr.fa.required.title),
|
||||
body('desc').notEmpty().isString().withMessage(_sr.fa.required.description),
|
||||
body('expireDate').notEmpty().withMessage(_sr.fa.required.field),
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
@@ -16,12 +16,11 @@ module.exports.createAward = [
|
||||
const { score, title, desc, expireDate } = req.body;
|
||||
const fixDate = new Date(expireDate)
|
||||
const award = await Award.create({ score, title, desc, expireDate:fixDate })
|
||||
// res.status(201).json({
|
||||
// msg: _sr.fa.response.success_save,
|
||||
// data: award
|
||||
// })
|
||||
res.status(201).json(award)
|
||||
|
||||
res.status(201).json({
|
||||
msg: _sr.fa.response.success_save,
|
||||
data: award
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
]
|
||||
@@ -29,12 +28,12 @@ module.exports.createAward = [
|
||||
|
||||
module.exports.findAllUser = async (req, res) => {
|
||||
const toDay = new Date()
|
||||
const data = await Award.find({expireDate: {$gt: toDay}})
|
||||
const data = await Award.find({expireDate: {$gt: toDay}, isDeleted:false})
|
||||
res.status(200).json(data)
|
||||
}
|
||||
|
||||
module.exports.findAllAdmin = async (req, res) => {
|
||||
const data = await Award.find({})
|
||||
const data = await Award.find({isDeleted:false})
|
||||
res.status(200).json(data)
|
||||
}
|
||||
|
||||
@@ -58,8 +57,8 @@ module.exports.update =[
|
||||
[
|
||||
param('id').notEmpty().isMongoId().withMessage('ایدی را وارد یا تصحیح کنید'),
|
||||
body('score').notEmpty().isInt().withMessage(_sr.fa.required.field),
|
||||
body('title').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('desc').notEmpty().isString().withMessage(_sr.fa.required.field),
|
||||
body('title').notEmpty().isString().withMessage(_sr.fa.required.title),
|
||||
body('desc').notEmpty().isString().withMessage(_sr.fa.required.description),
|
||||
body('expireDate').notEmpty().withMessage(_sr.fa.required.field),
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
@@ -74,11 +73,11 @@ module.exports.update =[
|
||||
data.desc = desc;
|
||||
data.expireDate = new Date(expireDate)
|
||||
data.save()
|
||||
// res.status(200).json({
|
||||
// msg: _sr.fa.response.success_save,
|
||||
// data
|
||||
// })
|
||||
res.status(200).json(data)
|
||||
res.status(200).json({
|
||||
msg: _sr.fa.response.success_save,
|
||||
data
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -86,3 +85,26 @@ module.exports.update =[
|
||||
]
|
||||
|
||||
|
||||
module.exports.delete=[
|
||||
[
|
||||
param('id').notEmpty().isMongoId().withMessage('ایدی را وارد یا تصحیح کنید'),
|
||||
],
|
||||
checkValidations(validationResult),
|
||||
async (req, res) => {
|
||||
const data = await Award.findById(req.params.id)
|
||||
if (!data) {
|
||||
res.status(404).json({ msg: _sr.fa.not_found.item_id })
|
||||
} else {
|
||||
data.isDeleted = true;
|
||||
data.expireDate = Date.now()
|
||||
data.save()
|
||||
res.status(200).json({
|
||||
msg: _sr.fa.response.success_remove,
|
||||
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
]
|
||||
@@ -5,7 +5,11 @@ const AwairdSchema = mongoose.Schema({
|
||||
score:Number,
|
||||
title:String,
|
||||
desc:String,
|
||||
expireDate:Date
|
||||
expireDate:Date,
|
||||
isDeleted:{
|
||||
type:Boolean,
|
||||
default:false
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@ router.post('/gps/award',hasPermission('gps'), award.createAward)
|
||||
router.get('/gps/award',hasPermission('gps'), award.findAllAdmin)
|
||||
router.get('/gps/award/:id',hasPermission('gps'), award.findOne)
|
||||
router.put('/gps/award/:id',hasPermission('gps'), award.update)
|
||||
router.delete('/gps/award/:id',hasPermission('gps'), award.delete)
|
||||
|
||||
/// ////////////// Award request
|
||||
router.get('/gps/award-request',hasPermission('gps'), awardRequest.findAllAdmin)
|
||||
|
||||
Reference in New Issue
Block a user