WarnSave.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <el-dialog custom-class="warn-save" width="230px" :visible="visible" :before-close="handleClose">
  3. <span class="warning">警告</span>
  4. <span>当前有内容未保存</span>
  5. <template slot="footer">
  6. <el-button type="info" @click="directQuit">直接退出</el-button>
  7. <el-button type="primary" @click="saveAndClose">保存并退出</el-button>
  8. </template>
  9. </el-dialog>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'WarnSave',
  14. props: {
  15. visible: {
  16. type: Boolean,
  17. required: true,
  18. },
  19. },
  20. data() {
  21. return {};
  22. },
  23. methods: {
  24. handleClose() {
  25. this.$emit('update:visible', false);
  26. },
  27. // 直接退出
  28. directQuit() {
  29. this.$emit('update:visible', false);
  30. this.$emit('directQuit');
  31. },
  32. // 保存并退出
  33. saveAndClose() {
  34. this.$emit('update:visible', false);
  35. this.$emit('saveAndClose', 'quit');
  36. },
  37. },
  38. };
  39. </script>
  40. <style lang="scss">
  41. .warn-save {
  42. padding: 0;
  43. .el-dialog {
  44. &__header {
  45. display: none;
  46. }
  47. &__body {
  48. display: flex;
  49. flex-direction: column;
  50. row-gap: 8px;
  51. align-items: center;
  52. padding-bottom: 10px;
  53. .warning {
  54. color: #e22b2b;
  55. }
  56. }
  57. &__footer {
  58. display: flex;
  59. }
  60. }
  61. }
  62. </style>