<template>
  <div class="container normal-panel normal-margin">
    <el-button icon="el-icon-plus" size="small" type="primary" @click="dialogFormVisible = true">新 建</el-button>
    <el-dialog title="新建分类" :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 {
  data () {
    return {
      dialogFormVisible:false,
      form:{
        "classname": "",
        "parentid": 0,
        "issystem": false,
        "sat_courseware_classid": 0,
        "isenable":true
      }
    }
  },
  methods:{
    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>