Compare commits
3 Commits
f210f5ec47
...
78c5bf3b6e
Author | SHA1 | Date |
---|---|---|
![]() |
78c5bf3b6e | 4 years ago |
![]() |
536618d528 | 4 years ago |
![]() |
648b7e8aa8 | 4 years ago |
2 changed files with 154 additions and 29 deletions
@ -1,28 +1,153 @@ |
|||||
<template> |
<template> |
||||
<div id="app"> |
<div id="app"> |
||||
<img alt="Vue logo" src="./assets/logo.png"> |
|
||||
<HelloWorld msg="Welcome to Your Vue.js App"/> |
|
||||
|
<h1>Letenka</h1> |
||||
|
<div class="wrapper"> |
||||
|
<div class="col form"> |
||||
|
<h2>Parametry letu</h2> |
||||
|
<form action=""> |
||||
|
<p> |
||||
|
<select v-model="travelType"> |
||||
|
<option value="" disabled>Vyberte jednu možnost</option> |
||||
|
<option v-for="(option, index) in travelTypes" :key="index" :value="option"> |
||||
|
{{ option.text }} |
||||
|
</option> |
||||
|
</select> |
||||
|
</p> |
||||
|
|
||||
|
<!-- volba destinace --> |
||||
|
<!-- datum odletu --> |
||||
|
<input type="date"> |
||||
|
<!-- datum příletu pokud zpáteční --> |
||||
|
|
||||
|
|
||||
|
<p> |
||||
|
<label for="inputPersonCount">Počet cestujících</label><br> |
||||
|
<input v-on:change="personCountChange()" v-model="personCount" type="number" id="inputPersonCount" min="1" max="10"> |
||||
|
</p> |
||||
|
|
||||
|
<!-- volba třídy E, B --> |
||||
|
<p> |
||||
|
<label for="inputClassType">Volba třídy</label><br> |
||||
|
<select v-model="classType" id="inputClassType"> |
||||
|
<option value="" disabled>Vyberte jednu možnost</option> |
||||
|
<option v-for="(option, index) in classTypes" :key="index" :value="option"> |
||||
|
{{ option.text }} |
||||
|
</option> |
||||
|
</select> |
||||
|
</p> |
||||
|
|
||||
|
<div class="seatWrap"> |
||||
|
<div class="seat" v-for="(seat, index) in seats" :key="index"> |
||||
|
<div v-if="chosenSeats.indexOf(seat) >= 0" v-on:click="chosenSeats.splice(chosenSeats.indexOf(seat), 1)" class="chosen"> |
||||
|
{{ seat }} |
||||
|
</div> |
||||
|
<div v-else v-on:click="addSeatClick(seat)"> |
||||
|
{{ seat }} |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
|
<button v-on:click="chosenSeats=[]">Odebrat všechna sedadla</button> |
||||
|
</form> |
||||
|
|
||||
|
</div> |
||||
|
<div class="col order"> |
||||
|
<h2>Objednávka</h2> |
||||
|
<p v-if="travelType"> |
||||
|
Typ cesty: |
||||
|
<span style="text-transform: lowercase"> |
||||
|
{{ travelType.text }} |
||||
|
</span> |
||||
|
</p> |
||||
|
<p> |
||||
|
Počet cestujích: {{ personCount}} |
||||
|
</p> |
||||
|
<p v-if="classType"> |
||||
|
Třída: |
||||
|
<span style="text-transform: lowercase"> |
||||
|
{{ classType.text }} |
||||
|
</span> |
||||
|
</p> |
||||
|
|
||||
|
<div v-if="chosenSeats.length"> |
||||
|
Vybraná místa: |
||||
|
<div class="seat" v-for="seat in chosenSeats" :key="seat"> |
||||
|
{{ seat }} |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
</div> |
||||
|
</div> |
||||
</div> |
</div> |
||||
</template> |
</template> |
||||
|
|
||||
<script> |
<script> |
||||
import HelloWorld from './components/HelloWorld.vue' |
|
||||
|
|
||||
export default { |
export default { |
||||
name: 'App', |
name: 'App', |
||||
components: { |
|
||||
HelloWorld |
|
||||
|
data: function() { |
||||
|
return { |
||||
|
travelType: "", |
||||
|
travelTypes: [ |
||||
|
{ value: "R", text: "Zpáteční" }, |
||||
|
{ value: "O", text: "Jednosměrná" }, |
||||
|
], |
||||
|
personCount: 1, |
||||
|
classType: "", |
||||
|
classTypes: [ |
||||
|
{ value: "E", text: "Ekonomická" }, |
||||
|
{ value: "B", text: "Byznys" } |
||||
|
], |
||||
|
seats: [ |
||||
|
"B1", "B2", "B3", |
||||
|
"E1", "E2", "E3", "E4", "E5" |
||||
|
], |
||||
|
chosenSeats: [] |
||||
|
} |
||||
|
}, |
||||
|
methods: { |
||||
|
addSeatClick: function(seat) { |
||||
|
if (this.chosenSeats.length < this.personCount) { |
||||
|
this.chosenSeats.push(seat); |
||||
|
} |
||||
|
else { |
||||
|
alert("Všichni cestující již sedí!"); |
||||
|
} |
||||
|
}, |
||||
|
personCountChange: function() { |
||||
|
let diff = this.personCount - this.chosenSeats.length; |
||||
|
if (diff < 0) { |
||||
|
// diff je záporné číslo |
||||
|
for (let i = diff; i < 0; i++) { |
||||
|
this.chosenSeats.pop(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
<style> |
<style> |
||||
#app { |
|
||||
font-family: Avenir, Helvetica, Arial, sans-serif; |
|
||||
-webkit-font-smoothing: antialiased; |
|
||||
-moz-osx-font-smoothing: grayscale; |
|
||||
|
.wrapper { |
||||
|
display: grid; |
||||
|
grid-template-columns: 1fr 1fr; |
||||
|
} |
||||
|
|
||||
|
.seat { |
||||
|
display: inline-block; |
||||
|
width: 30px; |
||||
text-align: center; |
text-align: center; |
||||
color: #2c3e50; |
|
||||
margin-top: 60px; |
|
||||
|
border: 1px solid gray; |
||||
|
margin: 2px; |
||||
|
} |
||||
|
|
||||
|
.seat div:hover { |
||||
|
cursor: pointer; |
||||
|
background-color: lightgray; |
||||
} |
} |
||||
|
|
||||
|
.seat .chosen { |
||||
|
background-color: lightgreen; |
||||
|
} |
||||
|
|
||||
</style> |
</style> |
Loading…
Reference in new issue