| | |
| | | import type { HrmEmployeeContractApi } from '#/api/hrm/employee/contract'; |
| | | |
| | | import { Page, useVbenModal } from '#/packages/effects/common-ui/src'; |
| | | import { downloadFileFromBlobPart } from '#/packages/utils/src'; |
| | | |
| | | import { message, Tag } from 'ant-design-vue'; |
| | | import { DownOutlined } from '@ant-design/icons-vue'; |
| | | import { Button, Dropdown, Menu, message, Modal, Tag } from 'ant-design-vue'; |
| | | |
| | | import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; |
| | | import { |
| | | deleteEmployeeContract, |
| | | downloadContractTemplate, |
| | | generateContractArchive, |
| | | generateContractDocx, |
| | | getEmployeeContractPage, |
| | | } from '#/api/hrm/employee/contract'; |
| | | import { $t } from '#/locales'; |
| | |
| | | import Form from './modules/form.vue'; |
| | | import ImportForm from './modules/import-form.vue'; |
| | | import Terminate from './modules/terminate.vue'; |
| | | import Attachment from './modules/attachment-modal.vue'; |
| | | |
| | | const [FormModal, formModalApi] = useVbenModal({ |
| | | connectedComponent: Form, |
| | |
| | | |
| | | const [TerminateModal, terminateModalApi] = useVbenModal({ |
| | | connectedComponent: Terminate, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | | const [AttachmentModal, attachmentModalApi] = useVbenModal({ |
| | | connectedComponent: Attachment, |
| | | destroyOnClose: true, |
| | | }); |
| | | |
| | |
| | | importModalApi.open(); |
| | | } |
| | | |
| | | /** ä¸è½½ååç©ºç½æ¨¡æ¿ï¼type 1-å³å¨ååç®ç 2-å³å¨ååæ å 3-å³å¡åå */ |
| | | const TEMPLATE_NAMES: Record<number, string> = { |
| | | 1: 'å³å¨ååï¼ç®çï¼.docx', |
| | | 2: 'å³å¨ååï¼æ åï¼.docx', |
| | | 3: 'å³å¡åå.doc', |
| | | }; |
| | | async function handleDownloadTemplate(type: number) { |
| | | const data = await downloadContractTemplate(type); |
| | | downloadFileFromBlobPart({ |
| | | fileName: TEMPLATE_NAMES[type] || 'å忍¡æ¿', |
| | | source: data, |
| | | }); |
| | | message.success('模æ¿å·²ä¸è½½'); |
| | | } |
| | | |
| | | /** ç¼è¾åå */ |
| | | function handleEdit(row: HrmEmployeeContractApi.EmployeeContract) { |
| | | formModalApi.setData({ id: row.id, formType: 'update' }).open(); |
| | |
| | | /** è§£é¤/ç»æ¢åå */ |
| | | function handleTerminate(row: HrmEmployeeContractApi.EmployeeContract) { |
| | | terminateModalApi.setData({ id: row.id }).open(); |
| | | } |
| | | |
| | | /** æ¥çååéä»¶ */ |
| | | function handleAttachments(row: HrmEmployeeContractApi.EmployeeContract) { |
| | | attachmentModalApi.setData({ id: row.id }).open(); |
| | | } |
| | | |
| | | /** çæååï¼docxï¼ï¼templateType 1-å³å¨ååç®ç 2-å³å¨ååæ å 3-å³å¡åå */ |
| | | async function handleGenerate( |
| | | row: HrmEmployeeContractApi.EmployeeContract, |
| | | templateType: number, |
| | | ) { |
| | | // 1. çæå¹¶åå为ååéä»¶ |
| | | await generateContractArchive(row.id!, templateType); |
| | | // 2. åæ¶ä¸è½½ä¸ä»½ |
| | | const data = await generateContractDocx(row.id!, templateType); |
| | | const genName = |
| | | { 1: 'å³å¨åå(ç®ç).docx', 2: 'å³å¨åå(æ å).docx', 3: 'å³å¡åå.docx' }[ |
| | | templateType |
| | | ] || 'åå.docx'; |
| | | downloadFileFromBlobPart({ |
| | | fileName: `${row.contractNo || row.id}-${genName}`, |
| | | source: data, |
| | | }); |
| | | message.success('ååå·²çæï¼å¹¶å½æ¡£å°è¯¥ååéä»¶'); |
| | | handleRefresh(); |
| | | } |
| | | |
| | | /** âæ´å¤âèåï¼ä¿®æ¹ / ç»ç¾ / è§£é¤ç»æ¢ / å é¤ */ |
| | | function handleMore({ key }: { key: number | string }, row: HrmEmployeeContractApi.EmployeeContract) { |
| | | switch (key) { |
| | | case 'edit': { |
| | | handleEdit(row); |
| | | break; |
| | | } |
| | | case 'renew': { |
| | | handleRenew(row); |
| | | break; |
| | | } |
| | | case 'terminate': { |
| | | handleTerminate(row); |
| | | break; |
| | | } |
| | | case 'delete': { |
| | | Modal.confirm({ |
| | | title: `确认å é¤ååã${row.contractNo || row.id}ãåï¼`, |
| | | okText: 'å é¤', |
| | | okType: 'danger', |
| | | cancelText: 'åæ¶', |
| | | onOk: () => handleDelete(row), |
| | | }); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** å é¤åå */ |
| | |
| | | <FormModal @success="handleRefresh" /> |
| | | <ImportModal @success="handleRefresh" /> |
| | | <TerminateModal @success="handleRefresh" /> |
| | | <AttachmentModal /> |
| | | <Grid table-title="åå·¥ååå表"> |
| | | <template #parentNo="{ row }"> |
| | | <span>{{ row.parentNo || '-' }}</span> |
| | |
| | | <span v-else>-</span> |
| | | </template> |
| | | <template #toolbar-tools> |
| | | <Dropdown> |
| | | <Button class="mr-2" type="primary"> |
| | | ä¸è½½å忍¡æ¿ <DownOutlined /> |
| | | </Button> |
| | | <template #overlay> |
| | | <Menu @click="({ key }) => handleDownloadTemplate(Number(key))"> |
| | | <Menu.Item key="1">å³å¨ååï¼ç®çï¼</Menu.Item> |
| | | <Menu.Item key="2">å³å¨ååï¼æ åï¼</Menu.Item> |
| | | <Menu.Item key="3">å³å¡åå</Menu.Item> |
| | | </Menu> |
| | | </template> |
| | | </Dropdown> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | |
| | | /> |
| | | </template> |
| | | <template #actions="{ row }"> |
| | | <TableAction |
| | | :actions="[ |
| | | { |
| | | label: 'ç»ç¾', |
| | | type: 'link', |
| | | icon: ACTION_ICON.ADD, |
| | | auth: ['hrm:employee-contract:create'], |
| | | ifShow: isTerminable(row), |
| | | onClick: handleRenew.bind(null, row), |
| | | }, |
| | | { |
| | | label: $t('common.edit'), |
| | | type: 'link', |
| | | icon: ACTION_ICON.EDIT, |
| | | auth: ['hrm:employee-contract:update'], |
| | | onClick: handleEdit.bind(null, row), |
| | | }, |
| | | { |
| | | label: 'è§£é¤/ç»æ¢', |
| | | type: 'link', |
| | | icon: ACTION_ICON.CLOSE, |
| | | auth: ['hrm:employee-contract:update'], |
| | | ifShow: isTerminable(row), |
| | | onClick: handleTerminate.bind(null, row), |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |
| | | type: 'link', |
| | | danger: true, |
| | | icon: ACTION_ICON.DELETE, |
| | | auth: ['hrm:employee-contract:delete'], |
| | | popConfirm: { |
| | | title: $t('ui.actionMessage.deleteConfirm', ['åå·¥åå']), |
| | | confirm: handleDelete.bind(null, row), |
| | | }, |
| | | }, |
| | | ]" |
| | | /> |
| | | <Dropdown> |
| | | <a class="text-primary" @click.prevent>çæåå <DownOutlined /></a> |
| | | <template #overlay> |
| | | <Menu @click="({ key }) => handleGenerate(row, Number(key))"> |
| | | <Menu.Item key="1">å³å¨ååï¼ç®çï¼</Menu.Item> |
| | | <Menu.Item key="2">å³å¨ååï¼æ åï¼</Menu.Item> |
| | | <Menu.Item key="3">å³å¡åå</Menu.Item> |
| | | </Menu> |
| | | </template> |
| | | </Dropdown> |
| | | <a class="ml-3 text-primary" @click="handleAttachments(row)">éä»¶</a> |
| | | <Dropdown> |
| | | <a class="ml-3 text-primary" @click.prevent>æ´å¤ <DownOutlined /></a> |
| | | <template #overlay> |
| | | <Menu @click="(e) => handleMore(e, row)"> |
| | | <Menu.Item key="edit">ä¿®æ¹</Menu.Item> |
| | | <Menu.Item v-if="isTerminable(row)" key="renew">ç»ç¾</Menu.Item> |
| | | <Menu.Item v-if="isTerminable(row)" key="terminate">è§£é¤/ç»æ¢</Menu.Item> |
| | | <Menu.Divider /> |
| | | <Menu.Item danger key="delete">å é¤</Menu.Item> |
| | | </Menu> |
| | | </template> |
| | | </Dropdown> |
| | | </template> |
| | | </Grid> |
| | | </Page> |