normalDialog.vue 854 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <div class="dialog-main">
  3. <el-dialog :title="title" :visible.sync="visible" @close="cancel()">
  4. <slot />
  5. <span slot="footer" class="dialog-footer">
  6. <el-button @click="cancel()">取 消</el-button>
  7. <el-button type="primary" @click="confirm()">确 定</el-button>
  8. </span>
  9. </el-dialog>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. props: {
  15. title: {
  16. type: String,
  17. default: '',
  18. required: false
  19. },
  20. showDialog: {
  21. type: Boolean,
  22. default: false,
  23. required: true
  24. }
  25. },
  26. data() {
  27. return {
  28. visible: this.showDialog
  29. }
  30. },
  31. watch: {
  32. showDialog() {
  33. this.visible = this.showDialog
  34. }
  35. },
  36. methods: {
  37. confirm() {
  38. this.$emit('confirm', true)
  39. },
  40. cancel() {
  41. this.$emit('cancel', false)
  42. }
  43. }
  44. }
  45. </script>