main.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :center="true"
  5. align="left"
  6. top="18vh"
  7. append-to-body
  8. :close-on-click-modal="false"
  9. :visible.sync="showModelThis"
  10. @close="showModelThis = false"
  11. @closed="closed"
  12. >
  13. <span v-html="msg"></span>
  14. <span slot="footer" class="dialog-footer">
  15. <b>{{ nums }}s&nbsp;后自动关闭</b>
  16. <el-button class="fr" type="primary" @click="showModelThis = false" size="mini"
  17. >确 定</el-button
  18. >
  19. </span>
  20. </el-dialog>
  21. </template>
  22. <script>
  23. export default {
  24. name: "OpenMsg",
  25. props: ["showModel", "title", "msg", "num"],
  26. watch: {
  27. showModel: function (val) {
  28. this.showModelThis = val;
  29. if (val) {
  30. this.initForm();
  31. }
  32. },
  33. showModelThis(val) {
  34. if (!val) {
  35. this.$emit("cancel");
  36. }
  37. },
  38. },
  39. data() {
  40. return {
  41. nums: this.num,
  42. timer: null,
  43. // title: "",
  44. showModelThis: this.showModel,
  45. };
  46. },
  47. beforeDestroy() {
  48. if (this.timer) {
  49. clearInterval(this.timer);
  50. }
  51. },
  52. methods: {
  53. closed() {
  54. if (this.timer) {
  55. clearInterval(this.timer);
  56. }
  57. },
  58. initForm() {
  59. this.timer = null;
  60. this.nums = Number(this.num);
  61. this.timer = setInterval(() => {
  62. if (this.nums !== 0) {
  63. this.nums--;
  64. } else {
  65. clearInterval(this.timer);
  66. this.$emit("cancel");
  67. }
  68. }, 1000);
  69. },
  70. },
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. .select-area {
  75. .loading-input {
  76. background-color: transparent;
  77. border: 1px solid #dfe4ed;
  78. color: #c0c4cc;
  79. width: 100%;
  80. height: 36px;
  81. line-height: 36px;
  82. padding: 0 30px 0 12px;
  83. border-radius: 4px;
  84. &.disabled {
  85. background-color: #f5f7fa;
  86. }
  87. span {
  88. font-size: 16px;
  89. height: 36px;
  90. line-height: 36px;
  91. padding: 0 0 0 3px;
  92. vertical-align: top;
  93. }
  94. }
  95. }
  96. </style>