liuyu
2 小时以前 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
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
<script lang="ts" setup>
import type { TrainRecordCatalogDetail, TrainRecordCatalogItem } from './types';
 
import { computed, onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
 
import { useMessage } from '@jnpf/hooks';
import { Table as ATable } from 'ant-design-vue';
import dayjs from 'dayjs';
 
import { getTrainRecordCatalog } from '#/api/x/tms/trainRecord';
 
defineOptions({ name: 'TmsTrainRecordCatalog' });
 
const route = useRoute();
const router = useRouter();
const { createMessage } = useMessage();
 
const loading = ref(false);
const detail = ref<TrainRecordCatalogDetail | null>(null);
/** jnpf-date-range 值为时间戳数组 */
const dateRange = ref<number[] | undefined>(undefined);
 
const queryDates = computed(() => {
  const range = dateRange.value;
  if (!range || range.length < 2) return { startDate: undefined, endDate: undefined };
  return {
    startDate: dayjs(range[0]).format('YYYY-MM-DD'),
    endDate: dayjs(range[1]).format('YYYY-MM-DD'),
  };
});
 
const columns = [
  { title: '序号', key: 'index', width: 70, align: 'center', customRender: ({ index }: any) => index + 1 },
  { title: '培训记录编号', dataIndex: 'recordNo', key: 'recordNo', width: 150 },
  { title: '培训类型', dataIndex: 'trainType', key: 'trainType', width: 110 },
  { title: '培训内容', dataIndex: 'trainContent', key: 'trainContent', ellipsis: true },
  { title: '培训方式', dataIndex: 'trainMode', key: 'trainMode', width: 110 },
  { title: '培训师', dataIndex: 'trainerName', key: 'trainerName', width: 120 },
  { title: '考核方式', dataIndex: 'evalMode', key: 'evalMode', width: 110 },
  { title: '培训结果', dataIndex: 'trainResult', key: 'trainResult', width: 100, align: 'center' },
  { title: '是否合格', dataIndex: 'passFlag', key: 'passFlag', width: 100, align: 'center' },
  { title: '具体培训时间', dataIndex: 'trainDate', key: 'trainDate', width: 130 },
];
 
onMounted(() => {
  loadData();
});
 
async function loadData() {
  const id = String(route.params.id || '');
  if (!id) {
    router.replace('/tms/trainRecord');
    return;
  }
  loading.value = true;
  try {
    const { startDate, endDate } = queryDates.value;
    detail.value = await getTrainRecordCatalog({
      recordId: id,
      startDate,
      endDate,
    });
  } catch (e: any) {
    createMessage.error(e?.message || '加载培训目录失败');
    router.replace('/tms/trainRecord');
  } finally {
    loading.value = false;
  }
}
 
function handleSearch() {
  loadData();
}
 
function handleReset() {
  dateRange.value = undefined;
  loadData();
}
 
function handleExport() {
  const list = detail.value?.list || [];
  if (!list.length) {
    createMessage.warning('暂无数据可导出');
    return;
  }
  createMessage.success(`已准备导出 ${list.length} 条(导出接口联调后生效)`);
}
 
function goBack() {
  router.push('/tms/trainRecord');
}
 
/** 弹出层挂到 body,避免被 jnpf-content-wrapper overflow:hidden 裁切 */
function popupContainer() {
  return document.body;
}
 
function resultText(row: TrainRecordCatalogItem) {
  if (row.trainResult === '' || row.trainResult === undefined || row.trainResult === null) return '';
  return String(row.trainResult);
}
</script>
 
<template>
  <div class="jnpf-content-wrapper tms-record-catalog-page">
    <div class="jnpf-content-wrapper-center tms-record-catalog-center">
      <div class="jnpf-content-wrapper-content tms-record-catalog-wrap">
        <a-spin :spinning="loading" class="catalog-spin">
          <div class="catalog-inner">
            <div class="catalog-toolbar">
              <div class="catalog-filter">
                <span class="filter-label">查询日期</span>
                <jnpf-date-range
                  v-model:value="dateRange"
                  allow-clear
                  format="YYYY-MM-DD"
                  class="date-range"
                  :placeholder="['开始日期', '结束日期']"
                  :get-popup-container="popupContainer"
                />
                <a-button type="primary" class="ml-3" @click="handleSearch">查询</a-button>
                <a-button class="ml-2" @click="handleReset">重置</a-button>
              </div>
              <a-space>
                <a-button @click="handleExport">导出</a-button>
                <a-button @click="goBack">关闭</a-button>
              </a-space>
            </div>
 
            <div class="catalog-heading">
              <div class="user-name">姓名:{{ detail?.userName || '-' }}</div>
              <div class="catalog-title">培训目录</div>
            </div>
 
            <div class="catalog-table-wrap">
              <ATable
                size="middle"
                bordered
                row-key="id"
                :columns="columns"
                :data-source="detail?.list || []"
                :pagination="false"
                :scroll="{ x: 1200 }"
                :locale="{ emptyText: '暂无培训记录' }"
              >
                <template #bodyCell="{ column, record }">
                  <template v-if="column.key === 'trainResult'">
                    {{ resultText(record) }}
                  </template>
                  <template v-else-if="column.key === 'passFlag'">
                    <span v-if="record.passFlag === '1'" class="pass-yes">合格</span>
                    <span v-else-if="record.passFlag === '0'" class="pass-no">不合格</span>
                    <span v-else>-</span>
                  </template>
                </template>
              </ATable>
            </div>
          </div>
        </a-spin>
      </div>
    </div>
  </div>
</template>
 
<style scoped>
.tms-record-catalog-page {
  height: 100%;
  min-height: 0;
}
 
.tms-record-catalog-center {
  height: 100% !important;
  min-height: 0 !important;
  display: flex;
  flex-direction: column;
}
 
.tms-record-catalog-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;
}
 
.catalog-spin {
  display: block;
  min-height: 100%;
  width: 100%;
}
 
.catalog-spin :deep(.ant-spin-container) {
  min-height: 100%;
  width: 100%;
}
 
.catalog-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  width: 100%;
  box-sizing: border-box;
  padding: 16px 20px 20px;
  gap: 12px;
}
 
.catalog-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
}
 
.catalog-filter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  padding: 10px 12px;
  background: #fafafa;
  border-radius: 6px;
}
 
.filter-label {
  margin-right: 8px;
  color: rgba(0, 0, 0, 0.65);
  flex-shrink: 0;
}
 
.date-range {
  width: 280px;
}
 
.catalog-heading {
  text-align: center;
  flex-shrink: 0;
  padding: 8px 0 4px;
}
 
.user-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
 
.catalog-title {
  font-size: 16px;
  font-weight: 600;
}
 
.catalog-table-wrap {
  flex: 1;
  width: 100%;
}
 
.catalog-table-wrap :deep(.ant-table-wrapper) {
  width: 100%;
}
 
.catalog-table-wrap :deep(.ant-table-thead > tr > th) {
  background: #fafafa !important;
  font-weight: 600;
  text-align: center;
}
 
.pass-yes {
  color: #52c41a;
  font-weight: 500;
}
 
.pass-no {
  color: #ff4d4f;
  font-weight: 500;
}
</style>