Commit b4db05ce authored by xiaoye's avatar xiaoye

fix

parent 19c0c0a9
......@@ -162,13 +162,34 @@
:avatar = 'i.avatar'
:title = 'i.username'
:note = "i.id >= 0 ? i.id.toString() : ''"
@click = 'tournament.remove(v)'
>
<view>
<view class = 'button'>
<uni-icons type = 'trash'></uni-icons>
<view>
<view class = 'button'>
<uni-icons type = 'trash'></uni-icons>
</view>
</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 = '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-card>
<br>
......@@ -213,6 +234,50 @@
</checkbox-group>
</view>
<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>
<span>创建</span>
......@@ -422,6 +487,7 @@
tournament.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0
}
},
collaborator : '',
collaborators : [] as Array<UserObject>,
init : async (t : Tournament) : Promise<void> => {
if (!t) return;
......@@ -449,7 +515,7 @@
},
update : () : void => {
if (tournament.visibility.select == '')
// @ts-ignore
// @ts-ignore
tournament.visibility.select = tournament.this.visibility;
const collaborators = tournament.collaborators.map(user => user.id);
......@@ -458,9 +524,33 @@
description: tournament.description,
visibility: tournament.visibility.select,
collaborators : collaborators,
rule : tournament.rule.select,
ruleSettings : tournament.rule.settings
// PS:这里接口暂时不通
// rule : tournament.rule.select,
// ruleSettings : tournament.rule.settings
} 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 @@
create.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0
}
},
collaborators : [] as Array<number>,
collaborator : '',
collaborators : [] as Array<UserObject>,
clear : () : void => {
create.name = '';
create.description = '';
......@@ -493,13 +584,14 @@
if (create.visibility.select == '')
// @ts-ignore
create.visibility.select = 'SingleElimination';
const collaborators = create.collaborators.map(user => user.id);
if (await Tabulator.Tournament.Create(Mycard.token, {
name: create.name,
description: create.description,
rule: create.rule.select,
ruleSettings: create.rule.settings,
visibility: create.visibility.select,
collaborators: create.collaborators
collaborators: collaborators
})
) {
page.show.drawer();
......@@ -508,6 +600,29 @@
create.clear();
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 @@
>
<uni-forms>
<view class = 'button_list' >
<view class = 'button click' @click = 'emitter.emit(tournamentInfo)'>
<view class = 'button click' @click = 'tournament.operatorChk(() => { emitter.emit(tournamentInfo); })'>
<span>设置</span>
<uni-icons type = 'info'></uni-icons>
</view>
<view class = 'button' @click = 'page.reload()'>
<view class = 'button' @click = 'tournament.operatorChk(page.reload)'>
<span>刷新</span>
<uni-icons type = 'reload'></uni-icons>
</view>
<view class = 'button' @click = 'page.clear()'>
<view class = 'button' @click = 'tournament.operatorChk(page.clear)'>
<span>关闭</span>
<uni-icons type = 'close'></uni-icons>
</view>
......@@ -46,7 +46,7 @@
<uni-card
v-show = '!page.loading'
:is-full = 'true'
title = '参与者'
:title = '`参与者:${participant.total}`'
>
<transition name = 'switch'>
<uni-list>
......@@ -117,7 +117,7 @@
<uni-card
v-show = '!page.loading'
:is-full = 'true'
title = '比赛'
:title = '`比赛:${match.total}`'
>
<view id = 'round'>
......@@ -135,12 +135,16 @@
title = '暂无比赛'
>
</uni-list-item>
<view
class = 'match'
v-for = '(i, v) in match.array'
:style = "{ '--top' : `${page.listHeight * v}px` }"
>
</view>
<uni-list-item
v-for = '(i, v) in match.array'
:clickable = true
>
<template v-slot:header>
</template>
<template v-slot:body>
<view id = 'body'>
<view id = 'left'>
......@@ -187,8 +191,6 @@
</view>
</view>
</template>
<template v-slot:footer>
</template>
</uni-list-item>
</uni-list>
</transition>
......@@ -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({
......@@ -337,6 +349,7 @@
let page = reactive({
height : 0,
listHeight : 0,
loading : false,
clear : async () : Promise<void>=> {
tournament.this = undefined;
......@@ -400,7 +413,14 @@
const matchs = await Tabulator.Match.FindALL(Mycard.token, {tournamentId : tournament.this.id, statusIn : 'Running,Finished', round : match.round});
match.array = matchs.matchs;
match.total = matchs.total;
})
});
watch(() => { return match.array; }, () => {
uni.createSelectorQuery().in(this).select('#left').boundingClientRect(res => {
// @ts-ignore
page.listHeight = res.height;
}).exec();
});
</script>
<style scoped lang = 'scss'>
......
......@@ -52,7 +52,7 @@ class TabulatorAPI {
title : '创建失败',
content : error.message,
showCancel : false
})
});
console.error(error);
return -1;
}
......
......@@ -49,9 +49,6 @@
overflow-y: auto;
overflow-x: auto;
height: 40vh;
:deep(.uni-list-chat) {
width: 200%;
}
}
.button {
border: 1px solid #409eff;
......
......@@ -28,6 +28,7 @@
}
}
#body {
position: relative;
width: 100%;
display: grid;
grid-template-columns: repeat(3, 1fr);
......@@ -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