Reservations.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="reservation-container">
  3. <el-form-item
  4. label-width="155px"
  5. style="height: 40px; margin-right: 40px"
  6. label="Enable Reservation"
  7. :rules="[{ required: true, trigger: 'blur'}]">
  8. <el-switch
  9. :value="enable"
  10. @change="enableChange" />
  11. </el-form-item>
  12. <el-form-item
  13. label-width="100px"
  14. :rules="[{ required: true, trigger: 'blur'}]"
  15. label="Time Limit">
  16. <el-select
  17. :disabled="!enable"
  18. class="reservation-time-limit-select"
  19. :value="timeLimit"
  20. @change="limitTimeChange"
  21. placeholder="">
  22. <el-option
  23. v-for="option in reservationTimeLimitOptions"
  24. :label="option.lable"
  25. :value="option.value"
  26. :key="option.lable"
  27. />
  28. </el-select>
  29. <span class="reservation-time-limit-unit">
  30. Minutes
  31. </span>
  32. </el-form-item>
  33. </div>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'Reservation',
  38. props: {
  39. enabled: {
  40. type: Boolean,
  41. default: true,
  42. },
  43. limit: Number
  44. },
  45. data() {
  46. return {
  47. enable: this.enabled,
  48. timeLimit: this.limit || 15,
  49. reservationTimeLimitOptions: [{
  50. value: 15,
  51. lable: "15"
  52. },{
  53. value: 30,
  54. lable: "30"
  55. },{
  56. value: 45,
  57. lable: "45"
  58. },{
  59. value: 60,
  60. lable: "60"
  61. }],
  62. }
  63. },
  64. watch: {
  65. enabled(n, o) {
  66. this.enable = n;
  67. },
  68. enable(n, o) {
  69. this.$emit('update:enabled', n)
  70. if (n && !this.limit) {
  71. this.$emit('update:limit', 15)
  72. }
  73. },
  74. limit(n, o) {
  75. this.timeLimit = n || 15;
  76. },
  77. timeLimit(n, o) {
  78. this.$emit('update:limit', n)
  79. }
  80. },
  81. mounted() {
  82. if (!this.limit) {
  83. this.$emit('update:limit', this.timeLimit);
  84. }
  85. },
  86. methods: {
  87. change() {
  88. this.$emit('change', {
  89. enable: this.enable,
  90. timeLimit: this.timeLimit
  91. })
  92. },
  93. limitTimeChange (limitTime) {
  94. this.timeLimit = limitTime;
  95. this.$emit('time-limit-change', limitTime)
  96. this.change();
  97. },
  98. enableChange (enable) {
  99. this.enable = enable;
  100. this.$emit('enable', enable);
  101. this.change();
  102. }
  103. },
  104. }
  105. </script>
  106. <style scoped lang='scss'>
  107. .sparator {
  108. margin: 10px -40px;
  109. height: 2px;
  110. background-color: #F0F5FC;
  111. }
  112. .section-title {
  113. color: #333333;
  114. margin-top: 20px;
  115. margin-bottom: 30px;
  116. font-size: 16px;
  117. line-height: 24px;
  118. font-weight: 500;
  119. font-family: sans-serif;
  120. text-transform: uppercase;
  121. }
  122. .reservation-container {
  123. display: flex;
  124. align-items: center;
  125. }
  126. .reservation-time-limit-select {
  127. width: 134px;
  128. }
  129. .reservation-time-limit-unit {
  130. font-family: sans-serif;
  131. font-style: normal;
  132. font-weight: 500;
  133. font-size: 14px;
  134. line-height: 21px;
  135. text-transform: capitalize;
  136. color: #434343;
  137. padding-left: 10px;
  138. }
  139. @media screen and (max-width: 851px) {
  140. .reservation-container {
  141. flex-wrap: wrap;
  142. }
  143. }
  144. </style>