ny
22 小时以前 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script lang="ts" setup>
import type { ActionItem, BasicColumn, FormProps } from '@jnpf/ui/vxeTable';
 
import { useMessage } from '@jnpf/hooks';
import { useModal } from '@jnpf/ui/modal';
import { BasicVxeTable, TableAction, useVxeTable } from '@jnpf/ui/vxeTable';
 
import { delEmployee, getEmployeeList } from '#/api/extend/employee';
import { $t } from '#/locales';
 
import ExportModal from './ExportModal.vue';
import ImportModal from './ImportModal.vue';
 
defineOptions({ name: 'ExtendImportAndExport' });
 
const { createMessage } = useMessage();
const [registerExportModal, { openModal: openExportModal }] = useModal();
const [registerImportModal, { openModal: openImportModal }] = useModal();
 
const columns: BasicColumn[] = [
  { title: '工号', dataIndex: 'enCode', width: 100, fixed: 'left' },
  { title: '姓名', dataIndex: 'fullName', width: 100, fixed: 'left' },
  { title: '性别', dataIndex: 'gender', width: 80, fixed: 'left' },
  { title: '部门', dataIndex: 'departmentName', width: 120 },
  { title: '岗位', dataIndex: 'positionName', width: 120 },
  { title: '用工性质', dataIndex: 'workingNature', width: 100 },
  { title: '身份证号', dataIndex: 'idNumber', width: 160 },
  { title: '联系电话', dataIndex: 'telephone', width: 100 },
  { title: '出生年月', dataIndex: 'birthday', width: 120, format: 'date|YYYY-MM-DD' },
  { title: '参加工作', dataIndex: 'attendWorkTime', width: 120, format: 'date|YYYY-MM-DD' },
  { title: '最高学历', dataIndex: 'education', width: 100 },
  { title: '所学专业', dataIndex: 'major', width: 120 },
  { title: '毕业院校', dataIndex: 'graduationAcademy', width: 150 },
  { title: '毕业时间', dataIndex: 'graduationTime', width: 120, format: 'date|YYYY-MM-DD' },
  { title: '创建时间', dataIndex: 'creatorTime', width: 150, format: 'date|YYYY-MM-DD HH:mm:ss' },
];
const [registerTable, { reload, getFetchParams }] = useVxeTable({
  api: getEmployeeList,
  columns,
  useSearchForm: true,
  formConfig: getFormConfig(),
  actionColumn: {
    width: 50,
    title: '操作',
    dataIndex: 'action',
  },
  afterFetch: (data) => {
    const list = data.map((o) => {
      o.birthday = o.birthday || null;
      o.attendWorkTime = o.attendWorkTime || null;
      o.graduationTime = o.graduationTime || null;
      return o;
    });
    return list;
  },
});
 
function getFormConfig(): Partial<FormProps> {
  return {
    schemas: [
      {
        field: 'condition',
        label: '查询字段',
        component: 'Select',
        defaultValue: 'EnCode',
        componentProps: {
          options: [
            { id: 'EnCode', fullName: '工号' },
            { id: 'FullName', fullName: '姓名' },
            { id: 'Telephone', fullName: '电话' },
            { id: 'DepartmentName', fullName: '部门' },
            { id: 'PositionName', fullName: '岗位' },
          ],
        },
      },
      {
        field: 'keyword',
        label: $t('common.keyword'),
        component: 'Input',
        componentProps: {
          placeholder: $t('common.enterKeyword'),
          submitOnPressEnter: true,
        },
      },
    ],
  };
}
function getTableActions(record): ActionItem[] {
  return [
    {
      label: $t('common.delText'),
      color: 'error',
      modelConfirm: {
        onOk: handleDelete.bind(null, record.id),
      },
    },
  ];
}
function handleDelete(id) {
  delEmployee(id).then((res) => {
    createMessage.success(res.msg);
    reload();
  });
}
function handleExport() {
  const listQuery = {
    ...getFetchParams(),
    condition: getFetchParams().condition || '',
    keyword: getFetchParams().keyword || '',
  };
  openExportModal(true, { listQuery });
}
function handleImport() {
  openImportModal(true, {});
}
</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-button type="primary" @click="handleExport"><i class="icon-ym icon-ym-btn-download button-preIcon"></i>{{ $t('common.exportText') }}</a-button>
            <a-button type="link" @click="handleImport"><i class="icon-ym icon-ym-btn-upload button-preIcon"></i>{{ $t('common.importText') }}</a-button>
          </template>
          <template #action="{ record }">
            <TableAction :actions="getTableActions(record)" />
          </template>
        </BasicVxeTable>
      </div>
    </div>
    <ExportModal @register="registerExportModal" />
    <ImportModal @register="registerImportModal" @reload="reload" />
  </div>
</template>