<template>
  <div>
    <el-switch
      v-model="data.isenable"
      active-color="#6F9BFC"
      inactive-color="#999"
      :active-value="1"
      :inactive-value="0"
      @change="switchChnage(data)">
    </el-switch>
  </div>
</template>

<script>
export default {
  props:['data'],
  data () {
    return {
      form:{}
    }
  },
  methods:{
    switchChnage (row) {
      this.form = Object.assign({},this.form,this.data)
      this.form.isenable = row.isenable
      this.form.issystem = false
      this.submit()
    },
    async submit () {
      const res = await this.$api.requested({
        "classname": "webmanage.saletool.courseware.coursewareclass",
        "method": "insertOrUpdate",
        "content":this.form
      })
      this.tool.showMessage(res)
      this.$emit('onSuccess')
    }
  }
}

</script>
<style>
</style>