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
<script lang="ts" setup>
import type { ActionItem, BasicColumn } from '@jnpf/ui/vxeTable';
 
import type { TrainRecordListItem } from './types';
 
import { useRouter } from 'vue-router';
 
import { useMessage } from '@jnpf/hooks';
import { BasicVxeTable, TableAction, useVxeTable } from '@jnpf/ui/vxeTable';
 
import { getTrainRecordList } from '#/api/x/tms/trainRecord';
 
defineOptions({ name: 'TmsTrainRecord' });
 
const router = useRouter();
const { createMessage } = useMessage();
 
const columns: BasicColumn[] = [
  { title: '档案编号', dataIndex: 'archiveNo', width: 130 },
  { title: '进岗时间', dataIndex: 'postDate', width: 120 },
  { title: '姓名', dataIndex: 'userName', width: 100 },
  { title: '部门', dataIndex: 'deptName', minWidth: 120 },
  { title: '岗位', dataIndex: 'postName', width: 120 },
  { title: '兼职岗位', dataIndex: 'partPostName', width: 120 },
  { title: '专业', dataIndex: 'major', width: 100 },
  { title: '学历', dataIndex: 'education', width: 90 },
  { title: '技术职称', dataIndex: 'techTitle', width: 110 },
  { title: '入职时间', dataIndex: 'hireDate', width: 120 },
  { title: '离职日期', dataIndex: 'leaveDate', width: 120 },
];
 
const [registerTable, { getSelectRows }] = useVxeTable({
  api: fetchList,
  columns,
  immediate: true,
  rowKey: 'id',
  rowSelection: { type: 'checkbox' },
  useSearchForm: true,
  formConfig: {
    baseColProps: { span: 6 },
    compact: true,
    schemas: [
      {
        field: 'keyword',
        label: '关键词',
        component: 'Input',
        componentProps: { placeholder: '姓名/部门/档案编号', submitOnPressEnter: true },
      },
      {
        field: 'archiveNo',
        label: '档案编号',
        component: 'Input',
        componentProps: { placeholder: '请输入档案编号', submitOnPressEnter: true },
      },
    ],
  },
  actionColumn: {
    width: 100,
    title: '操作',
    dataIndex: 'action',
    fixed: 'right',
  },
});
 
async function fetchList(params: Record<string, any>) {
  return { data: await getTrainRecordList(params) };
}
 
function handleView(record: TrainRecordListItem) {
  router.push(`/tms/trainRecord/catalog/${record.id}`);
}
 
function handleViewSelected() {
  const rows = (getSelectRows?.() || []) as TrainRecordListItem[];
  if (!rows.length) {
    createMessage.warning('请先勾选一条记录');
    return;
  }
  if (rows.length > 1) {
    createMessage.warning('请只勾选一条记录查看');
    return;
  }
  handleView(rows[0]);
}
 
function getTableActions(record: TrainRecordListItem): ActionItem[] {
  return [{ label: '查看', onClick: handleView.bind(null, record) }];
}
</script>
 
<template>
  <div class="jnpf-content-wrapper">
    <div class="jnpf-content-wrapper-center">
      <div class="jnpf-content-wrapper-content">
        <BasicVxeTable @register="registerTable">
          <template #tableTitle>
            <a-space>
              <a-button type="primary" @click="handleViewSelected">查看</a-button>
              <span class="text-gray-400 text-sm">个人培训记录表,选择人员查看培训目录。</span>
            </a-space>
          </template>
          <template #action="{ record }">
            <TableAction :actions="getTableActions(record)" />
          </template>
        </BasicVxeTable>
      </div>
    </div>
  </div>
</template>