Commit 482e86fa authored by xiaoye's avatar xiaoye

fix

parent c63eddcc
...@@ -217,7 +217,11 @@ ...@@ -217,7 +217,11 @@
create.collaborator = ''; create.collaborator = '';
} }
}, },
fromSwiss : (t : Tournament) : void => { fromSwiss : (obj : {
t : Tournament,
value : number
}) : void => {
const t = obj.t;
create.collaborators = []; create.collaborators = [];
t.collaborators.forEach(async id => { t.collaborators.forEach(async id => {
const i = await User.Find.Id(id); const i = await User.Find.Id(id);
...@@ -231,6 +235,7 @@ ...@@ -231,6 +235,7 @@
create.import.id = t.id; create.import.id = t.id;
create.name = t.name; create.name = t.name;
create.description = t.description; create.description = t.description;
create.import.count = obj.value > 0 ? obj.value : undefined;
} }
}); });
......
...@@ -70,13 +70,34 @@ ...@@ -70,13 +70,34 @@
:is-full = 'true' :is-full = 'true'
:title = '`参与者:${participant.total}`' :title = '`参与者:${participant.total}`'
> >
<view <view id = 'round'>
class = 'button' <div>
id = 'newTournament'
@click = 'tournament.new()' <uni-number-box
v-show = "tournament.this.rule == 'Swiss' && tournament.this.status == 'Finished'" v-model = 'participant.copyValue'
> :min = '0'
新建单淘赛 :max = 'participant.array.length'
v-show = "tournament.this.status == 'Finished'"
></uni-number-box>
</div>
<div>
<view
class = 'button'
@click = 'tournament.operatorChk(participant.copy)'
v-show = "tournament.this.status == 'Finished'"
>
复制排名
</view>
<view
class = 'button'
id = 'newTournament'
@click = 'tournament.operatorChk(tournament.new)'
v-show = "tournament.this.rule == 'Swiss' && tournament.this.status == 'Finished'"
>
新建单淘赛
</view>
</div>
</view> </view>
<transition name = 'switch'> <transition name = 'switch'>
<uni-list> <uni-list>
...@@ -189,7 +210,7 @@ ...@@ -189,7 +210,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.copy()'>复制对战表</view> <view class = 'button' @click = 'tournament.operatorChk(tournament.copy)'>复制对战表</view>
</div> </div>
</view> </view>
<transition name = 'switch'> <transition name = 'switch'>
...@@ -350,6 +371,7 @@ ...@@ -350,6 +371,7 @@
const id = url[1]; const id = url[1];
// @ts-ignore // @ts-ignore
const t : TournamentGet = await Tabulator.Tournament.Find(Mycard.token, id); const t : TournamentGet = await Tabulator.Tournament.Find(Mycard.token, id);
console.log(t)
if (t.tournament) { if (t.tournament) {
tournament.this = t.tournament; tournament.this = t.tournament;
const participants = t.participant; const participants = t.participant;
...@@ -472,7 +494,10 @@ ...@@ -472,7 +494,10 @@
}, },
new : () : void => { new : () : void => {
if (!tournament.this) return; if (!tournament.this) return;
emitter.emit(Const.newTournament, tournament.this); emitter.emit(Const.newTournament, {
t : tournament.this,
value : participant.copyValue
});
} }
}); });
...@@ -615,7 +640,25 @@ ...@@ -615,7 +640,25 @@
if (await Tabulator.Tournament.Drag(Mycard.token, tournament.this?.id, from, to)) if (await Tabulator.Tournament.Drag(Mycard.token, tournament.this?.id, from, to))
await tournament.search(); await tournament.search();
} }
} },
copy : () : void => {
if (!tournament.this) return;
let string = `<--- ${tournament.this.name} - [${tournament.this.rule == 'SingleElimination' ? '淘汰赛' : '瑞士轮'}]${tournament.this.ruleSettings.rounds ? `[${tournament.this.ruleSettings.rounds}轮]` : ''}[${tournament.this.count ?? 0}人] --->\n`;
let copyValue = participant.copyValue;
if (copyValue == 0) copyValue = participant.array.length;
const map : Map<number, string> = new Map([
[0, '冠军'],
[1, '亚军'],
[2, '季军'],
[3, '殿军'],
]);
for (let i = 0; i < copyValue; i++) {
let p = participant.array[i];
string += `[${map.get(i) ?? `${i + 1}名`}]${p.name}\n`
}
UniApp.copy(string);
},
copyValue : 0
}); });
let page = reactive({ let page = reactive({
...@@ -645,6 +688,7 @@ ...@@ -645,6 +688,7 @@
}).exec(); }).exec();
page.loading = true; page.loading = true;
participant.name = ''; participant.name = '';
participant.copyValue = 0;
if (await tournament.search()) { if (await tournament.search()) {
if (match.round > match.maxRound) if (match.round > match.maxRound)
match.round = match.maxRound; match.round = match.maxRound;
...@@ -653,8 +697,6 @@ ...@@ -653,8 +697,6 @@
page.height = 0; page.height = 0;
} else } else
UniApp.error('请重试或检查网络设置', '刷新失败'); UniApp.error('请重试或检查网络设置', '刷新失败');
}, },
clickClear : (e) : void => { clickClear : (e) : void => {
let element = e.target; let element = e.target;
......
...@@ -32,9 +32,9 @@ class Tournament { ...@@ -32,9 +32,9 @@ class Tournament {
this.creator = obj.creator; this.creator = obj.creator;
this.createdAt = new Date(obj.createdAt); this.createdAt = new Date(obj.createdAt);
this.count = obj.participants.length; this.count = obj.participants.length;
if (!Number.isNaN(this.ruleSettings.winScore)) this.ruleSettings.winScore = 3; if (Number.isNaN(this.ruleSettings.winScore)) this.ruleSettings.winScore = 3;
if (!Number.isNaN(this.ruleSettings.drawScore)) this.ruleSettings.drawScore = 1; if (Number.isNaN(this.ruleSettings.drawScore)) this.ruleSettings.drawScore = 1;
if (!Number.isNaN(this.ruleSettings.byeScore)) this.ruleSettings.byeScore = 0; if (Number.isNaN(this.ruleSettings.byeScore)) this.ruleSettings.byeScore = 3;
} }
} }
......
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