confirmDialog.vue 1.71 KB
<script lang="ts" setup name="confirmDialog">

const props = defineProps({
  visible: {
    type: Boolean,
    default: false,
  },
  type: {
    type: String,
    default: 'success'
  },
  msg: {
    type: String,
    default: ''
  }
});

const dialogVisible = computed(() => {
  return props.visible;
});

const emits = defineEmits([
  "btnClick",
]);

const cancelDialog = () => {
  emits("btnClick", 'cancel');
}

const submit = () => {
  emits("btnClick", 'submit');
}

const dialogClose = () => {
  emits("btnClick", 'cancel');
}

const imgSrc = computed(() => {
  return new URL(`../../../assets/images/confirmType/${props.type}.png`, import.meta.url).href;
})

</script>

<template>
  <el-dialog v-model="dialogVisible" title="规则详情" width="460" :modal="true" :close-on-click-modal="true"
    destroy-on-close align-center @close="dialogClose">
    <div class="content">
      <img class="header-img" :src="imgSrc"></img>
      <div class="title" v-html="msg"></div>
    </div>
    <div class="dialog-footer">
      <el-button @click="cancelDialog">取消</el-button>
      <el-button @click="submit" type="primary" v-preReClick>确定</el-button>
    </div>
  </el-dialog>
</template>

<style lang="scss" scoped>
.content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  .header-img {
    width: 126px;
    height: 72px;
    margin-bottom: 12px;
  }

  .title {
    width: 364px;
    font-size: 16px;
    color: #212121;
    text-align: center;
    line-height: 24px;
    font-weight: 400;
    margin-bottom: 32px;
    white-space: pre-line;
  }
}

.dialog-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  flex-direction: row;
  margin-bottom: 12px;
}
</style>