保存
This commit is contained in:
@@ -1,40 +1,35 @@
|
||||
<template>
|
||||
<view class="segmentation-container">
|
||||
<!-- 配置区域 -->
|
||||
<view class="config-section">
|
||||
<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>
|
||||
</view>
|
||||
|
||||
|
||||
<view class="config-info">
|
||||
<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>
|
||||
|
||||
<!-- 总计时器区域 -->
|
||||
<view class="total-time-section">
|
||||
<view class="total-time-section" style="position: relative;">
|
||||
<view class="timer-bar">
|
||||
<view class="timer-time">{{ formatTime(currentTime) }}</view>
|
||||
</view>
|
||||
<view class="config-info">
|
||||
<view class="info-text">总距离: {{ totalDistance }}米 ({{ segmentCount }}段 × {{ segmentDistance }}米)
|
||||
{{ startMode==0?'一起出发':'间隔出发' }} {{ startMode==0?'':' · '+intervalTime+'s' }} </view>
|
||||
</view>
|
||||
<view class="" style="position: absolute; top: 20rpx; right: 20rpx; ">
|
||||
<u-icon @click="Service.GoPage('/pages/userFunc/setCourse?id='+planId+'&type=2')" name="setting"
|
||||
size="24" color="#1890ff"></u-icon>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 学生列表 -->
|
||||
<view class="students-section" style="margin-top: 20rpx;" >
|
||||
<view class="section-header">
|
||||
<view class="students-section" style="margin-top: 20rpx;">
|
||||
<!-- <view class="section-header">
|
||||
<text class="section-title">学生列表</text>
|
||||
<text class="student-count">{{ students.length }}位学生</text>
|
||||
</view>
|
||||
</view> -->
|
||||
|
||||
<view class="students-list">
|
||||
<view v-for="(student, index) in students" :key="student.id" class="student-item"
|
||||
:class="{ 'not-started': !student.hasStarted }">
|
||||
<view class="student-header">
|
||||
<view class="student-number" :class="{ 'started': student.hasStarted }">{{ student.number }}
|
||||
<view class="student-number" @click="showStudentRecords(student)"
|
||||
:class="{ 'started': student.hasStarted }">{{ student.number }}
|
||||
</view>
|
||||
<view class="student-info">
|
||||
<text class="student-name">{{ student.name }}</text>
|
||||
@@ -51,17 +46,14 @@
|
||||
<view class="student-buttons">
|
||||
<button class="record-btn" :disabled="!student.hasStarted"
|
||||
@click="recordStudentSegment(student)">
|
||||
|
||||
<text class="btn-text">记录</text>
|
||||
</button>
|
||||
<button class="view-btn" @click="showStudentRecords(student)">
|
||||
|
||||
<text class="btn-text">详情</text>
|
||||
</button>
|
||||
<button class="reset-btn" @click="resetStudent(student)">
|
||||
|
||||
<view @click="resetStudent(student)" class="">
|
||||
<u-icon name="reload" :bold="true" size="24" color="#1890ff"></u-icon>
|
||||
</view>
|
||||
<!-- <button class="reset-btn" @click="resetStudent(student)">
|
||||
<text class="btn-text">重置</text>
|
||||
</button>
|
||||
</button> -->
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -206,12 +198,12 @@
|
||||
})
|
||||
}
|
||||
|
||||
// 格式化时间显示
|
||||
// 格式化时间显示(分:秒.毫秒)
|
||||
const formatTime = (seconds : number) : string => {
|
||||
const hours = Math.floor(seconds / 3600)
|
||||
const mins = Math.floor((seconds % 3600) / 60)
|
||||
const mins = Math.floor(seconds / 60)
|
||||
const secs = Math.floor(seconds % 60)
|
||||
return `${hours.toString().padStart(2, '0')}:${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`
|
||||
const millis = Math.floor((seconds % 1) * 100)
|
||||
return `${mins.toString().padStart(2, '0')}′${secs.toString().padStart(2, '0')}″${millis.toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
// 格式化持续时间
|
||||
@@ -261,11 +253,12 @@
|
||||
return student.segments[lastIndex].time - student.segments[lastIndex - 1].time
|
||||
}
|
||||
|
||||
// 简化时间格式化(分:秒)
|
||||
// 简化时间格式化(分:秒.毫秒)
|
||||
const formatSimpleTime = (seconds : number) : string => {
|
||||
const mins = Math.floor(seconds / 60)
|
||||
const secs = Math.floor(seconds % 60)
|
||||
return `${mins.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`
|
||||
const millis = Math.floor((seconds % 1) * 100)
|
||||
return `${mins.toString().padStart(2, '0')}′${secs.toString().padStart(2, '0')}″${millis.toString().padStart(2, '0')}`
|
||||
}
|
||||
|
||||
// 开始计时
|
||||
@@ -278,7 +271,7 @@
|
||||
timerInterval = setInterval(() => {
|
||||
const elapsed = (Date.now() - startTime) / 1000
|
||||
currentTime.value = elapsed
|
||||
}, 10)
|
||||
}, 1)
|
||||
|
||||
// 间隔出发模式
|
||||
if (startMode.value === 1) {
|
||||
@@ -333,7 +326,6 @@
|
||||
|
||||
// 记录学生分段
|
||||
const recordStudentSegment = (student : any) => {
|
||||
console.log(22222);
|
||||
if (!isRunning.value) {
|
||||
Service.Msg('请先开始计时')
|
||||
return
|
||||
@@ -355,9 +347,9 @@
|
||||
if (startMode.value === 1) {
|
||||
recordTime = currentTime.value - student.startTime
|
||||
}
|
||||
|
||||
|
||||
student.segments.push({
|
||||
time: recordTime
|
||||
time: Number(recordTime).toFixed(3)
|
||||
})
|
||||
|
||||
Service.Msg(`${student.name} 第${student.segments.length}段已记录`)
|
||||
@@ -399,13 +391,6 @@
|
||||
Service.Msg('暂无数据可保存!')
|
||||
return
|
||||
}
|
||||
|
||||
if (!isSave) {
|
||||
Service.Msg('存在学生未完成!')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let data = [
|
||||
{
|
||||
studentId: "",
|
||||
@@ -429,18 +414,29 @@
|
||||
})
|
||||
})
|
||||
|
||||
console.log(data);
|
||||
|
||||
PlanService.AddPlanLog(planId.value, '分段项目', '', JSON.stringify(data), '').then(res => {
|
||||
if (res.code == 0) {
|
||||
Service.Msg('提交成功!')
|
||||
setTimeout(()=>{
|
||||
Service.GoPageBack()
|
||||
},1000)
|
||||
} else {
|
||||
Service.Msg(res.msg)
|
||||
uni.showModal({
|
||||
title: '提示', // 对话框标题
|
||||
content: '请确定提交数据!', // 显示的内容
|
||||
showCancel: true, // 是否显示取消按钮
|
||||
cancelText: '取消', // 取消按钮的文字
|
||||
confirmText: '确定', // 确认按钮的文字
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
PlanService.AddPlanLog(planId.value, '分段项目', '', JSON.stringify(data), '').then(res => {
|
||||
if (res.code == 0) {
|
||||
Service.Msg('提交成功!')
|
||||
} else {
|
||||
Service.Msg(res.msg)
|
||||
}
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 显示学生记录弹窗
|
||||
@@ -474,41 +470,7 @@
|
||||
padding-bottom: 180rpx;
|
||||
}
|
||||
|
||||
/* 配置区域 */
|
||||
.config-section {
|
||||
background-color: #fff;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 30rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
|
||||
.config-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24rpx;
|
||||
|
||||
.config-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
.config-info {
|
||||
background-color: #e6f7ff;
|
||||
border-radius: 8rpx;
|
||||
padding: 16rpx 20rpx;
|
||||
|
||||
.info-text {
|
||||
font-size: 26rpx;
|
||||
color: #1890ff;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 总计时器区域 */
|
||||
.total-time-section {
|
||||
@@ -516,6 +478,20 @@
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
|
||||
.config-info {
|
||||
margin-top: 10rpx;
|
||||
background-color: #e6f7ff;
|
||||
border-radius: 8rpx;
|
||||
padding: 16rpx 20rpx;
|
||||
text-align: center;
|
||||
|
||||
.info-text {
|
||||
font-size: 26rpx;
|
||||
color: #1890ff;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.timer-bar {
|
||||
@@ -599,6 +575,7 @@
|
||||
gap: 12rpx;
|
||||
|
||||
.student-name {
|
||||
width: 120rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 500;
|
||||
color: #333;
|
||||
@@ -617,7 +594,7 @@
|
||||
}
|
||||
|
||||
.total-time-text {
|
||||
font-size: 24rpx;
|
||||
font-size: 30rpx;
|
||||
color: #999;
|
||||
font-family: 'DIN Alternate', monospace;
|
||||
font-weight: 500;
|
||||
@@ -652,7 +629,7 @@
|
||||
.view-btn,
|
||||
.reset-btn {
|
||||
height: 56rpx;
|
||||
padding: 0 20rpx;
|
||||
padding: 0 35rpx;
|
||||
border-radius: 8rpx;
|
||||
border: none;
|
||||
font-size: 24rpx;
|
||||
|
||||
Reference in New Issue
Block a user