Commit de938a2f authored by sunxiwei's avatar sunxiwei

修改审核比赛逻辑、修改比赛管理界面bug、修改注册界面bug、我的界面用户名绑定

parent 7cc2ba73
...@@ -2,7 +2,8 @@ ...@@ -2,7 +2,8 @@
<v-app> <v-app>
<!-- {{ filteredMatches }} --> <!-- {{ filteredMatches }} -->
<v-container> <v-container>
<v-data-table :headers="headers" :items="filteredMatches" item-key="id" :search="search.value" :items-per-page="10"> <v-data-table :headers="headers" :items="filteredMatches" item-key="id" :search="search.value"
:items-per-page="10">
<template v-slot:top> <template v-slot:top>
<v-toolbar flat> <v-toolbar flat>
<v-toolbar-title>比赛</v-toolbar-title> <v-toolbar-title>比赛</v-toolbar-title>
...@@ -21,13 +22,31 @@ ...@@ -21,13 +22,31 @@
{{ item.homeScore }} - {{ item.awayScore }} {{ item.homeScore }} - {{ item.awayScore }}
</template> </template>
<template v-slot:item.actions="{ item }"> <template v-slot:item.actions="{ item }">
<v-icon small @click="approveMatch(item)" style="padding-right: 20px;">mdi-check</v-icon> <v-icon v-if="!item.shenhe" small color="green" @click="opendialog(item, 'approve')"
<v-icon small @click="rejectMatch(item)" style="padding-left: 20px;">mdi-close</v-icon> style="padding-right: 20px;">mdi-check</v-icon>
<v-icon v-if="!item.shenhe" small color="red" @click="opendialog(item, 'reject')" style="padding-left: 20px;">mdi-close</v-icon>
<div v-if="item.shenhe" variant="text">已审核</div>
</template> </template>
</v-data-table> </v-data-table>
<v-dialog v-model="dialog" width="auto">
<v-card width="300px">
<v-card-title>
{{ cardtitle }}
</v-card-title>
<v-card-text>
{{ cardtext }}
</v-card-text>
<template v-slot:actions>
<v-btn class="ms-auto" variant="flat" color="indigo" text="确定" @click="confirmAction"></v-btn>
<v-btn class="ms-auto" variant="flat" color="indigo" text="取消" @click="dialog = false"></v-btn>
</template>
</v-card>
</v-dialog>
</v-container> </v-container>
</v-app> </v-app>
</template> </template>
<script setup> <script setup>
...@@ -37,51 +56,43 @@ import { computed } from 'vue'; ...@@ -37,51 +56,43 @@ import { computed } from 'vue';
import axios from 'axios'; import axios from 'axios';
const matches = ref(new Array()); const matches = ref(new Array());
refresh(); const actiontype = ref(null);
function refresh(){ const selectedMatch = ref(null);
axios.get('/api/lauchedGames',) const cardtitle = ref(null);
.then(function(response){ const cardtext = ref(null);
const data = response.data; const shenhetitle = ref(null);
for(var i = 0; i < data.Games.length; i++){ const shenhetext = ref(null);
var match = { const dialog = ref(false);
id:data.Games[i].id, const verify = ref(true);
date:data.Games[i].game_date,
homeTeam:data.Games[i].player1_real_name, function info(title, text) {
awayTeam:data.Games[i].player2_real_name, cardtitle.value = title;
homeScore:data.Games[i].score1, cardtext.value = text;
awayScore:data.Games[i].score2, dialog.value = true;
verify:true,
}
matches.value[i] = match;
}
})
.catch(function (error) {
console.log(error);
})
} }
function refresh1(){ function refresh() {
axios.get('/api/lauchedGames',) axios.get('/api/lauchedGames',)
.then(function(response){ .then(function (response) {
const data = response.data; const data = response.data;
const matches = ref(new Array()); for (var i = 0; i < data.Games.length; i++) {
for(var i = 0; i < data.Games.length; i++){ var match = {
var match = { id: data.Games[i].id,
id:data.Games[i].id, date: data.Games[i].game_date,
date:data.Games[i].game_date, homeTeam: data.Games[i].player1_real_name,
homeTeam:data.Games[i].player1_real_name, awayTeam: data.Games[i].player2_real_name,
awayTeam:data.Games[i].player2_real_name, homeScore: data.Games[i].score1,
homeScore:data.Games[i].score1, awayScore: data.Games[i].score2,
awayScore:data.Games[i].score2, shenhe: false,
verify:true,
}
matches.value[i] = match;
} }
matches.value[i] = match;
}
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}) })
} }
refresh();
const search = ref(''); const search = ref('');
const headers = reactive([ const headers = reactive([
...@@ -102,31 +113,54 @@ const filteredMatches = computed(() => { ...@@ -102,31 +113,54 @@ const filteredMatches = computed(() => {
); );
}) })
function approveMatch(match) { function opendialog(game, type) {
match.verify = true; if (type === 'approve') {
axios.post('/api/confirmGame',{ shenhetitle.value = `审核比赛 ${game.homeTeam} VS ${game.awayTeam}`;
game_id:match.id, shenhetext.value = `确定要通过这场比赛吗?`;
confirm:match.verify } else if (type === 'reject') {
}) shenhetitle.value = `审核比赛 ${game.homeTeam} VS ${game.awayTeam}`;
.then(function(){ shenhetext.value = `确定要不通过这场比赛吗?`;
refresh1(); }
}) info(shenhetitle.value, shenhetext.value);
.catch(function (error) { selectedMatch.value = game;
console.log(error); actiontype.value = type;
})
} }
function rejectMatch(match){ function confirmAction() {
match.verify = false; if (actiontype.value === 'approve') {
axios.post('/api/confirmGame',{ verify.value = true;
game_id:match.id, selectedMatch.value.shenhe = true;
confirm:match.verify axios.post('/api/confirmGame', {
}) game_id: selectedMatch.value.id,
.then(function(){ confirm: verify.value,
refresh1();
}) })
.catch(function (error) { .then(function (response) {
console.log(error); const data = response.data;
}) if (data.status === "SUCCESS") {
console.log('success');
}
})
.catch(function (error) {
console.log(error);
})
}
else if(actiontype.value === 'reject') {
verify.value = false;
selectedMatch.value.shenhe = true;
axios.post('/api/confirmGame', {
game_id: selectedMatch.value.id,
confirm: verify.value,
})
.then(function (response) {
const data = response.data;
if (data.status === "SUCCESS") {
console.log('success');
}
})
.catch(function (error) {
console.log(error);
})
}
dialog.value = false;
} }
</script> </script>
\ No newline at end of file
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<!-- <v-card-title color="indigo"> <!-- <v-card-title color="indigo">
提交比赛 提交比赛
</v-card-title> --> </v-card-title> -->
<v-form v-model="isValid"> <v-form ref="form" v-model="isValid">
<v-row no-gutters> <v-row no-gutters>
<v-col align-self="center"> <v-col align-self="center">
<v-autocomplete variant="underlined" v-model="player1" label="姓名" <v-autocomplete variant="underlined" v-model="player1" label="姓名"
...@@ -92,6 +92,7 @@ ...@@ -92,6 +92,7 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { reactive } from 'vue'; import { reactive } from 'vue';
import axios from 'axios'; import axios from 'axios';
import { watch } from 'vue';
const isValid = ref(false); const isValid = ref(false);
const player1 = ref(null); const player1 = ref(null);
...@@ -102,6 +103,7 @@ const loading = ref(false); ...@@ -102,6 +103,7 @@ const loading = ref(false);
const selectedDate = ref(new Date()); const selectedDate = ref(new Date());
const arr = ref(new Array()); const arr = ref(new Array());
const id = ref(null); const id = ref(null);
const form = ref(null);
var s1; var s1;
var s2; var s2;
var p1_id; var p1_id;
...@@ -123,6 +125,31 @@ const rules = reactive({ ...@@ -123,6 +125,31 @@ const rules = reactive({
score2: v => v != score1.value || '得分不能相同', score2: v => v != score1.value || '得分不能相同',
}); });
// 监听 player1 的变化,并更新 player2 的验证规则
watch(player1, (newVal, oldVal) => {
if (newVal !== oldVal) {
form.value.validate(); // 触发表单验证
}
});
watch(player2, (newVal, oldVal) => {
if (newVal !== oldVal) {
form.value.validate(); // 触发表单验证
}
});
watch(score1, (newVal, oldVal) => {
if (newVal !== oldVal) {
form.value.validate(); // 触发表单验证
}
});
watch(score2, (newVal, oldVal) => {
if (newVal !== oldVal) {
form.value.validate(); // 触发表单验证
}
});
axios.get('/api/players') axios.get('/api/players')
.then(function (response) { .then(function (response) {
const data = response.data; const data = response.data;
......
...@@ -89,6 +89,7 @@ function login() { ...@@ -89,6 +89,7 @@ function login() {
else if (!data.is_member) { else if (!data.is_member) {
// console.log("not member"); // console.log("not member");
// console.log(realname1); // console.log(realname1);
window.location.href = '/main.html';
realname1.value = true; realname1.value = true;
} }
} }
......
...@@ -29,9 +29,17 @@ ...@@ -29,9 +29,17 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { reactive } from 'vue'; import { reactive } from 'vue';
import { watch } from 'vue';
import axios from 'axios'; import axios from 'axios';
const form = ref(null) const usrname = ref(null);
const password = ref(null);
const confirmpassword = ref(null);
const isValid = ref(false);
// const isLoading = ref(false);
const loading = ref(false);
const form = ref(null);
const rules = reactive({ const rules = reactive({
email: v => !!(v || '').match(/@/) || 'Please enter a valid email', email: v => !!(v || '').match(/@/) || 'Please enter a valid email',
length: len => v => (v || '').length >= len || `Invalid character length, required ${len}`, length: len => v => (v || '').length >= len || `Invalid character length, required ${len}`,
...@@ -42,12 +50,13 @@ const rules = reactive({ ...@@ -42,12 +50,13 @@ const rules = reactive({
// 'Password must contain an upper case letter, a numeric character, and a special character', // 'Password must contain an upper case letter, a numeric character, and a special character',
required: v => !!v || 'This field is required', required: v => !!v || 'This field is required',
}); });
const usrname = ref(null);
const password = ref(null); // 监听 password 的变化,并更新 confirmpassword 的验证规则
const confirmpassword = ref(null); watch(password, (newVal, oldVal) => {
const isValid = ref(false); if (newVal !== oldVal) {
// const isLoading = ref(false); form.value.validate(); // 触发表单验证
const loading = ref(false); }
});
function register(){ function register(){
loading.value =true; loading.value =true;
......
...@@ -141,11 +141,10 @@ ...@@ -141,11 +141,10 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { reactive } from 'vue'; import { reactive } from 'vue';
import axios from 'axios';
const username = ref('XXX'); const username = ref('XXX');
const username1 = ref('XXX');
const score = ref(1); const score = ref(1);
const score1 = ref(1);
const score2 = ref(1);
const level = ref("A"); const level = ref("A");
const items = reactive([ const items = reactive([
{ {
...@@ -165,6 +164,17 @@ const items = reactive([ ...@@ -165,6 +164,17 @@ const items = reactive([
] ]
); );
axios.get('/api/currentUser',)
.then(function(response){
const data = response.data;
if(data.status === "SUCCESS"){
username.value = data.username;
}
})
.catch(function (error) {
console.log(error);
})
</script> </script>
<style> <style>
......
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