Authored by 李奇

活动创建修改

... ... @@ -19,7 +19,7 @@ const whSurfController = {
page: 'wheel-surf'
});
},
async create(req, res) {
async actCreate(req, res) {
const title = req.body.title;
const startTime = req.body.startTime;
const endTime = req.body.endTime;
... ... @@ -39,20 +39,39 @@ const whSurfController = {
type
};
const result = await req.ctx(wheelSurfModel).create(params);
try {
const result = await req.ctx(wheelSurfModel).create(params);
return res.json({ code: 200, data: result});
} catch (err) {
res.json(err);
}
return res.json({
code: 200,
data: result
});
},
async list(req, res) {
const result = await req.ctx(wheelSurfModel).list();
async actDelete(req, res) {
const id = req.body.id;
return res.json({
code: 200,
data: result
});
try {
const result = await req.ctx(wheelSurfModel).actDelete(id);
return res.json({ code: 200, data: result});
} catch (err) {
res.json(err);
}
},
async actList(req, res) {
try {
const result = await req.ctx(wheelSurfModel).list();
return res.json({
code: 200,
data: result
});
} catch (err) {
res.json(err);
}
}
};
... ...
... ... @@ -11,6 +11,11 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
create(data) {
return Activity.create(data);
}
actDelete(id) {
return Activity.findOne({where: {id}}).then(activity => {
return activity.destroy();
});
}
}
module.exports = ActWheelSurfModel;
... ...
... ... @@ -93,10 +93,9 @@ router.get('/api/user/exportInfoUserList', user.exportInfoUserList);
// 大转盘活动管理
router.get('/wheelSurf', wheelSurf.entry);
router.post('/wheelSurf/api/create', wheelSurf.create);
router.get('/wheelSurf/api/list', wheelSurf.list);
router.post('/wheelSurf/api/create', wheelSurf.actCreate);
router.post('/wheelSurf/api/delete', wheelSurf.actDelete);
router.get('/wheelSurf/api/list', wheelSurf.actList);
router.get('/wheelSurf/*', wheelSurf.entry);
... ...
... ... @@ -40,8 +40,6 @@
<a class="btn btn-info" href="/admin/activity/article?actId={{id}}">文章列表</a>
<a class="btn btn-primary" href="/admin/activity/createArticle?actId={{id}}">
创建文章</a>
<a class="btn btn-primary" href="/admin/wheelSurf/decor?actId={{id}}">
大转盘活动配置</a>
<button class="btn btn-danger btn-delete" data-id="{{id}}">删除活动
</button>
</td>
... ...
... ... @@ -2,7 +2,7 @@ import Vue from 'vue';
import VueRouter from 'vue-router';
import iView from 'iview';
import App from 'vue@/App.vue';
import {create, list, decor} from 'vue@/wheel-surf';
import {create, list, conf} from 'vue@/wheel-surf';
import 'admin/wheel-surf.page.css';
import 'iview/dist/styles/iview.css';
... ... @@ -13,7 +13,7 @@ Vue.use(iView);
const router = new VueRouter({
routes: [
{path: '/admin/wheelSurf', name: 'list', component: list},
{path: '/admin/wheelSurf/decor', name: 'decor', component: decor},
{path: '/admin/wheelSurf/conf', name: 'conf', component: conf},
{path: '/admin/wheelSurf/create', name: 'create', component: create}
],
mode: 'history'
... ...
... ... @@ -4,7 +4,7 @@
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>大转盘活动创建</h2>
<h2>活动创建</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
... ...
import list from './list';
import decor from './decor';
import conf from './conf';
import create from './create';
export {
list,
decor,
conf,
create
}
... ...
<template>
<div class="list">
<button class="btn btn-primary" @click="toCreate">创建新活动</button>
<Button type="primary" class="create-btn">创建新活动</Button>
<div class="activity-list">
<Table :columns="columns1" :data="data"></Table>
</div>
... ... @@ -22,6 +22,38 @@
{
title: '结束时间',
key: 'endTime'
},
{
title: '操作',
render: (h, {row}) => {
return h('div', [
h('Button', {
props: {
type: 'primary',
size: 'small'
},
style: {
marginRight: '5px'
},
on: {
click: () => {
this.conf(row.id)
}
}
}, '配置'),
h('Button', {
props: {
type: 'error',
size: 'small'
},
on: {
click: () => {
this.delete(row.id)
}
}
}, '删除'),
])
}
}
],
data: []
... ... @@ -30,14 +62,34 @@
methods: {
toCreate() {
this.$router.push({name: 'create'});
},
conf(actId) {
this.$router.push({name: 'conf', query: {actId}});
},
delete(id) {
this.$Modal.warning({
content: '删除后不可恢复,确认删除?',
onOk: () => {
$.ajax({
method: 'post',
url: '/admin/wheelSurf/api/delete',
data: {id}
}).then(() => {
this.list();
});
}
});
},
list() {
$.ajax({
url: '/admin/wheelSurf/api/list',
}).then(res => {
this.data = res.data;
});
}
},
created() {
$.ajax({
url: '/admin/wheelSurf/api/list',
}).then(res => {
this.data = res.data;
});
this.list();
}
}
</script>
... ... @@ -46,4 +98,8 @@
height: 600px;
}
.create-btn {
margin-bottom: 10px;
}
</style>
... ...