Commit 0f07f6d3 authored by xiaoye's avatar xiaoye

打乱选手

parent 25ca965e
...@@ -39,6 +39,10 @@ ...@@ -39,6 +39,10 @@
<span>重置</span> <span>重置</span>
<uni-icons type = 'loop'></uni-icons> <uni-icons type = 'loop'></uni-icons>
</view> </view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.shuffle)'>
<span>打乱</span>
<uni-icons type = 'loop'></uni-icons>
</view>
<view class = 'button click' @click = 'tournament.operatorChk(tournament.upload)'> <view class = 'button click' @click = 'tournament.operatorChk(tournament.upload)'>
<span>上传</span> <span>上传</span>
<uni-icons type = 'cloud-upload'></uni-icons> <uni-icons type = 'cloud-upload'></uni-icons>
...@@ -347,6 +351,18 @@ ...@@ -347,6 +351,18 @@
} }
}); });
}, },
shuffle : () : void => {
if (tournament.this?.status != 'Ready') return;
uni.showModal({
title : '确认要打乱次序吗?',
success : async (res : UniApp.ShowModalRes) : Promise<void> => {
if (!res.confirm) return;
// @ts-ignore
if (await Tabulator.Tournament.Shuffle(Mycard.token, tournament.this.id))
participant.search();
}
});
},
operatorChk : (f : Function, para : Array<any> = []) : void => { operatorChk : (f : Function, para : Array<any> = []) : void => {
if (Mycard.id >= 0 && (Mycard.id == tournament.this?.creator || tournament.this?.collaborators.includes(Mycard.id))) if (Mycard.id >= 0 && (Mycard.id == tournament.this?.creator || tournament.this?.collaborators.includes(Mycard.id)))
f(...para); f(...para);
......
...@@ -257,6 +257,47 @@ class TabulatorAPI { ...@@ -257,6 +257,47 @@ class TabulatorAPI {
console.error(error); console.error(error);
return false; return false;
} }
},
Shuffle : async (token : string, id : number) : Promise<Boolean> => {
let response : {
data : {
success : boolean;
}
};
try {
response = await this.url.post(`/api/tournament/${id}/shuffle-participants`, {}, {
headers: {
'x-user-token' : token
}
});
return response.data.success;
}
catch(error) {
console.error(error);
return false;
}
},
Drag : async (token : string, id : number, from : number, to : number) : Promise<Boolean> => {
let response : {
data : {
success : boolean;
}
};
try {
response = await this.url.post(`/api/tournament/${id}/drag-participant`, {
draggingParticipantId : from,
placeAfterParticipantId : to
}, {
headers: {
'x-user-token' : token
}
});
return response.data.success;
}
catch(error) {
console.error(error);
return false;
}
} }
} }
Participant = { Participant = {
......
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