Commit 818eb0e7 authored by 刘斌's avatar 刘斌

feat: 重新改版流程

parent bbfaeace
...@@ -57,7 +57,7 @@ export function exportEmployeeList(params: PageQuery) { ...@@ -57,7 +57,7 @@ export function exportEmployeeList(params: PageQuery) {
} }
/** /**
* 导出员工信息 * 导出员工信息
* @param params * @param id
*/ */
export function apiExport(id: number) { export function apiExport(id: number) {
return commonExport(`/employee/info/export/${id}`, {}); return commonExport(`/employee/info/export/${id}`, {});
...@@ -68,36 +68,52 @@ export function apiExport(id: number) { ...@@ -68,36 +68,52 @@ export function apiExport(id: number) {
* @param data * @param data
*/ */
export function applyEntry(data: EmployeeInfoApi.EmployeeApplyBo) { export function applyEntry(data: EmployeeInfoApi.EmployeeApplyBo) {
return requestClient.post('/employee/info/applyEntry', data, { return requestClient.post<EmployeeInfoApi.EmployeeApplyBaseBo>(
successMessageMode: 'modal', '/employee/info/applyEntry',
}); data,
{
successMessageMode: 'message',
},
);
} }
/** /**
* 申请员工离职 * 申请员工离职
* @param data * @param data
*/ */
export function applyResign(data: EmployeeInfoApi.EmployeeResignApplyBo) { export function applyResign(data: EmployeeInfoApi.EmployeeResignApplyBo) {
return requestClient.post('/employee/info/applyResign', data, { return requestClient.post<EmployeeInfoApi.EmployeeApplyBaseBo>(
successMessageMode: 'modal', '/employee/info/applyResign',
}); data,
{
successMessageMode: 'message',
},
);
} }
/** /**
* 申请员工调职 * 申请员工调职
* @param id * @param data
*/ */
export function applyTransfer(data: EmployeeInfoApi.EmployeeTransferApplyBo) { export function applyTransfer(data: EmployeeInfoApi.EmployeeTransferApplyBo) {
return requestClient.post('/employee/info/applyTransfer', data, { return requestClient.post<EmployeeInfoApi.EmployeeApplyBaseBo>(
successMessageMode: 'modal', '/employee/info/applyTransfer',
}); data,
{
successMessageMode: 'message',
},
);
} }
/** /**
* 申请员工入职 * 申请员工入职
* @param data * @param data
*/ */
export function applyRegular(data: EmployeeInfoApi.EmployeeRegularApplyBo) { export function applyRegular(data: EmployeeInfoApi.EmployeeRegularApplyBo) {
return requestClient.post('/employee/info/applyRegular', data, { return requestClient.post<EmployeeInfoApi.EmployeeApplyBaseBo>(
successMessageMode: 'modal', '/employee/info/applyRegular',
}); data,
{
successMessageMode: 'message',
},
);
} }
/** /**
* 申请员工入职 * 申请员工入职
...@@ -106,9 +122,13 @@ export function applyRegular(data: EmployeeInfoApi.EmployeeRegularApplyBo) { ...@@ -106,9 +122,13 @@ export function applyRegular(data: EmployeeInfoApi.EmployeeRegularApplyBo) {
export function applyRenewalContract( export function applyRenewalContract(
data: EmployeeInfoApi.EmployeeRenewalContractApplyBo, data: EmployeeInfoApi.EmployeeRenewalContractApplyBo,
) { ) {
return requestClient.post('/employee/info/applyRenewalContract', data, { return requestClient.post<EmployeeInfoApi.EmployeeApplyBaseBo>(
successMessageMode: 'modal', '/employee/info/applyRenewalContract',
}); data,
{
successMessageMode: 'message',
},
);
} }
/** /**
......
...@@ -380,6 +380,26 @@ export namespace EmployeeInfoApi { ...@@ -380,6 +380,26 @@ export namespace EmployeeInfoApi {
*/ */
id?: number; id?: number;
/**
* 申请编号
*/
applyCode?: string;
/**
* 流程code
*/
flowCode?: string;
/**
* 员工id
*/
employeeId?: number;
/**
* 部门名称
*/
deptName?: string;
/** /**
* 员工姓名 * 员工姓名
*/ */
...@@ -389,6 +409,11 @@ export namespace EmployeeInfoApi { ...@@ -389,6 +409,11 @@ export namespace EmployeeInfoApi {
* 备注 * 备注
*/ */
remark?: string; remark?: string;
/**
* 审核列表
*/
auditLogList?: AuditLogBo[];
} }
export interface EmployeeApplyBo extends EmployeeApplyBaseBo { export interface EmployeeApplyBo extends EmployeeApplyBaseBo {
...@@ -419,6 +444,11 @@ export namespace EmployeeInfoApi { ...@@ -419,6 +444,11 @@ export namespace EmployeeInfoApi {
* 部门ID * 部门ID
*/ */
deptId?: number; deptId?: number;
/**
* 原先部门
*/
oldDeptName?: string;
} }
export interface EmployeeResignApplyBo extends EmployeeApplyBaseBo { export interface EmployeeResignApplyBo extends EmployeeApplyBaseBo {
...@@ -497,6 +527,27 @@ export namespace EmployeeInfoApi { ...@@ -497,6 +527,27 @@ export namespace EmployeeInfoApi {
} }
} }
/**
* 审核记录
*/
export interface AuditLogBo {
/**
* 字段名称
*/
auditField: string;
/**
* 字段注释名称
*/
auditFieldName: string;
/**
* 变更后值
*/
afterVal: string;
}
// export interface EmployeeResign extends EmployeeInfoApi.Employee { // export interface EmployeeResign extends EmployeeInfoApi.Employee {
// } // }
...@@ -124,7 +124,7 @@ const routes: RouteRecordRaw[] = [ ...@@ -124,7 +124,7 @@ const routes: RouteRecordRaw[] = [
}, },
{ {
name: 'EmployeeFlowList', name: 'EmployeeFlowList',
path: '/hr/employee/flow', path: '/hr/employee/flow/list',
// hidden: false, // hidden: false,
component: () => import('#/views/workflow/hrFlow/list.vue'), component: () => import('#/views/workflow/hrFlow/list.vue'),
meta: { meta: {
...@@ -135,6 +135,20 @@ const routes: RouteRecordRaw[] = [ ...@@ -135,6 +135,20 @@ const routes: RouteRecordRaw[] = [
// link: null, // link: null,
}, },
}, },
{
name: 'EmployeeFlowEdit',
path: '/hr/employee/flow',
// hidden: false,
component: () => import('#/views/workflow/hrFlow/hrEdit.vue'),
meta: {
title: '人事申请编辑',
icon: 'fluent-mdl2:leave-user',
noCache: false,
hideInMenu: true,
componentPath: '#/views/workflow/hrFlow/hrEdit.vue',
// link: null,
},
},
], ],
}, },
]; ];
......
<script lang="ts" setup> <script lang="ts" setup>
import type { ExtendedModalApi } from '@vben/common-ui';
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { EmployeeInfoApi } from '#/api/hr/employeeModel'; import type { EmployeeInfoApi } from '#/api/hr/employeeModel';
import { ref } from 'vue'; import { computed, ref, shallowRef } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Button } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { apiDetail } from '#/api/hr/employeeFlow';
import { applyRenewalContract } from '#/api/hr/employeeInfo'; import { applyRenewalContract } from '#/api/hr/employeeInfo';
import { getDictOptions } from '#/utils/dict'; import { getDictOptions } from '#/utils/dict';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { HrDictEnum } from '../dict-enum'; import { HrDictEnum } from '../dict-enum';
import { useHrFlowHook } from '../useHrFlowHook';
const emit = defineEmits<{ const emit = defineEmits<{
success: []; success: [];
}>(); }>();
const formData = ref<EmployeeInfoApi.EmployeeRenewalContractApplyBo>(); const isUpdate = ref(false);
const formSchema: VbenFormSchema[] = [ const formSchema: VbenFormSchema[] = [
{ {
...@@ -29,6 +35,25 @@ const formSchema: VbenFormSchema[] = [ ...@@ -29,6 +35,25 @@ const formSchema: VbenFormSchema[] = [
triggerFields: [''], triggerFields: [''],
}, },
}, },
{
label: '员工id',
fieldName: 'employeeId',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
component: 'Input',
fieldName: 'applyCode',
label: '申请编号',
dependencies: {
show: () => false,
triggerFields: [''],
},
disabled: true,
},
{ {
component: 'Input', component: 'Input',
fieldName: 'name', fieldName: 'name',
...@@ -109,6 +134,7 @@ const formSchema: VbenFormSchema[] = [ ...@@ -109,6 +134,7 @@ const formSchema: VbenFormSchema[] = [
formItemClass: 'items-start', formItemClass: 'items-start',
}, },
]; ];
const applyModalApi = shallowRef<ExtendedModalApi | null>(null);
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
...@@ -141,45 +167,86 @@ const [BasicModal, modalApi] = useVbenModal({ ...@@ -141,45 +167,86 @@ const [BasicModal, modalApi] = useVbenModal({
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const data = modalApi.getData() as { id?: number; name?: string }; let data = modalApi.getData() as EmployeeInfoApi.EmployeeApplyBaseBo & {
if (data) { applyModalApi: ExtendedModalApi;
formData.value = data; };
await formApi.setValues(formData.value); applyModalApi.value = data.applyModalApi;
isUpdate.value = !!data?.id;
if (isUpdate.value && data.id) {
updateForm(isUpdate.value);
data = await apiDetail(data.id);
updateDataInfo(data);
} }
await formApi.setValues(data);
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
async function onSubmit() { const { handleTempSave, onSubmitFunc, updateDataInfo, updateForm } =
const { valid } = await formApi.validate(); useHrFlowHook(formApi, modalApi, applyRenewalContract, () => {
if (valid) { resetInitialized();
modalApi.lock(); emit('success');
const data = });
await formApi.getValues<EmployeeInfoApi.EmployeeRenewalContractApplyBo>();
try { function onSubmit() {
await applyRenewalContract(data); onSubmitFunc(applyModalApi.value);
resetInitialized();
emit('success');
modalApi.close();
} finally {
modalApi.unlock();
}
}
} }
// function updateDataInfo(data: EmployeeInfoApi.EmployeeApplyBaseBo) {
// if (data.auditLogList && data.auditLogList.length > 0) {
// data.auditLogList.map((t) => {
// if (t && t.auditField) {
// (data as any)[t.auditField] = t.afterVal;
// }
// return t;
// });
// }
// }
// function updateForm(update: boolean) {
// formApi.updateSchema([
// {
// dependencies: {
// show: () => update,
// triggerFields: [''],
// },
// fieldName: 'applyCode',
// },
// ]);
// }
// async function onSubmit() {
// const { valid } = await formApi.validate();
// if (valid) {
// modalApi.lock();
// const data =
// await formApi.getValues<EmployeeInfoApi.EmployeeRenewalContractApplyBo>();
// try {
// await applyRenewalContract(data);
// resetInitialized();
// emit('success');
// modalApi.close();
// } finally {
// modalApi.unlock();
// }
// }
// }
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();
} }
// const getModalTitle = computed(() => const getModalTitle = computed(() =>
// formData.value?.id ? '修改字典类型' : '新增字典类型', isUpdate.value ? '修改合同续约申请' : '合同续约申请',
// ); );
</script> </script>
<template> <template>
<BasicModal title="合同续约申请"> <BasicModal :title="getModalTitle">
<BasicForm class="mx-4" /> <BasicForm class="mx-4" />
<template #center-footer>
<Button @click="handleTempSave">暂存</Button>
</template>
</BasicModal> </BasicModal>
</template> </template>
...@@ -18,8 +18,9 @@ import { GhostButton } from '#/components/global/button'; ...@@ -18,8 +18,9 @@ import { GhostButton } from '#/components/global/button';
import { commonDownloadExcel } from '#/utils/file/download'; import { commonDownloadExcel } from '#/utils/file/download';
import DeptTree from '#/views/auth/user/deptTree.vue'; import DeptTree from '#/views/auth/user/deptTree.vue';
import { applyModal } from '../../workflow/components';
import employeeDetailDrawer from '../employeeInfo/employee-detail-drawer.vue'; import employeeDetailDrawer from '../employeeInfo/employee-detail-drawer.vue';
import applyRenewalContractModel from './apply-renewal_contract-model.vue'; import applyRenewalContractModel from './apply-renewal-contract-model.vue';
import { querySchema, useColumns } from './data'; import { querySchema, useColumns } from './data';
// import Form from './form.vue'; // import Form from './form.vue';
...@@ -64,6 +65,9 @@ const [EmployeeDetailDrawer, employeeDetailDrawerApi] = useVbenDrawer({ ...@@ -64,6 +65,9 @@ const [EmployeeDetailDrawer, employeeDetailDrawerApi] = useVbenDrawer({
const [ApplyRenewalContractModel, applyRenewalContractModelApi] = useVbenModal({ const [ApplyRenewalContractModel, applyRenewalContractModelApi] = useVbenModal({
connectedComponent: applyRenewalContractModel, connectedComponent: applyRenewalContractModel,
}); });
const [ApplyModal, applyModalApi] = useVbenModal({
connectedComponent: applyModal,
});
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions, formOptions,
...@@ -126,14 +130,19 @@ function onApplyRenewalContract( ...@@ -126,14 +130,19 @@ function onApplyRenewalContract(
) { ) {
applyRenewalContractModelApi applyRenewalContractModelApi
.setData({ .setData({
id: row.id, employeeId: row.id,
name: row.name, name: row.name,
deptName: `${row.plate} / ${row.firstLevelDepartment} / ${ deptName: `${row.plate} / ${row.firstLevelDepartment} / ${
row.secondLevelDepartment row.secondLevelDepartment
} / ${row.thirdLevelDepartment}`, } / ${row.thirdLevelDepartment}`,
applyModalApi,
}) })
.open(); .open();
} }
async function handleCompleteOrCancel() {
applyRenewalContractModelApi.close();
gridApi.query();
}
// function onCreate() { // function onCreate() {
// formDrawerApi.setData({}).open(); // formDrawerApi.setData({}).open();
// } // }
...@@ -221,5 +230,9 @@ function handleDownloadExcel() { ...@@ -221,5 +230,9 @@ function handleDownloadExcel() {
</template> </template>
</Grid> </Grid>
<ApplyRenewalContractModel /> <ApplyRenewalContractModel />
<ApplyModal
@complete="handleCompleteOrCancel"
@cancel="handleCompleteOrCancel"
/>
</Page> </Page>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { ExtendedModalApi } from '@vben/common-ui';
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { EmployeeInfoApi } from '#/api/hr/employeeModel'; import type { EmployeeInfoApi } from '#/api/hr/employeeModel';
import { ref } from 'vue'; import { computed, ref, shallowRef } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Button } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { apiDetail } from '#/api/hr/employeeFlow';
import { applyEntry } from '#/api/hr/employeeInfo'; import { applyEntry } from '#/api/hr/employeeInfo';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { useHrFlowHook } from '../useHrFlowHook';
const emit = defineEmits<{ const emit = defineEmits<{
success: []; success: [];
}>(); }>();
const formData = ref<EmployeeInfoApi.EmployeeApplyBo>(); const isUpdate = ref(false);
const formSchema: VbenFormSchema[] = [ const formSchema: VbenFormSchema[] = [
{ {
...@@ -26,6 +33,25 @@ const formSchema: VbenFormSchema[] = [ ...@@ -26,6 +33,25 @@ const formSchema: VbenFormSchema[] = [
triggerFields: [''], triggerFields: [''],
}, },
}, },
{
label: '员工id',
fieldName: 'employeeId',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
component: 'Input',
fieldName: 'applyCode',
label: '申请编号',
dependencies: {
show: () => false,
triggerFields: [''],
},
disabled: true,
},
{ {
component: 'Input', component: 'Input',
fieldName: 'name', fieldName: 'name',
...@@ -82,6 +108,8 @@ const [BasicForm, formApi] = useVbenForm({ ...@@ -82,6 +108,8 @@ const [BasicForm, formApi] = useVbenForm({
wrapperClass: 'grid-cols-2', wrapperClass: 'grid-cols-2',
}); });
const applyModalApi = shallowRef<ExtendedModalApi | null>(null);
const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff( const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
{ {
initializedGetter: defaultFormValueGetter(formApi), initializedGetter: defaultFormValueGetter(formApi),
...@@ -89,55 +117,104 @@ const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff( ...@@ -89,55 +117,104 @@ const { onBeforeClose, markInitialized, resetInitialized } = useBeforeCloseDiff(
}, },
); );
function onSubmit() {
onSubmitFunc(applyModalApi.value);
}
const [BasicModal, modalApi] = useVbenModal({ const [BasicModal, modalApi] = useVbenModal({
fullscreenButton: false, fullscreenButton: false,
onBeforeClose, onBeforeClose,
onClosed: handleClosed, onClosed: handleClosed,
onConfirm: onSubmit, onConfirm: onSubmit,
confirmText: '提交申请',
onOpenChange: async (isOpen) => { onOpenChange: async (isOpen) => {
if (!isOpen) { if (!isOpen) {
return null; return null;
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const data = modalApi.getData() as { id?: number; name?: string }; let data = modalApi.getData() as EmployeeInfoApi.EmployeeApplyBo & {
if (data) { applyModalApi: ExtendedModalApi;
formData.value = data; };
await formApi.setValues(formData.value); applyModalApi.value = data.applyModalApi;
isUpdate.value = !!data?.id;
if (isUpdate.value && data.id) {
updateForm(isUpdate.value);
data = await apiDetail(data.id);
updateDataInfo(data);
} }
await formApi.setValues(data);
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
async function onSubmit() { const { handleTempSave, onSubmitFunc, updateDataInfo, updateForm } =
const { valid } = await formApi.validate(); useHrFlowHook(formApi, modalApi, applyEntry, () => {
if (valid) { resetInitialized();
modalApi.lock(); emit('success');
const data = await formApi.getValues<EmployeeInfoApi.EmployeeApplyBo>(); });
try {
await applyEntry(data); // async function onSubmit() {
resetInitialized(); // const { valid } = await formApi.validate();
emit('success'); // if (valid) {
modalApi.close(); // modalApi.lock();
} finally { // const data = await formApi.getValues<EmployeeInfoApi.EmployeeApplyBo>();
modalApi.unlock(); // try {
} // await applyEntry(data);
} // resetInitialized();
} // emit('success');
// modalApi.close();
// } finally {
// modalApi.unlock();
// }
// }
// }
// /**
// * 暂存/提交 提取通用逻辑
// */
// async function handleSaveOrUpdate() {
// const { valid } = await formApi.validate();
// if (!valid) {
// throw new Error('表单验证失败');
// }
// const data = await formApi.getValues<EmployeeInfoApi.EmployeeApplyBo>();
// return await applyEntry(data);
// }
// /**
// * 暂存 草稿状态
// */
// async function handleTempSave() {
// modalApi.lock();
// try {
// await handleSaveOrUpdate();
// resetInitialized();
// emit('success');
// modalApi.close();
// } catch (error) {
// console.error(error);
// } finally {
// modalApi.unlock();
// }
// }
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();
} }
// const getModalTitle = computed(() => const getModalTitle = computed(() =>
// formData.value?.id ? '修改字典类型' : '新增字典类型', isUpdate.value ? '修改入职申请' : '入职申请',
// ); );
</script> </script>
<template> <template>
<BasicModal title="入职申请"> <BasicModal :title="getModalTitle">
<BasicForm class="mx-4" /> <BasicForm class="mx-4" />
<template #center-footer>
<Button @click="handleTempSave">暂存</Button>
</template>
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { ExtendedModalApi } from '@vben/common-ui';
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { EmployeeInfoApi } from '#/api/hr/employeeModel'; import type { EmployeeInfoApi } from '#/api/hr/employeeModel';
import { ref } from 'vue'; import { computed, ref, shallowRef } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Button } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { apiDetail } from '#/api/hr/employeeFlow';
import { applyResign } from '#/api/hr/employeeInfo'; import { applyResign } from '#/api/hr/employeeInfo';
import { getDictOptions } from '#/utils/dict'; import { getDictOptions } from '#/utils/dict';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { HrDictEnum } from '../dict-enum'; import { HrDictEnum } from '../dict-enum';
import { useHrFlowHook } from '../useHrFlowHook';
const emit = defineEmits<{ const emit = defineEmits<{
success: []; success: [];
}>(); }>();
const formData = ref<EmployeeInfoApi.EmployeeResignApplyBo>(); const isUpdate = ref(false);
const formSchema: VbenFormSchema[] = [ const formSchema: VbenFormSchema[] = [
{ {
...@@ -29,6 +35,25 @@ const formSchema: VbenFormSchema[] = [ ...@@ -29,6 +35,25 @@ const formSchema: VbenFormSchema[] = [
triggerFields: [''], triggerFields: [''],
}, },
}, },
{
label: '员工id',
fieldName: 'employeeId',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
component: 'Input',
fieldName: 'applyCode',
label: '申请编号',
dependencies: {
show: () => false,
triggerFields: [''],
},
disabled: true,
},
{ {
component: 'Input', component: 'Input',
fieldName: 'name', fieldName: 'name',
...@@ -49,6 +74,7 @@ const formSchema: VbenFormSchema[] = [ ...@@ -49,6 +74,7 @@ const formSchema: VbenFormSchema[] = [
options: getDictOptions(HrDictEnum.HR_RESIGNATION_TYPE), options: getDictOptions(HrDictEnum.HR_RESIGNATION_TYPE),
}, },
fieldName: 'resignationType', fieldName: 'resignationType',
defaultValue: '1',
label: '离职类型', label: '离职类型',
rules: 'required', rules: 'required',
}, },
...@@ -93,6 +119,7 @@ const formSchema: VbenFormSchema[] = [ ...@@ -93,6 +119,7 @@ const formSchema: VbenFormSchema[] = [
formItemClass: 'items-start', formItemClass: 'items-start',
}, },
]; ];
const applyModalApi = shallowRef<ExtendedModalApi | null>(null);
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
...@@ -125,45 +152,92 @@ const [BasicModal, modalApi] = useVbenModal({ ...@@ -125,45 +152,92 @@ const [BasicModal, modalApi] = useVbenModal({
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const data = modalApi.getData() as { id?: number; name?: string }; let data = modalApi.getData() as EmployeeInfoApi.EmployeeResignApplyBo & {
if (data) { applyModalApi: ExtendedModalApi;
formData.value = data; };
await formApi.setValues(formData.value); applyModalApi.value = data.applyModalApi;
isUpdate.value = !!data?.id;
if (isUpdate.value && data.id) {
updateForm(isUpdate.value);
data = await apiDetail(data.id);
updateDataInfo(data, mapDict);
} }
await formApi.setValues(data);
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
async function onSubmit() { const { handleTempSave, onSubmitFunc, updateDataInfo, updateForm } =
const { valid } = await formApi.validate(); useHrFlowHook(formApi, modalApi, applyResign, () => {
if (valid) { resetInitialized();
modalApi.lock(); emit('success');
const data = });
await formApi.getValues<EmployeeInfoApi.EmployeeResignApplyBo>();
try { function onSubmit() {
await applyResign(data); onSubmitFunc(applyModalApi.value);
resetInitialized();
emit('success');
modalApi.close();
} finally {
modalApi.unlock();
}
}
} }
const mapDict: Record<string, string> = {
resignationType: 'resignationType',
resignationDate: 'resignDate',
resignationReason: 'resignReason',
finalPayDate: 'finalPayDate',
};
// function updateDataInfo(data: EmployeeInfoApi.EmployeeApplyBaseBo) {
// if (data.auditLogList && data.auditLogList.length > 0) {
// data.auditLogList.map((t) => {
// if (t && t.auditField) {
// (data as any)[mapDict[t.auditField]!] = t.afterVal;
// }
// return t;
// });
// }
// }
// function updateForm(update: boolean) {
// formApi.updateSchema([
// {
// dependencies: {
// show: () => update,
// triggerFields: [''],
// },
// fieldName: 'applyCode',
// },
// ]);
// }
// async function onSubmit() {
// const { valid } = await formApi.validate();
// if (valid) {
// modalApi.lock();
// const data =
// await formApi.getValues<EmployeeInfoApi.EmployeeResignApplyBo>();
// try {
// await applyResign(data);
// resetInitialized();
// emit('success');
// modalApi.close();
// } finally {
// modalApi.unlock();
// }
// }
// }
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();
} }
// const getModalTitle = computed(() => const getModalTitle = computed(() =>
// formData.value?.id ? '修改字典类型' : '新增字典类型', isUpdate.value ? '修改离职申请' : '离职申请',
// ); );
</script> </script>
<template> <template>
<BasicModal title="离职申请"> <BasicModal :title="getModalTitle">
<BasicForm class="mx-4" /> <BasicForm class="mx-4" />
<template #center-footer>
<Button @click="handleTempSave">暂存</Button>
</template>
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { ExtendedModalApi } from '@vben/common-ui';
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { EmployeeInfoApi } from '#/api/hr/employeeModel'; import type { EmployeeInfoApi } from '#/api/hr/employeeModel';
import { ref } from 'vue'; import { computed, ref, shallowRef } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { addFullName, getVxePopupContainer } from '@vben/utils'; import { addFullName, getVxePopupContainer } from '@vben/utils';
import { Button } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { treeList } from '#/api/auth/dept'; import { treeList } from '#/api/auth/dept';
import { apiDetail } from '#/api/hr/employeeFlow';
import { applyTransfer } from '#/api/hr/employeeInfo'; import { applyTransfer } from '#/api/hr/employeeInfo';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { useHrFlowHook } from '../useHrFlowHook';
const emit = defineEmits<{ const emit = defineEmits<{
success: []; success: [];
}>(); }>();
const formData = ref<EmployeeInfoApi.EmployeeTransferApplyBo>(); const isUpdate = ref(false);
const formSchema: VbenFormSchema[] = [ const formSchema: VbenFormSchema[] = [
{ {
...@@ -27,6 +34,25 @@ const formSchema: VbenFormSchema[] = [ ...@@ -27,6 +34,25 @@ const formSchema: VbenFormSchema[] = [
triggerFields: [''], triggerFields: [''],
}, },
}, },
{
label: '员工id',
fieldName: 'employeeId',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
component: 'Input',
fieldName: 'applyCode',
label: '申请编号',
dependencies: {
show: () => false,
triggerFields: [''],
},
disabled: true,
},
{ {
component: 'Input', component: 'Input',
fieldName: 'name', fieldName: 'name',
...@@ -113,6 +139,7 @@ const formSchema: VbenFormSchema[] = [ ...@@ -113,6 +139,7 @@ const formSchema: VbenFormSchema[] = [
formItemClass: 'items-start', formItemClass: 'items-start',
}, },
]; ];
const applyModalApi = shallowRef<ExtendedModalApi | null>(null);
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
...@@ -145,45 +172,87 @@ const [BasicModal, modalApi] = useVbenModal({ ...@@ -145,45 +172,87 @@ const [BasicModal, modalApi] = useVbenModal({
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const data = modalApi.getData() as { id?: number; name?: string }; let data = modalApi.getData() as EmployeeInfoApi.EmployeeTransferApplyBo & {
if (data) { applyModalApi: ExtendedModalApi;
formData.value = data; };
await formApi.setValues(formData.value); applyModalApi.value = data.applyModalApi;
isUpdate.value = !!data?.id;
if (isUpdate.value && data.id) {
updateForm(isUpdate.value);
data = await apiDetail(data.id);
data.oldDeptName = data.deptName;
updateDataInfo(data);
} }
await formApi.setValues(data);
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
async function onSubmit() { const { handleTempSave, onSubmitFunc, updateDataInfo, updateForm } =
const { valid } = await formApi.validate(); useHrFlowHook(formApi, modalApi, applyTransfer, () => {
if (valid) { resetInitialized();
modalApi.lock(); emit('success');
const data = });
await formApi.getValues<EmployeeInfoApi.EmployeeTransferApplyBo>();
try { function onSubmit() {
await applyTransfer(data); onSubmitFunc(applyModalApi.value);
resetInitialized();
emit('success');
modalApi.close();
} finally {
modalApi.unlock();
}
}
} }
// function updateDataInfo(data: EmployeeInfoApi.EmployeeApplyBaseBo) {
// if (data.auditLogList && data.auditLogList.length > 0) {
// data.auditLogList.map((t) => {
// if (t && t.auditField) {
// (data as any)[t.auditField] = t.afterVal;
// }
// return t;
// });
// }
// }
// function updateForm(update: boolean) {
// formApi.updateSchema([
// {
// dependencies: {
// show: () => update,
// triggerFields: [''],
// },
// fieldName: 'applyCode',
// },
// ]);
// }
// async function onSubmit() {
// const { valid } = await formApi.validate();
// if (valid) {
// modalApi.lock();
// const data =
// await formApi.getValues<EmployeeInfoApi.EmployeeTransferApplyBo>();
// try {
// await applyTransfer(data);
// resetInitialized();
// emit('success');
// modalApi.close();
// } finally {
// modalApi.unlock();
// }
// }
// }
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();
} }
// const getModalTitle = computed(() => const getModalTitle = computed(() =>
// formData.value?.id ? '修改字典类型' : '新增字典类型', isUpdate.value ? '修改调配申请' : '调配申请',
// ); );
</script> </script>
<template> <template>
<BasicModal title="调配申请"> <BasicModal :title="getModalTitle">
<BasicForm class="mx-4" /> <BasicForm class="mx-4" />
<template #center-footer>
<Button @click="handleTempSave">暂存</Button>
</template>
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { VbenFormProps } from '@vben/common-ui'; import type { ExtendedModalApi, VbenFormProps } from '@vben/common-ui';
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { EmployeeInfoApi } from '#/api/hr/employeeModel'; import type { EmployeeInfoApi } from '#/api/hr/employeeModel';
import { ref } from 'vue'; import { ref, shallowRef } from 'vue';
import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui';
...@@ -26,6 +26,7 @@ import { GhostButton } from '#/components/global/button'; ...@@ -26,6 +26,7 @@ import { GhostButton } from '#/components/global/button';
import { commonDownloadExcel } from '#/utils/file/download'; import { commonDownloadExcel } from '#/utils/file/download';
import DeptTree from '#/views/auth/user/deptTree.vue'; import DeptTree from '#/views/auth/user/deptTree.vue';
import { applyModal } from '../../workflow/components';
import applyEntryModel from './apply-entry-model.vue'; import applyEntryModel from './apply-entry-model.vue';
import applyResignModel from './apply-resign-model.vue'; import applyResignModel from './apply-resign-model.vue';
import applyTransferModel from './apply-transfer-model.vue'; import applyTransferModel from './apply-transfer-model.vue';
...@@ -44,6 +45,9 @@ function handleImport() { ...@@ -44,6 +45,9 @@ function handleImport() {
employeeImportModalApi.open(); employeeImportModalApi.open();
} }
const [ApplyModal, applyModalApi] = useVbenModal({
connectedComponent: applyModal,
});
const [ApplyEntryModel, applyEntryModelApi] = useVbenModal({ const [ApplyEntryModel, applyEntryModelApi] = useVbenModal({
connectedComponent: applyEntryModel, connectedComponent: applyEntryModel,
}); });
...@@ -54,6 +58,7 @@ const [ApplyResignModel, applyResignModelApi] = useVbenModal({ ...@@ -54,6 +58,7 @@ const [ApplyResignModel, applyResignModelApi] = useVbenModal({
connectedComponent: applyResignModel, connectedComponent: applyResignModel,
}); });
const modalApi = shallowRef<ExtendedModalApi | null>(null);
// 左边部门用 // 左边部门用
const selectDeptId = ref<number[]>([]); const selectDeptId = ref<number[]>([]);
const formOptions: VbenFormProps = { const formOptions: VbenFormProps = {
...@@ -138,40 +143,53 @@ function onCreate() { ...@@ -138,40 +143,53 @@ function onCreate() {
formDrawerApi.setData({}).open(); formDrawerApi.setData({}).open();
} }
function onEntryApply(row: EmployeeInfoApi.Employee) { function onEntryApply(row: EmployeeInfoApi.Employee) {
modalApi.value = applyEntryModelApi;
applyEntryModelApi applyEntryModelApi
.setData({ .setData({
id: row.id, employeeId: row.id,
name: row.name, name: row.name,
deptName: `${row.plate} / ${row.firstLevelDepartment} / ${ deptName: `${row.plate} / ${row.firstLevelDepartment} / ${
row.secondLevelDepartment row.secondLevelDepartment
} / ${row.thirdLevelDepartment}`, } / ${row.thirdLevelDepartment}`,
applyModalApi,
}) })
.open(); .open();
} }
function onResign(row: EmployeeInfoApi.Employee) { function onResign(row: EmployeeInfoApi.Employee) {
modalApi.value = applyResignModelApi;
applyResignModelApi applyResignModelApi
.setData({ .setData({
id: row.id, employeeId: row.id,
name: row.name, name: row.name,
deptName: `${row.plate} / ${row.firstLevelDepartment} / ${ deptName: `${row.plate} / ${row.firstLevelDepartment} / ${
row.secondLevelDepartment row.secondLevelDepartment
} / ${row.thirdLevelDepartment}`, } / ${row.thirdLevelDepartment}`,
applyModalApi,
}) })
.open(); .open();
} }
function onTransfer(row: EmployeeInfoApi.Employee) { function onTransfer(row: EmployeeInfoApi.Employee) {
modalApi.value = applyTransferModelApi;
applyTransferModelApi applyTransferModelApi
.setData({ .setData({
id: row.id, employeeId: row.id,
name: row.name, name: row.name,
oldDeptName: `${row.plate} / ${row.firstLevelDepartment} / ${ oldDeptName: `${row.plate} / ${row.firstLevelDepartment} / ${
row.secondLevelDepartment row.secondLevelDepartment
} / ${row.thirdLevelDepartment}`, } / ${row.thirdLevelDepartment}`,
applyModalApi,
}) })
.open(); .open();
} }
async function handleCompleteOrCancel() {
if (modalApi.value) {
modalApi.value.close();
}
gridApi.query();
}
function handleDownloadExcel(row: EmployeeInfoApi.Employee) { function handleDownloadExcel(row: EmployeeInfoApi.Employee) {
commonDownloadExcel(apiExport, '员工信息', row.id); commonDownloadExcel(apiExport, '员工信息', row.id);
} }
...@@ -248,18 +266,21 @@ function handleDownloadEmployeeList() { ...@@ -248,18 +266,21 @@ function handleDownloadEmployeeList() {
查看 查看
</GhostButton> </GhostButton>
<GhostButton <GhostButton
v-if="[0].includes(row.status)"
v-access:code="['employee:info:edit']" v-access:code="['employee:info:edit']"
@click.stop="onEdit(row)" @click.stop="onEdit(row)"
> >
编辑 编辑
</GhostButton> </GhostButton>
<GhostButton <GhostButton
v-if="[0].includes(row.status)"
v-access:code="['employee:info:add']" v-access:code="['employee:info:add']"
@click.stop="onEntryApply(row)" @click.stop="onEntryApply(row)"
> >
申请入职 申请入职
</GhostButton> </GhostButton>
<GhostButton <GhostButton
v-if="[1, 2].includes(row.status)"
v-access:code="['employee:info:edit']" v-access:code="['employee:info:edit']"
@click.stop="onTransfer(row)" @click.stop="onTransfer(row)"
> >
...@@ -267,6 +288,7 @@ function handleDownloadEmployeeList() { ...@@ -267,6 +288,7 @@ function handleDownloadEmployeeList() {
</GhostButton> </GhostButton>
<GhostButton <GhostButton
danger danger
v-if="[1, 2].includes(row.status)"
v-access:code="['employee:info:resign']" v-access:code="['employee:info:resign']"
@click.stop="onResign(row)" @click.stop="onResign(row)"
> >
...@@ -277,8 +299,12 @@ function handleDownloadEmployeeList() { ...@@ -277,8 +299,12 @@ function handleDownloadEmployeeList() {
</template> </template>
</Grid> </Grid>
<EmployeeImportModal @reload="onRefresh" /> <EmployeeImportModal @reload="onRefresh" />
<ApplyEntryModel @reload="onRefresh" /> <ApplyEntryModel />
<ApplyTransferModel @reload="onRefresh" /> <ApplyTransferModel />
<ApplyResignModel @reload="onRefresh" /> <ApplyResignModel />
<ApplyModal
@complete="handleCompleteOrCancel"
@cancel="handleCompleteOrCancel"
/>
</Page> </Page>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import type { ExtendedModalApi } from '@vben/common-ui';
import type { VbenFormSchema } from '#/adapter/form'; import type { VbenFormSchema } from '#/adapter/form';
import type { EmployeeInfoApi } from '#/api/hr/employeeModel'; import type { EmployeeInfoApi } from '#/api/hr/employeeModel';
import { ref } from 'vue'; import { computed, ref, shallowRef } from 'vue';
import { useVbenModal } from '@vben/common-ui'; import { useVbenModal } from '@vben/common-ui';
import { DictEnum } from '@vben/constants'; import { DictEnum } from '@vben/constants';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Button } from 'ant-design-vue';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { apiDetail } from '#/api/hr/employeeFlow';
import { applyRegular } from '#/api/hr/employeeInfo'; import { applyRegular } from '#/api/hr/employeeInfo';
import { getDictOptions } from '#/utils/dict'; import { getDictOptions } from '#/utils/dict';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
import { useHrFlowHook } from '../useHrFlowHook';
const emit = defineEmits<{ const emit = defineEmits<{
success: []; success: [];
}>(); }>();
const formData = ref<EmployeeInfoApi.EmployeeRegularApplyBo>(); const isUpdate = ref(false);
const formSchema: VbenFormSchema[] = [ const formSchema: VbenFormSchema[] = [
{ {
...@@ -28,6 +35,25 @@ const formSchema: VbenFormSchema[] = [ ...@@ -28,6 +35,25 @@ const formSchema: VbenFormSchema[] = [
triggerFields: [''], triggerFields: [''],
}, },
}, },
{
label: '员工id',
fieldName: 'employeeId',
component: 'Input',
dependencies: {
show: () => false,
triggerFields: [''],
},
},
{
component: 'Input',
fieldName: 'applyCode',
label: '申请编号',
dependencies: {
show: () => false,
triggerFields: [''],
},
disabled: true,
},
{ {
component: 'Input', component: 'Input',
fieldName: 'name', fieldName: 'name',
...@@ -142,6 +168,7 @@ const formSchema: VbenFormSchema[] = [ ...@@ -142,6 +168,7 @@ const formSchema: VbenFormSchema[] = [
formItemClass: 'items-start', formItemClass: 'items-start',
}, },
]; ];
const applyModalApi = shallowRef<ExtendedModalApi | null>(null);
const [BasicForm, formApi] = useVbenForm({ const [BasicForm, formApi] = useVbenForm({
commonConfig: { commonConfig: {
...@@ -174,45 +201,86 @@ const [BasicModal, modalApi] = useVbenModal({ ...@@ -174,45 +201,86 @@ const [BasicModal, modalApi] = useVbenModal({
} }
modalApi.modalLoading(true); modalApi.modalLoading(true);
const data = modalApi.getData() as { id?: number; name?: string }; let data = modalApi.getData() as EmployeeInfoApi.EmployeeApplyBaseBo & {
if (data) { applyModalApi: ExtendedModalApi;
formData.value = data; };
await formApi.setValues(formData.value); applyModalApi.value = data.applyModalApi;
isUpdate.value = !!data?.id;
if (isUpdate.value && data.id) {
updateForm(isUpdate.value);
data = await apiDetail(data.id);
updateDataInfo(data);
} }
await formApi.setValues(data);
await markInitialized(); await markInitialized();
modalApi.modalLoading(false); modalApi.modalLoading(false);
}, },
}); });
async function onSubmit() { const { handleTempSave, onSubmitFunc, updateDataInfo, updateForm } =
const { valid } = await formApi.validate(); useHrFlowHook(formApi, modalApi, applyRegular, () => {
if (valid) { resetInitialized();
modalApi.lock(); emit('success');
const data = });
await formApi.getValues<EmployeeInfoApi.EmployeeRegularApplyBo>();
try { function onSubmit() {
await applyRegular(data); onSubmitFunc(applyModalApi.value);
resetInitialized();
emit('success');
modalApi.close();
} finally {
modalApi.unlock();
}
}
} }
// function updateDataInfo(data: EmployeeInfoApi.EmployeeApplyBaseBo) {
// if (data.auditLogList && data.auditLogList.length > 0) {
// data.auditLogList.map((t) => {
// if (t && t.auditField) {
// (data as any)[t.auditField] = t.afterVal;
// }
// return t;
// });
// }
// }
// function updateForm(update: boolean) {
// formApi.updateSchema([
// {
// dependencies: {
// show: () => update,
// triggerFields: [''],
// },
// fieldName: 'applyCode',
// },
// ]);
// }
// async function onSubmit() {
// const { valid } = await formApi.validate();
// if (valid) {
// modalApi.lock();
// const data =
// await formApi.getValues<EmployeeInfoApi.EmployeeRegularApplyBo>();
// try {
// await applyRegular(data);
// resetInitialized();
// emit('success');
// modalApi.close();
// } finally {
// modalApi.unlock();
// }
// }
// }
async function handleClosed() { async function handleClosed() {
await formApi.resetForm(); await formApi.resetForm();
resetInitialized(); resetInitialized();
} }
// const getModalTitle = computed(() => const getModalTitle = computed(() =>
// formData.value?.id ? '修改字典类型' : '新增字典类型', isUpdate.value ? '修改转正申请' : '转正申请',
// ); );
</script> </script>
<template> <template>
<BasicModal title="转正申请"> <BasicModal :title="getModalTitle">
<BasicForm class="mx-4" /> <BasicForm class="mx-4" />
<template #center-footer>
<Button @click="handleTempSave">暂存</Button>
</template>
</BasicModal> </BasicModal>
</template> </template>
...@@ -18,6 +18,7 @@ import { GhostButton } from '#/components/global/button'; ...@@ -18,6 +18,7 @@ import { GhostButton } from '#/components/global/button';
import { commonDownloadExcel } from '#/utils/file/download'; import { commonDownloadExcel } from '#/utils/file/download';
import DeptTree from '#/views/auth/user/deptTree.vue'; import DeptTree from '#/views/auth/user/deptTree.vue';
import { applyModal } from '../../workflow/components';
import employeeDetailDrawer from '../employeeInfo/employee-detail-drawer.vue'; import employeeDetailDrawer from '../employeeInfo/employee-detail-drawer.vue';
import applyRegularModel from './apply-regular-model.vue'; import applyRegularModel from './apply-regular-model.vue';
import { querySchema, useColumns } from './data'; import { querySchema, useColumns } from './data';
...@@ -64,6 +65,9 @@ const [EmployeeDetailDrawer, employeeDetailDrawerApi] = useVbenDrawer({ ...@@ -64,6 +65,9 @@ const [EmployeeDetailDrawer, employeeDetailDrawerApi] = useVbenDrawer({
const [ApplyRegularModel, applyRegularModelApi] = useVbenModal({ const [ApplyRegularModel, applyRegularModelApi] = useVbenModal({
connectedComponent: applyRegularModel, connectedComponent: applyRegularModel,
}); });
const [ApplyModal, applyModalApi] = useVbenModal({
connectedComponent: applyModal,
});
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions, formOptions,
...@@ -126,14 +130,19 @@ function onApplyRegular( ...@@ -126,14 +130,19 @@ function onApplyRegular(
) { ) {
applyRegularModelApi applyRegularModelApi
.setData({ .setData({
id: row.id, employeeId: row.id,
name: row.name, name: row.name,
deptName: `${row.plate} / ${row.firstLevelDepartment} / ${ deptName: `${row.plate} / ${row.firstLevelDepartment} / ${
row.secondLevelDepartment row.secondLevelDepartment
} / ${row.thirdLevelDepartment}`, } / ${row.thirdLevelDepartment}`,
applyModalApi,
}) })
.open(); .open();
} }
async function handleCompleteOrCancel() {
applyRegularModelApi.close();
gridApi.query();
}
// function onCreate() { // function onCreate() {
// formDrawerApi.setData({}).open(); // formDrawerApi.setData({}).open();
// } // }
...@@ -217,5 +226,9 @@ function handleDownloadExcel() { ...@@ -217,5 +226,9 @@ function handleDownloadExcel() {
</template> </template>
</Grid> </Grid>
<ApplyRegularModel /> <ApplyRegularModel />
<ApplyModal
@complete="handleCompleteOrCancel"
@cancel="handleCompleteOrCancel"
/>
</Page> </Page>
</template> </template>
import type { ExtendedFormApi, ExtendedModalApi } from '@vben/common-ui';
import type { EmployeeInfoApi } from '#/api/hr/employeeModel';
import type { StartWorkFlowReqData } from '#/api/workflow/task/model';
import { startWorkFlow } from '#/api/workflow/task';
export function useHrFlowHook(
formApi: ExtendedFormApi,
modalApi: ExtendedModalApi,
applyFunc: <T extends EmployeeInfoApi.EmployeeApplyBaseBo>(
data: T,
) => Promise<EmployeeInfoApi.EmployeeApplyBaseBo>,
callback: () => void,
) {
/**
* 暂存/提交 提取通用逻辑
*/
async function handleSaveOrUpdate() {
const { valid } = await formApi.validate();
if (!valid) {
throw new Error('表单验证失败');
}
const data = await formApi.getValues<EmployeeInfoApi.EmployeeApplyBaseBo>();
return await applyFunc(data);
}
/**
* 暂存 草稿状态
*/
async function handleTempSave() {
modalApi.lock();
try {
await handleSaveOrUpdate();
callback();
// resetInitialized();
// emit('success');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.unlock();
}
}
async function onSubmitFunc(applyModelApi: ExtendedModalApi | null) {
modalApi.lock();
try {
const applyResp = await handleSaveOrUpdate();
initAndStartFlow(applyResp, applyModelApi);
callback();
// resetInitialized();
// emit('success');
modalApi.close();
} catch (error) {
console.error(error);
} finally {
modalApi.unlock();
}
}
async function initAndStartFlow(
applyResp: EmployeeInfoApi.EmployeeApplyBaseBo,
applyModelApi: ExtendedModalApi | null,
) {
// 启动流程
const taskVariables = {
leaveDays: applyResp.name,
userList: [applyResp.employeeId],
};
// const formValues = await formApi.getValues();
// const flowCode = formValues?.flowType ?? 'leave1';
const startWorkFlowData: StartWorkFlowReqData = {
businessId: applyResp.id,
flowCode: applyResp.flowCode || 'hrEntryFlow',
variables: taskVariables,
flowInstanceBizExtBo: {
businessTitle: '申请',
businessCode: applyResp.applyCode,
},
};
const { taskId } = await startWorkFlow(startWorkFlowData);
// 打开窗口
applyModelApi?.setData({
taskId,
taskVariables,
variables: {},
});
applyModelApi?.open();
}
function updateDataInfo(
data: EmployeeInfoApi.EmployeeApplyBo,
mapDict?: Record<string, string>,
) {
if (data.auditLogList && data.auditLogList.length > 0) {
if (mapDict) {
data.auditLogList.map((t) => {
if (t && t.auditField) {
// 使用中间变量进行类型检查
const targetField = mapDict?.[t.auditField] ?? t.auditField;
if (targetField) {
(data as any)[targetField] = t.afterVal;
}
}
return t;
});
} else {
data.auditLogList.map((t) => {
if (t && t.auditField) {
(data as any)[t.auditField] = t.afterVal;
}
return t;
});
}
}
}
function updateForm(update: boolean) {
formApi.updateSchema([
{
dependencies: {
show: () => update,
triggerFields: [''],
},
fieldName: 'applyCode',
},
]);
}
return {
handleTempSave,
onSubmitFunc,
updateDataInfo,
updateForm,
};
}
...@@ -97,7 +97,10 @@ const router = useRouter(); ...@@ -97,7 +97,10 @@ const router = useRouter();
function handleEdit() { function handleEdit() {
const path = props.task?.formPath; const path = props.task?.formPath;
if (path) { if (path) {
router.push({ path, query: { id: props.task!.businessId } }); router.push({
path,
query: { id: props.task!.businessId, flowCode: props.task!.flowCode },
});
} }
} }
...@@ -174,10 +177,10 @@ function handleDelegation(userList: User[]) { ...@@ -174,10 +177,10 @@ function handleDelegation(userList: User[]) {
const current = userList[0]; const current = userList[0];
approveWithReasonModal({ approveWithReasonModal({
title: '委托', title: '委托',
description: `确定委托给[${current?.nickName}]?`, description: `确定委托给[${current?.name}]?`,
onOk: async (reason) => { onOk: async (reason) => {
await taskOperation( await taskOperation(
{ taskId: props.task!.id, userId: current!.userId, message: reason }, { taskId: props.task!.id, userId: current!.id, message: reason },
'delegateTask', 'delegateTask',
); );
emit('reload'); emit('reload');
...@@ -196,10 +199,10 @@ function handleTransfer(userList: User[]) { ...@@ -196,10 +199,10 @@ function handleTransfer(userList: User[]) {
const current = userList[0]; const current = userList[0];
approveWithReasonModal({ approveWithReasonModal({
title: '转办', title: '转办',
description: `确定转办给[${current?.nickName}]?`, description: `确定转办给[${current?.name}]?`,
onOk: async (reason) => { onOk: async (reason) => {
await taskOperation( await taskOperation(
{ taskId: props.task!.id, userId: current!.userId, message: reason }, { taskId: props.task!.id, userId: current!.id, message: reason },
'transferTask', 'transferTask',
); );
emit('reload'); emit('reload');
...@@ -212,7 +215,7 @@ const [AddSignatureModal, addSignatureModalApi] = useVbenModal({ ...@@ -212,7 +215,7 @@ const [AddSignatureModal, addSignatureModalApi] = useVbenModal({
}); });
function handleAddSignature(userList: User[]) { function handleAddSignature(userList: User[]) {
if (userList.length === 0) return; if (userList.length === 0) return;
const userIds = userList.map((user) => user.userId); const userIds = userList.map((user) => user.id);
Modal.confirm({ Modal.confirm({
title: '提示', title: '提示',
content: '确认加签吗?', content: '确认加签吗?',
...@@ -229,7 +232,7 @@ const [ReductionSignatureModal, reductionSignatureModalApi] = useVbenModal({ ...@@ -229,7 +232,7 @@ const [ReductionSignatureModal, reductionSignatureModalApi] = useVbenModal({
}); });
function handleReductionSignature(userList: User[]) { function handleReductionSignature(userList: User[]) {
if (userList.length === 0) return; if (userList.length === 0) return;
const userIds = userList.map((user) => user.userId); const userIds = userList.map((user) => user.id);
Modal.confirm({ Modal.confirm({
title: '提示', title: '提示',
content: '确认减签吗?', content: '确认减签吗?',
...@@ -263,10 +266,10 @@ function handleUpdateAssignee(userList: User[]) { ...@@ -263,10 +266,10 @@ function handleUpdateAssignee(userList: User[]) {
if (!current) return; if (!current) return;
Modal.confirm({ Modal.confirm({
title: '修改办理人', title: '修改办理人',
content: `确定修改办理人为${current?.nickName}?`, content: `确定修改办理人为${current?.name}?`,
centered: true, centered: true,
onOk: async () => { onOk: async () => {
await updateAssignee([props.task!.id], current.userId); await updateAssignee([props.task!.id], current.id);
emit('reload'); emit('reload');
}, },
}); });
......
...@@ -7,7 +7,7 @@ import { computed, ref } from 'vue'; ...@@ -7,7 +7,7 @@ import { computed, ref } from 'vue';
import { useVbenDrawer } from '@vben/common-ui'; import { useVbenDrawer } from '@vben/common-ui';
import { useVbenForm } from '#/adapter/form'; import { useVbenForm } from '#/adapter/form';
import { apiAdd, apiUpdate } from '#/api/hr/employeeFlow'; import { apiAdd, apiDetail, apiUpdate } from '#/api/hr/employeeFlow';
import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup'; import { defaultFormValueGetter, useBeforeCloseDiff } from '#/utils/popup';
const emit = defineEmits<{ const emit = defineEmits<{
...@@ -29,20 +29,23 @@ const formSchema: VbenFormSchema[] = [ ...@@ -29,20 +29,23 @@ const formSchema: VbenFormSchema[] = [
component: 'Input', component: 'Input',
fieldName: 'applyCode', fieldName: 'applyCode',
label: '申请编号', label: '申请编号',
rules: 'required', disabled: true,
// rules: 'required',
}, },
{ {
component: 'Select', component: 'Select',
componentProps: {}, componentProps: {},
fieldName: 'flowType', fieldName: 'flowType',
label: '审批类型', label: '审批类型',
rules: 'selectRequired', disabled: true,
// rules: 'selectRequired',
}, },
{ {
component: 'Input', component: 'Input',
fieldName: 'employeeId', fieldName: 'employeeId',
label: '员工信息ID', label: '员工信息ID',
rules: 'required', disabled: true,
// rules: 'required',
}, },
// { // {
// component: 'DatePicker', // component: 'DatePicker',
...@@ -102,10 +105,13 @@ const [Drawer, drawerApi] = useVbenDrawer({ ...@@ -102,10 +105,13 @@ const [Drawer, drawerApi] = useVbenDrawer({
if (!isOpen) { if (!isOpen) {
return null; return null;
} }
const data = drawerApi.getData<EmployeeFlowApi.EmployeeFlow>(); const { id } = drawerApi.getData<EmployeeFlowApi.EmployeeFlow>() as {
isUpdate.value = !!data?.id; id?: number;
if (isUpdate.value) { };
await formApi.setValues(formData.value); isUpdate.value = !!id;
if (isUpdate.value && id) {
const data = await apiDetail(id);
await formApi.setValues(data);
} else { } else {
formApi.resetForm(); formApi.resetForm();
} }
......
import { onActivated, onMounted, ref } from 'vue';
import { createGlobalState } from '@vueuse/core';
export function useRouteIdEdit(
callback: (id: string, flowCode: string) => void,
timeout = 800,
) {
const { businessId, flowCodeRef } = useQueryId();
function openEditFromRouteId() {
const id = businessId.value;
const flowCode = flowCodeRef.value;
if (!id) {
return;
}
setTimeout(() => {
// 回调
callback?.(id, flowCode);
// 执行完 清理id
businessId.value = '';
}, timeout);
}
onMounted(openEditFromRouteId);
onActivated(openEditFromRouteId);
}
/**
* 用来存储业务ID 传值
*/
export const useQueryId = createGlobalState(() => {
const businessId = ref('');
const flowCodeRef = ref('');
return {
businessId,
flowCodeRef,
};
});
<!--
后端版本>=5.4.0 这个从本地路由变为从后台返回
未修改文件名 而是新加了这个文件
-->
<script setup lang="ts">
import { onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useTabs } from '@vben/hooks';
import { Spin } from 'ant-design-vue';
import { useQueryId } from './hook';
const router = useRouter();
const route = useRoute();
const id = route.query.id as string;
const flowCode = route.query.flowCode as string;
/**
* 从我的任务 -> 点击重新编辑会跳转到这里
* 相当于一个中转 因为我的任务无法获取到列表页的路径(与ele交互不同)
*
* 为什么不使用路由的query来实现?
* 因为刷新后参数不会丢失 且tab存的也是全路径 切换也不会丢失 这不符合预期
* 可以通过window.history.replaceState来删除query参数 但是tab切换还是会保留
*/
const { closeCurrentTab } = useTabs();
const { businessId, flowCodeRef } = useQueryId();
onMounted(async () => {
await closeCurrentTab();
if (id) {
// 设置业务ID 存储在内存
businessId.value = id;
flowCodeRef.value = flowCode;
router.push({ path: '/hr/employee/flow/list' });
}
});
</script>
<template>
<div>
<Spin :spinning="true" />
</div>
</template>
<script lang="ts" setup> <script lang="ts" setup>
import type { VbenFormProps } from '@vben/common-ui'; import type { ExtendedModalApi, VbenFormProps } from '@vben/common-ui';
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { EmployeeFlowApi } from '#/api/hr/employeeFlow'; import type { EmployeeFlowApi } from '#/api/hr/employeeFlow';
import { Page, useVbenDrawer, useVbenModal } from '@vben/common-ui'; import { shallowRef } from 'vue';
import { Plus } from '@vben/icons';
import { Page, useVbenModal } from '@vben/common-ui';
import { getVxePopupContainer } from '@vben/utils'; import { getVxePopupContainer } from '@vben/utils';
import { Button, message, Popconfirm, Space } from 'ant-design-vue'; import { Button, message, Popconfirm, Space } from 'ant-design-vue';
...@@ -15,9 +16,14 @@ import { apiDelete, apiExport, apiPage } from '#/api/hr/employeeFlow'; ...@@ -15,9 +16,14 @@ import { apiDelete, apiExport, apiPage } from '#/api/hr/employeeFlow';
import { cancelProcessApply } from '#/api/workflow/instance/index'; import { cancelProcessApply } from '#/api/workflow/instance/index';
import { commonDownloadExcel } from '#/utils/file/download'; import { commonDownloadExcel } from '#/utils/file/download';
import applyRenewalContractModel from '../../hr/contractExpirationReminder/apply-renewal-contract-model.vue';
import applyEntryModel from '../../hr/employeeInfo/apply-entry-model.vue';
import applyResignModel from '../../hr/employeeInfo/apply-resign-model.vue';
import applyTransferModel from '../../hr/employeeInfo/apply-transfer-model.vue';
import applyRegularModel from '../../hr/regularReminder/apply-regular-model.vue';
import { applyModal, flowInfoModal } from '../components'; import { applyModal, flowInfoModal } from '../components';
import { querySchema, useColumns } from './data'; import { querySchema, useColumns } from './data';
import Form from './form.vue'; import { useRouteIdEdit } from './hook';
const formOptions: VbenFormProps = { const formOptions: VbenFormProps = {
commonConfig: { commonConfig: {
...@@ -29,6 +35,7 @@ const formOptions: VbenFormProps = { ...@@ -29,6 +35,7 @@ const formOptions: VbenFormProps = {
schema: querySchema, schema: querySchema,
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4', wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
}; };
const modalApi = shallowRef<ExtendedModalApi | null>(null);
const [ApplyModal, applyModalApi] = useVbenModal({ const [ApplyModal, applyModalApi] = useVbenModal({
connectedComponent: applyModal, connectedComponent: applyModal,
...@@ -36,9 +43,24 @@ const [ApplyModal, applyModalApi] = useVbenModal({ ...@@ -36,9 +43,24 @@ const [ApplyModal, applyModalApi] = useVbenModal({
const [FlowInfoModal, flowInfoModalApi] = useVbenModal({ const [FlowInfoModal, flowInfoModalApi] = useVbenModal({
connectedComponent: flowInfoModal, connectedComponent: flowInfoModal,
}); });
const [FormDrawer, formDrawerApi] = useVbenDrawer({ const [ApplyEntryModel, applyEntryModelApi] = useVbenModal({
connectedComponent: Form, connectedComponent: applyEntryModel,
});
const [ApplyResignModel, applyResignModelApi] = useVbenModal({
connectedComponent: applyResignModel,
});
const [ApplyTransferModel, applyTransferModelApi] = useVbenModal({
connectedComponent: applyTransferModel,
});
const [ApplyRegularModel, applyRegularModelApi] = useVbenModal({
connectedComponent: applyRegularModel,
});
const [ApplyRenewalContractModel, applyRenewalContractModelApi] = useVbenModal({
connectedComponent: applyRenewalContractModel,
}); });
// const [FormDrawer, formDrawerApi] = useVbenDrawer({
// connectedComponent: Form,
// });
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
formOptions, formOptions,
...@@ -79,15 +101,80 @@ const [Grid, gridApi] = useVbenVxeGrid({ ...@@ -79,15 +101,80 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
}); });
useRouteIdEdit((id, flowCode) => {
// 打开编辑
if (id && flowCode) {
let flowType = '1';
switch (flowCode) {
case 'hrEntryFlow': {
flowType = '1';
break;
}
case 'hrRegularizationFlow': {
flowType = '4';
break;
}
case 'hrRenewalContractFlow': {
flowType = '5';
break;
}
case 'hrResignFlow': {
flowType = '2';
break;
}
case 'hrTransferFlow': {
flowType = '3';
break;
}
default: {
break;
}
}
// 打开编辑
onEdit({ flowType, id: Number(id) });
}
});
function onRefresh() { function onRefresh() {
gridApi.query(); gridApi.query();
} }
function onEdit(row: EmployeeFlowApi.EmployeeFlow) { function onEdit(row: EmployeeFlowApi.EmployeeFlow) {
formDrawerApi.setData(row).open(); // formDrawerApi.setData(row).open();
} switch (row.flowType) {
function onCreate() { case '1': {
formDrawerApi.setData({}).open(); modalApi.value = applyEntryModelApi;
applyEntryModelApi.setData({ id: row.id, applyModalApi }).open();
break;
}
case '2': {
modalApi.value = applyResignModelApi;
applyResignModelApi.setData({ id: row.id, applyModalApi }).open();
break;
}
case '3': {
modalApi.value = applyTransferModelApi;
applyTransferModelApi.setData({ id: row.id, applyModalApi }).open();
break;
}
case '4': {
modalApi.value = applyRegularModelApi;
applyRegularModelApi.setData({ id: row.id, applyModalApi }).open();
break;
}
case '5': {
modalApi.value = applyRenewalContractModelApi;
applyRenewalContractModelApi
.setData({ id: row.id, applyModalApi })
.open();
break;
}
// No default
}
} }
// function onCreate() {
// formDrawerApi.setData({}).open();
// }
function onDelete(row: EmployeeFlowApi.EmployeeFlow) { function onDelete(row: EmployeeFlowApi.EmployeeFlow) {
const hideLoading = message.loading({ const hideLoading = message.loading({
content: `正在删除${row.applyCode}...`, content: `正在删除${row.applyCode}...`,
...@@ -119,7 +206,9 @@ async function handleRevoke(row: Required<EmployeeFlowApi.EmployeeFlow>) { ...@@ -119,7 +206,9 @@ async function handleRevoke(row: Required<EmployeeFlowApi.EmployeeFlow>) {
} }
async function handleCompleteOrCancel() { async function handleCompleteOrCancel() {
formDrawerApi.close(); if (modalApi.value) {
modalApi.value.close();
}
gridApi.query(); gridApi.query();
} }
...@@ -130,7 +219,7 @@ function handleInfo(row: Required<EmployeeFlowApi.EmployeeFlow>) { ...@@ -130,7 +219,7 @@ function handleInfo(row: Required<EmployeeFlowApi.EmployeeFlow>) {
</script> </script>
<template> <template>
<Page auto-content-height> <Page auto-content-height>
<FormDrawer @success="onRefresh" /> <!-- <FormDrawer @success="onRefresh" /> -->
<Grid table-title="人事审批列表"> <Grid table-title="人事审批列表">
<template #toolbar-tools> <template #toolbar-tools>
<Space> <Space>
...@@ -140,14 +229,14 @@ function handleInfo(row: Required<EmployeeFlowApi.EmployeeFlow>) { ...@@ -140,14 +229,14 @@ function handleInfo(row: Required<EmployeeFlowApi.EmployeeFlow>) {
> >
导出 导出
</Button> </Button>
<Button <!-- <Button
v-access:code="['employee:flow:add']" v-access:code="['employee:flow:add']"
type="primary" type="primary"
@click="onCreate" @click="onCreate"
> >
<Plus class="size-5" /> <Plus class="size-5" />
新增 新增
</Button> </Button> -->
</Space> </Space>
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
...@@ -204,5 +293,10 @@ function handleInfo(row: Required<EmployeeFlowApi.EmployeeFlow>) { ...@@ -204,5 +293,10 @@ function handleInfo(row: Required<EmployeeFlowApi.EmployeeFlow>) {
@complete="handleCompleteOrCancel" @complete="handleCompleteOrCancel"
@cancel="handleCompleteOrCancel" @cancel="handleCompleteOrCancel"
/> />
<ApplyEntryModel @reload="onRefresh" />
<ApplyResignModel @reload="onRefresh" />
<ApplyTransferModel @reload="onRefresh" />
<ApplyRegularModel @reload="onRefresh" />
<ApplyRenewalContractModel @reload="onRefresh" />
</Page> </Page>
</template> </template>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment