create.vue 2.16 KB
<template>
    <div>
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                    <div class="x_title">
                        <h2>活动创建</h2>
                        <div class="clearfix"></div>
                    </div>
                    <div class="x_content">
                        <Form :label-width="80">
                            <FormItem label="活动名称">
                                <Input v-model="title" placeholder="活动名称" style="width: 400px"></Input>
                            </FormItem>
                            <FormItem label="活动时间">
                                <DatePicker type="datetimerange" placeholder="开始时间-结束时间"
                                            style="width: 400px" @on-change="dateTimeChange"></DatePicker>
                            </FormItem>
                            <FormItem>
                                <Button type="primary" @click="save">保存</Button>
                                <Button style="margin-left: 8px">取消</Button>
                            </FormItem>
                        </Form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    export default {
        data() {
            return {
                title: '',
                startTime: '',
                endTime: ''
            };
        },
        methods: {
            dateTimeChange(range) {
              this.startTime = range[0];
              this.endTime = range[1];
            },
            save() {
                $.ajax({
                    method: 'post',
                    url: '/admin/wheelSurf/api/create',
                    data: {
                        title: this.title,
                        type: 1,
                        startTime: moment(this.startTime).format('X'),
                        endTime: moment(this.endTime).format('X')
                    }
                }).then(res => {
                    this.$router.push({name: 'list'})
                });

            }
        }
    }
</script>
<style>

</style>