<template>
  <el-dialog title="新增文档" :visible.sync="visible" width="85%" append-to-body>
    <edit-document ref="editDocumentRef" :toolId="toolId" @submit="editDocumentSubmit"/>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="$refs.editDocumentRef.submitForm()">确 定</el-button>
      <el-button @click="cancel()">取 消</el-button>
    </div>
  </el-dialog>
</template>
<script>
import editDocument from "../document/editDocument";
export default {
  components: {
    editDocument
  },
  props: {
    /**
     * 控制显示/隐藏
     */
    show: {
      type: Boolean,
      default: false
    },
    /**
     * 工具id
     */
    toolId: {
      type: String,
      default: true
    }
  },
  computed: {
    visible: {
      get() {
        return this.show
      },
      set(val) {
        this.$emit('update:show', false)
      }
    }
  },
  data () {
    return {

    }
  },
  methods: {
    editDocumentSubmit(){
      this.$emit('callback')
      this.visible = false
    },
    cancel() {
      this.$refs.editDocumentRef.cancel()
      this.visible = false
    }
  }
}
</script>
