Commit b4db05ce authored by xiaoye's avatar xiaoye

fix

parent 19c0c0a9
...@@ -162,13 +162,34 @@ ...@@ -162,13 +162,34 @@
:avatar = 'i.avatar' :avatar = 'i.avatar'
:title = 'i.username' :title = 'i.username'
:note = "i.id >= 0 ? i.id.toString() : ''" :note = "i.id >= 0 ? i.id.toString() : ''"
@click = 'tournament.remove(v)'
> >
<view> <view>
<view class = 'button'> <view class = 'button'>
<uni-icons type = 'trash'></uni-icons> <uni-icons type = 'trash'></uni-icons>
</view>
</view> </view>
</view>
</uni-list-chat> </uni-list-chat>
<uni-list-item>
<template v-slot:header>
<uni-forms>
<uni-forms-item id = 'header'>
<uni-easyinput type = 'text' placeholder = '添加协作者' v-model = 'tournament.collaborator'/>
</uni-forms-item>
</uni-forms>
</template>
<template v-slot:footer>
<view id = 'footer'>
<view
class = 'button'
:style = "{ '--color' : '#409eff' }"
@click = 'tournament.add()'
>
<uni-icons type = 'personadd'></uni-icons>
</view>
</view>
</template>
</uni-list-item>
</uni-list> </uni-list>
</uni-card> </uni-card>
<br> <br>
...@@ -213,6 +234,50 @@ ...@@ -213,6 +234,50 @@
</checkbox-group> </checkbox-group>
</view> </view>
<br> <br>
<uni-card
id = 'collaborators'
title = '协作者'
:is-full = 'true'
>
<uni-list>
<uni-list-chat
v-for = '(i, v) in create.collaborators'
:avatarCircle = 'true'
:clickable = true
:avatar = 'i.avatar'
:title = 'i.username'
:note = "i.id >= 0 ? i.id.toString() : ''"
@click = 'create.remove(v)'
>
<view>
<view class = 'button'>
<uni-icons type = 'trash'></uni-icons>
</view>
</view>
</uni-list-chat>
<uni-list-item>
<template v-slot:header>
<uni-forms>
<uni-forms-item id = 'header'>
<uni-easyinput type = 'text' placeholder = '添加协作者' v-model = 'create.collaborator'/>
</uni-forms-item>
</uni-forms>
</template>
<template v-slot:footer>
<view id = 'footer'>
<view
class = 'button'
:style = "{ '--color' : '#409eff' }"
@click = 'create.add()'
>
<uni-icons type = 'personadd'></uni-icons>
</view>
</view>
</template>
</uni-list-item>
</uni-list>
</uni-card>
<br>
<view class = 'button' @click = 'create.update()'> <view class = 'button' @click = 'create.update()'>
<view> <view>
<span>创建</span> <span>创建</span>
...@@ -422,6 +487,7 @@ ...@@ -422,6 +487,7 @@
tournament.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0 tournament.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0
} }
}, },
collaborator : '',
collaborators : [] as Array<UserObject>, collaborators : [] as Array<UserObject>,
init : async (t : Tournament) : Promise<void> => { init : async (t : Tournament) : Promise<void> => {
if (!t) return; if (!t) return;
...@@ -449,7 +515,7 @@ ...@@ -449,7 +515,7 @@
}, },
update : () : void => { update : () : void => {
if (tournament.visibility.select == '') if (tournament.visibility.select == '')
// @ts-ignore // @ts-ignore
tournament.visibility.select = tournament.this.visibility; tournament.visibility.select = tournament.this.visibility;
const collaborators = tournament.collaborators.map(user => user.id); const collaborators = tournament.collaborators.map(user => user.id);
...@@ -458,9 +524,33 @@ ...@@ -458,9 +524,33 @@
description: tournament.description, description: tournament.description,
visibility: tournament.visibility.select, visibility: tournament.visibility.select,
collaborators : collaborators, collaborators : collaborators,
rule : tournament.rule.select, // PS:这里接口暂时不通
ruleSettings : tournament.rule.settings // rule : tournament.rule.select,
// ruleSettings : tournament.rule.settings
} as TournamentCreateObject); } as TournamentCreateObject);
},
remove : (v : number) : void => {
tournament.collaborators.splice(v, 1);
},
add : async() : Promise<void> => {
try {
if (tournament.collaborators.findIndex(i => i.username == tournament.collaborator) >= 0)
throw new Error('协作者已存在');
const i = await User.Find.Name(tournament.collaborator);
if (!i)
throw new Error('未搜索到此用户');
if (tournament.this?.creator == i.id)
throw new Error('协作者不可以是比赛创建者');
tournament.collaborators.push(i);
} catch(error) {
uni.showModal({
title : '添加失败',
content : error.message,
showCancel : false
});
} finally {
tournament.collaborator = '';
}
} }
}); });
...@@ -480,7 +570,8 @@ ...@@ -480,7 +570,8 @@
create.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0 create.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0
} }
}, },
collaborators : [] as Array<number>, collaborator : '',
collaborators : [] as Array<UserObject>,
clear : () : void => { clear : () : void => {
create.name = ''; create.name = '';
create.description = ''; create.description = '';
...@@ -493,13 +584,14 @@ ...@@ -493,13 +584,14 @@
if (create.visibility.select == '') if (create.visibility.select == '')
// @ts-ignore // @ts-ignore
create.visibility.select = 'SingleElimination'; create.visibility.select = 'SingleElimination';
const collaborators = create.collaborators.map(user => user.id);
if (await Tabulator.Tournament.Create(Mycard.token, { if (await Tabulator.Tournament.Create(Mycard.token, {
name: create.name, name: create.name,
description: create.description, description: create.description,
rule: create.rule.select, rule: create.rule.select,
ruleSettings: create.rule.settings, ruleSettings: create.rule.settings,
visibility: create.visibility.select, visibility: create.visibility.select,
collaborators: create.collaborators collaborators: collaborators
}) })
) { ) {
page.show.drawer(); page.show.drawer();
...@@ -508,6 +600,29 @@ ...@@ -508,6 +600,29 @@
create.clear(); create.clear();
await search.on(); await search.on();
} }
},
remove : (v : number) : void => {
create.collaborators.splice(v, 1);
},
add : async() : Promise<void> => {
try {
if (create.collaborators.findIndex(i => i.username == create.collaborator) >= 0)
throw new Error('协作者已存在');
const i = await User.Find.Name(create.collaborator);
if (!i)
throw new Error('未搜索到此用户');
if (Mycard.id == i.id)
throw new Error('协作者不可以是比赛创建者');
create.collaborators.push(i);
} catch(error) {
uni.showModal({
title : '添加失败',
content : error.message,
showCancel : false
});
} finally {
create.collaborator = '';
}
} }
}); });
......
...@@ -12,15 +12,15 @@ ...@@ -12,15 +12,15 @@
> >
<uni-forms> <uni-forms>
<view class = 'button_list' > <view class = 'button_list' >
<view class = 'button click' @click = 'emitter.emit(tournamentInfo)'> <view class = 'button click' @click = 'tournament.operatorChk(() => { emitter.emit(tournamentInfo); })'>
<span>设置</span> <span>设置</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 = 'tournament.operatorChk(page.reload)'>
<span>刷新</span> <span>刷新</span>
<uni-icons type = 'reload'></uni-icons> <uni-icons type = 'reload'></uni-icons>
</view> </view>
<view class = 'button' @click = 'page.clear()'> <view class = 'button' @click = 'tournament.operatorChk(page.clear)'>
<span>关闭</span> <span>关闭</span>
<uni-icons type = 'close'></uni-icons> <uni-icons type = 'close'></uni-icons>
</view> </view>
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
<uni-card <uni-card
v-show = '!page.loading' v-show = '!page.loading'
:is-full = 'true' :is-full = 'true'
title = '参与者' :title = '`参与者:${participant.total}`'
> >
<transition name = 'switch'> <transition name = 'switch'>
<uni-list> <uni-list>
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
<uni-card <uni-card
v-show = '!page.loading' v-show = '!page.loading'
:is-full = 'true' :is-full = 'true'
title = '比赛' :title = '`比赛:${match.total}`'
> >
<view id = 'round'> <view id = 'round'>
...@@ -135,12 +135,16 @@ ...@@ -135,12 +135,16 @@
title = '暂无比赛' title = '暂无比赛'
> >
</uni-list-item> </uni-list-item>
<view
class = 'match'
v-for = '(i, v) in match.array'
:style = "{ '--top' : `${page.listHeight * v}px` }"
>
</view>
<uni-list-item <uni-list-item
v-for = '(i, v) in match.array' v-for = '(i, v) in match.array'
:clickable = true :clickable = true
> >
<template v-slot:header>
</template>
<template v-slot:body> <template v-slot:body>
<view id = 'body'> <view id = 'body'>
<view id = 'left'> <view id = 'left'>
...@@ -187,8 +191,6 @@ ...@@ -187,8 +191,6 @@
</view> </view>
</view> </view>
</template> </template>
<template v-slot:footer>
</template>
</uni-list-item> </uni-list-item>
</uni-list> </uni-list>
</transition> </transition>
...@@ -282,6 +284,16 @@ ...@@ -282,6 +284,16 @@
} }
}); });
}, },
operatorChk : (f : Function, para : Array<any> = []) : void => {
if (Mycard.id >= 0 && (Mycard.id == tournament.this?.creator || tournament.this?.collaborators.includes(Mycard.id)))
f(...para);
else
uni.showModal({
title : '缺少权限',
content : '请先登陆或联系比赛主办方',
showCancel : false
});
}
}); });
let match = reactive({ let match = reactive({
...@@ -337,6 +349,7 @@ ...@@ -337,6 +349,7 @@
let page = reactive({ let page = reactive({
height : 0, height : 0,
listHeight : 0,
loading : false, loading : false,
clear : async () : Promise<void>=> { clear : async () : Promise<void>=> {
tournament.this = undefined; tournament.this = undefined;
...@@ -400,7 +413,14 @@ ...@@ -400,7 +413,14 @@
const matchs = await Tabulator.Match.FindALL(Mycard.token, {tournamentId : tournament.this.id, statusIn : 'Running,Finished', round : match.round}); const matchs = await Tabulator.Match.FindALL(Mycard.token, {tournamentId : tournament.this.id, statusIn : 'Running,Finished', round : match.round});
match.array = matchs.matchs; match.array = matchs.matchs;
match.total = matchs.total; match.total = matchs.total;
}) });
watch(() => { return match.array; }, () => {
uni.createSelectorQuery().in(this).select('#left').boundingClientRect(res => {
// @ts-ignore
page.listHeight = res.height;
}).exec();
});
</script> </script>
<style scoped lang = 'scss'> <style scoped lang = 'scss'>
......
...@@ -52,7 +52,7 @@ class TabulatorAPI { ...@@ -52,7 +52,7 @@ class TabulatorAPI {
title : '创建失败', title : '创建失败',
content : error.message, content : error.message,
showCancel : false showCancel : false
}) });
console.error(error); console.error(error);
return -1; return -1;
} }
......
...@@ -49,9 +49,6 @@ ...@@ -49,9 +49,6 @@
overflow-y: auto; overflow-y: auto;
overflow-x: auto; overflow-x: auto;
height: 40vh; height: 40vh;
:deep(.uni-list-chat) {
width: 200%;
}
} }
.button { .button {
border: 1px solid #409eff; border: 1px solid #409eff;
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
} }
} }
#body { #body {
position: relative;
width: 100%; width: 100%;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(3, 1fr);
...@@ -60,5 +61,12 @@ ...@@ -60,5 +61,12 @@
} }
} }
} }
.match {
position: absolute;
z-index: 1;
top : var(--top);
left : 100%;
}
} }
} }
\ No newline at end of file
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