Modal.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div v-if="modalFlag">
  3. <div class="vehicle_servies_modal" @mousewheel="mousewheel">
  4. <div class="modal_content">
  5. <div class="time">
  6. <p>选择时间</p>
  7. <input type="month" v-model="time" />
  8. </div>
  9. <div class="plate">
  10. <p>选择平台</p>
  11. <select v-model="selectedForm" @change="slectPlatForm($event)">
  12. <option v-for="(item, index) in optionList" :key="index">
  13. {{ item.platformName }}
  14. </option>
  15. </select>
  16. </div>
  17. <div class="num">
  18. <p>设置上传数量</p>
  19. <input type="text" v-model="num" />
  20. </div>
  21. <div class="btn">
  22. <button @click="submit" style="margin: 0">保存</button>
  23. <button @click="hideModal" style="margin: 0">取消</button>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. props: {
  32. modalFlag: {
  33. type: Boolean,
  34. default: false,
  35. },
  36. optionList: {
  37. type: Array,
  38. default: () => {
  39. return [];
  40. },
  41. },
  42. },
  43. data() {
  44. return {
  45. time: "",
  46. num: 0,
  47. selectedForm: this.optionList[0]['platformName'],
  48. platformId: this.optionList[0]['id'],
  49. };
  50. },
  51. methods: {
  52. submit: function () {
  53. if (!this.num) {
  54. alert("请选择上传数量");
  55. return;
  56. }
  57. let num = +this.num;
  58. if (typeof num !== "number") {
  59. alert("请输入大于零的数字");
  60. } else if (num <= 0) {
  61. alert("请输入大于零的整数");
  62. } else if (Math.ceil(num) !== num) {
  63. alert("请输入大于零的整数");
  64. } else {
  65. this.$emit("submit", this.time, this.num, this.platformId);
  66. }
  67. },
  68. hideModal: function () {
  69. this.$emit("hide_modal");
  70. },
  71. mousewheel: function (e) {
  72. e.preventDefault();
  73. },
  74. slectPlatForm: function (e) {
  75. let index = e.target.options.selectedIndex
  76. this.platformId = this.optionList[index]['id']
  77. },
  78. },
  79. created() {
  80. console.log(this.optionList);
  81. }
  82. };
  83. </script>
  84. <style scoped lang="less">
  85. .vehicle_servies_modal {
  86. position: fixed;
  87. left: 0;
  88. top: 0;
  89. height: 100vh;
  90. width: 100vw;
  91. background-color: rgba(127, 127, 127, 0.7);
  92. display: flex;
  93. justify-content: center;
  94. align-items: center;
  95. .modal_content {
  96. width: 600px;
  97. height: 400px;
  98. background-color: #fff;
  99. transform: translateY(-80px);
  100. padding-left: 240px;
  101. .time {
  102. margin-top: 80px;
  103. display: flex;
  104. height: 28px;
  105. p {
  106. width: 80px;
  107. height: 28px;
  108. line-height: 28px;
  109. margin-right: 20px;
  110. }
  111. input {
  112. height: 28px;
  113. width: 200px;
  114. border: 1px solid #ccc;
  115. color: #555;
  116. }
  117. }
  118. .plate {
  119. margin-top: 20px;
  120. margin-right: 20px;
  121. display: flex;
  122. p {
  123. width: 100px;
  124. }
  125. select{
  126. height: 26px;
  127. width: 144px;
  128. }
  129. }
  130. .num {
  131. display: flex;
  132. margin-top: 20px;
  133. p {
  134. height: 28px;
  135. line-height: 28px;
  136. width: 100px;
  137. }
  138. input {
  139. color: #555;
  140. height: 28px;
  141. width: 200px;
  142. border: 1px solid #ccc;
  143. }
  144. }
  145. .btn {
  146. width: 200px;
  147. margin-top: 30px;
  148. display: flex;
  149. justify-content: space-between;
  150. }
  151. }
  152. }
  153. </style>