<template>
  <div>
    <xy-dialog ref="dialog" :width="60" :is-show.sync="isShow" :type="'form'" title="批量审核不通过"
      :form="form" :rules='rules' @submit="submit">
      <template v-slot:reason>
        <div class="xy-table-item">
          <div class="xy-table-item-label" style="font-weight: bold">
            <span style="color: red;font-weight: bold;padding-right: 4px;">*</span>备注：
          </div>
          <div class="xy-table-item-content">
            <el-input type="textarea" :rows="5" v-model="form.reason" placeholder="请输入备注(展示给学员查看)"></el-input>
          </div>
        </div>
      </template>

    </xy-dialog>

  </div>
</template>

<script>
  import {
    updateStatus
  } from '@/api/apply/index.js'
  export default {
    components: {

    },
    data() {
      return {
        isShow: false,
        id: '',
        form: {
          reason: '',
        },
        ids_obj:{
          ids:'',
          status:2,
          course_id:''
        },
        rules: {
          reason:[{
            required: true,
            message: '请输入备注'
          }],
        }
      }
    },
    created() {
    },
    methods: {
      setIds(e){
        this.ids_obj = e
      },
      submit() {
        if(this.base.isNull(this.form.reason)){
          this.$message({
            type:'warning',
            message:'请输入备注'
          })
          return
        }

        console.log(this.ids_obj,this.form.reason)
        // return
        updateStatus({
          course_id: this.ids_obj.course_id,
          ids: this.ids_obj.ids,
          status: this.ids_obj.status,
          reason:this.form.reason
        }).then(res => {
          this.$message({
            type: 'success',
            message: '批量审核不通过，设置成功'
          })
          this.isShow = false
          this.$emit('refresh')
        })
      },
    },
    watch: {
      isShow(newVal) {
        if (newVal) {
        } else {
          this.ids_obj = {
            ids:'',
            status:2,
            course_id:''
          },
          this.$refs['dialog'].reset()
        }
      },
    }

  }
</script>

<style scoped lang="scss">
  ::v-deep .reason{
    flex-basis: 100%;
  }
</style>
