<template>
  <div class="demo-dialog-confirm">
    <ui-space>
      <ui-button @click="handleConfirm">
        弹出确认
      </ui-button>
      <ui-button @click="handleConfirm2">
        弹出确认2
      </ui-button>
    </ui-space>
  </div>
</template>

<script>
import { Button,Space } from "amumu-ui"
import { dialog, message } from "amumu-ui/src/factory"

export default {
  components: {
    "ui-button": Button,
    "ui-space": Space,
  },
  methods: {
    handleConfirm() {
      dialog.confirm({
        title: "确认",
        message: "确认内容。",
        type: "success",
      })
        .then(() => {
          message.success("已确认！")
        })
        .catch(type => {
          message.info(`取消，取消操作来自于: ${type}`)
        })
    },
    handleConfirm2() {
      dialog.confirm({
        title: "确认",
        message: "确认内容。",
        type: "success",
        onCancel (type) {
          console.log(`取消，取消操作来自于: ${type}`)
        },
        onConfirm (event) {
          console.log(`已确认`, event)
        }
      })
    },
  },
}
</script>
