Тестовое задание про оптимальный розлив варенья по банкам
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div class="tabs">
  3. <div class="tabs__buttons">
  4. <button
  5. @click="activeTab = 'Intro'"
  6. :class="activeTab === 'Intro' && 'active'"
  7. >
  8. Задача
  9. </button>
  10. <button
  11. @click="activeTab = 'Pots'"
  12. :class="activeTab === 'Pots' && 'active'"
  13. >
  14. Банки
  15. </button>
  16. <button
  17. @click="activeTab = 'Jams'"
  18. :class="activeTab === 'Jams' && 'active'"
  19. >
  20. Варенья
  21. </button>
  22. <button
  23. @click="activeTab = 'Result'"
  24. :class="activeTab === 'Result' && 'active'"
  25. >
  26. Разливаем
  27. </button>
  28. </div>
  29. <Intro v-if="activeTab === 'Intro'" class="tabs__body" />
  30. <Pots
  31. v-if="activeTab === 'Pots'"
  32. class="tabs__body"
  33. :pots="pots"
  34. @removePot="removePot"
  35. @addPot="addPot"
  36. />
  37. <Jams
  38. v-if="activeTab === 'Jams'"
  39. class="tabs__body"
  40. :jams="jams"
  41. @removeJam="removeJam"
  42. @addJam="addJam"
  43. />
  44. <Result
  45. v-if="activeTab === 'Result'"
  46. class="tabs__body"
  47. :propPots="pots"
  48. :propJams="jams"
  49. />
  50. </div>
  51. </template>
  52. <script>
  53. /* eslint-disable no-unused-vars */
  54. import Intro from "./components/Intro";
  55. import Pots from "./components/Pots";
  56. import Jams from "./components/Jams";
  57. import Result from "./components/Result";
  58. export default {
  59. name: "App",
  60. components: {
  61. Intro,
  62. Pots,
  63. Jams,
  64. Result,
  65. },
  66. data: function () {
  67. return {
  68. activeTab: "Intro",
  69. pots: [
  70. { id: "b1", vol: 3000 },
  71. { id: "b2", vol: 1000 },
  72. { id: "b3", vol: 100 },
  73. { id: "b4", vol: 850 },
  74. { id: "b5", vol: 500 },
  75. { id: "b6", vol: 750 },
  76. { id: "b7", vol: 500 },
  77. { id: "b8", vol: 450 },
  78. { id: "b9", vol: 450 },
  79. { id: "b10", vol: 300 },
  80. { id: "b11", vol: 350 },
  81. { id: "b12", vol: 100 },
  82. { id: "b13", vol: 150 },
  83. { id: "b14", vol: 100 },
  84. { id: "b15", vol: 50 },
  85. ],
  86. jams: [
  87. { id: "j1", vol: 3550 },
  88. { id: "j2", vol: 1700 },
  89. { id: "j3", vol: 2220 },
  90. ],
  91. };
  92. },
  93. methods: {
  94. removePot: function (index) {
  95. this.pots.splice(index, 1);
  96. },
  97. addPot: function (id, vol) {
  98. const f = this.pots.filter((p) => p.id === id);
  99. if (f.length > 0) {
  100. f[0].vol = +vol;
  101. } else {
  102. this.pots.push({ id, vol: +vol });
  103. }
  104. },
  105. removeJam: function (index) {
  106. this.jams.splice(index, 1);
  107. },
  108. addJam: function (id, vol) {
  109. const f = this.jams.filter((j) => j.id === id);
  110. if (f.length > 0) {
  111. f[0].vol = +vol;
  112. } else {
  113. this.jams.push({ id, vol: +vol });
  114. }
  115. },
  116. },
  117. };
  118. </script>
  119. <style lang="scss" scoped>
  120. #app {
  121. margin: 1rem;
  122. }
  123. .tabs {
  124. max-width: 1440px;
  125. margin: 60px auto;
  126. min-height: 75vh;
  127. display: flex;
  128. flex-direction: column;
  129. &__buttons {
  130. display: flex;
  131. flex-direction: row;
  132. button {
  133. appearance: none;
  134. border: none;
  135. padding: 1rem 2rem;
  136. font-size: 1.25rem;
  137. background: #ccc;
  138. border-bottom: 1px solid #ccc;
  139. &.active {
  140. background: #fff;
  141. border-bottom: 1px solid #fff;
  142. }
  143. }
  144. }
  145. &__body {
  146. background: #fff;
  147. flex-grow: 1;
  148. padding: 1rem 2rem;
  149. }
  150. }
  151. </style>