trainDetail.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="container">
  3. <scroll-view scroll-y class="content">
  4. <!-- 培训信息 -->
  5. <view class="info-card" v-if="trainDetail">
  6. <view class="card-title">培训信息</view>
  7. <view class="info-item">
  8. <text class="label">培训主题:</text>
  9. <text class="value">{{ trainDetail.train_name || '-' }}</text>
  10. </view>
  11. <view class="info-item">
  12. <text class="label">负责人:</text>
  13. <text class="value">{{ trainDetail.responsible_people || '-' }}</text>
  14. </view>
  15. <view class="info-item">
  16. <text class="label">学员姓名:</text>
  17. <text class="value">{{ trainDetail.user_name || trainDetail.trainees_name || '-' }}</text>
  18. </view>
  19. <view class="info-item">
  20. <text class="label">课程类别:</text>
  21. <text class="value">{{ trainDetail.class_name || '-' }}</text>
  22. </view>
  23. <view class="info-item">
  24. <text class="label">课程名称:</text>
  25. <text class="value">{{ trainDetail.course_name || '-' }}</text>
  26. </view>
  27. <view class="info-item">
  28. <text class="label">讲师:</text>
  29. <text class="value">{{ trainDetail.teacher_name || '-' }}</text>
  30. </view>
  31. <view class="info-item">
  32. <text class="label">培训地点:</text>
  33. <text class="value">{{ trainDetail.location_name || '-' }}</text>
  34. </view>
  35. <view class="info-item">
  36. <text class="label">开始时间:</text>
  37. <text class="value">{{ formatDateTime(trainDetail.imple_start_time) }}</text>
  38. </view>
  39. <view class="info-item">
  40. <text class="label">结束时间:</text>
  41. <text class="value">{{ formatDateTime(trainDetail.imple_end_time) }}</text>
  42. </view>
  43. </view>
  44. <!-- 评估信息 -->
  45. <view class="info-card" v-if="trainDetail">
  46. <view class="card-title">我的评估</view>
  47. <view class="info-item">
  48. <text class="label">项目组织:</text>
  49. <text class="value stars">{{ renderStars(trainDetail.project_org) }}</text>
  50. </view>
  51. <view class="info-item">
  52. <text class="label">课程评分:</text>
  53. <text class="value stars">{{ renderStars(trainDetail.course_score) }}</text>
  54. </view>
  55. <view class="info-item">
  56. <text class="label">讲师评分:</text>
  57. <text class="value stars">{{ renderStars(trainDetail.teacher_score) }}</text>
  58. </view>
  59. <view class="info-item" v-if="trainDetail.advice">
  60. <text class="label">意见建议:</text>
  61. <text class="value advice">{{ trainDetail.advice }}</text>
  62. </view>
  63. <view class="info-item" v-else>
  64. <text class="label">意见建议:</text>
  65. <text class="value empty-text">暂无</text>
  66. </view>
  67. </view>
  68. <!-- 课程附件 -->
  69. <uni-card v-if="trainDetail && fileList && fileList.length > 0">
  70. <uni-section titleFontSize="1.3rem" title="课程附件" type="line"></uni-section>
  71. <attachment-list :attachments="fileList" :canEdit="false"></attachment-list>
  72. </uni-card>
  73. <view v-if="loading" class="loading">加载中...</view>
  74. <view v-else-if="!trainDetail" class="empty">
  75. <text>暂无数据</text>
  76. </view>
  77. </scroll-view>
  78. <!-- 底部按钮 -->
  79. <!-- <view class="footer" v-if="trainDetail">
  80. <button class="btn btn-assess" @click="goToAssess">去评估</button>
  81. </view>-->
  82. </view>
  83. </template>
  84. <script setup>
  85. import { ref } from 'vue';
  86. import { onLoad } from '@dcloudio/uni-app';
  87. import { getMyTrainDetail } from '@/api/train.js';
  88. import AttachmentList from '@/components/ygoa/attachmentList.vue';
  89. const trainDetail = ref(null);
  90. const fileList = ref([]);
  91. const loading = ref(false);
  92. // 页面参数
  93. const universalid = ref('');
  94. const impleId = ref('');
  95. const courseId = ref('');
  96. const traineesId = ref('');
  97. const assessId = ref('');
  98. onLoad((options) => {
  99. universalid.value = options.universalid || '';
  100. impleId.value = options.imple_id || '';
  101. courseId.value = options.course_id || '';
  102. traineesId.value = options.trainees_id || '';
  103. assessId.value = options.assess_id || '';
  104. loadTrainDetail();
  105. });
  106. // 渲染星星评分
  107. function renderStars(score) {
  108. if (!score || score === 0) {
  109. return '☆ ☆ ☆ ☆ ☆';
  110. }
  111. const filledStars = '★ '.repeat(parseInt(score));
  112. const emptyStars = '☆ '.repeat(5 - parseInt(score));
  113. return filledStars + emptyStars;
  114. }
  115. // 格式化日期时间
  116. function formatDateTime(dateStr) {
  117. if (!dateStr) return '-';
  118. // 如果是字符串格式,直接返回
  119. if (typeof dateStr === 'string') {
  120. return dateStr;
  121. }
  122. // 如果是时间戳或 Date 对象,进行格式化
  123. const date = new Date(dateStr);
  124. const year = date.getFullYear();
  125. const month = String(date.getMonth() + 1).padStart(2, '0');
  126. const day = String(date.getDate()).padStart(2, '0');
  127. const hours = String(date.getHours()).padStart(2, '0');
  128. const minutes = String(date.getMinutes()).padStart(2, '0');
  129. return `${year}-${month}-${day} ${hours}:${minutes}`;
  130. }
  131. // 加载培训详情
  132. async function loadTrainDetail() {
  133. loading.value = true;
  134. try {
  135. const res = await getMyTrainDetail({
  136. universalid: universalid.value,
  137. imple_id: impleId.value,
  138. course_id: courseId.value,
  139. trainees_id: traineesId.value,
  140. assess_id: assessId.value
  141. });
  142. if (res && res.returnCode === '0' && res.returnParams) {
  143. trainDetail.value = res.returnParams;
  144. // 处理附件列表
  145. if (res.returnParams.files && Array.isArray(res.returnParams.files)) {
  146. fileList.value = res.returnParams.files;
  147. }
  148. } else {
  149. uni.showToast({
  150. title: '加载失败',
  151. icon: 'none'
  152. });
  153. }
  154. } catch (error) {
  155. uni.showToast({
  156. title: '加载失败',
  157. icon: 'none'
  158. });
  159. console.error('加载培训详情失败:', error);
  160. } finally {
  161. loading.value = false;
  162. }
  163. }
  164. // 去评估
  165. function goToAssess() {
  166. uni.navigateTo({
  167. url: `/pages/mine/train/trainAssess?universalid=${universalid.value}&imple_id=${impleId.value}&course_id=${courseId.value}&trainees_id=${traineesId.value}`
  168. });
  169. }
  170. </script>
  171. <style lang="scss" scoped>
  172. .container {
  173. min-height: 100vh;
  174. background-color: #f5f5f5;
  175. display: flex;
  176. flex-direction: column;
  177. }
  178. .content {
  179. flex: 1;
  180. padding: 20rpx;
  181. }
  182. .info-card {
  183. background: #fff;
  184. border-radius: 12rpx;
  185. padding: 30rpx;
  186. margin-bottom: 20rpx;
  187. .card-title {
  188. font-size: 32rpx;
  189. font-weight: 600;
  190. color: #333;
  191. margin-bottom: 24rpx;
  192. padding-bottom: 16rpx;
  193. border-bottom: 1rpx solid #f0f0f0;
  194. }
  195. }
  196. .info-item {
  197. display: flex;
  198. align-items: flex-start;
  199. font-size: 28rpx;
  200. line-height: 1.8;
  201. margin-bottom: 16rpx;
  202. .label {
  203. color: #999;
  204. min-width: 160rpx;
  205. flex-shrink: 0;
  206. }
  207. .value {
  208. color: #333;
  209. flex: 1;
  210. &.stars {
  211. color: #FF9912;
  212. font-size: 26rpx;
  213. }
  214. &.advice {
  215. line-height: 1.6;
  216. }
  217. &.empty-text {
  218. color: #ccc;
  219. }
  220. }
  221. }
  222. .loading, .empty {
  223. text-align: center;
  224. padding: 80rpx 0;
  225. color: #999;
  226. font-size: 28rpx;
  227. }
  228. .footer {
  229. padding: 20rpx 30rpx;
  230. background: #fff;
  231. border-top: 1rpx solid #eee;
  232. .btn {
  233. width: 100%;
  234. height: 80rpx;
  235. line-height: 80rpx;
  236. font-size: 30rpx;
  237. border-radius: 8rpx;
  238. padding: 0;
  239. margin: 0;
  240. background: #fa8c16;
  241. color: #fff;
  242. &::after {
  243. border: none;
  244. }
  245. }
  246. }
  247. </style>