| | |
| | | const operationBtnMap: Record<string, OperationBtnType> = { |
| | | editBtn: { |
| | | emits: { |
| | | onClick: (role) => openDialog(role), |
| | | onClick: (role) => openInternalDialog(role), |
| | | }, |
| | | extraProps: { |
| | | hide: (row: API.GetEnterpriseEmployeesQueryResultItem) => |
| | | row.source === EnumEnterpriseEmployeeSource.External, |
| | | }, |
| | | }, |
| | | detailBtn: { |
| | |
| | | const { |
| | | dialogProps: dialogAddInternalStaffProps, |
| | | handleAdd: handleInternalStaffAdd, |
| | | handleEdit: handleInternalStaffEdit, |
| | | editForm: internalStaffEditForm, |
| | | } = useFormDialog({ |
| | | onConfirm: addEnterpriseEmployee, |
| | | defaultFormParams: { |
| | | id: '', |
| | | name: '', |
| | | identity: '', |
| | | contactPhoneNumber: '', |
| | |
| | | }, |
| | | }); |
| | | |
| | | async function openInternalDialog(row: API.GetEnterpriseEmployeesQueryResultItem) { |
| | | try { |
| | | let detail = await enterpriseEmployeeServices.getEnterpriseEmployee({ id: row.id }); |
| | | handleInternalStaffEdit({ |
| | | id: row.id, |
| | | name: row.name, |
| | | identity: row.identity, |
| | | contactPhoneNumber: row.contactPhoneNumber, |
| | | gender: detail.gender, |
| | | age: detail.age ?? null, |
| | | identityImg: convertApi2FormUrlOnlyOne(detail.identityImg), |
| | | identityBackImg: convertApi2FormUrlOnlyOne(detail.identityBackImg), |
| | | contractUrl: convertApi2FormUrlOnlyOne(detail.contractUrl, { |
| | | fileName: detail.contractUrl ? detail.contractUrl.split('/').pop() : '合同', |
| | | }), |
| | | regiterTime: detail.applyTime ?? '', |
| | | userRealTime: row.userRealTime ?? '', |
| | | userSignContractTime: row.userSignContractTime ?? '', |
| | | contractTime: [row.contractBegin, row.contractEnd], |
| | | }); |
| | | } catch (error) {} |
| | | } |
| | | |
| | | async function addEnterpriseEmployee() { |
| | | try { |
| | | const isEdit = !!internalStaffEditForm.id; |
| | | let params: API.AddEnterpriseEmployeeCommand = { |
| | | name: internalStaffEditForm.name, |
| | | identity: internalStaffEditForm.identity, |
| | |
| | | contractBegin: format(internalStaffEditForm.contractTime[0], 'YYYY-MM-DD 00:00:00'), |
| | | contractEnd: format(internalStaffEditForm.contractTime[1], 'YYYY-MM-DD 23:59:59'), |
| | | }; |
| | | let res = await enterpriseEmployeeServices.addEnterpriseEmployee(params); |
| | | let res; |
| | | if (isEdit) { |
| | | (params as API.EditEnterpriseEmployeeCommand).id = internalStaffEditForm.id; |
| | | res = await enterpriseEmployeeServices.editEnterpriseEmployee(params); |
| | | } else { |
| | | res = await enterpriseEmployeeServices.addEnterpriseEmployee(params); |
| | | } |
| | | if (res) { |
| | | Message.successMessage('操作成功'); |
| | | getList(paginationState.pageIndex); |