4-23
This commit is contained in:
@@ -5,13 +5,14 @@
|
||||
<view class="config-header">
|
||||
<text class="config-title">分段设置</text>
|
||||
|
||||
<u-icon @click="Service.GoPage('/pages/userFunc/setCourse?id='+planId+'&type=2')" name="setting" size="24"
|
||||
color="#1890ff"></u-icon>
|
||||
<u-icon @click="Service.GoPage('/pages/userFunc/setCourse?id='+planId+'&type=2')" name="setting"
|
||||
size="24" color="#1890ff"></u-icon>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="config-info">
|
||||
<text class="info-text">总距离: {{ totalDistance }}米 ({{ segmentCount }}段 × {{ segmentDistance }}米)</text>
|
||||
<view class="info-text">总距离: {{ totalDistance }}米 ({{ segmentCount }}段 × {{ segmentDistance }}米) {{ startMode==0?'一起出发':'间隔出发' }} {{ startMode==0?'':' · '+intervalTime+'s' }} </view>
|
||||
<view class="info-text" style="margin-top: 14rpx;" >启动模式: {{ startMode==0?'一起出发':'间隔出发' }} {{ startMode==0?'':' · '+intervalTime+'s' }} </view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -23,7 +24,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 学生列表 -->
|
||||
<view class="students-section">
|
||||
<view class="students-section" style="margin-top: 20rpx;" >
|
||||
<view class="section-header">
|
||||
<text class="section-title">学生列表</text>
|
||||
<text class="student-count">{{ students.length }}位学生</text>
|
||||
@@ -171,10 +172,10 @@
|
||||
let planId = ref('')
|
||||
onLoad((data : any) => {
|
||||
planId.value = data.id
|
||||
|
||||
|
||||
})
|
||||
|
||||
onShow(()=>{
|
||||
|
||||
onShow(() => {
|
||||
getPlanInfo()
|
||||
})
|
||||
|
||||
@@ -183,17 +184,17 @@
|
||||
PlanService.GetPlanInfo(planId.value).then(res => {
|
||||
if (res.code == 0) {
|
||||
// planName.value = res.data.plan.name
|
||||
segmentDistance.value=res.data.plan.subsectionDistance/res.data.plan.subsectionInt
|
||||
segmentCount.value=res.data.plan.subsectionInt
|
||||
segmentDistance.value = res.data.plan.subsectionDistance / res.data.plan.subsectionInt
|
||||
segmentCount.value = res.data.plan.subsectionInt
|
||||
// 将计划数据转换为选手数据
|
||||
// athletes.value = res.data.plan.users.
|
||||
students.value=res.data.plan.users.map((item:any,index:any)=>{
|
||||
students.value = res.data.plan.users.map((item : any, index : any) => {
|
||||
return {
|
||||
id: item.studentId,
|
||||
number: index+1,
|
||||
number: index + 1,
|
||||
name: item.name,
|
||||
segments: [],
|
||||
hasStarted: res.data.plan.departType == '间隔出发'?false:true,
|
||||
hasStarted: res.data.plan.departType == '间隔出发' ? false : true,
|
||||
startTime: 0
|
||||
}
|
||||
})
|
||||
@@ -230,10 +231,12 @@
|
||||
return result
|
||||
}
|
||||
|
||||
// 格式化时间差
|
||||
// 格式化时间差(详情弹窗用)
|
||||
// 第一段显示累计时间,后续段显示分段用时
|
||||
const formatTimeDiff = (index : number, currentTime : number) : string => {
|
||||
if (index === 0) {
|
||||
return '00:00:00'
|
||||
// 第一段显示累计时间
|
||||
return formatTime(currentTime)
|
||||
}
|
||||
if (!currentStudent.value || !currentStudent.value.segments[index - 1]) {
|
||||
return '00:00:00'
|
||||
@@ -243,12 +246,19 @@
|
||||
return formatTime(diff)
|
||||
}
|
||||
|
||||
// 获取学生最后一次记录的累计时间
|
||||
// 获取学生最后一次记录的分段用时
|
||||
// 第一段返回累计时间,后续段返回当前段用时(当前累计 - 上一次累计)
|
||||
const getLastSegmentTime = (student : any) : number => {
|
||||
if (!student.segments || student.segments.length === 0) {
|
||||
return 0
|
||||
}
|
||||
return student.segments[student.segments.length - 1].time
|
||||
const lastIndex = student.segments.length - 1
|
||||
if (lastIndex === 0) {
|
||||
// 第一段,返回累计时间
|
||||
return student.segments[0].time
|
||||
}
|
||||
// 后续段,返回分段用时
|
||||
return student.segments[lastIndex].time - student.segments[lastIndex - 1].time
|
||||
}
|
||||
|
||||
// 简化时间格式化(分:秒)
|
||||
@@ -374,8 +384,8 @@
|
||||
currentTime.value = 0
|
||||
students.value.forEach(student => {
|
||||
student.segments = []
|
||||
student.hasStarted = startMode.value == 1?false:true,
|
||||
student.startTime = 0
|
||||
student.hasStarted = startMode.value == 1 ? false : true,
|
||||
student.startTime = 0
|
||||
})
|
||||
Service.Msg('已全部重置')
|
||||
}
|
||||
@@ -384,15 +394,17 @@
|
||||
const saveData = () => {
|
||||
// 检查是否有记录的数据
|
||||
const hasData = students.value.some(s => s.segments.length > 0)
|
||||
let isSave = students.value.every(s => s.segments.length >= segmentCount.value)
|
||||
if (!hasData) {
|
||||
Service.Msg('暂无数据可保存')
|
||||
Service.Msg('暂无数据可保存!')
|
||||
return
|
||||
}
|
||||
|
||||
if (!isSave) {
|
||||
Service.Msg('存在学生未完成!')
|
||||
return
|
||||
}
|
||||
|
||||
console.log(students.value);
|
||||
|
||||
// 这里可以添加保存到后端或本地存储的逻辑
|
||||
Service.Msg('保存成功', 'success')
|
||||
|
||||
let data = [
|
||||
{
|
||||
@@ -405,22 +417,27 @@
|
||||
students.value.map((item : any) => {
|
||||
let record = item.segments.map((content : any, index : any) => {
|
||||
return {
|
||||
circle: (index + 1)*segmentDistance.value,
|
||||
circle: (index + 1) * segmentDistance.value,
|
||||
time: content.time
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
data.push({
|
||||
studentId: item.id,
|
||||
studentName: item.name,
|
||||
data: record
|
||||
})
|
||||
})
|
||||
|
||||
PlanService.AddPlanLog(planId.value,'分段项目','',JSON.stringify(data),'').then(res=>{
|
||||
if(res.code==0){
|
||||
|
||||
console.log(data);
|
||||
|
||||
PlanService.AddPlanLog(planId.value, '分段项目', '', JSON.stringify(data), '').then(res => {
|
||||
if (res.code == 0) {
|
||||
Service.Msg('提交成功!')
|
||||
}else{
|
||||
setTimeout(()=>{
|
||||
Service.GoPageBack()
|
||||
},1000)
|
||||
} else {
|
||||
Service.Msg(res.msg)
|
||||
}
|
||||
})
|
||||
@@ -495,15 +512,14 @@
|
||||
|
||||
/* 总计时器区域 */
|
||||
.total-time-section {
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.timer-bar {
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.timer-bar {
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
Reference in New Issue
Block a user