gaoluyang
8 天以前 aecc3d1e0fa1a2f18c77f9a2544debea8f262926
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
<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>