You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
5.8 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div v-show="show" :class="[
  3. 'optionItem',
  4. index <= 2
  5. ? 'tw-pb-[10px] tw-mb-[10px] tw-border-0 tw-border-b tw-border-solid tw-border-neutrals-100'
  6. : '',
  7. seeMore
  8. ? 'tw-pb-[10px] tw-mb-[10px] tw-border-0 tw-border-b tw-border-solid tw-border-neutrals-100'
  9. : '',
  10. ]">
  11. <div class="tw-flex tw-flex-col">
  12. <div :class="['tw-flex tw-justify-between tw-items-center']">
  13. <div class="tw-flex tw-items-center">
  14. <h4 class="t12 tw-mb-[4px] tw-text-neutrals-900 md:t16 tw-font-normal">
  15. {{ item.TruckName }} {{$t("Ton truck")}}
  16. </h4>
  17. <!-- <div
  18. class="t12 tw-mb-[4px] tw-text-neutrals-500 md:t16 md:tw-font-normal"
  19. >
  20. {{ $t("Notes : Inclusive Of oooooooooo") }}
  21. </div> -->
  22. <div class="t12 tw-mb-[4px] tw-ml-[10px] tw-text-neutrals-600 md:t14 tw-font-normal">
  23. {{$t("Maximum load")}}{{item.MaxWeight}}{{$t("Car size")}}{{item.Size}}
  24. </div>
  25. </div>
  26. <div class="tw-flex tw-justify-between tw-items-center">
  27. <!-- <div class="t12 tw-mr-[35px] tw-text-neutrals-900 tw-hidden md:tw-block md:t16 md:tw-font-normal">
  28. ${{ price.toLocaleString() }} {{ currency }}
  29. </div> -->
  30. <button :class="[
  31. 'custom-button button-reduce tw-text-transparent tw-p-[6px] tw-rounded-[8px] tw-max-w-[24px] tw-max-h-[24px] tw-mr-[16px] md:tw-max-w-[30px] md:tw-max-h-[30px] md:tw-mr-[42px]',
  32. value == 0 ? 'tw-bg-neutrals-200' : 'tw-bg-primary-default',
  33. ]" @click="reduce()">
  34. reduce
  35. </button>
  36. <div class="tw-min-w-[24px] tw-text-center md:t18 md:tw-font-normal">
  37. {{ value }}
  38. </div>
  39. <button :class="[
  40. 'custom-button button-add tw-text-transparent tw-p-[6px] tw-rounded-[8px] tw-max-w-[24px] tw-max-h-[24px] tw-ml-[16px] md:tw-max-w-[30px] md:tw-max-h-[30px] md:tw-text-medium md:tw-ml-[42px]',
  41. ]" @click="add()">
  42. add
  43. </button>
  44. </div>
  45. </div>
  46. <div class="tw-flex tw-justify-end tw-py-[20px]">
  47. <div class="element">
  48. <div class="tw-flex tw-justify-between tw-items-center">
  49. <label class="tw-font-normal t14 md:t16"><span>{{ $t("The number of lift tailgate trucks")}}</span></label>
  50. <select :class="['tw-pr-[40px] tw-max-w-[200px]']" @change="inputVal" v-model="selectValue"
  51. >
  52. <option :value="0">{{ $t("Select option") }}</option>
  53. <option v-for="item in tailgates" :key="item" :value="item">{{ item }}</option>
  54. </select>
  55. </div>
  56. </div>
  57. </div>
  58. <div class="tw-border-0 tw-border-b tw-border-solid tw-border-neutrals-200 tw-mb-[20px]"></div>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. export default {
  64. props: {
  65. index: {
  66. type: Number,
  67. },
  68. item: {
  69. type: Object,
  70. },
  71. hasValue: {
  72. type: Number,
  73. },
  74. seeMore: {
  75. type: Boolean,
  76. },
  77. },
  78. data() {
  79. return {
  80. value: 0,
  81. currentPirce: "US",
  82. selectValue: 0,
  83. tailgate: 10,
  84. };
  85. },
  86. computed: {
  87. currency() {
  88. return this.$store.getters.getCurrency;
  89. },
  90. show() {
  91. if (this.index + 1 <= 3) {
  92. return true;
  93. } else {
  94. if (this.seeMore == true) {
  95. return true;
  96. } else {
  97. return false;
  98. }
  99. }
  100. },
  101. tailgates(){
  102. if(this.value == 0){
  103. this.selectValue = 0;
  104. return 0;
  105. }
  106. return this.tailgate;
  107. }
  108. },
  109. watch: {
  110. hasValue: {
  111. handler: function () {
  112. if (this.hasValue == null) {
  113. this.value = 0;
  114. this.selectValue = 0;
  115. }
  116. },
  117. },
  118. choicesIndex: {
  119. handler: function (newVal, oldVal) {
  120. if (newVal !== oldVal) {
  121. this.value = 0;
  122. }
  123. },
  124. },
  125. item: {
  126. handler: function () {
  127. let vm = this;
  128. vm.$nextTick(function () {
  129. vm.$emit("selected", {
  130. number: this.value,
  131. id: this.item.TruckID,
  132. name: this.item.TruckName,
  133. maxWeight: this.item.MaxWeight,
  134. size: this.item.Size,
  135. });
  136. })
  137. },
  138. }
  139. },
  140. methods: {
  141. add() {
  142. this.value += 1;
  143. if (this.value !== 0) {
  144. this.$emit("disabled", this.index);
  145. }
  146. this.$emit("selected", {
  147. number: this.value,
  148. id: this.item.TruckID,
  149. name: this.item.TruckName,
  150. maxWeight: this.item.MaxWeight,
  151. size: this.item.Size,
  152. });
  153. },
  154. reduce() {
  155. if (this.value !== 0) {
  156. this.value -= 1;
  157. this.$emit("selected", {
  158. number: this.value,
  159. id: this.item.TruckID,
  160. name: this.item.TruckName,
  161. maxWeight: this.item.MaxWeight,
  162. size: this.item.Size,
  163. });
  164. }
  165. },
  166. inputVal(){
  167. this.$emit("change", {
  168. number: this.selectValue,
  169. id: this.item.TruckID,
  170. name: this.item.TruckName,
  171. });
  172. }
  173. },
  174. };
  175. </script>
  176. <style lang="scss" scoped>
  177. .custom-button {
  178. background-position: center;
  179. background-repeat: no-repeat;
  180. background-size: 12px;
  181. }
  182. .button {
  183. &-reduce {
  184. background-image: url("~/assets/svg/reduce.svg");
  185. background-color: #e5e5e5;
  186. }
  187. &-add {
  188. background-image: url("~/assets/svg/add.svg");
  189. background-color: #f48800;
  190. }
  191. }
  192. .bounce-enter-active {
  193. animation: bounce-in 0.3s ease-out;
  194. }
  195. .bounce-leave-active {
  196. animation: bounce-in 0.3s reverse;
  197. }
  198. @keyframes bounce-in {
  199. 0% {
  200. opacity: 0;
  201. }
  202. 50% {
  203. opacity: 0.5;
  204. }
  205. 100% {
  206. opacity: 1;
  207. }
  208. }
  209. select {
  210. -moz-appearance: none;
  211. /* Firefox */
  212. -webkit-appearance: none;
  213. /* Safari and Chrome */
  214. appearance: none;
  215. background-image: url("~/assets/svg/down-arrow.svg");
  216. background-size: 9px 6px;
  217. background-position: right 20px center;
  218. background-repeat: no-repeat;
  219. }
  220. </style>