index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div>
  3. <el-dialog
  4. v-dialogDrag
  5. :append-to-body="true"
  6. :show-close="false"
  7. :close-on-click-modal="false"
  8. :close-on-press-escape="false"
  9. :title="title"
  10. :width="width"
  11. :visible.sync="dialog"
  12. >
  13. <span>
  14. <slot name="content" />
  15. </span>
  16. <span slot="footer" class="dialog-footer">
  17. <el-button v-show="cancel" @click="handleCancel">{{ cancelText }}</el-button>
  18. <el-button v-show="confirm" type="primary" @click="handleConfirm">{{ confirmText }}</el-button>
  19. </span>
  20. </el-dialog>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'CustomDialog',
  26. props: {
  27. dialog: {
  28. type: Boolean,
  29. default: false
  30. },
  31. cancel: {
  32. type: Boolean,
  33. default: false
  34. },
  35. cancelText: {
  36. type: String,
  37. default: '取 消'
  38. },
  39. confirm: {
  40. type: Boolean,
  41. default: true
  42. },
  43. confirmText: {
  44. type: String,
  45. default: '确 定'
  46. },
  47. width: {
  48. type: String,
  49. default: '30%'
  50. },
  51. title: {
  52. type: String,
  53. default: ''
  54. }
  55. },
  56. methods: {
  57. handleCancel() {
  58. this.$emit('cancel')
  59. },
  60. handleConfirm() {
  61. this.$emit('confirm')
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss" scoped>
  67. ::v-deep .el-dialog__body{
  68. padding: 20px!important;
  69. }
  70. .el-dialog{
  71. margin: 0!important;
  72. }
  73. ::v-deep .el-dialog__header {
  74. border-bottom: 1px solid #e8e8e8;
  75. }
  76. ::v-deep .el-dialog__footer{
  77. border-top: 1px solid #e8e8e8;
  78. padding: 10px 20px!important;
  79. box-sizing: border-box;
  80. }
  81. ::v-deep .el-dialog__title{
  82. font-size: 16px;
  83. }
  84. </style>