<template>
  <div class="demo-dialog-buttons">
    <ui-button @click="handleConfirm">
      自定义底部按钮
    </ui-button>
  </div>
</template>

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

export default {
  components: {
    "ui-button": Button,
  },
  methods: {
    handleConfirm() {
      const h = this.$createElement
      dialog
        .confirm({
          title: "提示",
          type: "success",
          buttons: [
            {
              name:'操作1',
              onClick(){
                console.log("操作1")
                return Promise.resolve()
              }
            },
            {
              name:'操作2',
              onClick(){
                console.log("操作2")
                return new Promise((resolve,reject) => {
                  setTimeout(() => {
                    reject()
                  }, 1000);
                })
              }
            },
            {
              name:'操作3',
              onClick(){
                console.log("操作3 弹窗不关闭")
                // 返回 false 时，不关闭弹窗
                return false
              }
            }
          ]
        })
        .then(() => {
          console.log("返回Promise.resolve()")
        })
        .catch(() => {
          console.log("返回Promise.reject()")
        })
    },
  },
}
</script>