Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <template lang="pug">
- section.participants.contest__table-content
- div.participants__inner
- //-div.participants__filters.filters
- div.btn-group.js-radio-button-group
- button.btn.btn--filter(:class="{'is-checked': i === chosenDistance }", v-for="(group, i) in groups", :key="i", @click="chooseDistance(i)") {{ group.distance.distanceType.nameRus }}
- //-div.participants__search
- .search
- form.search__form
- fieldset.search__wrap
- legend.search__legend.screen-reader Поиск спортсменов
- label.search__label
- span.search__wrap-field
- input.search__field(type='text', v-model="search" placeholder='Введите имя, номер спортсмена или название мероприятия...')
- .search__action
- button.btn.btn--main.btn--size-lg.search__btn(type='button')
- span Поиск
- //-div.participants__selects
- div.filters__group
- fieldset.filters__group
- div.filters__table-wrap
- div.filters__fields
- div.filters__field
- select.filters__select#gender(name='gender', v-model="chosenGender")
- option(:value="0") Пол
- option(:value='1') Мужской
- option(:value='2') Женский
- div.filters__field
- select.filters__select#age(name='age', v-model="chosenAgeCategory")
- option(:value='0') Возраст
- option(v-for="(item, index) in ageCategories", :key="index", :value="item.id") {{ item.from + ' - ' + item.to }}
- div.filters__field
- select.filters__select#city(name='city', v-model="chosenCity")
- option(:value="0") Город
- option(v-for="(city, i) in cities", :value='city.id', :key="i") {{ city.nameRus }}
- div.filters__field
- select.filters__select#club(name='club', v-model="chosenSportClub")
- option(:value='0') Клуб
- option(v-for="(sportClub, i) in sportClubs", :value="sportClub.id", :key="i") {{ sportClub.nameRus }}
- div.filters__amount-row
- div.filters__amount-name Количество строк
- div.filters__field
- select.filters__select(name='amount-row', v-model="rows")
- option(:value='1') 1
- option(:value='2') 2
- option(:value='3') 3
- option(:value='4') 4
- option(:value='5') 5
- table.table-responsive
- thead
- tr
- th Фамилия Имя
- th Номер
- th Дистанция
- th Категория
- th Абсолютное время
- th Чистое время
- th Место абс.
- th Место М/Ж
- th Место кат.
- th Город
- th Клуб
- th Сертификат
- th
- th
- tbody
- tr(v-for="prop in props")
- td(data-label='Фамилия Имя') {{ prop.FirstName }} {{ prop.LastName }}
- td(data-label='Номер') {{ prop.StartNumber }}
- td(data-label ='Дистанция') {{ prop.Distance }}
- td(data-label='Категория') {{ prop.Category != null ? prop.Category : ''}}
- td(data-label='Абсолютное время') {{ msToTime(prop.AbsoluteTimeResult) }}
- td(data-label='Чистое время') {{msToTime(prop.IndividualTimeResult)}}
- td(data-label='Место абс.') {{ prop.Position }}
- td(data-label='Место М/Ж') {{ prop.GenderNominationPosition }}
- td(data-label="Место кат.") {{ prop.GenderAgeNominationPosition }}
- //-td(data-label='Город') {{ part.participant.city !== null ? part.participant.city.nameRus : '' }}
- //-td(data-label='Клуб') {{ part.participant.sportClub != null ? part.participant.sportClub.nameRus : '' }}
- //-td(data-label='Медиа')
- //- a.table__link.isDisabled 0 Фото
- //-td(data-label='')
- //- a.table__link(:href="part.video", target="_blank", :class="{ 'isDisabled' : part.video === null }")
- //- i.material-icons.table__icon video_library
- //-td(data-label='')
- //- a.table__link(:href="part.protocol", target="_blank", :class="{ 'isDisabled' : part.protocol === null }")
- //- icon-diploma
- div.participants__pagination(v-show="pages !== 0")
- div.pagination
- a.pagination__nav.pagination__prev
- arrow-left(@click="prevPage")
- .pagination__items
- a.link.pagination__item.cursor(v-for="(page,i) in pages", :key="page", @click="setPage(i)") {{ i + 1 }}
- a.pagination__nav.pagination__next
- arrow-right(@click="nextPage")
- //-results-table
- //-triathlon-results
- div.participants__pagination
- div.pagination
- a.pagination__nav.pagination__prev(href="#")
- arrow-left
- div.pagination__items
- a.link.pagination__item(href="#") 1
- a.link.pagination__item(href="#") 2
- a.link.pagination__item(href="#") 3
- a.pagination__nav.pagination__next(href="#")
- arrow-right
- </template>
- <script>
- import axios from "axios";
- import ArrowLeft from "../blocks/arrow-left";
- import ArrowRight from "../blocks/arrow-right";
- import IconDiploma from "../blocks/icon-diploma";
- import ResultsTable from "./tables/results-table";
- import TriathlonResults from "./tables/triathlon-results";
- import ageCategories from "@/data/age-categories";
- import { baseURLForFiles } from '@/config/baseURL';
- import { idFilter, filterByAgeCategory, stringFilter } from "@/filters";
- export default {
- name: "event-results",
- components: { TriathlonResults, ArrowRight, ArrowLeft, IconDiploma,ResultsTable },
- data() {
- return {
- listings: [],
- chosenDistance: null,
- rows: 5,
- currentPage: 0,
- chosenSportClub: 0,
- chosenCity: 0,
- chosenGender: 0,
- chosenAgeCategory: 0,
- ageCategories,
- search: "",
- weather: null,
- count: 0,
- props: [],
- event: '',
- testRow: [],
- POST: '',
- };
- },
- computed: {
- item() {
- return this.$store.getters.event
- },
- cities() {
- return this.$store.getters.cities;
- },
- sportClubs() {
- return this.$store.getters["part/sportClubs"];
- },
- sports() {
- return this.$store.getters["sports"];
- },
- groups() {
- return this.$store.getters.participantsResultsOnEvent;
- },
- chosenParticipants() {
- if (this.chosenDistance === null) {
- return [];
- }
- return this.groups[this.chosenDistance].result;
- },
- length() {
- return this.chosenParticipants.length;
- },
- pages() {
- return Math.floor(this.length / this.rows);
- },
- paginatedData() {
- const start = this.currentPage * this.rows,
- end = start + this.rows;
- return this.chosenParticipants.slice(start, end);
- },
- filtered() {
- return this.paginatedData.filter(element => {
- return (
- (stringFilter(this.search, element.participant.firstNameRus) ||
- stringFilter(this.search, element.participant.lastNameRus) ||
- stringFilter(this.search, element.participant.middleNameRus) ||
- stringFilter(this.search, element.startingNumber)) &&
- (this.chosenCity === 0
- ? true
- : !!element.participant.city
- ? idFilter(this.chosenCity, element.participant.city.id)
- : false) &&
- (this.chosenSportClub === 0
- ? true
- : !!element.participant.sportClub
- ? idFilter(this.chosenSportClub, element.participant.sportClub.id)
- : false) &&
- (this.chosenGender === 0 || this.chosenAgeCategory === 0
- ? true
- : !!element.participant.ageCategory
- ? filterByAgeCategory(
- this.chosenGender,
- this.chosenAgeCategory,
- element.participant.ageCategory.id
- )
- : false)
- );
- });
- }
- },
- watch: {
- groups() {
- if (this.groups.length > 0) {
- this.chosenDistance = 0;
- }
- }
- },
- methods: {
- chooseDistance(val) {
- this.chosenDistance = val;
- },
- msToTime(duration) {
- var milliseconds = parseInt((duration % 1000) / 100),
- seconds = Math.floor((duration / 1000) % 60),
- minutes = Math.floor((duration / (1000 * 60)) % 60),
- hours = Math.floor((duration / (1000 * 60 * 60)) % 24);
- hours = (hours < 10) ? "0" + hours : hours;
- minutes = (minutes < 10) ? "0" + minutes : minutes;
- seconds = (seconds < 10) ? "0" + seconds : seconds;
- return hours + ":" + minutes + ":" + seconds + "." + milliseconds;
- },
- nextPage() {
- if (this.currentPage === this.pages) return;
- this.currentPage++;
- },
- prevPage() {
- if (this.currentPage === 0) return;
- this.currentPage--;
- },
- setPage(val) {
- this.currentPage = val;
- },
- },
- mounted() {
- axios
- .get(`/api/v1/eventResults/${this.$store.getters.event.id}`)
- //.get('http://localhost:4382/api/v1/eventResults/184')
- .then(response => (this.props = JSON.parse(response.data)));
- if (this.groups.length > 0) {
- this.chosenDistance = 0;
- }
- }
- };
- </script>
- <style scoped>
- .isDisabled {
- color: currentColor;
- cursor: not-allowed;
- opacity: 0.5;
- text-decoration: none;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement