[refactoring] eventAdmin component
This commit is contained in:
43
pages/event/eventAdmin.vue
Normal file
43
pages/event/eventAdmin.vue
Normal file
@@ -0,0 +1,43 @@
|
||||
<template lang='pug'>
|
||||
div
|
||||
el-divider {{$t('common.admin')}}
|
||||
el-menu-item
|
||||
div(@click.prevents='toggle') {{$t(event.is_visible?'common.hide':'common.confirm')}}
|
||||
el-menu-item
|
||||
div(@click.prevent='remove') {{$t('common.remove')}}
|
||||
el-menu-item(@click='$router.replace(`/add/${event.id}`)') {{$t('common.edit')}}
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'EventAdmin',
|
||||
props: ['event'],
|
||||
methods: {
|
||||
async remove () {
|
||||
try {
|
||||
await MessageBox.confirm(this.$t('event.remove_confirmation'), this.$t('common.confirm'), {
|
||||
confirmButtonText: this.$t('common.ok'),
|
||||
cancelButtonText: this.$t('common.cancel'),
|
||||
type: 'error' })
|
||||
await this.$axios.delete(`/user/event/${this.event.id}`)
|
||||
this.delEvent(Number(this.event.id))
|
||||
this.$router.replace('/')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
async toggle () {
|
||||
try {
|
||||
if (this.event.is_visible) {
|
||||
await this.$axios.$get(`/event/unconfirm/${this.event.id}`)
|
||||
this.event.is_visible = false
|
||||
} else {
|
||||
await this.$axios.$get(`/event/confirm/${this.event.id}`)
|
||||
this.event.is_visible = true
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -2,7 +2,7 @@ import Vue from 'vue'
|
||||
import { Button, Select, Tag, Option, Table, FormItem, Card, Row, Col, Upload, Checkbox, RadioButton, RadioGroup,
|
||||
Form, Tabs, TabPane, Switch, Input, Loading, TimeSelect, Badge, ButtonGroup, Divider, Step, Steps, Radio, Main,
|
||||
TableColumn, ColorPicker, Pagination, Popover, Tooltip, Dialog, Image, Backtop, Collapse, CollapseItem, Link,
|
||||
Dropdown, DropdownMenu, DropdownItem, Submenu, PageHeader, Header,
|
||||
Dropdown, DropdownMenu, DropdownItem, Submenu, PageHeader, Header, Icon,
|
||||
Container, Footer, Timeline, TimelineItem, Menu, MenuItem } from 'element-ui'
|
||||
import locale from 'element-ui/lib/locale'
|
||||
|
||||
@@ -15,6 +15,7 @@ const locales = {
|
||||
export default ({ app, store }) => {
|
||||
locale.use(locales[store.state.locale])
|
||||
Vue.use(Button)
|
||||
Vue.use(Icon)
|
||||
Vue.use(Dropdown)
|
||||
Vue.use(Header)
|
||||
Vue.use(PageHeader)
|
||||
|
||||
Reference in New Issue
Block a user