liuyu
4 小时以前 82a74ba0402ab546ba524d23ce62198c4d00d2f7
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
<script lang="ts" setup>
import type { TmsRecordDetail, TmsRecordParticipant } from './types';
 
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
 
import { useMessage } from '@jnpf/hooks';
import {
  Descriptions as ADescriptions,
  DescriptionsItem as ADescriptionsItem,
  Table as ATable,
} from 'ant-design-vue';
 
import { getTmsRecordDetail } from '#/api/x/tms/record';
 
defineOptions({ name: 'TmsRecordDetail' });
 
const route = useRoute();
const router = useRouter();
const { createMessage } = useMessage();
 
const loading = ref(false);
const detail = ref<TmsRecordDetail | null>(null);
 
const participantColumns = [
  { title: '姓名', dataIndex: 'userName', key: 'userName', width: 140, align: 'center' },
  { title: '部门', dataIndex: 'deptName', key: 'deptName', width: 200, align: 'center' },
  { title: '签到日期', dataIndex: 'signDate', key: 'signDate', width: 180, align: 'center' },
  { title: '考试成绩', dataIndex: 'examScore', key: 'examScore', width: 120, align: 'center' },
  {
    title: '是否合格',
    dataIndex: 'passFlag',
    key: 'passFlag',
    width: 120,
    align: 'center',
    customRender: ({ record }: { record: TmsRecordParticipant }) => passText(record),
  },
];
 
onMounted(() => {
  loadData();
});
 
async function loadData() {
  const id = String(route.params.id || '');
  if (!id) {
    router.replace('/tms/record');
    return;
  }
  loading.value = true;
  try {
    detail.value = await getTmsRecordDetail(id);
  } catch (e: any) {
    createMessage.error(e?.message || '加载培训记录失败');
    router.replace('/tms/record');
  } finally {
    loading.value = false;
  }
}
 
function goBack() {
  const from = String(route.query.from || '');
  if (from === 'archived') {
    router.push('/tms/record/archived');
    return;
  }
  if (from === 'ready') {
    router.push('/tms/record/ready');
    return;
  }
  if (from === 'main') {
    router.push('/tms/record');
    return;
  }
  router.back();
}
 
function passText(row: TmsRecordParticipant) {
  if (row.passFlag === '1') return '合格';
  if (row.passFlag === '0') return '不合格';
  return '';
}
 
function openAttachment(url?: string) {
  if (!url || url === '#') {
    createMessage.info('附件预览联调后生效');
    return;
  }
  window.open(url, '_blank');
}
</script>
 
<template>
  <div class="jnpf-content-wrapper tms-record-detail-page">
    <div class="jnpf-content-wrapper-center tms-record-detail-center">
      <div class="jnpf-content-wrapper-content tms-record-detail-wrap">
        <a-spin :spinning="loading" class="detail-spin">
          <div v-if="detail" class="detail-inner">
            <div class="detail-header">
              <div class="text-base font-medium">培训记录</div>
              <a-button type="primary" @click="goBack">返回</a-button>
            </div>
 
            <ADescriptions bordered :column="2" size="middle" class="detail-desc">
              <ADescriptionsItem label="培训编号">{{ detail.recordNo }}</ADescriptionsItem>
              <ADescriptionsItem label="任务关闭时间">{{ detail.closeTime || '-' }}</ADescriptionsItem>
              <ADescriptionsItem label="培训主题" :span="2">
                <div class="pre-line">{{ detail.subject }}</div>
              </ADescriptionsItem>
              <ADescriptionsItem label="培训要点" :span="2">
                <div class="pre-line">{{ detail.keyPoints || '-' }}</div>
              </ADescriptionsItem>
              <ADescriptionsItem label="培训开始时间">{{ detail.startTime }}</ADescriptionsItem>
              <ADescriptionsItem label="培训结束时间">{{ detail.endTime || '-' }}</ADescriptionsItem>
              <ADescriptionsItem label="培训地点" :span="2">{{ detail.placeName || '-' }}</ADescriptionsItem>
              <ADescriptionsItem label="培训分类">{{ detail.category }}</ADescriptionsItem>
              <ADescriptionsItem label="培训方式">{{ detail.trainMode || detail.trainType || '-' }}</ADescriptionsItem>
              <ADescriptionsItem label="培训师">{{ detail.trainerName }}</ADescriptionsItem>
              <ADescriptionsItem label="培训考核方式">{{ detail.evalMode }}</ADescriptionsItem>
              <ADescriptionsItem label="培训对象" :span="2">{{ detail.trainees || '-' }}</ADescriptionsItem>
              <ADescriptionsItem label="附件" :span="2">
                <div v-if="detail.attachments?.length" class="attach-list">
                  <div v-for="file in detail.attachments" :key="file.id" class="attach-item">
                    <span>{{ file.name }}</span>
                    <a class="attach-link" @click.prevent="openAttachment(file.url)">原文</a>
                  </div>
                </div>
                <span v-else>-</span>
              </ADescriptionsItem>
              <ADescriptionsItem label="备注" :span="2">{{ detail.remark || '-' }}</ADescriptionsItem>
            </ADescriptions>
 
            <div class="section-title">参加人员名单如下</div>
            <div class="participant-table">
              <ATable
                size="middle"
                bordered
                row-key="id"
                table-layout="fixed"
                :columns="participantColumns"
                :data-source="detail.participants || []"
                :pagination="false"
                :scroll="{ x: 760 }"
                :locale="{ emptyText: '暂无参加人员' }"
              />
            </div>          </div>
        </a-spin>
      </div>
    </div>
  </div>
</template>
 
<style scoped>
/* 全局 jnpf-content-wrapper* 为 overflow:hidden 且无 min-height:0,整条高度链补齐才能滚 */
.tms-record-detail-page {
  height: 100%;
  min-height: 0;
}
 
.tms-record-detail-center {
  height: 100% !important;
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
}
 
.tms-record-detail-wrap {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 0 !important;
  min-height: 0 !important;
  height: 100%;
  overflow: auto !important;
  background: #fff;
  padding: 0;
}
 
.detail-spin {
  display: block;
  min-height: 100%;
  width: 100%;
}
 
.detail-spin :deep(.ant-spin-container) {
  min-height: 100%;
  width: 100%;
}
 
.detail-inner {
  padding: 16px 20px 24px;
  box-sizing: border-box;
}
 
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}
 
.detail-desc {
  margin-bottom: 16px;
}
 
.pre-line {
  white-space: pre-wrap;
  line-height: 1.5;
}
 
.attach-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
 
.attach-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
 
.attach-link {
  flex-shrink: 0;
  color: var(--primary-color, #1677ff);
  cursor: pointer;
}
 
.attach-link:hover {
  text-decoration: underline;
}
 
.section-title {
  margin: 8px 0 12px;
  font-size: 15px;
  font-weight: 600;
}
 
.participant-table :deep(.ant-table-table) {
  table-layout: fixed !important;
}
 
.participant-table :deep(.ant-table-thead > tr > th),
.participant-table :deep(.ant-table-tbody > tr > td) {
  text-align: center;
}
 
.participant-table :deep(.ant-table-placeholder .ant-table-cell) {
  text-align: center;
}
</style>