index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="operateBox">
  3. <div class="leftBox">
  4. <svg-icon
  5. :icon-class="jiaDisabled ? 'bujian' : 'jian'"
  6. class="svgStyle"
  7. size="25"
  8. @click="value = value - step"
  9. />
  10. </div>
  11. <el-input
  12. v-model="value"
  13. :disabled="jiaDisabled"
  14. :max="max"
  15. :min="min"
  16. class="showSum"
  17. />
  18. <div class="rightBox">
  19. <svg-icon
  20. :icon-class="jiaDisabled ? 'bujia' : 'jia'"
  21. class="svgStyle"
  22. size="25"
  23. @click="value = value + step"
  24. />
  25. </div>
  26. </div>
  27. </template>
  28. <script lang="ts" setup>
  29. const props = defineProps({
  30. modelValue: {
  31. type: Number,
  32. default: 0,
  33. },
  34. min: {
  35. type: Number,
  36. default: 0,
  37. },
  38. max: {
  39. type: Number,
  40. default: 100000000,
  41. },
  42. step: {
  43. type: Number,
  44. default: 1,
  45. },
  46. });
  47. const emits = defineEmits(["update:modelValue"]);
  48. const jiaDisabled = computed(() => {
  49. return props.max && props.modelValue >= props.max;
  50. });
  51. const value = computed({
  52. get() {
  53. return Number(props.modelValue);
  54. },
  55. set(val) {
  56. if (val < props.min) {
  57. val = props.min;
  58. }
  59. if (val > props.max) {
  60. val = props.max;
  61. }
  62. emits("update:modelValue", val);
  63. },
  64. });
  65. </script>
  66. <style lang="scss" scoped>
  67. :deep(.el-input__inner) {
  68. width: 100%;
  69. height: 100%;
  70. text-align: center;
  71. font-weight: bold;
  72. font-size: $f38;
  73. color: black;
  74. background-color: rgba(255, 255, 255, 0);
  75. }
  76. :deep(.el-input__wrapper) {
  77. border: none !important;
  78. outline: none;
  79. box-shadow: none;
  80. background-color: rgba(255, 255, 255, 0);
  81. }
  82. .describeText {
  83. font-size: $f20;
  84. color: $font-default-60;
  85. line-height: 25px;
  86. text-align: center !important;
  87. }
  88. .operate {
  89. .operateText {
  90. margin-bottom: $p5;
  91. }
  92. .operateBox {
  93. width: 290px;
  94. height: 70px;
  95. border: 2px solid black;
  96. border-radius: 16px;
  97. display: flex;
  98. justify-content: space-between;
  99. .leftBox {
  100. width: 70px;
  101. height: 70px;
  102. @include flex;
  103. }
  104. .showSum {
  105. flex: 1;
  106. @include flex;
  107. border: 2px solid black;
  108. border-top: 0px;
  109. border-bottom: 0px;
  110. font-weight: bold;
  111. font-size: $f38;
  112. }
  113. .rightBox {
  114. width: 70px;
  115. height: 70px;
  116. @include flex;
  117. }
  118. }
  119. }
  120. .operateBox {
  121. width: 290px;
  122. height: 70px;
  123. border: 2px solid black;
  124. border-radius: 16px;
  125. display: flex;
  126. justify-content: space-between;
  127. .leftBox {
  128. width: 70px;
  129. height: 70px;
  130. @include flex;
  131. }
  132. .showSum {
  133. flex: 1;
  134. @include flex;
  135. border: 2px solid black;
  136. border-top: 0px;
  137. border-bottom: 0px;
  138. font-weight: bold;
  139. font-size: $f38;
  140. }
  141. .rightBox {
  142. width: 70px;
  143. height: 70px;
  144. @include flex;
  145. }
  146. }
  147. </style>