Commit 4b5369f9 authored by xiaoye's avatar xiaoye

fix

parent 5b77ab4b
<template>
<uni-card class = 'Create'>
<uni-easyinput type = 'text' placeholder = '比赛名称' v-model = 'create.name'/>
<uni-easyinput type = 'text' placeholder = '比赛描述' v-model = 'create.description'/>
<uni-data-select
placeholder = '可见性'
v-model = 'create.visibility.select'
:localdata = 'create.visibility.range'
></uni-data-select>
<uni-data-select
placeholder = '规则'
v-model = 'create.rule.select'
:localdata = 'create.rule.range'
></uni-data-select>
<view v-show = "create.rule.select == 'Swiss'">
<uni-easyinput type = 'number' placeholder = '胜利分' v-model = 'create.rule.settings.winScore'/>
<uni-easyinput type = 'number' placeholder = '平局分' v-model = 'create.rule.settings.drawScore'/>
<uni-easyinput type = 'number' placeholder = '轮空分' v-model = 'create.rule.settings.byeScore'/>
</view>
<view v-show = "create.rule.select == 'SingleElimination'">
<checkbox-group @change = 'create.hasThirdPlaceMatch.select'>
<label>
<checkbox :checked = 'create.rule.settings.hasThirdPlaceMatch'/>季军赛
</label>
</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>
<uni-icons type = 'calendar'></uni-icons>
</view>
</view>
</uni-card>
</template>
<script setup lang = 'ts'>
import { ref, reactive, onMounted, onUnmounted, onBeforeMount, watch} from 'vue';
import { TournamentFindObject, ruleSettings, UserObject } from '../script/type.ts';
import {Tabulator, User} from '../script/post.ts';
import Mycard from '../script/mycard.ts';
import emitter from '../script/emitter.ts'
import {
updateTournament ,
tournamentInfo,
tournamentReload,
createOff
} from '../script/const.ts'
let create = reactive({
name : '',
description : '',
visibility : {
select : '',
range : [
{ value: 'Public', text: '公开' },
{ value: 'Internal', text: '仅登陆可见' },
{ value: 'Private', text: '私密' }
]
},
rule : {
select : '',
settings : {
} as ruleSettings,
range : [
{ value: 'SingleElimination', text: '单淘' },
{ value: 'Swiss', text: '瑞士轮' }
]
},
hasThirdPlaceMatch : {
select : (e) => {
create.rule.settings.hasThirdPlaceMatch = e.detail.value.length > 0
}
},
collaborator : '',
collaborators : [] as Array<UserObject>,
clear : () : void => {
create.name = '';
create.description = '';
create.visibility.select = '';
create.rule.select = '';
create.rule.settings = {} as ruleSettings;
create.collaborators = [];
},
update : async() : Promise<void> => {
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: collaborators
})
) {
emitter.emit(createOff);
create.clear();
}
},
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 = '';
}
}
});
</script>
\ No newline at end of file
This diff is collapsed.
...@@ -500,7 +500,6 @@ ...@@ -500,7 +500,6 @@
</script> </script>
<style scoped lang = 'scss'> <style scoped lang = 'scss'>
@import '../style/style.scss';
@import '../style/tournament.scss'; @import '../style/tournament.scss';
@import '../style/transition.scss'; @import '../style/transition.scss';
</style> </style>
\ No newline at end of file
const selectTournament = 'selectTournament';
const updateTournament = 'updateTournament'; const updateTournament = 'updateTournament';
const tournamentInfo = 'tournamentInfo'; const tournamentInfo = 'tournamentInfo';
const tournamentExit = 'tournamentExit'; const tournamentReload = 'tournamentReload';
const tournamentReload = 'tournamentReload'
const createOff = 'createOff';
export { export {
updateTournament , updateTournament ,
tournamentInfo, tournamentInfo,
tournamentReload tournamentReload,
createOff
}; };
\ No newline at end of file
...@@ -67,4 +67,18 @@ ...@@ -67,4 +67,18 @@
cursor: pointer; cursor: pointer;
} }
} }
button {
background-color: white;
color : #606266;
border-radius: 4px;
white-space: nowrap;
border: 0.02px solid #606266;
transition: all 0.3s ease;
&:hover {
color: #ecf5ff;
background-color: #ecf5ff;
border: 0.02px solid #409eff;
}
}
} }
$color: #606266;
$background-color: white;
$color-hover: #409eff;
$background-color-hover: #ecf5ff;
$font-size: 1.3vw;
$font-family: Arial, sans-serif;
select, input, textarea {
font-family: $font-family;
line-height: normal;
font-size: $font-size;
background-color: $background-color;
color : $color;
border: 0.02px solid $color;
border-radius: 8px;
transition: all 0.3s ease;
}
button {
background-color: $background-color;
color : $color;
border-radius: 4px;
white-space: nowrap;
border: 0.02px solid $color;
transition: all 0.3s ease;
&:hover {
color: $color-hover;
background-color: $background-color-hover;
border: 0.02px solid $color-hover;
}
}
input {
:focus {
color: $color-hover;
background-color: $background-color-hover;
border: 0.02px solid $color-hover;
}
}
select {
&:focus {
color: $color-hover;
border-color: $color-hover;
}
}
textarea {
:focus {
color: $color-hover;
background-color: $background-color-hover;
}
}
ul {
display: flex;
list-style: none;
gap: 3%;
font-size: $font-size;
color : $color;
font-family: $font-family;
transition: all 0.3s ease;
:hover {
color: $color-hover;
transform: scale(1.2);
cursor: pointer;
}
}
\ 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