Тестовое задание про оптимальный розлив варенья по банкам
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.

95 lines
2.2KB

  1. <template>
  2. <div>
  3. <div class="pots-list">
  4. <div class="pots-list__header">
  5. <div class="id">ID</div>
  6. <div class="vol">Объем, мл</div>
  7. </div>
  8. <div class="pots-list__add">
  9. <div class="id"><input type="text" v-model.trim="addId" /></div>
  10. <div class="vol">
  11. <input type="number" v-model.number="addVol" />
  12. </div>
  13. <div class="add"><button @click="$emit('addPot', addId, addVol); addId=''; addVol=0;">+</button></div>
  14. </div>
  15. <div
  16. v-for="(pot, index) in pots"
  17. :key="pot.id"
  18. class="pots-list__row"
  19. >
  20. <div class="id">{{ pot.id }}</div>
  21. <div class="vol">{{ pot.vol }}</div>
  22. <div class="remove" @click="$emit('removePot', index)">
  23. &times;
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. export default {
  31. props: ["pots"],
  32. emits: ["removePot", "addPot"],
  33. data() {
  34. return {
  35. addId: "",
  36. addVol: 0,
  37. };
  38. },
  39. };
  40. </script>
  41. <style lang="scss" scoped>
  42. .pots-list {
  43. &__header,
  44. &__add,
  45. &__row {
  46. display: flex;
  47. padding: 0.5rem 1rem;
  48. border-bottom: 1px solid #ccc;
  49. &:last-child {
  50. border-bottom: none;
  51. }
  52. .id {
  53. width: 7rem;
  54. flex-shrink: 0;
  55. }
  56. .vol {
  57. flex-grow: 1;
  58. }
  59. }
  60. &__header {
  61. background: #ccc;
  62. }
  63. &__add {
  64. input {
  65. width: 100%;
  66. padding: 0.3rem 0.5rem;
  67. font-size: 1.15rem;
  68. }
  69. .add {
  70. flex-shrink: 0;
  71. button {
  72. appearance: none;
  73. width: 100%;
  74. padding: 0.3rem 0.5rem;
  75. font-size: 1.15rem;
  76. }
  77. }
  78. }
  79. &__row {
  80. .remove {
  81. flex-shrink: 0;
  82. width: 1rem;
  83. cursor: pointer;
  84. &:hover {
  85. color: #f00;
  86. }
  87. }
  88. }
  89. }
  90. </style>