2023-09-24 20:10:53 +08:00
|
|
|
<template>
|
|
|
|
<div ref="modal" @keydown.esc="cancel" class="modal" tabindex="-1" role="dialog">
|
2024-05-23 19:12:05 +08:00
|
|
|
<div class="modal-dialog" role="document" :data-e2e="e2eAttributes.modalName">
|
2023-09-24 20:10:53 +08:00
|
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header">
|
2024-05-23 19:12:05 +08:00
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close" :data-e2e="e2eAttributes.close"><i class="sn-icon sn-icon-close"></i></button>
|
|
|
|
<h4 class="modal-title" :data-e2e="e2eAttributes.title">
|
2023-09-24 20:10:53 +08:00
|
|
|
{{ title }}
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
<div class="modal-body" v-html="description"></div>
|
|
|
|
<div class="modal-footer">
|
2024-05-23 19:12:05 +08:00
|
|
|
<button :class="cancelClass" @click="cancel" :data-e2e="e2eAttributes.cancel">{{ cancelText || i18n.t('general.cancel') }}</button>
|
|
|
|
<button :class="confirmClass" @click="confirm" :data-e2e="e2eAttributes.confirm">{{ confirmText || i18n.t('general.confirm') }}</button>
|
2023-09-24 20:10:53 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
2024-05-24 19:26:58 +08:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'confirmationModal',
|
|
|
|
props: {
|
|
|
|
title: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
2023-09-24 20:10:53 +08:00
|
|
|
},
|
2024-05-24 19:26:58 +08:00
|
|
|
description: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
cancelText: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
cancelClass: {
|
|
|
|
type: String,
|
|
|
|
default: 'btn btn-secondary'
|
|
|
|
},
|
|
|
|
confirmText: {
|
|
|
|
type: String
|
|
|
|
},
|
|
|
|
confirmClass: {
|
|
|
|
type: String,
|
|
|
|
default: 'btn btn-primary'
|
|
|
|
},
|
|
|
|
e2eAttributes: {
|
|
|
|
type: Object,
|
|
|
|
default: () => ({})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
$(this.$refs.modal).on('hidden.bs.modal', () => {
|
|
|
|
this.resolvePromise(false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
resolvePromise: null,
|
|
|
|
rejectPromise: null
|
2024-05-24 19:44:51 +08:00
|
|
|
};
|
2024-05-24 19:26:58 +08:00
|
|
|
},
|
|
|
|
methods: {
|
2024-05-24 19:44:51 +08:00
|
|
|
show() {
|
2024-05-24 19:26:58 +08:00
|
|
|
$(this.$refs.modal).modal('show');
|
|
|
|
return new Promise((resolve, reject) => {
|
2024-05-24 19:44:51 +08:00
|
|
|
this.resolvePromise = resolve;
|
|
|
|
this.rejectPromise = reject;
|
|
|
|
});
|
2023-09-24 20:10:53 +08:00
|
|
|
},
|
2024-05-24 19:26:58 +08:00
|
|
|
confirm() {
|
2024-05-24 19:44:51 +08:00
|
|
|
this.resolvePromise(true);
|
2024-05-24 19:26:58 +08:00
|
|
|
$(this.$refs.modal).modal('hide');
|
2023-09-24 20:10:53 +08:00
|
|
|
},
|
2024-05-24 19:26:58 +08:00
|
|
|
cancel() {
|
2024-05-24 19:44:51 +08:00
|
|
|
this.resolvePromise(false);
|
2024-05-24 19:26:58 +08:00
|
|
|
$(this.$refs.modal).modal('hide');
|
2023-09-24 20:10:53 +08:00
|
|
|
}
|
|
|
|
}
|
2024-05-24 19:26:58 +08:00
|
|
|
};
|
2024-03-12 21:14:16 +08:00
|
|
|
</script>
|