重构项3: 添加表号生成和显示功能
- 在编排页面项目头部添加表号显示 - 实现generateTableNo方法,格式为: 场地(1位)+时段(1位)+序号(2位) - 时段规则: 上午=1, 下午=2 - 序号在同场地同时段中按id排序确定 Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
@@ -87,6 +87,7 @@
|
||||
<span class="project-meta">{{ getTeamCount(group) }}队</span>
|
||||
<span class="project-meta">{{ group.items?.length || 0 }}组</span>
|
||||
<span class="project-meta">{{ group.code }}</span>
|
||||
<span class="project-table-no">表号: {{ generateTableNo(group) }}</span>
|
||||
</div>
|
||||
<div class="project-actions" @click.stop>
|
||||
<el-popover
|
||||
@@ -504,6 +505,44 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 生成表号: 场地(1位) + 时段(1位,上午=1/下午=2) + 序号(2位)
|
||||
generateTableNo(group) {
|
||||
// 1. 获取场地编号
|
||||
let venueNo = 1
|
||||
if (group.venueId) {
|
||||
const venue = this.venues.find(v => v.id === group.venueId || String(v.id) === String(group.venueId))
|
||||
if (venue && venue.venueName) {
|
||||
// 从场地名称提取数字
|
||||
const match = venue.venueName.match(/\d+/)
|
||||
if (match) {
|
||||
venueNo = parseInt(match[0])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 获取时段:上午=1, 下午=2
|
||||
let period = 1
|
||||
if (group.timeSlot) {
|
||||
const hour = parseInt(group.timeSlot.split(':')[0])
|
||||
period = hour < 12 ? 1 : 2
|
||||
}
|
||||
|
||||
// 3. 获取序号:在同场地同时段中的顺序
|
||||
const sameSlotGroups = this.competitionGroups.filter(g => {
|
||||
const gVenueMatch = String(g.venueId) === String(group.venueId)
|
||||
if (!gVenueMatch) return false
|
||||
const gHour = parseInt((g.timeSlot || '08:30').split(':')[0])
|
||||
const gPeriod = gHour < 12 ? 1 : 2
|
||||
return gPeriod === period
|
||||
})
|
||||
// 按id排序保持稳定顺序
|
||||
sameSlotGroups.sort((a, b) => (a.id || 0) - (b.id || 0))
|
||||
const orderIndex = sameSlotGroups.findIndex(g => g.id === group.id) + 1
|
||||
|
||||
// 4. 格式化: 场地(1位) + 时段(1位) + 序号(2位)
|
||||
return `${venueNo}${period}${String(orderIndex).padStart(2, '0')}`
|
||||
},
|
||||
|
||||
// 检查项目是否展开
|
||||
isProjectExpanded(groupId) {
|
||||
return this.expandedProjects[groupId] === true
|
||||
@@ -1457,6 +1496,16 @@ export default {
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.project-table-no {
|
||||
color: #409EFF;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
margin-left: 10px;
|
||||
padding: 2px 8px;
|
||||
background-color: #ecf5ff;
|
||||
border-radius: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.project-actions {
|
||||
|
||||
Reference in New Issue
Block a user