<template>
  <Modal
    v-model="modal"
    :width="width"
    :footer-hide="true"
    :closable="false"
    class-name="vertical-center-modal"
  >
    <div class="header">
      提示
    </div>
    <div class="content">
      <div class="text info">
        <Icon type="md-information-circle" size="16" color="red" />
        {{ option.text }}
      </div>
      <div class="footer">
        <Button @click="cfm" class="btn" type="primary" ghost style="background-color: #cce4ff;">确认</Button>
        <Button @click="cancel" class="btn" style="">取消</Button>
      </div>
    </div>
  </Modal>
</template>

<script>
import exitIcon from '@/assets/images/exit.png'
export default {
  name: 'my-modal',
  data () {
    return {
      exitIcon,
      modal: false,
      option: {},
      width: '386px'
    }
  },
  methods: {
    /*
    * 显示对话框
    * option.type 弹窗类型 info exit
    * option.text 显示文字
    * this.$MyModal.show({
    *   type: '',
    *   text: ''
    *  }).$on('comfim', res => {})
    *
    * */
    show (option = {}) {
      this.option = option
      option.width && (this.width = option.width)
      this.modal = true
    },
    cancel () {
      this.$emit('cancel')
      this.modal = false
      this.$off('cancel')
    },
    cfm () {
      this.$emit('confirm')
      this.modal = false
      this.$off('confirm')
    }
  }
}
</script>

<style lang="less" scoped>
.header {
  padding: 0 22px;
  height: 51px;
  line-height: 51px;
  border-radius: 5px 5px 0px 0px;
  font-size: 18px;
  font-weight: bold;
  color: #333333;
  background-color: #f5f7fa;
}
.content {
  position: relative;
  height: 168px;
  .text {
    padding-top: 38px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    color: #333333;
  }
  .footer {
    margin-top: 48px;
    width: 100%;
    display: flex;
    justify-content: center;
    .btn {
      width: 100px;
      height: 40px;
      font-size: 14px;
      &:first-child {
        margin-right: 15px;
      }
    }
  }
}
/deep/ .vertical-center-modal{
  display: flex;
  align-items: center;
  justify-content: space-between;
  .ivu-modal{
    top: 0;
  }
}
/deep/ .ivu-modal {
  min-width: 400px;
}
/deep/ .ivu-modal-body {
  padding: 0;
}
</style>
