<template>
  <div>
    <el-button type="text" @click="onShow(dialogFormVisible = true)" size="mini">新增子类</el-button>
    <el-dialog title="新增子类" append-to-body :visible.sync="dialogFormVisible" width="600px">
      <el-form :model="form" size="small">
        <el-form-item label="子类名称" label-width="80px">
          <el-input v-model="form.classname" autocomplete="off" placeholder="输入分类名称"></el-input>
        </el-form-item>
      </el-form>
      <div class="dialog-footer">
        <el-button size="small" @click="dialogFormVisible = false" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" @click="submit" class="normal-btn-width btn-warning">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props:['data'],
  data () {
    return {
      dialogFormVisible:false,
      form:{
        "classname": "",
        "parentid": 0,
        "issystem": false,
        "sat_courseware_classid": 0,
        "isenable":true
      }
    }
  },
  methods:{
    onShow () {
      this.form.parentid = this.data.sat_courseware_classid
    },
    async submit () {
      const res = await this.$api.requested({
        "classname": "webmanage.saletool.courseware.coursewareclass",
        "method": "insertOrUpdate",
        "content":this.form
      })
      this.tool.showMessage(res)
      res.code === 1?this.dialogFormVisible = false:""
      this.$emit('onSuccess')
    }
  }
}

</script>
<style>
</style>