<template>
  <el-dialog
    :title="title"
    :visible.sync="dialogVisible"
    width="40%"
    :before-close="handleClose"
  >
    <div>
      <slot />
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button v-print="print" size="small">打印</el-button>
      <el-button size="small" @click="handleClose">取 消</el-button>
      <el-button type="primary" size="small" @click="handleSave">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'MyDialog',
  props: {
    isShow: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    },
    print: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      dialogVisible: this.isShow
    }
  },
  watch: {
    isShow(val) {
      this.dialogVisible = val
    }
  },
  methods: {
    handleClose() {
      this.$emit('close', false)
    },
    handleSave() {
      this.handleClose()
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog__body{
  border-bottom:1px solid #F0F0F0;
  border-top:1px solid #F0F0F0;
}
::v-deep .el-dialog__header{
  padding: 16px 24px;
}
::v-deep .el-dialog__footer{
  padding: 16px;
}
::v-deep .el-dialog__body{
  padding: 16px 24px;
}
</style>
