Files
martial-admin-mini/mock/score.js
宅房 7ec9a77c2a feat: 添加Mock版本保护机制 - 基础架构完成
完成内容:
 第一层保护: Git分支隔离
  - 创建 v1.0-mock 标签
  - 创建 feature/api-integration 分支

 第二层保护: 配置开关控制
  - config/env.config.js (环境配置,支持Mock/API模式切换)

 第三层保护: 代码架构分离
  - utils/request.js (网络请求封装,支持Blade-Auth)
  - utils/dataAdapter.js (核心适配器,自动选择数据源)

 Mock数据模块 (4个文件):
  - mock/index.js (统一入口)
  - mock/login.js (登录Mock数据)
  - mock/athlete.js (选手Mock数据,含场地、项目)
  - mock/score.js (评分Mock数据,含扣分项、详情、修改)

 API接口模块 (4个文件):
  - api/index.js (统一入口)
  - api/auth.js (认证API,含后端接口规范)
  - api/athlete.js (选手API,含SQL示例)
  - api/score.js (评分API,含实现逻辑说明)

特性:
- 通过修改 config/env.config.js 的 dataMode 即可切换Mock/API模式
- Mock模式: 完全离线,无需后端,UI功能完整
- API模式: 调用真实后端接口(需后端实现5个专用接口)
- 零UI修改: 原有页面代码完全保护,仅替换数据源

下一步:
- 修改5个页面使用 dataAdapter
- 测试Mock模式功能
- 后端开发5个小程序专用接口

代码统计:
- 新增11个文件
- 约1000行代码
- 完整的注释和使用说明
2025-12-11 14:06:03 +08:00

163 lines
3.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Mock 数据 - 评分模块
* 模拟评分相关数据
*/
/**
* 获取扣分项列表
* @param {Object} params
* @param {String} params.projectId - 项目ID
* @returns {Array} 扣分项列表
*/
export function getDeductions(params) {
// 模拟8个扣分项
return [
{ id: '1', text: '扣分项描述', score: -0.1, checked: false },
{ id: '2', text: '扣分项描述', score: -0.1, checked: false },
{ id: '3', text: '扣分项描述', score: -0.1, checked: false },
{ id: '4', text: '扣分项描述', score: -0.1, checked: false },
{ id: '5', text: '扣分项描述', score: -0.1, checked: false },
{ id: '6', text: '扣分项描述', score: -0.1, checked: false },
{ id: '7', text: '扣分项描述', score: -0.1, checked: false },
{ id: '8', text: '扣分项描述', score: -0.1, checked: false }
]
}
/**
* 提交评分
* @param {Object} params
* @param {String} params.athleteId - 选手ID
* @param {String} params.judgeId - 评委ID
* @param {Number} params.score - 评分
* @param {Array} params.deductions - 扣分项
* @param {String} params.note - 备注
* @returns {Object} 提交结果
*/
export function submitScore(params) {
const { athleteId, judgeId, score, deductions, note } = params
// 模拟提交成功
console.log('Mock提交评分:', {
athleteId,
judgeId,
score,
deductions: deductions.filter(d => d.checked).length + '项',
note
})
return {
scoreId: 'score_' + Date.now(),
athleteId,
judgeId,
score,
submitTime: new Date().toISOString(),
message: '评分提交成功'
}
}
/**
* 获取评分详情(裁判长查看)
* @param {Object} params
* @param {String} params.athleteId - 选手ID
* @returns {Object} 评分详情
*/
export function getScoreDetail(params) {
const { athleteId } = params
// 模拟选手信息和评委评分
return {
athleteInfo: {
athleteId,
name: '张三',
idCard: '123456789000000000',
team: '少林寺武术大学院',
number: '123-4567898275',
totalScore: 8.907
},
// 6位评委的评分
judgeScores: [
{
judgeId: '1',
judgeName: '欧阳丽娜',
score: 8.907,
scoreTime: '2025-06-25 09:15:00',
note: ''
},
{
judgeId: '2',
judgeName: '张三',
score: 8.901,
scoreTime: '2025-06-25 09:15:30',
note: ''
},
{
judgeId: '3',
judgeName: '裁判姓名',
score: 8.902,
scoreTime: '2025-06-25 09:16:00',
note: ''
},
{
judgeId: '4',
judgeName: '裁判姓名',
score: 8.907,
scoreTime: '2025-06-25 09:16:30',
note: ''
},
{
judgeId: '5',
judgeName: '裁判姓名',
score: 8.905,
scoreTime: '2025-06-25 09:17:00',
note: ''
},
{
judgeId: '6',
judgeName: '裁判姓名',
score: 8.904,
scoreTime: '2025-06-25 09:17:30',
note: ''
}
],
// 修改记录(如果有)
modification: null
}
}
/**
* 修改评分(裁判长)
* @param {Object} params
* @param {String} params.athleteId - 选手ID
* @param {String} params.modifierId - 修改人ID裁判长
* @param {Number} params.modifiedScore - 修改后的分数
* @param {String} params.note - 修改原因
* @returns {Object} 修改结果
*/
export function modifyScore(params) {
const { athleteId, modifierId, modifiedScore, note } = params
// 模拟修改成功
console.log('Mock修改评分:', {
athleteId,
modifierId,
originalScore: 8.907,
modifiedScore,
note
})
return {
athleteId,
originalScore: 8.907,
modifiedScore,
modifyTime: new Date().toISOString(),
message: '评分修改成功'
}
}
export default {
getDeductions,
submitScore,
getScoreDetail,
modifyScore
}