feat: 小项类型加「个人+团体」+ 报名导入拆团体/个人两部分
小项类型: - 迁移 0016 给 events.event_type 的 CHECK 增加 individual_team。SQLite 改不了 CHECK, 而 events 被多张子表引用(含 ON DELETE CASCADE/SET NULL),事务内 DROP 重建会级联删数据, 故用 writable_schema 就地改写建表语句文本(只追加一个枚举值,'match' 在建表语句里仅出现一次, 无副作用),零数据搬动 - domain 加 EventTypeIndividualTeam;管理端下拉加「个人+团体」并提示会同时走两条通道; guards/rules 的 eventType 白名单同步(否则会被降级成 individual) - 注意:该类型目前只解决「能被选出来」,双计的算分语义(个人分不计入单位、团体按队内平均排名) 尚未实现,等口径确认后再动数据模型 报名导入: - 卡片拆成「个人报名 / 团体报名」两个 tab,小项+组别提到 tab 之上共享 - 团体报名 = 从已配置单位清单里多选(默认全不勾,正好表达「部分单位不参加」), 可逐单位为登记队员(0 人即纯单位报名),一次提交为多个单位各建一条报名 - 已报名单位仍可覆盖名单,但会提示「提交将清空原名单」,且「全选」只勾启用中且未报名的单位 自检:服务端 12 包全绿;前端 vue-tsc + build、node --test 117/117;console 16 文件通过。
This commit is contained in:
1 parent
b5f40642ff
commit
592e47aef7
19 files changed
+1318
-117
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { normalizeRulePack } from '../rules'
|
||||
|
||||
// 「个人+团体」是服务端新增的小项类型;规则包模板按 eventType 匹配它时必须原样保留,
|
||||
// 否则前端归一化会把 match.eventType 丢掉,模板会退化成「匹配全部项目」。
|
||||
test('规则包模板保留 eventType: individual_team', () => {
|
||||
const pack = normalizeRulePack({
|
||||
format: 'scoreboard-rules',
|
||||
formatVersion: 1,
|
||||
meta: { code: 'demo', name: '示例规则' },
|
||||
profiles: [{ code: 'individual_top6', name: '个人项目前六名', awardRanks: 1, tieMode: 'skip', rules: [{ rank: 1, points: 10 }] }],
|
||||
channelTemplates: [
|
||||
{
|
||||
match: { eventType: 'individual_team' },
|
||||
channels: [
|
||||
{ scope: 'athlete', basis: 'result', profile: 'individual_top6' },
|
||||
{ scope: 'team', basis: 'manual', profile: 'individual_top6' },
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
assert.ok(pack !== null)
|
||||
assert.equal(pack.channelTemplates[0]?.match.eventType, 'individual_team')
|
||||
assert.equal(pack.channelTemplates[0]?.channels.length, 2)
|
||||
})
|
||||
|
||||
test('规则包模板仍接受原有三种类型', () => {
|
||||
for (const eventType of ['individual', 'team', 'match'] as const) {
|
||||
const pack = normalizeRulePack({
|
||||
format: 'scoreboard-rules',
|
||||
formatVersion: 1,
|
||||
meta: { code: 'demo', name: '示例规则' },
|
||||
profiles: [{ code: 'p', name: '模板', awardRanks: 1, tieMode: 'skip', rules: [{ rank: 1, points: 1 }] }],
|
||||
channelTemplates: [{ match: { eventType }, channels: [{ scope: 'athlete', basis: 'result', profile: 'p' }] }],
|
||||
})
|
||||
assert.ok(pack !== null)
|
||||
assert.equal(pack.channelTemplates[0]?.match.eventType, eventType)
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user