Commit 69c2cafd authored by xiaoye's avatar xiaoye

Update tournament.vue

parent 9a2356b3
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
</view> </view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.shuffle)'> <view class = 'button click' @click = 'tournament.operatorChk(tournament.shuffle)'>
<span>打乱</span> <span>打乱</span>
<uni-icons type = 'loop'></uni-icons> <uni-icons type = 'auth'></uni-icons>
</view> </view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.upload)'> <view class = 'button click' @click = 'tournament.operatorChk(tournament.upload)'>
<span>上传</span> <span>上传</span>
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
> >
</uni-list-item> </uni-list-item>
<view <view
v-for = '(i, v) in (match.round == 0) ? match.array.slice((match.page - 1) * 20, match.page * 20) : match.array.filter(m => m.round == match.round).slice((match.page - 1) * 20, match.page * 20)' v-for = 'i in (match.round == 0) ? match.array.slice((match.page - 1) * 20, match.page * 20) : match.array.filter(m => m.round == match.round).slice((match.page - 1) * 20, match.page * 20)'
> >
<view <view
class = 'match' class = 'match'
...@@ -189,7 +189,7 @@ ...@@ -189,7 +189,7 @@
:clearable = 'false' :clearable = 'false'
type = 'number' type = 'number'
:placeholder = 'participant.array.find(p => p.id == i.player1Id)?.name' :placeholder = 'participant.array.find(p => p.id == i.player1Id)?.name'
v-model = 'match.submit.chk[v][0]' v-model = 'match.submit.chk[match.array.findIndex(m => m === i)][0]'
:disabled = "i.status != 'Running'" :disabled = "i.status != 'Running'"
></uni-easyinput> ></uni-easyinput>
<view> <view>
...@@ -199,11 +199,11 @@ ...@@ -199,11 +199,11 @@
:clearable = 'false' :clearable = 'false'
type = 'number' type = 'number'
:placeholder = 'participant.array.find(p => p.id == i.player2Id)?.name' :placeholder = 'participant.array.find(p => p.id == i.player2Id)?.name'
v-model = 'match.submit.chk[v][1]' v-model = 'match.submit.chk[match.array.findIndex(m => m === i)][1]'
:disabled = "i.status != 'Running'" :disabled = "i.status != 'Running'"
></uni-easyinput> ></uni-easyinput>
</view> </view>
<view class = 'button' @click = 'match.submit.on(v)'>{{ i.status == 'Running' ? '提交比分' : i.status == 'Finished' ? '重赛' : '' }}</view> <view class = 'button' @click = 'match.submit.on(i)'>{{ i.status == 'Running' ? '提交比分' : i.status == 'Finished' ? '重赛' : '' }}</view>
</view> </view>
<uni-list-item <uni-list-item
:clickable = true :clickable = true
...@@ -440,14 +440,15 @@ ...@@ -440,14 +440,15 @@
if (!match.submit.page) if (!match.submit.page)
match.submit.chk = match.array.map(i => [i.player1Score ?? 0, i.player2Score ?? 0]); match.submit.chk = match.array.map(i => [i.player1Score ?? 0, i.player2Score ?? 0]);
}, },
on : async (v : number) : Promise<void> => { on : async (i : Match) : Promise<void> => {
switch (match.array[v].status) { const v = match.array.findIndex(m => m === i);
switch (i.status) {
case 'Running': case 'Running':
const player1 : number = match.submit.chk[v][0] ?? 0; const player1 : number = match.submit.chk[v][0] ?? 0;
const player2 : number = match.submit.chk[v][1] ?? 0; const player2 : number = match.submit.chk[v][1] ?? 0;
const id : null | number = player1 > player2 ? match.array[v].player1Id : player1 == player2 ? null : match.array[v].player2Id const id : null | number = player1 > player2 ? i.player1Id : player1 == player2 ? null : i.player2Id
// @ts-ignore // @ts-ignore
if (await Tabulator.Match.Update(Mycard.token, match.array[v].id, { if (await Tabulator.Match.Update(Mycard.token, i.id, {
player1Score : player1, player1Score : player1,
player2Score : player2, player2Score : player2,
winnerId : id winnerId : id
...@@ -456,7 +457,7 @@ ...@@ -456,7 +457,7 @@
break; break;
case 'Finished': case 'Finished':
// @ts-ignore // @ts-ignore
if (await Tabulator.Match.Update(Mycard.token, match.array[v].id, { if (await Tabulator.Match.Update(Mycard.token, i.id, {
player1Score : 0, player1Score : 0,
player2Score : 0, player2Score : 0,
winnerId : undefined winnerId : undefined
......
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