This commit is contained in:
那些花儿
2025-04-30 10:12:46 +08:00
parent bb394ce8e3
commit 29d286319a
5 changed files with 102 additions and 31 deletions
@@ -39,20 +39,29 @@ layout("/layouts/platform_1.html"){
</div>
</el-card>
<el-card shadow="never" class="mt-3">
<el-table v-loading="tableLoading" show-overflow-tooltip :data="tableData">
<el-table-column label="队伍" prop="groupName" header-align="center" align="center"
width="100px"></el-table-column>
<el-table v-loading="tableLoading" show-overflow-tooltip :data="tableData" @cell-click="cellClick">
<el-table-column label="队伍" prop="groupName" fixed="left" width="100px"></el-table-column>
<el-table-column v-for="item in itemOptions" :key="item.id" :label="item.name" show-overflow-tooltip
width="10%">
<template slot="header" slot-scope="scope">
<span v-html="formatName(item.name)"></span>
</template>
<el-table-column label="成绩" min-width="50px"></el-table-column>
<el-table-column label="名次" min-width="50px"></el-table-column>
<el-table-column label="成绩" :prop="item.id+item.name" min-width="50px">
<template slot-scope="scope">
<el-input v-model="scope.row[item.id]['totalScore']"></el-input>
</template>
</el-table-column>
<el-table-column label="名次" :prop="item.id+item.name" min-width="50px">
<template slot-scope="scope">
<el-input v-model="scope.row[item.id]['totalRank']"></el-input>
</template>
</el-table-column>
</el-table-column>
</el-table>
<!--#include("/layouts/pagination.html"){}#-->
<el-row type="flex"justify="end" class="mt-3">
<el-button type="primary" @click="saveScore">保存</el-button>
</el-row>
</el-card>
</div>
@@ -76,10 +85,12 @@ layout("/layouts/platform_1.html"){
}
},
methods: {
// 格式化名称
formatName(name) {
if (!name) return ""
return name.match(/.{1,4}/g)?.join("<br>") || ""
},
// 获取活动
listAct() {
$.get("/platform/activity/scoreEnter/list-activity", this.pageForm).then(res => {
if (res.code === 0) {
@@ -93,36 +104,62 @@ layout("/layouts/platform_1.html"){
}
})
},
listGroup() {
$.get("/platform/activity/scoreEnter/list-group/" + this.pageForm.activityId).then(res => {
if (res.code === 0) {
this.groupOptions = res.data
this.buildTableData()
} else {
this.$message.error(res.msg)
}
})
// 获取队伍
async listGroup() {
const {
code,
data,
msg
} = await $.get("/platform/activity/scoreEnter/list-group/" + this.pageForm.activityId)
if (code === 0) {
this.groupOptions = data
} else {
this.$message.error(msg)
}
},
listItem() {
$.get("/platform/activity/scoreEnter/list-item/" + this.pageForm.activityId).then(res => {
if (res.code === 0) {
this.itemOptions = res.data
} else {
this.$message.error(res.msg)
}
})
// 获取项目
async listItem() {
const {
code,
data,
msg
} = await $.get("/platform/activity/scoreEnter/list-item/" + this.pageForm.activityId)
if (code === 0) {
this.itemOptions = data
} else {
this.$message.error(msg)
}
},
activityChange() {
this.listGroup()
this.listItem()
// 活动改变
async activityChange() {
await this.listGroup()
await this.listItem()
this.buildTableData()
},
// 构建表格数据
buildTableData() {
this.tableData = this.groupOptions.map((group) => {
return{
const row = {
groupId: group.id,
groupName: group.groupName
}
this.itemOptions.forEach((item) => {
row[item.id] = {
totalScore: item.totalScore,
totalRank: item.totalRank
}
})
return row
})
console.log(this.tableData)
},
// 单元格点击
cellClick(row, column){
console.log(row, column)
},
// 保存成绩
saveScore(){
console.log(this.tableData)
}
},
created() {