<template>
|
<view class="result-detail">
|
<!-- 页面头部 -->
|
<PageHeader title="结果明细"
|
@back="goBack" />
|
<!-- 内容区域 -->
|
<view class="content">
|
<!-- 课程详情 -->
|
<view class="section">
|
<view class="section-title">课程详情</view>
|
<view class="info-list">
|
<view class="info-item">
|
<text class="info-label">课程编号</text>
|
<text class="info-value">{{ currentTraining.courseCode || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">培训内容</text>
|
<text class="info-value">{{ currentTraining.trainingContent || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">状态</text>
|
<text class="info-value">
|
<u-tag :type="currentTraining.state === 0 ? 'success' : (currentTraining.state === 1 ? 'warning' : 'info')">
|
{{ currentTraining.state === 0 ? '未开始' : (currentTraining.state === 1 ? '进行中' : '已结束') }}
|
</u-tag>
|
</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">培训讲师</text>
|
<text class="info-value">{{ currentTraining.trainingLecturer || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">培训开始时间</text>
|
<text class="info-value">{{ currentTraining.trainingDate + ' ' + currentTraining.openingTime || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">培训结束时间</text>
|
<text class="info-value">{{ currentTraining.trainingDate + ' ' + currentTraining.endTime || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">培训目标</text>
|
<text class="info-value">{{ currentTraining.trainingObjectives || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">参加对象</text>
|
<text class="info-value">{{ currentTraining.participants || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">培训方式</text>
|
<text class="info-value">{{ getTrainingModeLabel(currentTraining.trainingMode) || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">培训地点</text>
|
<text class="info-value">{{ currentTraining.placeTraining || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">课时</text>
|
<text class="info-value">{{ currentTraining.classHour || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">课程学分</text>
|
<text class="info-value">{{ currentTraining.projectCredits || '-' }}</text>
|
</view>
|
<view class="info-item">
|
<text class="info-label">报名人数</text>
|
<text class="info-value">{{ currentTraining.nums || '-' }}</text>
|
</view>
|
</view>
|
</view>
|
<!-- 课程评价 -->
|
<view class="section">
|
<view class="section-title">课程评价</view>
|
<u-form ref="formRef"
|
label-width="90"
|
:model="endform">
|
<u-form-item label="评价人">
|
<u-input v-model="endform.assessmentUserName"
|
disabled
|
placeholder="请选择评价人" />
|
</u-form-item>
|
<u-form-item label="评价时间">
|
<u-input v-model="endform.assessmentDate"
|
disabled
|
placeholder="请选择评价时间" />
|
</u-form-item>
|
<u-form-item label="考核方式">
|
<u-input v-model="endform.assessmentMethod"
|
placeholder="请输入考核方式" />
|
</u-form-item>
|
<u-form-item label="综合评价">
|
<u-input v-model="endform.comprehensiveAssessment"
|
placeholder="请输入本次课程综合评价" />
|
</u-form-item>
|
<u-form-item label="培训摘要">
|
<u-textarea v-model="endform.trainingAbstract"
|
:rows="4"
|
placeholder="请输入培训摘要" />
|
</u-form-item>
|
</u-form>
|
</view>
|
<!-- 考核列表 -->
|
<view class="section">
|
<view class="section-title">考核列表</view>
|
<view class="assessment-list">
|
<view v-for="(item, index) in endform.safeTrainingDetailsDtoList"
|
:key="index"
|
class="assessment-item">
|
<view class="assessment-info">
|
<view class="info-row">
|
<text class="label">姓名:</text>
|
<text class="value">{{ item.nickName || '-' }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">电话号码:</text>
|
<text class="value">{{ item.phonenumber || '-' }}</text>
|
</view>
|
</view>
|
<view class="assessment-result">
|
<text class="result-label">考核结果:</text>
|
<u-radio-group v-model="endform.safeTrainingDetailsDtoList[index].examinationResults"
|
:key="index"
|
size="default">
|
<u-radio label="合格"
|
name="合格"></u-radio>
|
<u-radio label="不合格"
|
name="不合格"></u-radio>
|
</u-radio-group>
|
</view>
|
</view>
|
</view>
|
</view>
|
<!-- 提交按钮 -->
|
<view class="submit-btn">
|
<u-button type="primary"
|
@click="submitForm"
|
:loading="loading">提交</u-button>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { ref, onMounted } from "vue";
|
import PageHeader from "@/components/PageHeader.vue";
|
import { onLoad } from "@dcloudio/uni-app";
|
import { useDict } from "@/utils/dict";
|
import dayjs from "dayjs";
|
import useUserStore from "@/store/modules/user";
|
import {
|
safeTrainingGet,
|
safeTrainingSave,
|
} from "@/api/safeProduction/safetyTrainingAssessment";
|
|
// 获取字典数据
|
const { safe_training_methods } = useDict("safe_training_methods");
|
|
// 页面状态
|
const loading = ref(false);
|
const currentTraining = ref({});
|
const endform = ref({
|
assessmentUserId: "",
|
assessmentUserName: "",
|
assessmentMethod: "",
|
assessmentDate: "",
|
comprehensiveAssessment: "",
|
trainingAbstract: "",
|
safeTrainingFileList: [],
|
safeTrainingDetailsDtoList: [],
|
});
|
|
// 获取培训方式标签
|
const getTrainingModeLabel = val => {
|
if (!safe_training_methods || !Array.isArray(safe_training_methods.value)) {
|
return val;
|
}
|
const item = safe_training_methods.value.find(
|
i => String(i.value) === String(val)
|
);
|
return item ? item.label : val;
|
};
|
|
// 返回上一页
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
// 提交表单
|
const submitForm = () => {
|
// 验证考核结果
|
for (let i = 0; i < endform.value.safeTrainingDetailsDtoList.length; i++) {
|
const item = endform.value.safeTrainingDetailsDtoList[i];
|
if (!item.examinationResults) {
|
uni.showToast({
|
title: `请选择${item.nickName}的考核结果`,
|
icon: "none",
|
});
|
return;
|
}
|
}
|
|
loading.value = true;
|
safeTrainingSave(endform.value)
|
.then(res => {
|
loading.value = false;
|
if (res.code === 200) {
|
uni.showToast({ title: "提交成功", icon: "success" });
|
setTimeout(() => {
|
goBack();
|
}, 500);
|
} else {
|
uni.showToast({ title: res.msg || "提交失败", icon: "none" });
|
}
|
})
|
.catch(() => {
|
loading.value = false;
|
uni.showToast({ title: "提交失败,请重试", icon: "none" });
|
});
|
};
|
|
// 页面加载
|
onLoad(() => {
|
const trainingId = uni.getStorageSync("safetyTrainingResultId");
|
const trainingNums = uni.getStorageSync("safetyTrainingResultNums");
|
|
if (trainingId) {
|
getTrainingDetail(trainingId, trainingNums);
|
}
|
});
|
const userStore = useUserStore();
|
const getuserInfo = () => {
|
const userInfo = {
|
id: "",
|
nickName: "",
|
};
|
userStore.getInfo().then(res => {
|
userInfo.id = res.user.userId;
|
userInfo.nickName = res.user.nickName;
|
endform.value.assessmentUserName = res.user.nickName;
|
endform.value.assessmentUserId = res.user.userId;
|
});
|
return userInfo;
|
};
|
|
// 获取培训详情
|
const getTrainingDetail = (id, trainingNums) => {
|
loading.value = true;
|
safeTrainingGet({ id })
|
.then(res => {
|
loading.value = false;
|
if (res.code === 200) {
|
currentTraining.value = res.data;
|
currentTraining.value.nums = trainingNums;
|
|
endform.value = { ...res.data };
|
// 设置默认值
|
if (!endform.value.assessmentUserId) {
|
getuserInfo();
|
}
|
|
endform.value.assessmentDate = endform.value.assessmentDate
|
? dayjs(endform.value.assessmentDate).format("YYYY-MM-DD")
|
: dayjs().format("YYYY-MM-DD");
|
endform.value.safeTrainingDetailsDtoList =
|
endform.value.safeTrainingDetailsDtoList || [];
|
} else {
|
uni.showToast({ title: "获取详情失败", icon: "none" });
|
}
|
})
|
.catch(() => {
|
loading.value = false;
|
uni.showToast({ title: "获取详情失败", icon: "none" });
|
});
|
};
|
</script>
|
|
<style scoped lang="scss">
|
.result-detail {
|
min-height: 100vh;
|
background: #f8f9fa;
|
}
|
|
.content {
|
padding: 16px;
|
}
|
|
.section {
|
background: #fff;
|
border-radius: 8px;
|
padding: 16px;
|
margin-bottom: 16px;
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
}
|
|
.section-title {
|
font-size: 16px;
|
font-weight: 600;
|
margin-bottom: 16px;
|
color: #333;
|
}
|
|
.info-list {
|
display: flex;
|
flex-direction: column;
|
gap: 12px;
|
}
|
|
.info-item {
|
display: flex;
|
justify-content: space-between;
|
align-items: flex-start;
|
padding-bottom: 12px;
|
border-bottom: 1px solid #f0f0f0;
|
}
|
|
.info-item:last-child {
|
border-bottom: none;
|
padding-bottom: 0;
|
}
|
|
.info-label {
|
font-size: 14px;
|
color: #666;
|
width: 100px;
|
}
|
|
.info-value {
|
flex: 1;
|
font-size: 14px;
|
color: #333;
|
text-align: right;
|
}
|
|
.assessment-list {
|
display: flex;
|
flex-direction: column;
|
gap: 12px;
|
}
|
|
.assessment-item {
|
background: #f8f9fa;
|
border-radius: 8px;
|
padding: 16px;
|
border: 1px solid #e8e8e8;
|
}
|
|
.assessment-info {
|
margin-bottom: 12px;
|
}
|
|
.info-row {
|
display: flex;
|
align-items: center;
|
margin-bottom: 8px;
|
}
|
|
.info-row:last-child {
|
margin-bottom: 0;
|
}
|
|
.label {
|
font-size: 14px;
|
color: #666;
|
min-width: 80px;
|
}
|
|
.value {
|
font-size: 14px;
|
color: #333;
|
flex: 1;
|
}
|
|
.assessment-result {
|
display: flex;
|
align-items: center;
|
padding-top: 8px;
|
border-top: 1px solid #e8e8e8;
|
}
|
|
.result-label {
|
font-size: 14px;
|
color: #666;
|
min-width: 80px;
|
}
|
|
.submit-btn {
|
margin-top: 24px;
|
margin-bottom: 32px;
|
}
|
</style>
|