Commit 60fa8bc0 authored by xiaoye's avatar xiaoye

fix

parent 506c38e4
...@@ -110,7 +110,38 @@ ...@@ -110,7 +110,38 @@
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` }"
> >
<uni-easyinput type = 'text' placeholder = '比赛名称' v-model = 'tournament.name'/>
<uni-easyinput type = 'text' placeholder = '比赛描述' v-model = 'tournament.description'/>
<uni-data-select
placeholder = '可见性'
v-model = 'tournament.visibility.select'
:localdata = 'tournament.visibility.range'
></uni-data-select>
<uni-data-select
placeholder = '规则'
v-model = 'tournament.rule.select'
:localdata = 'tournament.rule.range'
></uni-data-select>
<view v-show = "tournament.rule.select == 'Swiss'">
<uni-easyinput type = 'number' placeholder = '轮数' v-model = 'tournament.rule.settings.rounds'/>
<uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'tournament.rule.settings.winScore'/>
<uni-easyinput type = 'number' placeholder = '平局分' v-model = 'tournament.rule.settings.drawScore'/>
<uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'tournament.rule.settings.byeScore'/>
</view>
<view v-show = "tournament.rule.select == 'SingleElimination'">
<checkbox-group @change = 'tournament.hasThirdPlaceMatch.select'>
<label>
<checkbox :checked = 'tournament.rule.settings.hasThirdPlaceMatch'/>季军赛
</label>
</checkbox-group>
</view>
<br>
<view class = 'button' @click = 'tournament.update()'>
<view>
<span>设置</span>
<uni-icons type = 'search'></uni-icons>
</view>
</view>
</uni-card> </uni-card>
</transition> </transition>
<br> <br>
...@@ -153,14 +184,20 @@ ...@@ -153,14 +184,20 @@
</template> </template>
<script setup lang = 'ts'> <script setup lang = 'ts'>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue'; import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import { TournamentFindObject } from '../script/type.ts'; import { TournamentFindObject, TournamentUpdateObject, ruleSettings } from '../script/type.ts';
import Uniapp from '../script/uniapp.ts'; import Uniapp from '../script/uniapp.ts';
import Tabulator from '../script/post.ts'; import Tabulator from '../script/post.ts';
import Tournament from '../script/tournament.ts'; import Tournament from '../script/tournament.ts';
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, tournamentInfo, tournamentExit } from '../script/const.ts' import {
selectTournament,
updateTournament ,
tournamentInfo,
tournamentExit,
tournamentReload
} from '../script/const.ts'
import PageTournament from './tournament.vue'; import PageTournament from './tournament.vue';
let page = reactive({ let page = reactive({
...@@ -174,15 +211,19 @@ ...@@ -174,15 +211,19 @@
}, },
drawer : () : void => { drawer : () : void => {
page.drawer = !page.drawer; page.drawer = !page.drawer;
if (!page.drawer && page.tournament)
tournament.init(tournament.this as Tournament);
}, },
tournament : async(v : number = 0): Promise<void> => { tournament : async(v : number = 0): Promise<void> => {
page.menu = false; page.menu = false;
await (new Promise(resolve => setTimeout(resolve, 500))); await (new Promise(resolve => setTimeout(resolve, 500)));
page.tournament = true; page.tournament = true;
emitter.emit(selectTournament, search.result.tournaments[v]); emitter.emit(selectTournament, search.result.tournaments[v]);
tournament.init(search.result.tournaments[v]);
}, },
menu : async(): Promise<void> => { menu : async(): Promise<void> => {
page.tournament = false; page.tournament = false;
tournament.clear();
await search.on(); await search.on();
await (new Promise(resolve => setTimeout(resolve, 500))); await (new Promise(resolve => setTimeout(resolve, 500)));
page.menu = true; page.menu = true;
...@@ -266,25 +307,79 @@ ...@@ -266,25 +307,79 @@
} }
}); });
let tournament = reactive({
this : undefined as undefined | Tournament,
name : '',
description : '',
visibility : {
select : '',
range : [
{ value: 'Public', text: '公开' },
{ value: 'Internal', text: '仅登陆可见' },
{ value: 'Private', text: '私密' }
]
},
rule : {
select : '',
range : [
{ value: 'SingleElimination', text: '单淘' },
{ value: 'Swiss', text: '瑞士轮' }
],
settings : {
hasThirdPlaceMatch : true
} as ruleSettings
},
hasThirdPlaceMatch : {
select : (e) => {
tournament.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0
console.log(tournament.rule.settings.hasThirdPlaceMatch)
}
},
collaborators : [] as Array<number>,
init : (t : Tournament) : void => {
tournament.this = t;
tournament.name = t.name;
tournament.description = t.description;
tournament.visibility.select = t.visibility;
tournament.collaborators = t.collaborators;
},
clear : () : void => {
tournament.this = undefined;
tournament.name = '';
tournament.description = '';
tournament.visibility.select = '';
tournament.collaborators = [];
},
update : () : void => {
if (tournament.visibility.select == '')
// @ts-ignore
tournament.visibility.select = tournament.this.visibility;
emitter.emit(updateTournament, {
name: tournament.name,
description: tournament.description,
visibility: tournament.visibility.select,
collaborators : tournament.collaborators
} as TournamentUpdateObject);
}
});
const test = async () => { const test = async () => {
page.user = !page.user; let response = await Tabulator.Tournament.Create(Mycard.token, {
// Mycard.login() name: "test",
// let response = await Tabulator.Tournament.Create(token, { description: "暂无介绍。",
// name: "string", rule: "SingleElimination",
// description: "暂无介绍。", ruleSettings: {
// rule: "SingleElimination", rounds: 0,
// ruleSettings: { winScore: 0,
// rounds: 0, drawScore: 0,
// winScore: 0, byeScore: 0,
// drawScore: 0, hasThirdPlaceMatch: true
// byeScore: 0, },
// hasThirdPlaceMatch: true visibility: "Public",
// }, collaborators: [
// visibility: "Public", 1
// collaborators: [ ]
// 1 });
// ]
// });
// await Tabulator.Tournament.Delete(token, 3); // await Tabulator.Tournament.Delete(token, 3);
// await Tabulator.Tournament.FindALL(token, {}); // await Tabulator.Tournament.FindALL(token, {});
// await Tabulator.Tournament.Update(token, 3, { // await Tabulator.Tournament.Update(token, 3, {
...@@ -296,7 +391,7 @@ ...@@ -296,7 +391,7 @@
// ] // ]
// }); // });
// console.log(await Tabulator.Participant.Create(token, { name : 'jwyxym', tournamentId : 5})) // console.log(await Tabulator.Tournament.Create(Mycard.token, { name : 'test'}))
// console.log(await Tabulator.Tournament.FindALL(token, {})) // console.log(await Tabulator.Tournament.FindALL(token, {}))
// console.log(await Tabulator.Match.FindALL(token, { id : 5 })) // console.log(await Tabulator.Match.FindALL(token, { id : 5 }))
// console.log(await Tabulator.Participant.FindALL(token)) // console.log(await Tabulator.Participant.FindALL(token))
...@@ -315,21 +410,21 @@ ...@@ -315,21 +410,21 @@
}); });
onBeforeMount(() => { onBeforeMount(() => {
/*
if (Mycard.id < 0)
Mycard.login();
*/
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(tournamentInfo, page.show.drawer);
emitter.on(tournamentExit, page.show.menu); emitter.on(tournamentExit, page.show.menu);
// @ts-ignore
emitter.on(tournamentReload, tournament.init);
}); });
onUnmounted(() => { onUnmounted(() => {
document.removeEventListener("click", page.show.clear); document.removeEventListener("click", page.show.clear);
emitter.off(tournamentInfo, page.show.drawer); emitter.off(tournamentInfo, page.show.drawer);
emitter.off(tournamentExit, page.show.menu); emitter.off(tournamentExit, page.show.menu);
// @ts-ignore
emitter.off(tournamentReload, tournament.init);
}); });
watch(() => { return search.date; }, () => { watch(() => { return search.date; }, () => {
......
This diff is collapsed.
const selectTournament = '1'; const selectTournament = 'selectTournament';
const tournamentInfo = '2'; const updateTournament = 'updateTournament';
const tournamentExit = '3';
const tournamentInfo = 'tournamentInfo';
const tournamentExit = 'tournamentExit';
const tournamentReload = 'tournamentReload'
export { export {
selectTournament, selectTournament,
updateTournament ,
tournamentInfo, tournamentInfo,
tournamentExit tournamentExit,
tournamentReload
}; };
\ No newline at end of file
...@@ -19,7 +19,8 @@ import { ...@@ -19,7 +19,8 @@ import {
ApiKeyCreateObject, ApiKeyCreateObject,
ApiKeyFindObject, ApiKeyFindObject,
AllTournament, AllTournament,
AllParticipant AllParticipant,
AllMatch
} from './type.ts' } from './type.ts'
class TabulatorAPI { class TabulatorAPI {
...@@ -217,7 +218,7 @@ class TabulatorAPI { ...@@ -217,7 +218,7 @@ class TabulatorAPI {
}, },
} }
Participant = { Participant = {
Create : async (token : string, Data : ParticipantCreateObject, Array : Array<Participant>) : Promise<boolean> => { Create : async (token : string, Data : ParticipantCreateObject, Array : Array<Participant> = []) : Promise<boolean> => {
let response : { let response : {
data : { data : {
success : boolean; success : boolean;
...@@ -377,9 +378,10 @@ class TabulatorAPI { ...@@ -377,9 +378,10 @@ class TabulatorAPI {
return undefined; return undefined;
} }
}, },
FindALL : async (token : string, obj : MatchFindObject = {}) : Promise<Array<Match>> => { FindALL : async (token : string, obj : MatchFindObject = {}) : Promise<AllMatch> => {
let response : { let response : {
data : { data : {
total : number;
data : Array<MatchObject>; data : Array<MatchObject>;
} }
}; };
...@@ -408,11 +410,17 @@ class TabulatorAPI { ...@@ -408,11 +410,17 @@ class TabulatorAPI {
response.data.data.forEach((i : MatchObject) => { response.data.data.forEach((i : MatchObject) => {
matchs.push(new Match(i)); matchs.push(new Match(i));
}) })
return matchs; return {
total : response.data.total,
matchs : matchs
};
} }
catch(error) { catch(error) {
console.error(error); console.error(error);
return []; return {
total : 0,
matchs : []
};
} }
}, },
Update : async (token : string, id : number, Data : MatchUpdateObject) : Promise<boolean> => { Update : async (token : string, id : number, Data : MatchUpdateObject) : Promise<boolean> => {
......
...@@ -47,15 +47,17 @@ interface TournamentUpdateObject { ...@@ -47,15 +47,17 @@ interface TournamentUpdateObject {
collaborators : Array<number>; collaborators : Array<number>;
} }
interface ruleSettings {
rounds : number;
winScore : number;
drawScore : number;
byeScore : number;
hasThirdPlaceMatch : boolean;
}
interface TournamentCreateObject extends TournamentUpdateObject { interface TournamentCreateObject extends TournamentUpdateObject {
rule : string; rule : string;
ruleSettings : { ruleSettings : ruleSettings;
rounds : number;
winScore : number;
drawScore : number;
byeScore : number;
hasThirdPlaceMatch : boolean;
};
} }
interface TournamentObject extends TournamentCreateObject { interface TournamentObject extends TournamentCreateObject {
...@@ -142,6 +144,9 @@ interface AllTournament extends All { ...@@ -142,6 +144,9 @@ interface AllTournament extends All {
interface AllParticipant extends All { interface AllParticipant extends All {
participants : Array<Participant>; participants : Array<Participant>;
} }
interface AllMatch extends All {
matchs : Array<Match>;
}
export { export {
Score, Score,
...@@ -160,5 +165,7 @@ export { ...@@ -160,5 +165,7 @@ export {
ApiKeyCreateObject, ApiKeyCreateObject,
ApiKeyFindObject, ApiKeyFindObject,
AllTournament, AllTournament,
AllParticipant AllParticipant,
AllMatch,
ruleSettings
} }
\ No newline at end of file
...@@ -61,4 +61,4 @@ ...@@ -61,4 +61,4 @@
cursor: pointer; cursor: pointer;
} }
} }
} }
\ No newline at end of file
.PageTournament { .PageTournament {
#PageTournament { #PageTournament {
:deep(.uni-forms) { .button_list {
.button_list { display: flex;
.button {
border: 1px solid #409eff;
display: flex; display: flex;
.button { width: 20%;
border: 1px solid #409eff; justify-content: center;
display: flex; &:hover {
width: 20%; cursor: pointer;
justify-content: center; background-color: #e6e6e6;
&:hover {
cursor: pointer;
}
} }
} }
} }
:deep(.uni-list-item) { :deep(.uni-list-item) {
#header { #header {
min-width: 30%; min-width: 30%;
...@@ -24,13 +24,34 @@ ...@@ -24,13 +24,34 @@
overflow: hidden; overflow: hidden;
} }
} }
#body {
width: 100%;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: 1fr;
justify-content: center;
transition: all 0.3s ease;
#left {
justify-self: left;
}
#center {
justify-self: center;
}
#right {
justify-self: right;
}
&:hover {
cursor: pointer;
scale: (1.05);
}
}
#footer { #footer {
.button { .button {
border: 0.5px solid var(--color);
display: flex; display: flex;
width: 10%;
justify-content: center; justify-content: center;
:hover { :hover {
color: red; background-color: #e6e6e6;
cursor: pointer; cursor: pointer;
} }
} }
......
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