<template>
  <div class="demo-dialog-basic">
    <ui-button @click="visible = !visible">
      打开
    </ui-button>
    <ui-dialog
      :visible.sync="visible"
      :on-confirm="onConfirm">
      测试确定
    </ui-dialog>
  </div>
</template>
<script>
import { Dialog, Button } from "amumu-ui"
import { message, dialog } from "amumu-ui/src/factory"

export default {
  components: {
    "ui-dialog": Dialog,
    "ui-button": Button,
  },
  data() {
    return {
      visible: false,
    }
  },
  methods: {
    onConfirm() {
      return new Promise(resolve => {
        setTimeout(() => {
          resolve(
            dialog.confirm({
              title: "确认框",
              message: "你确定关闭吗?",
            })
              .then(() => {
                message.success("关闭成功")
              })
          )
        }, 2000)
      })
    },
  },
}
</script>
