Commit 9f52027c authored by xiaoye's avatar xiaoye

fix

parent d3e9eefb
<template> <template>
<view id = 'page'> <view id = 'page'>
<view id = 'head'> <view id = 'head' class = 'click'>
<view> <view>
<button class = 'button click' @click = 'page.show.search()'> <button class = 'button' @click = 'page.show.drawer()'>
<uni-icons class = 'click' :type = "page.search ? 'left' : 'search'"></uni-icons> <uni-icons :type = "page.menu ? page.drawer ? 'left' : 'search' : page.drawer ? 'left' : 'info'"></uni-icons>
</button> </button>
</view> </view>
<view>&nbsp;</view> <view>&nbsp;</view>
...@@ -17,14 +17,14 @@ ...@@ -17,14 +17,14 @@
:clickable = true :clickable = true
:avatar = 'Mycard.avatar' :avatar = 'Mycard.avatar'
@click = 'page.show.user()' @click = 'page.show.user()'
class = 'click'
> >
<uni-icons class = 'click' :type = "page.user ? 'right' : 'left'"></uni-icons> <uni-icons :type = "page.user ? 'right' : 'left'"></uni-icons>
</uni-list-chat> </uni-list-chat>
</uni-list> </uni-list>
</view> </view>
<transition name = 'move_right'> <transition name = 'move_right'>
<uni-card <uni-card
class = 'click'
id = 'user' id = 'user'
v-show = 'page.user' v-show = 'page.user'
:title = 'Mycard.username' :title = 'Mycard.username'
...@@ -40,17 +40,18 @@ ...@@ -40,17 +40,18 @@
><span>获取api_key</span></view> ><span>获取api_key</span></view>
<hr v-show = 'Mycard.id >= 0'> <hr v-show = 'Mycard.id >= 0'>
<view <view
class = 'user click' class = 'user'
@click = '() => { @click = '() => {
Mycard.id >= 0 ? Mycard.logout() : Mycard.login(); Mycard.id >= 0 ? Mycard.logout() : Mycard.login();
}' }'
><span class = 'click'>{{ Mycard.id >= 0 ? '退出登陆' : '登陆' }}</span></view> ><span>{{ Mycard.id >= 0 ? '退出登陆' : '登陆' }}</span></view>
</uni-card> </uni-card>
</transition> </transition>
<transition name = 'move_left'> <transition name = 'move_left'>
<uni-card <uni-card
id = 'search' class = 'click'
v-show = 'page.search' id = 'drawer'
v-show = 'page.drawer && page.menu'
title = '搜索' title = '搜索'
:style = "{ '--size' : `${size.width > size.height ? size.width / 4 : size.width / 2}px` }" :style = "{ '--size' : `${size.width > size.height ? size.width / 4 : size.width / 2}px` }"
> >
...@@ -75,32 +76,43 @@ ...@@ -75,32 +76,43 @@
</uni-search-bar> </uni-search-bar>
<uni-data-select <uni-data-select
placeholder = '比赛规则' placeholder = '比赛规则'
v-model = 'search.rule.select' v-model = 'search.info.rule'
:localdata = 'search.rule.range' :localdata = 'search.rule.range'
> >
</uni-data-select> </uni-data-select>
<uni-data-select <uni-data-select
placeholder = '状态' placeholder = '状态'
v-model = 'search.status.select' v-model = 'search.info.status'
:localdata = 'search.status.range' :localdata = 'search.status.range'
> >
</uni-data-select> </uni-data-select>
<uni-data-select <uni-data-select
placeholder = '可见性' placeholder = '可见性'
v-model = 'search.visibility.select' v-model = 'search.info.visibility'
:localdata = 'search.visibility.range' :localdata = 'search.visibility.range'
v-show = 'Mycard.id >= 0' v-show = 'Mycard.id >= 0'
> >
</uni-data-select> </uni-data-select>
<br> <br>
<view class = 'button click' @click = 'search.on()'> <view class = 'button' @click = 'search.on()'>
<view class = 'click'> <view>
<span class = 'click'>搜索</span> <span>搜索</span>
<uni-icons class = 'click' type = 'search'></uni-icons> <uni-icons type = 'search'></uni-icons>
</view> </view>
</view> </view>
</uni-card> </uni-card>
</transition> </transition>
<transition name = 'move_left'>
<uni-card
class = 'click'
id = 'drawer'
v-show = 'page.drawer && page.tournament'
title = '比赛设置'
:style = "{ '--size' : `${size.width > size.height ? size.width / 4 : size.width / 2}px` }"
>
</uni-card>
</transition>
<br> <br>
<transition name = 'switch'> <transition name = 'switch'>
<view <view
...@@ -112,14 +124,14 @@ ...@@ -112,14 +124,14 @@
v-show = 'search.result.total > 0 && page.menu' v-show = 'search.result.total > 0 && page.menu'
> >
<uni-list-item <uni-list-item
id = 'list'
v-for = '(i, v) in search.result.tournaments' v-for = '(i, v) in search.result.tournaments'
:title = 'i.name' :title = 'i.name'
:note = 'i.description' :note = 'search.rule.note.get(i.rule)'
:rightText = '`${i.createdAt.toLocaleDateString()}\n${i.count}`' :rightText = '`${i.createdAt.toLocaleDateString()}\n${i.count}`'
:clickable = true :clickable = true
@click = 'page.show.tournament(v)' @click = 'page.show.tournament(v)'
> ></uni-list-item>
</uni-list-item>
</uni-list> </uni-list>
</transition> </transition>
<transition name = 'switch'> <transition name = 'switch'>
...@@ -133,9 +145,7 @@ ...@@ -133,9 +145,7 @@
</uni-pagination> </uni-pagination>
</transition> </transition>
<transition name = 'switch'> <transition name = 'switch'>
<PageTournament <PageTournament v-show = 'page.tournament'/>
v-show = 'page.tournament'
></PageTournament>
</transition> </transition>
</view> </view>
</transition> </transition>
...@@ -150,22 +160,20 @@ ...@@ -150,22 +160,20 @@
import ApiKey from '../script/apikey.ts'; import ApiKey from '../script/apikey.ts';
import Mycard from '../script/mycard.ts'; import Mycard from '../script/mycard.ts';
import emitter from '../script/emitter.ts' import emitter from '../script/emitter.ts'
import { selectTournament } from '../script/const.ts' import { selectTournament, tournamentInfo, tournamentExit } from '../script/const.ts'
import PageTournament from './tournament.vue'; import PageTournament from './tournament.vue';
let page = reactive({ let page = reactive({
user : false, user : false,
search : false, drawer : false,
// menu : true, menu : true,
// tournament : false, tournament : false,
menu : false,
tournament : true,
show : { show : {
user : () : void => { user : () : void => {
page.user = !page.user; page.user = !page.user;
}, },
search : () : void => { drawer : () : void => {
page.search = !page.search; page.drawer = !page.drawer;
}, },
tournament : async(v : number = 0): Promise<void> => { tournament : async(v : number = 0): Promise<void> => {
page.menu = false; page.menu = false;
...@@ -175,16 +183,30 @@ ...@@ -175,16 +183,30 @@
}, },
menu : async(): Promise<void> => { menu : async(): Promise<void> => {
page.tournament = false; page.tournament = false;
await search.on();
await (new Promise(resolve => setTimeout(resolve, 500))); await (new Promise(resolve => setTimeout(resolve, 500)));
page.menu = true; page.menu = true;
}, },
clear : (e) : void => { clear : (e) : void => {
if (!e.target.className.includes('click')) { let element = e.target;
if (page.user) let chk = false;
page.show.user() let inPage = false;
if (page.search) let uniElement = false;
page.show.search() while (element) {
if (['head', 'user', 'drawer'].includes(element.id) || element.classList.contains('click'))
chk = true;
if (element.id == 'page')
inPage = true;
if (element.className.includes('uni'))
uniElement = true;
element = element.parentElement;
} }
if (chk || (!inPage && uniElement))
return undefined;
if (page.user)
page.show.user()
if (page.drawer)
page.show.drawer()
} }
} }
}); });
...@@ -194,46 +216,30 @@ ...@@ -194,46 +216,30 @@
creator : '', creator : '',
date : [] as Array<string>, date : [] as Array<string>,
rule : { rule : {
select : '',
range : [ range : [
{ value: 0, text: '全部' }, { value: ' ', text: '全部' },
{ value: 1, text: '单淘' }, { value: 'SingleElimination', text: '单淘' },
{ value: 2, text: '瑞士轮' } { value: 'Swiss', text: '瑞士轮' }
], ],
info : [ note : new Map([
{ value: 0, text: '' }, ['SingleElimination' , '单淘'],
{ value: 1, text: 'SingleElimination' }, ['Swiss' , '瑞士轮']
{ value: 2, text: 'Swiss' } ]) as Map<string, string>
]
}, },
visibility : { visibility : {
select : '',
range: [ range: [
{ value: 0, text: '全部' }, { value: ' ', text: '全部' },
{ value: 1, text: '公开' }, { value: 'Public', text: '公开' },
{ value: 2, text: '仅登陆可见' }, { value: 'Internal', text: '仅登陆可见' },
{ value: 3, text: '私密' } { value: 'Private', text: '私密' }
],
info : [
{ value: 0, text: '' },
{ value: 1, text: 'Public' },
{ value: 2, text: 'Internal' },
{ value: 3, text: 'Private' }
] ]
}, },
status : { status : {
select : '',
range: [ range: [
{ value: 0, text: '全部' }, { value: ' ', text: '全部' },
{ value: 1, text: '准备中' }, { value: 'Ready', text: '准备中' },
{ value: 2, text: '进行中' }, { value: 'Running', text: '进行中' },
{ value: 3, text: '已结束' } { value: 'Finished', text: '已结束' }
],
info : [
{ value: 0, text: '' },
{ value: 1, text: 'Ready' },
{ value: 2, text: 'Running' },
{ value: 3, text: 'Finished' }
] ]
}, },
info : { info : {
...@@ -250,7 +256,7 @@ ...@@ -250,7 +256,7 @@
tournaments : [] as Array<Tournament> tournaments : [] as Array<Tournament>
}, },
on : async () : Promise<void> => { on : async () : Promise<void> => {
page.search = false; page.drawer = false;
if (search.result.total > 0) { if (search.result.total > 0) {
search.result.total = 0; search.result.total = 0;
} }
...@@ -316,99 +322,38 @@ ...@@ -316,99 +322,38 @@
Uniapp.chkScreen(size.get); Uniapp.chkScreen(size.get);
search.on(); search.on();
document.addEventListener("click", page.show.clear); document.addEventListener("click", page.show.clear);
emitter.on(tournamentInfo, page.show.drawer);
emitter.on(tournamentExit, page.show.menu);
}); });
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener("click", page.show.clear); document.removeEventListener("click", page.show.clear);
emitter.off(tournamentInfo, page.show.drawer);
emitter.off(tournamentExit, page.show.menu);
}); });
watch(() => { return search.date; }, () => { watch(() => { return search.date; }, () => {
search.info.after = new Date(search.date[0]); search.date.length > 0 ? () => {
search.info.before = new Date(`${search.date[1]}T23:59:59.999`); search.info.after = new Date(search.date[0]);
search.info.before = new Date(`${search.date[1]}T23:59:59.999`);
} : () => {
search.info.after = undefined;
search.info.before = undefined;
}
}); });
watch(() => { return search.id; }, () => { watch(() => { return search.id; }, () => {
if (search.id == '') search.info.id = search.id == '' ? 0 : parseInt(search.id);
search.info.id = 0;
else if (!isNaN(parseInt(search.id)))
search.info.id = parseInt(search.id);
}); });
watch(() => { return search.creator; }, () => { watch(() => { return search.creator; }, () => {
if (search.creator == '') search.info.creator = search.creator == '' ? 0 : parseInt(search.creator);
search.info.creator = 0;
else if (!isNaN(parseInt(search.creator)))
search.info.creator = parseInt(search.creator);
});
watch(() => { return search.rule.select; }, () => {
if (!isNaN(parseInt(search.rule.select)) && search.rule.select != '')
search.info.rule = search.rule.info[search.rule.select].text;
});
watch(() => { return search.visibility.select; }, () => {
if (!isNaN(parseInt(search.visibility.select)) && search.visibility.select != '')
search.info.visibility = search.visibility.info[search.visibility.select].text;
});
watch(() => { return search.status.select; }, () => {
if (!isNaN(parseInt(search.status.select)) && search.status.select != '')
search.info.status = search.status.info[search.status.select].text;
}); });
</script> </script>
<style scoped lang = 'scss'> <style scoped lang = 'scss'>
@import '../style/style.scss'; @import '../style/style.scss';
@import '../style/page.scss'; @import '../style/page.scss';
@import '../style/transition.scss';
.switch {
&-enter-active,
&-leave-active {
transition: opacity 0.5s ease;
}
&-enter-from,
&-leave-to {
opacity: 0;
}
&-enter-to,
&-leave-from {
opacity: 1;
}
}
.move_left {
&-enter-active,
&-leave-active {
transition: transform 0.5s ease;
}
&-enter-from,
&-leave-to {
transform: translateX(-200%);
}
&-enter-to,
&-leave-from {
transform: translateX(0%);
}
}
.move_right {
&-enter-active,
&-leave-active {
transition: transform 0.5s ease;
}
&-enter-from,
&-leave-to {
transform: translateX(200%);
}
&-enter-to,
&-leave-from {
transform: translateX(0%);
}
}
</style> </style>
\ No newline at end of file
<template> <template>
<view class = 'PageTournament'> <view class = 'PageTournament'>
<!-- <uni-card <uni-card
v-if = 'tournament.tournament' id = 'PageTournament'
:style = "page.height > 0 ? { height: `${page.height}px` } : { height: '100%' }"
v-if = 'tournament.this'
:is-full = 'true' :is-full = 'true'
:title = 'tournament.tournament.name' :title = 'tournament.this.name'
:sub-title = 'tournament.tournament.description' :sub-title = 'tournament.this.description'
:extra = 'tournament.tournament.createdAt.toLocaleDateString()' :extra = 'tournament.this.createdAt.toLocaleDateString()'
> --> >
<uni-card>
<uni-forms> <uni-forms>
<uni-forms-item> <view class = button_list >
<uni-easyinput type = 'text' placeholder = '添加选手' v-model = 'participant.name'/> <view class = 'button click' @click = 'emitter.emit(tournamentInfo)'>
</uni-forms-item> <span>设置</span>
<view class = 'button' @click = 'participant.add()'> <uni-icons type = 'info'></uni-icons>
<uni-icons type = 'personadd'></uni-icons> </view>
<view class = 'button' @click = 'page.reload()'>
<span>刷新</span>
<uni-icons type = 'reload'></uni-icons>
</view>
<view class = 'button' @click = 'page.clear()'>
<span>关闭</span>
<uni-icons type = 'close'></uni-icons>
</view>
</view> </view>
<!-- <view class = 'button' @click = 'participant.add()'> <!-- <view class = 'button' @click = 'participant.add()'>
<uni-icons type = 'personadd'></uni-icons> <uni-icons type = 'personadd'></uni-icons>
</view> --> </view> -->
</uni-forms> </uni-forms>
<br> <br>
<uni-card <transition name = 'switch'>
:is-full = 'true' <uni-card
title = '参与者' v-show = '!page.loading'
> :is-full = 'true'
<uni-list> title = '参与者'
<uni-list-item >
v-for = '(i, v) in tournament.participants' <uni-list>
:title = 'i.name' <uni-list-item
:note = "i.score ? i.score.rank : ''" v-for = '(i, v) in participant.array'
:rightText = "i.score ? `${i.score.score}\n${i.score.win + i.score.bye}-${i.score.draw}-${i.score.lose}` : ''" :note = "i.score ? i.score.rank : ''"
:clickable = true :title = "i.score ? `${i.score.score}\n${i.score.win + i.score.bye}-${i.score.draw}-${i.score.lose}` : ''"
></uni-list-item> :clickable = true
</uni-list> >
</uni-card> <template v-slot:header>
<uni-card <view id = 'header'>
:is-full = 'true' <span>{{ i.name }}</span>
title = '比赛' <br>
> <span class = 'rank'>{{ i.score ? i.score.rank : '' }}</span>
<uni-list> </view>
<uni-list-item </template>
v-for = '(i, v) in tournament.matchs' <template v-slot:footer>
:clickable = true <view id = 'footer'>
<view class = 'button' @click = 'participant.del(v)' v-show = '!i.quit'>
<uni-icons type = 'trash' color = 'red'></uni-icons>
</view>
<span v-show = 'i.quit'>已退赛</span>
</view>
</template>
</uni-list-item>
<uni-list-item>
<template v-slot:header>
<uni-forms>
<uni-forms-item id = 'header'>
<uni-easyinput type = 'text' placeholder = '添加选手' v-model = 'participant.name'/>
</uni-forms-item>
</uni-forms>
</template>
<template v-slot:footer>
<view id = 'footer'>
<view class = 'button' @click = 'participant.add()'>
<uni-icons type = 'personadd'></uni-icons>
</view>
</view>
</template>
</uni-list-item>
</uni-list>
<uni-pagination
:current = 'participant.page'
v-model = 'participant.page'
pageSize = 20
:total = 'participant.total'
> >
<template v-slot:header> </uni-pagination>
{{ i.player1Id }} </uni-card>
<br> </transition>
{{ i.player1Score }} <transition name = 'switch'>
</template> <uni-card
<template v-slot:body> v-show = '!page.loading'
</template> :is-full = 'true'
<template v-slot:footer> title = '比赛'
{{ i.player2Id }} >
<br> <uni-list>
{{ i.player2Score }} <uni-list-item
</template> v-for = '(i, v) in tournament.matchs'
</uni-list-item> :clickable = true
</uni-list> >
</uni-card> <template v-slot:header>
{{ i.player1Id }}
<br>
{{ i.player1Score }}
</template>
<template v-slot:body>
</template>
<template v-slot:footer>
{{ i.player2Id }}
<br>
{{ i.player2Score }}
</template>
</uni-list-item>
</uni-list>
</uni-card>
</transition>
</uni-card> </uni-card>
</view> </view>
</template> </template>
...@@ -68,44 +121,104 @@ ...@@ -68,44 +121,104 @@
import Tournament from '../script/tournament.ts'; import Tournament from '../script/tournament.ts';
import Participant from '../script/participant.ts'; import Participant from '../script/participant.ts';
import Match from '../script/match.ts'; import Match from '../script/match.ts';
import { selectTournament } from '../script/const.ts' import { selectTournament, tournamentInfo, tournamentExit } from '../script/const.ts'
import Mycard from '../script/mycard.ts'; import Mycard from '../script/mycard.ts';
import { AllParticipant } from '../script/type.ts'
let tournament = reactive({ let tournament = reactive({
tournament : undefined as undefined | Tournament, this : undefined as undefined | Tournament,
matchs : [] as Array<Match>, matchs : [] as Array<Match>,
participants : [] as Array<Participant>,
get : async (t : Tournament) : Promise<void> => {
tournament.tournament = t;
tournament.matchs = await Tabulator.Match.FindALL(Mycard.token, {tournamentId : t.id});
tournament.participants = await Tabulator.Participant.FindALL(Mycard.token, {tournamentId : t.id});
}
}); });
let participant = reactive({ let participant = reactive({
array : [] as Array<Participant>,
total : 0,
page : 1,
add : async() : Promise<void> => { add : async() : Promise<void> => {
const name = participant.name;
// @ts-ignore
if (await Tabulator.Participant.Create(Mycard.token, { name : participant.name, tournamentId : tournament.this.id}, participant.array)) {
participant.name = '';
await (new Promise(resolve => setTimeout(resolve, 200)));
// @ts-ignore
const participants : AllParticipant = await Tabulator.Participant.FindALL(Mycard.token, {tournamentId : tournament.this.id});
participant.array = participants.participants;
participant.total = participants.total;
}
},
del : async(v : number) : Promise<void> => {
const del = async() : Promise<boolean> => {
// @ts-ignore
return await Tabulator.Participant.Delete(Mycard.token, participant.array[v].id);
}
const update = async() : Promise<boolean> => {
return await Tabulator.Participant.Update(Mycard.token, participant.array[v].id, {
name : participant.array[v].name,
quit : true
});
}
// @ts-ignore // @ts-ignore
if (await Tabulator.Participant.Create(Mycard.token, { name : participant.name, tournamentId : tournament.tournament.id})) { if (tournament.this.status == 'Ready' ? await del() : await update()) {
await (new Promise(resolve => setTimeout(resolve, 500))); await (new Promise(resolve => setTimeout(resolve, 200)));
// @ts-ignore // @ts-ignore
tournament.participants = await Tabulator.Participant.FindALL(Mycard.token, {tournamentId : tournament.tournament.id}); const participants : AllParticipant = await Tabulator.Participant.FindALL(Mycard.token, {tournamentId : tournament.this.id});
participant.array = participants.participants;
participant.total = participants.total;
} }
}, },
name : '' name : ''
}); });
onMounted(() => { let page = reactive({
height : 0,
loading : false,
clear : async() : Promise<void> => {
emitter.emit(tournamentExit);
await (new Promise(resolve => setTimeout(resolve, 500)));
participant.array = [];
participant.total = 0;
participant.page = 1;
tournament.this = undefined;
},
get : async (t : Tournament) : Promise<void> => {
tournament.this = t;
tournament.matchs = await Tabulator.Match.FindALL(Mycard.token, {tournamentId : t.id});
const participants : AllParticipant = await Tabulator.Participant.FindALL(Mycard.token, {tournamentId : t.id});
participant.array = participants.participants;
participant.total = participants.total;
},
reload : async () : Promise<void> => {
const query = uni.createSelectorQuery().in(this);
query.select('#PageTournament').boundingClientRect(res => {
// @ts-ignore
page.height = res.height ?? 0;
}).exec();
page.loading = true;
// @ts-ignore
tournament.matchs = await Tabulator.Match.FindALL(Mycard.token, {tournamentId : tournament.this.id});
// @ts-ignore
const participants : AllParticipant = await Tabulator.Participant.FindALL(Mycard.token, {tournamentId : tournament.this.id});
participant.array = participants.participants;
participant.total = participants.total;
await (new Promise(resolve => setTimeout(resolve, 500)));
page.loading = false;
page.height = 0;
},
});
onBeforeMount(() => {
// @ts-ignore // @ts-ignore
emitter.on(selectTournament, tournament.get); emitter.on(selectTournament, page.get);
}); });
onUnmounted(() => { onUnmounted(() => {
// @ts-ignore // @ts-ignore
emitter.off(selectTournament, tournament.get); emitter.off(selectTournament, page.get);
}); });
</script> </script>
<style scoped lang = 'scss'> <style scoped lang = 'scss'>
@import '../style/style.scss'; @import '../style/style.scss';
@import '../style/tournament.scss'; @import '../style/tournament.scss';
@import '../style/transition.scss';
</style> </style>
\ No newline at end of file
const selectTournament = 'selectTournament'; const selectTournament = '1';
const tournamentInfo = '2';
const tournamentExit = '3';
export { export {
selectTournament selectTournament,
tournamentInfo,
tournamentExit
}; };
\ No newline at end of file
...@@ -49,7 +49,7 @@ class MyCard { ...@@ -49,7 +49,7 @@ class MyCard {
logout() { logout() {
window.localStorage.removeItem('mycardLogin'); window.localStorage.removeItem('mycardLogin');
window.location.href = window.location.href.replace(/\/\?.*/, ''); window.location.replace(window.location.href.replace(/\/\?.*/, ''))
} }
} }
......
...@@ -18,7 +18,8 @@ import { ...@@ -18,7 +18,8 @@ import {
ApiKeyObject, ApiKeyObject,
ApiKeyCreateObject, ApiKeyCreateObject,
ApiKeyFindObject, ApiKeyFindObject,
AllTournament AllTournament,
AllParticipant
} from './type.ts' } from './type.ts'
class TabulatorAPI { class TabulatorAPI {
...@@ -89,6 +90,10 @@ class TabulatorAPI { ...@@ -89,6 +90,10 @@ class TabulatorAPI {
} }
}, },
FindALL : async (token : string, obj : TournamentFindObject = {}) : Promise<AllTournament> => { FindALL : async (token : string, obj : TournamentFindObject = {}) : Promise<AllTournament> => {
const filter = (obj : any) : any => {
const v = obj ?? '';
return v != '' && v != ' ' ? obj : undefined;
}
let response : { let response : {
data : { data : {
total : number; total : number;
...@@ -101,11 +106,11 @@ class TabulatorAPI { ...@@ -101,11 +106,11 @@ class TabulatorAPI {
recordsPerPage : 20, recordsPerPage : 20,
pageCount : obj.pageCount ?? 1, pageCount : obj.pageCount ?? 1,
id : (obj.id ?? 0) > 0 ? obj.id : undefined, id : (obj.id ?? 0) > 0 ? obj.id : undefined,
creator : (obj.creator ?? '') != '' ? obj.creator : undefined, creator : filter(obj.creator),
name : (obj.name ?? '') != '' ? obj.name : undefined, name : filter(obj.name),
rule : (obj.rule ?? '') != '' ? obj.rule : undefined, rule : filter(obj.rule),
visibility : (obj.visibility ?? '') != '' ? obj.visibility : undefined, visibility : filter(obj.visibility),
status : (obj.status ?? '') != '' ? obj.status : undefined, status : filter(obj.status),
createdAtBefore: obj.before?.toISOString() ?? undefined, createdAtBefore: obj.before?.toISOString() ?? undefined,
createdAtAfter: obj.after?.toISOString() ?? undefined createdAtAfter: obj.after?.toISOString() ?? undefined
}, },
...@@ -212,13 +217,17 @@ class TabulatorAPI { ...@@ -212,13 +217,17 @@ class TabulatorAPI {
}, },
} }
Participant = { Participant = {
Create : async (token : string, Data : ParticipantCreateObject) : Promise<boolean> => { Create : async (token : string, Data : ParticipantCreateObject, Array : Array<Participant>) : Promise<boolean> => {
let response : { let response : {
data : { data : {
success : boolean; success : boolean;
} }
}; };
try { try {
if (Data.name.length == 0)
throw new Error('请填写名称');
if (Array.findIndex(i => Data.name == i.name) > -1)
throw new Error('名称重复');
response = await this.url.post(`/api/participant`, Data, { response = await this.url.post(`/api/participant`, Data, {
headers : { headers : {
'x-user-token' : token 'x-user-token' : token
...@@ -271,9 +280,10 @@ class TabulatorAPI { ...@@ -271,9 +280,10 @@ class TabulatorAPI {
return undefined; return undefined;
} }
}, },
FindALL : async (token : string, obj : ParticipantFindObject = {}) : Promise<Array<Participant>> => { FindALL : async (token : string, obj : ParticipantFindObject = {}) : Promise<AllParticipant> => {
let response : { let response : {
data : { data : {
total : number;
data : Array<ParticipantObject>; data : Array<ParticipantObject>;
} }
}; };
...@@ -295,11 +305,17 @@ class TabulatorAPI { ...@@ -295,11 +305,17 @@ class TabulatorAPI {
response.data.data.forEach((i : ParticipantObject) => { response.data.data.forEach((i : ParticipantObject) => {
participants.push(new Participant(i)); participants.push(new Participant(i));
}) })
return participants; return {
total : response.data.total,
participants : participants
};
} }
catch(error) { catch(error) {
console.error(error); console.error(error);
return []; return {
total : 0,
participants : []
};
} }
}, },
Update : async (token : string, id : number, Data : ParticipantUpdateObject) : Promise<boolean> => { Update : async (token : string, id : number, Data : ParticipantUpdateObject) : Promise<boolean> => {
......
...@@ -139,6 +139,10 @@ interface AllTournament extends All { ...@@ -139,6 +139,10 @@ interface AllTournament extends All {
tournaments : Array<Tournament>; tournaments : Array<Tournament>;
} }
interface AllParticipant extends All {
participants : Array<Participant>;
}
export { export {
Score, Score,
TournamentObject, TournamentObject,
...@@ -155,5 +159,6 @@ export { ...@@ -155,5 +159,6 @@ export {
ApiKeyObject, ApiKeyObject,
ApiKeyCreateObject, ApiKeyCreateObject,
ApiKeyFindObject, ApiKeyFindObject,
AllTournament AllTournament,
AllParticipant
} }
\ No newline at end of file
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#body { #body {
width: var(--size); width: var(--size);
margin: 0 auto; margin: 0 auto;
:deep(.uni-list-item) { :deep(#list) {
transition: all 0.3s ease; transition: all 0.3s ease;
&:hover { &:hover {
cursor: pointer; cursor: pointer;
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
} }
} }
} }
:deep(#search) { :deep(#drawer) {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
width: var(--size); width: var(--size);
......
.PageTournament { .PageTournament {
:deep(.uni-forms) { #PageTournament {
.button { :deep(.uni-forms) {
border: 1px solid #409eff; .button_list {
display: flex; display: flex;
width: 10%; .button {
justify-content: center; border: 1px solid #409eff;
&:hover { display: flex;
cursor: pointer; width: 20%;
justify-content: center;
&:hover {
cursor: pointer;
}
}
}
}
:deep(.uni-list-item) {
#header {
min-width: 30%;
.rank {
margin-top: 6rpx;
color: #999;
font-size: 12px;
overflow: hidden;
}
}
#footer {
.button {
display: flex;
width: 10%;
justify-content: center;
:hover {
color: red;
cursor: pointer;
}
}
} }
} }
} }
......
.switch {
&-enter-active,
&-leave-active {
transition: opacity 0.5s ease;
}
&-enter-from,
&-leave-to {
opacity: 0;
}
&-enter-to,
&-leave-from {
opacity: 1;
}
}
.move_left {
&-enter-active,
&-leave-active {
transition: transform 0.5s ease;
}
&-enter-from,
&-leave-to {
transform: translateX(-200%);
}
&-enter-to,
&-leave-from {
transform: translateX(0%);
}
}
.move_right {
&-enter-active,
&-leave-active {
transition: transform 0.5s ease;
}
&-enter-from,
&-leave-to {
transform: translateX(200%);
}
&-enter-to,
&-leave-from {
transform: translateX(0%);
}
}
\ No newline at end of file
...@@ -343,7 +343,7 @@ ...@@ -343,7 +343,7 @@
background-color: #fff; background-color: #fff;
flex-direction: row; flex-direction: row;
/* #ifdef H5 */ /* #ifdef H5 */
cursor: pointer; // cursor: pointer;
/* #endif */ /* #endif */
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment