WarnSave.vue 1.3 KB

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