<template>
    <div>
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-form-item label="优惠券数量" >
                    {{ids.length}}个
                </el-form-item>
                <el-form-item label="优惠券开始时间" prop="startTime">
                <el-date-picker clearable size="small" style="width: 200px"
                    v-model="form.startTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择开始时间">
                </el-date-picker>
                </el-form-item>
                <el-form-item label="优惠券结束时间" prop="limitTime">
                <el-date-picker clearable size="small" style="width: 200px"
                    v-model="form.limitTime"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择结束时间">
                </el-date-picker>
                </el-form-item>
                <el-form-item label="优惠券领取数量" prop="totalCount">
                <el-input-number v-model="form.totalCount" :min="0" placeholder="请输入优惠券领取数量" />
                </el-form-item>
            </el-form>
             <div   class="footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </div>
</template>

<script>
    import { batchPublishCoupon  } from "@/api/live/liveCoupon";
export default {
        name: "batchPublish",
        data() {
            return {
                statusOptions:[],
                ids:[],
                // 表单参数
                form: {},
                // 表单校验
                rules: {
                    totalCount: [
                    { required: true, message: "数量不能为空", trigger: "blur" }
                    ],
                    startTime: [
                    { required: true, message: "开始时间不能为空", trigger: "blur" }
                    ],
                    limitTime: [
                    { required: true, message: "结束时间不能为空", trigger: "blur" }
                    ],
                }
            };
        },
        created() {

        },
        methods: {
            cancel(){
                this.$emit('close');
            },
            handleBatch(ids) {
                console.log(ids)
                this.ids=ids;

            },
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (valid) {
                        this.myloading = this.$loading({
                            lock: true,
                            text: '处理中...',
                            spinner: 'el-icon-loading',
                            background: 'rgba(0, 0, 0, 0.7)'
                        });
                        this.form.ids=this.ids.toString();
                        batchPublishCoupon(this.form).then(response => {
                            this.myloading.close()
                            if (response.code === 200) {
                                this.msgSuccess("发布成功");
                                this.$emit('close');
                            }
                        });
                    }
                });
            },
        }
    };
</script>
<style lang="scss" scoped>
.contents{
    height: 100%;
    background-color: #fff;
    padding: 20px;

}
.footer{
    display: flex;
    align-items: center;
    justify-content: flex-end;
}
</style>



