<template>
  <div>
    <el-dialog
      id="custom-dialog"
      v-model="visible"
      :close-on-click-modal="false"
      :title="null"
      close-icon="null"
    >
      <div class="top-title">{{ title }}</div>
      <div class="center-content">
        <div class="desc-title">{{ tip }}</div>
      </div>

      <div class="bottom-btns">
        <el-button class="cancelBtn" @click="visible = false">取消</el-button>
        <el-button class="sureBtn" type="primary" @click="sure"
          >{{ sureText }}
        </el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script lang="ts" setup>
const visible = ref(false);

let callBack: Function | null = null;

const title = ref("");
const tip = ref("");
const sureText = ref("");

const showDialog = (
  msg: string,
  tipText: string,
  sureTxt: string,
  callback: Function | null
) => {
  title.value = msg;
  tip.value = tipText;
  sureText.value = sureTxt;
  visible.value = true;
  callBack = callback;
};

const sure = () => {
  callBack && callBack();
  visible.value = false;
};

defineExpose({
  showDialog,
});
</script>

<style lang="scss" scoped>
:deep(.el-dialog) {
  background: #f1f3f5;
  box-shadow: 0px 0px 80px 10px rgba(0, 0, 0, 0.25);
  border-radius: 16px;
}

#custom-dialog {
  background: #f1f3f5;
  box-shadow: 0px 0px 80px 10px rgba(0, 0, 0, 0.25);
  border-radius: 16px 16px 16px 16px;
  width: 924px;
  max-height: 80vh;

  .top-title {
    width: 100%;

    font-weight: 500;
    font-size: 38px;
    color: rgba(0, 0, 0, 0.9);
    text-align: center;
  }

  .desc-title {
    font-weight: 400;
    font-size: 20px;
    color: rgba(0, 0, 0, 0.9);
    text-align: center;
  }

  .center-content {
    margin-top: 24px;
    width: 100%;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .bottom-btns {
    display: flex;
    justify-content: center;
    margin-top: 40px;
    margin-bottom: 20px;

    .button {
      margin-right: 20px;
    }

    .cancelBtn {
      width: 292px;
      height: 80px;
      background: rgba(0, 0, 0, 0.06);
      border-radius: 76px 76px 76px 76px;
    }

    .sureBtn {
      width: 292px;
      height: 80px;
      background: #0a59f7;
      border-radius: 76px 76px 76px 76px;
    }
  }
}
</style>
