threeStateMessageBox.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <DialogCom
  3. @closed="onClose"
  4. class="elDialog"
  5. :title="title"
  6. :visible.sync="isShow"
  7. width="500px"
  8. >
  9. <div>{{ message }}</div>
  10. <div slot="footer" class="dialog-footer">
  11. <el-button size="small" type="primary" @click="onYes">是</el-button>
  12. <el-button size="small" @click="onNo">否</el-button>
  13. <el-button size="small" @click="onCanel">取消</el-button>
  14. </div>
  15. </DialogCom>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. isShow: false,
  22. message: "",
  23. title: "提示",
  24. callback: null,
  25. state: null, //0否,1:是,2取消
  26. };
  27. },
  28. methods: {
  29. /**
  30. * option:扩展
  31. */
  32. show(message, callback, option) {
  33. this.isShow = true;
  34. this.message = message;
  35. this.callback = callback;
  36. },
  37. onYes() {
  38. this.state = 1;
  39. this.isShow = false;
  40. },
  41. onNo() {
  42. this.state = 0;
  43. this.isShow = false;
  44. },
  45. onCanel() {
  46. this.state = 2;
  47. this.isShow = false;
  48. },
  49. onClose() {
  50. this.callback && this.callback(this.state);
  51. },
  52. },
  53. };
  54. </script>
  55. <style lang="scss" scoped>
  56. .elDialog {
  57. ::v-deep .el-dialog {
  58. display: flex;
  59. flex-direction: column;
  60. margin: 0 !important;
  61. top: 40%;
  62. left: 50% !important;
  63. transform: translate(-50%, -50%);
  64. }
  65. ::v-deep .el-dialog__header {
  66. position: relative;
  67. padding: 15px;
  68. padding-bottom: 10px;
  69. height: 43px;
  70. }
  71. ::v-deep .el-dialog__body {
  72. padding: 10px 15px;
  73. color: #606266;
  74. font-size: inherit;
  75. }
  76. ::v-deep .dialog-footer {
  77. padding: 5px 15px 0;
  78. text-align: right;
  79. }
  80. }
  81. </style>