Commit 534c062a authored by xiaoye's avatar xiaoye

更改交互

parent 67cab6fb
Pipeline #38808 canceled with stages
in 1 minute and 40 seconds
...@@ -128,9 +128,6 @@ ...@@ -128,9 +128,6 @@
rule : { rule : {
select : '', select : '',
settings : { settings : {
winScore : 3,
drawScore : 1,
byeScore : 3,
hasThirdPlaceMatch : true hasThirdPlaceMatch : true
} as ruleSettings, } as ruleSettings,
range : [ range : [
...@@ -181,6 +178,14 @@ ...@@ -181,6 +178,14 @@
if (n > 0 && !Number.isInteger(n) || n <= 0) if (n > 0 && !Number.isInteger(n) || n <= 0)
throw new Error('出轮的人数必须是2的幂'); throw new Error('出轮的人数必须是2的幂');
} }
if (create.visibility.select = 'Swiss') {
if (!create.rule.settings.winScore && create.rule.settings.winScore == undefined)
throw new Error('请填写胜利分');
if (!create.rule.settings.drawScore && create.rule.settings.drawScore == undefined)
throw new Error('请填写平局分');
if (!create.rule.settings.byeScore && create.rule.settings.byeScore == undefined)
throw new Error('请填写轮空分');
}
const collaborators = create.collaborators.map(user => user.id); const collaborators = create.collaborators.map(user => user.id);
const id = await Tabulator.Tournament.Create(Mycard.token, { const id = await Tabulator.Tournament.Create(Mycard.token, {
name: create.name, name: create.name,
......
<template> <template>
<uni-card class = 'Setting' v-if = 'tournament'> <uni-card class = 'Setting' v-if = 'tournament'>
<uni-easyinput type = 'text' placeholder = '比赛名称' v-model = 'tournament.name' :disabled = 'tournament.operatorChk()'/> <uni-easyinput type = 'text' placeholder = '比赛名称' v-model = 'tournament.name' :disabled = '!operatorChk()'/>
<uni-easyinput type = 'text' placeholder = '比赛描述' v-model = 'tournament.description' :disabled = 'tournament.operatorChk()'/> <uni-easyinput type = 'text' placeholder = '比赛描述' v-model = 'tournament.description' :disabled = '!operatorChk()'/>
<uni-data-select <uni-data-select
placeholder = '可见性' placeholder = '可见性'
v-model = 'tournament.visibility.select' v-model = 'tournament.visibility.select'
:localdata = 'tournament.visibility.range' :localdata = 'tournament.visibility.range'
:disabled = 'tournament.operatorChk()' :disabled = '!operatorChk()'
></uni-data-select> ></uni-data-select>
<uni-data-select <uni-data-select
placeholder = '规则' placeholder = '规则'
v-model = 'tournament.rule.select' v-model = 'tournament.rule.select'
:localdata = 'tournament.rule.range' :localdata = 'tournament.rule.range'
:disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()" :disabled = "tournament.this?.status != 'Ready' || !operatorChk()"
></uni-data-select> ></uni-data-select>
<view v-show = "tournament.rule.select == 'Swiss'"> <view v-show = "tournament.rule.select == 'Swiss'">
<uni-easyinput type = 'number' placeholder = '轮数' v-model = 'tournament.rule.settings.rounds' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> <uni-easyinput type = 'number' placeholder = '轮数' v-model = 'tournament.rule.settings.rounds' :disabled = "tournament.this?.status != 'Ready' || !operatorChk()"/>
<uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'tournament.rule.settings.winScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> <uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'tournament.rule.settings.winScore' :disabled = "tournament.this?.status != 'Ready' || !operatorChk()"/>
<uni-easyinput type = 'number' placeholder = '平局分' v-model = 'tournament.rule.settings.drawScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> <uni-easyinput type = 'number' placeholder = '平局分' v-model = 'tournament.rule.settings.drawScore' :disabled = "tournament.this?.status != 'Ready' || !operatorChk()"/>
<uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'tournament.rule.settings.byeScore' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/> <uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'tournament.rule.settings.byeScore' :disabled = "tournament.this?.status != 'Ready' || !operatorChk()"/>
</view> </view>
<view v-show = "tournament.rule.select == 'SingleElimination'"> <view v-show = "tournament.rule.select == 'SingleElimination'">
<checkbox-group @change = 'tournament.hasThirdPlaceMatch.select'> <checkbox-group @change = 'tournament.hasThirdPlaceMatch.select'>
<label> <label>
<checkbox :checked = 'tournament.rule.settings.hasThirdPlaceMatch' :disabled = "tournament.this?.status != 'Ready' || tournament.operatorChk()"/>季军赛 <checkbox :checked = 'tournament.rule.settings.hasThirdPlaceMatch' :disabled = "tournament.this?.status != 'Ready' || !operatorChk()"/>季军赛
</label> </label>
</checkbox-group> </checkbox-group>
</view> </view>
<br> <br>
<view v-show = 'operatorChk()'>
<view class = 'button click' @click = 'emit.on()'>
<span>{{ `切换状态:${status.text.get(tournament.this.status)}` }}</span>
<uni-icons type = 'circle-filled' :color = 'status.color.get(tournament.this.status)'></uni-icons>
</view>
<view class = 'button click' @click = 'emit.reset()'>
<span>重置比赛</span>
<uni-icons type = 'loop'></uni-icons>
</view>
<view class = 'button click' @click = 'emit.shuffle()'>
<span>打乱选手</span>
<uni-icons type = 'auth'></uni-icons>
</view>
<view class = 'button click' @click = 'emit.upload()'>
<span>上传选手</span>
<uni-icons type = 'cloud-upload'></uni-icons>
</view>
<view class = 'button click' @click = 'emit.empty()'>
<span>清空选手</span>
<uni-icons type = 'spinner-cycle' color = 'red'></uni-icons>
</view>
<view class = 'button click' @click = 'emit.del()'>
<span>删除比赛</span>
<uni-icons type = 'trash' color = 'red'></uni-icons>
</view>
</view>
<br>
<uni-card <uni-card
id = 'collaborators' id = 'collaborators'
title = '协作者' title = '协作者'
...@@ -49,7 +76,7 @@ ...@@ -49,7 +76,7 @@
</view> </view>
</view> </view>
</uni-list-chat> </uni-list-chat>
<uni-list-item> <uni-list-item v-show = 'operatorChk()'>
<template v-slot:header> <template v-slot:header>
<uni-forms> <uni-forms>
<uni-forms-item id = 'header'> <uni-forms-item id = 'header'>
...@@ -72,7 +99,7 @@ ...@@ -72,7 +99,7 @@
</uni-list> </uni-list>
</uni-card> </uni-card>
<br> <br>
<uni-easyinput v-show = '!tournament.operatorChk()' type = 'text' placeholder = '卡图图床(例:https://example.com/api/)' v-model = 'tournament.pics'/> <uni-easyinput v-show = 'operatorChk()' type = 'text' placeholder = '卡图图床(例:https://example.com/api/)' v-model = 'tournament.pics'/>
<br> <br>
<view class = 'button' @click = 'tournament.update()'> <view class = 'button' @click = 'tournament.update()'>
<view> <view>
...@@ -86,13 +113,52 @@ ...@@ -86,13 +113,52 @@
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue'; import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import emitter from '../../script/emitter.ts'; import emitter from '../../script/emitter.ts';
import Const from '../../script/const.ts' import Const from '../../script/const.ts'
import Mycard from '../../script/mycard.ts';
let tournament; let tournament;
const operatorChk = () : boolean => {
return Mycard.id >= 0 && (Mycard.id == tournament.this?.creator || (tournament.this?.collaborators.includes(Mycard.id) ?? false));
}
const init = (t) : void => { const init = (t) : void => {
tournament = t; tournament = t;
}; };
const status = {
text : new Map([
['Ready', '开始'],
['Running', '结束'],
['Finished', '已结束']
]) as Map<string, string>,
color : new Map([
['Ready', 'rgb(84, 200, 17)'],
['Running', 'red'],
['Finished', 'darkgray']
]) as Map<string, string>,
}
const emit = {
on : () : void => {
emitter.emit(Const.tournamentOn);
},
reset : () : void => {
emitter.emit(Const.tournamentReset);
},
shuffle : () : void => {
emitter.emit(Const.tournamentShuffle);
},
upload : () : void => {
emitter.emit(Const.tournamentUpload);
},
empty : () : void => {
emitter.emit(Const.tournamentEmpty);
},
del : () : void => {
emitter.emit(Const.tournamentDel);
}
};
onBeforeMount(() : void => { onBeforeMount(() : void => {
emitter.on(Const.settingInit, init) emitter.on(Const.settingInit, init)
}); });
...@@ -100,3 +166,12 @@ ...@@ -100,3 +166,12 @@
emitter.off(Const.settingInit, init) emitter.off(Const.settingInit, init)
}); });
</script> </script>
<style lang = 'scss' scoped>
.button {
display: flex !important;
width: 100%;
justify-content: center !important;
font-size: 16px;
gap: 5%
}
</style>
\ No newline at end of file
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<uni-forms> <uni-forms>
<view class = 'button_list' > <view class = 'button_list' >
<view class = 'button click' @click = '() => { emitter.emit(Const.tournamentInfo); }'> <view class = 'button click' @click = '() => { emitter.emit(Const.tournamentInfo); }'>
<span>设置</span> <span>{{ tournament.operatorChk() ? '设置' : '信息' }}</span>
<uni-icons type = 'info'></uni-icons> <uni-icons type = 'info'></uni-icons>
</view> </view>
<view class = 'button' @click = 'page.reload()'> <view class = 'button' @click = 'page.reload()'>
...@@ -38,33 +38,15 @@ ...@@ -38,33 +38,15 @@
<span>关闭</span> <span>关闭</span>
<uni-icons type = 'close'></uni-icons> <uni-icons type = 'close'></uni-icons>
</view> </view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.on)'>
<span>{{ tournament.status.text.get(tournament.this.status) }}</span>
<uni-icons type = 'circle-filled' :color = 'tournament.status.color.get(tournament.this.status)'></uni-icons>
</view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.reset)'>
<span>重置</span>
<uni-icons type = 'loop'></uni-icons>
</view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.shuffle)'>
<span>打乱</span>
<uni-icons type = 'auth'></uni-icons>
</view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.upload)'>
<span>上传</span>
<uni-icons type = 'cloud-upload'></uni-icons>
</view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.empty)'>
<span>清空</span>
<uni-icons type = 'spinner-cycle' color = 'red'></uni-icons>
</view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.del)'>
<span>删除</span>
<uni-icons type = 'trash' color = 'red'></uni-icons>
</view>
</view> </view>
</uni-forms> </uni-forms>
<br> <br>
<transition name = 'switch'>
<view v-show = '!page.loading'>
<uni-icons type = 'circle-filled' :color = 'tournament.status.color.get(tournament.this.status)'></uni-icons>
<span id = 'status'>{{ tournament.status.text.get(tournament.this.status) }}</span>
</view>
</transition>
<transition name = 'switch'> <transition name = 'switch'>
<uni-card <uni-card
v-show = '!page.loading' v-show = '!page.loading'
...@@ -84,15 +66,15 @@ ...@@ -84,15 +66,15 @@
<div> <div>
<view <view
class = 'button' class = 'button'
@click = 'tournament.operatorChk(participant.copy)' @click = 'participant.copy()'
> >
复制排名 复制排名
</view> </view>
<view <view
class = 'button' class = 'button'
id = 'newTournament' id = 'newTournament'
@click = 'tournament.operatorChk(tournament.new)' @click = 'tournament.new'
v-show = 'tournament.operatorChk()'
> >
新建单淘赛 新建单淘赛
</view> </view>
...@@ -122,13 +104,13 @@ ...@@ -122,13 +104,13 @@
</view> </view>
</template> </template>
<template v-slot:footer> <template v-slot:footer>
<view id = 'footer'> <view id = 'footer' v-show = 'tournament.operatorChk()'>
<view <view
class = 'button' class = 'button'
id = 'deckbutton' id = 'deckbutton'
:style = "{ '--color' : participant.move.this === i ? '#409eff' : 'gray', 'background-color' : participant.move.this === i ? '#e6e6e6' : 'white'}" :style = "{ '--color' : participant.move.this === i ? '#409eff' : 'gray', 'background-color' : participant.move.this === i ? '#e6e6e6' : 'white'}"
v-show = "!i.quit && tournament.this.status == 'Ready'" v-show = "!i.quit && tournament.this.status == 'Ready'"
@click = 'tournament.operatorChk(participant.move.start, [i, $event])' @click = 'participant.move.start(i)'
> >
<uni-icons :type = "participant.move.this && participant.move.this !== i ? 'pulldown' : 'list'"></uni-icons> <uni-icons :type = "participant.move.this && participant.move.this !== i ? 'pulldown' : 'list'"></uni-icons>
</view> </view>
...@@ -139,20 +121,20 @@ ...@@ -139,20 +121,20 @@
v-show = '!i.quit' v-show = '!i.quit'
@click = 'participant.pics.on(i)' @click = 'participant.pics.on(i)'
> >
<svgCards/> <svgDeck/>
</view> </view>
<view <view
class = 'button' class = 'button'
:style = "{ '--color' : 'gray' }" :style = "{ '--color' : 'gray' }"
v-show = '!i.quit' v-show = '!i.quit'
@click = 'tournament.operatorChk(participant.upload, [i])' @click = 'participant.upload(i)'
> >
<svgDeck/> <uni-icons type = 'cloud-upload'></uni-icons>
</view> </view>
<view <view
class = 'button' class = 'button'
:style = "{ '--color' : 'red' }" :style = "{ '--color' : 'red' }"
@click = 'tournament.operatorChk(participant.del, [i])' @click = 'participant.del(i)'
v-show = '!i.quit' v-show = '!i.quit'
> >
<uni-icons type = 'trash' color = 'red'></uni-icons> <uni-icons type = 'trash' color = 'red'></uni-icons>
...@@ -161,12 +143,13 @@ ...@@ -161,12 +143,13 @@
<view <view
class = 'button' class = 'button'
:style = "{ '--color' : 'gray' }" :style = "{ '--color' : 'gray' }"
@click = 'tournament.operatorChk(participant.undo, [i])' @click = 'participant.undo(i)'
v-show = 'i.quit' v-show = 'i.quit'
> >
<uni-icons type = 'undo'></uni-icons> <uni-icons type = 'undo'></uni-icons>
</view> </view>
</view> </view>
<span v-show = '!tournament.operatorChk()' class = 'small'>{{ i.quit ? '已退赛' : '参与中'}}</span>
</template> </template>
</uni-list-item> </uni-list-item>
<uni-list-item> <uni-list-item>
...@@ -182,7 +165,7 @@ ...@@ -182,7 +165,7 @@
<view <view
class = 'button' class = 'button'
:style = "{ '--color' : '#409eff' }" :style = "{ '--color' : '#409eff' }"
@click = 'tournament.operatorChk(participant.add)' @click = 'participant.add()'
> >
<uni-icons type = 'personadd'></uni-icons> <uni-icons type = 'personadd'></uni-icons>
</view> </view>
...@@ -220,7 +203,7 @@ ...@@ -220,7 +203,7 @@
</div> </div>
<div> <div>
<view class = 'button' @click = '() => { match.round = 0; }'>全部轮次</view> <view class = 'button' @click = '() => { match.round = 0; }'>全部轮次</view>
<view class = 'button' @click = 'tournament.operatorChk(tournament.copy)'>复制对战表</view> <view class = 'button' @click = 'tournament.copy()'>复制对战表</view>
</div> </div>
</view> </view>
<view> <view>
...@@ -361,14 +344,14 @@ ...@@ -361,14 +344,14 @@
this : undefined as undefined | Tournament, this : undefined as undefined | Tournament,
status : { status : {
text : new Map([ text : new Map([
['Ready', '开始'], ['Ready', '准备中'],
['Running', '结束'], ['Running', '进行中'],
['Finished', '已结束'] ['Finished', '已结束']
]) as Map<string, string>, ]) as Map<string, string>,
color : new Map([ color : new Map([
['Ready', 'rgb(84, 200, 17)'], ['Ready', 'darkgray'],
['Running', 'red'], ['Running', 'rgb(84, 200, 17)'],
['Finished', 'darkgray'] ['Finished', 'red']
]) as Map<string, string>, ]) as Map<string, string>,
}, },
search : async () : Promise<boolean> => { search : async () : Promise<boolean> => {
...@@ -391,6 +374,7 @@ ...@@ -391,6 +374,7 @@
return false; return false;
}, },
on : () : void => { on : () : void => {
if (!tournament.operatorChk()) return;
switch(tournament.this?.status) { switch(tournament.this?.status) {
case 'Ready': case 'Ready':
uni.showModal({ uni.showModal({
...@@ -466,14 +450,8 @@ ...@@ -466,14 +450,8 @@
} }
}); });
}, },
operatorChk : (f : Function = () => {}, para : Array<any> = []) : boolean => { operatorChk : () : boolean => {
if (Mycard.id >= 0 && (Mycard.id == tournament.this?.creator || tournament.this?.collaborators.includes(Mycard.id))) { return Mycard.id >= 0 && (Mycard.id == tournament.this?.creator || (tournament.this?.collaborators.includes(Mycard.id) ?? false));
f(...para);
return true
}
else
UniApp.error('请先登陆或联系比赛主办方', '缺少权限');
return false;
}, },
upload : async () : Promise<void> => { upload : async () : Promise<void> => {
const f = async (res : UniApp.ChooseFileSuccessCallbackResult) : Promise<void> => { const f = async (res : UniApp.ChooseFileSuccessCallbackResult) : Promise<void> => {
...@@ -636,7 +614,7 @@ ...@@ -636,7 +614,7 @@
}, },
move : { move : {
this : undefined as Participant | undefined, this : undefined as Participant | undefined,
start : (i : Participant, e : TouchEvent) : void => { start : (i : Participant) : void => {
const on = () : void => { const on = () : void => {
participant.move.this = i; participant.move.this = i;
}; };
...@@ -775,6 +753,12 @@ ...@@ -775,6 +753,12 @@
// @ts-ignore // @ts-ignore
emitter.on(Const.updateTournament, participant.update); emitter.on(Const.updateTournament, participant.update);
emitter.on(Const.showTournament, loading); emitter.on(Const.showTournament, loading);
emitter.on(Const.tournamentOn, tournament.on);
emitter.on(Const.tournamentReset, tournament.reset);
emitter.on(Const.tournamentShuffle, tournament.shuffle);
emitter.on(Const.tournamentUpload, tournament.upload);
emitter.on(Const.tournamentEmpty, tournament.empty);
emitter.on(Const.tournamentDel, tournament.del);
}); });
onUnmounted(() => { onUnmounted(() => {
...@@ -782,6 +766,12 @@ ...@@ -782,6 +766,12 @@
// @ts-ignore // @ts-ignore
emitter.off(Const.updateTournament, participant.update); emitter.off(Const.updateTournament, participant.update);
emitter.off(Const.showTournament, loading); emitter.off(Const.showTournament, loading);
emitter.off(Const.tournamentOn, tournament.on);
emitter.off(Const.tournamentReset, tournament.reset);
emitter.off(Const.tournamentShuffle, tournament.shuffle);
emitter.off(Const.tournamentUpload, tournament.upload);
emitter.off(Const.tournamentEmpty, tournament.empty);
emitter.off(Const.tournamentDel, tournament.del);
}); });
watch(() => { return match.round; }, () : void => { watch(() => { return match.round; }, () : void => {
......
...@@ -12,6 +12,12 @@ class ConstData { ...@@ -12,6 +12,12 @@ class ConstData {
showTournament = 'showTournament'; showTournament = 'showTournament';
updateRounds = 'updateRounds'; updateRounds = 'updateRounds';
newTournament = 'newTournament'; newTournament = 'newTournament';
tournamentOn = 'tournamentOn';
tournamentReset = 'tournamentReset';
tournamentShuffle = 'tournamentShuffle';
tournamentUpload = 'tournamentUpload';
tournamentEmpty = 'tournamentEmpty';
tournamentDel = 'tournamentDel';
ot = { ot = {
CustomJpg : 0, CustomJpg : 0,
CustomPng : 1, CustomPng : 1,
......
...@@ -25,6 +25,10 @@ ...@@ -25,6 +25,10 @@
} }
} }
#status {
font-size: 16px;
}
#body { #body {
width: 80%; width: 80%;
min-width: 208px; min-width: 208px;
......
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