feat: 电子签全场景集成+场景筛选+设置开关

- ESignRecord 模型新增 scene 字段(CONTRACT/RESIGNATION/POLICY/PAYSLIP/ONBOARDING)
- Organization 模型新增3个电子签开关:esignPolicyEnabled/esignPayslipEnabled/esignOnboardingEnabled
- 设置页面企业信息新增电子签署设置区域,3个开关各自独立,缺省关闭
- 规章制度签收:开启电子签后,员工阅读确认时自动创建POLICY场景签署记录
- 工资条确认:开启电子签后,员工确认工资条时自动创建PAYSLIP场景签署记录
- 入职文件签署:开启电子签后,HR审批通过入职流程时自动创建ONBOARDING场景签署记录
- 电子签署列表增加场景筛选下拉(全部场景/劳动合同/离职协议/规章制度/工资条/入职文件)
- 管理端和员工端列表均展示场景标签(基于scene字段,替代硬编码判断)
- 合同和离职流程的esign调用已加scene参数
This commit is contained in:
freedakgmail
2026-08-05 07:47:00 +08:00
parent e8cd0f472b
commit 9512b555ee
11 changed files with 153 additions and 16 deletions
+3 -3
View File
@@ -603,9 +603,9 @@ export const benefitApi = {
// ========== 电子签署(易签宝) ==========
export const esignApi = {
list: (status?: string) =>
get('/esign', { params: status ? { status } : {} }).then(unwrap<any[]>()),
create: (data: { contractId?: string; employeeId: string; documentTitle: string; documentContent?: string; remark?: string }) =>
list: (params?: { status?: string; scene?: string }) =>
get('/esign', { params: params || {} }).then(unwrap<any[]>()),
create: (data: { contractId?: string; employeeId: string; documentTitle: string; documentContent?: string; remark?: string; scene?: string }) =>
post('/esign/create', data),
status: (id: string) =>
get(`/esign/${id}/status`).then(unwrap<any>()),
+21 -7
View File
@@ -19,9 +19,18 @@ const STATUS_CONFIG: Record<string, { label: string; color: string }> = {
CANCELLED: { label: '已取消', color: 'bg-gray-100 text-gray-500' },
}
const SCENE_CONFIG: Record<string, { label: string; color: string }> = {
CONTRACT: { label: '劳动合同', color: 'bg-blue-50 text-blue-600 border border-blue-200' },
RESIGNATION: { label: '离职协议', color: 'bg-orange-50 text-orange-600 border border-orange-200' },
POLICY: { label: '规章制度', color: 'bg-amber-50 text-amber-600 border border-amber-200' },
PAYSLIP: { label: '工资条', color: 'bg-emerald-50 text-emerald-600 border border-emerald-200' },
ONBOARDING: { label: '入职文件', color: 'bg-purple-50 text-purple-600 border border-purple-200' },
}
export default function ESign() {
const queryClient = useQueryClient()
const [filterStatus, setFilterStatus] = useState('')
const [filterScene, setFilterScene] = useState('')
const [showCreate, setShowCreate] = useState(false)
const [formData, setFormData] = useState({
employeeId: '',
@@ -30,9 +39,9 @@ export default function ESign() {
})
const { data: records = [], isLoading } = useQuery<any[]>({
queryKey: ['esign-records', filterStatus],
queryKey: ['esign-records', filterStatus, filterScene],
queryFn: async () => {
return await esignApi.list(filterStatus || undefined)
return await esignApi.list({ status: filterStatus || undefined, scene: filterScene || undefined })
},
})
@@ -114,6 +123,14 @@ export default function ESign() {
<option value=""></option>
{Object.entries(STATUS_CONFIG).map(([k, v]) => <option key={k} value={k}>{v.label}</option>)}
</select>
<select
value={filterScene}
onChange={(e) => setFilterScene(e.target.value)}
className="h-9 rounded-md border border-gray-200 bg-white px-3 text-sm text-gray-700 shadow-sm outline-none transition focus:border-primary focus:ring-2 focus:ring-primary/10"
>
<option value=""></option>
{Object.entries(SCENE_CONFIG).map(([k, v]) => <option key={k} value={k}>{v.label}</option>)}
</select>
</div>
<Button size="sm" onClick={() => setShowCreate(true)}>
<Plus className="w-4 h-4 mr-1" />
@@ -149,11 +166,8 @@ export default function ESign() {
<div className="flex items-center gap-1.5">
<FileText className="w-3.5 h-3.5 text-gray-400 shrink-0" />
<span className="font-medium truncate max-w-[200px]">{r.documentTitle}</span>
{r.contractId && (
<span className="px-1.5 py-0.5 rounded text-xs bg-blue-50 text-blue-600 border border-blue-200 shrink-0"></span>
)}
{!r.contractId && r.documentTitle?.includes('离职') && (
<span className="px-1.5 py-0.5 rounded text-xs bg-orange-50 text-orange-600 border border-orange-200 shrink-0"></span>
{r.scene && SCENE_CONFIG[r.scene] && (
<span className={`px-1.5 py-0.5 rounded text-xs shrink-0 ${SCENE_CONFIG[r.scene].color}`}>{SCENE_CONFIG[r.scene].label}</span>
)}
</div>
{r.remark && <div className="text-xs text-gray-400 mt-0.5">{r.remark}</div>}
+37 -1
View File
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react'
import { toast } from 'sonner'
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { Building2, Users, CreditCard, Plus, Bell, Download, Upload, FileSpreadsheet, Clock, CheckCircle, AlertCircle, ClipboardList, LayoutGrid } from 'lucide-react'
import { Building2, Users, CreditCard, Plus, Bell, Download, Upload, FileSpreadsheet, Clock, CheckCircle, AlertCircle, ClipboardList, LayoutGrid, PenTool } from 'lucide-react'
import { settingsApi, notificationsApi } from '../lib/api-services'
import { useAuthStore } from '../store/authStore'
import { getPageSize, setPageSize as setGlobalPageSize } from '../lib/pageSize'
@@ -93,6 +93,9 @@ function OrgSettings({ orgData, onSave, saving }: { orgData: any; onSave: (data:
contactPhone: '',
payrollFrequency: 1,
retirementReminderEnabled: false,
esignPolicyEnabled: false,
esignPayslipEnabled: false,
esignOnboardingEnabled: false,
})
useEffect(() => {
@@ -103,6 +106,9 @@ function OrgSettings({ orgData, onSave, saving }: { orgData: any; onSave: (data:
contactPhone: orgData.contactPhone || '',
payrollFrequency: orgData.payrollFrequency || 1,
retirementReminderEnabled: orgData.retirementReminderEnabled || false,
esignPolicyEnabled: orgData.esignPolicyEnabled || false,
esignPayslipEnabled: orgData.esignPayslipEnabled || false,
esignOnboardingEnabled: orgData.esignOnboardingEnabled || false,
})
}
}, [orgData])
@@ -139,6 +145,36 @@ function OrgSettings({ orgData, onSave, saving }: { orgData: any; onSave: (data:
</div>
<RetirementSection enabled={form.retirementReminderEnabled} onToggle={(v) => { setForm({ ...form, retirementReminderEnabled: v }); onSave({ ...form, retirementReminderEnabled: v }) }} />
{/* 电子签设置 */}
<div className="mt-6 pt-6 border-t">
<div className="flex items-center gap-2 mb-4">
<PenTool className="w-5 h-5 text-primary" />
<h3 className="font-medium"></h3>
</div>
<p className="text-xs text-gray-500 mb-3">使/</p>
<div className="space-y-3">
{[
{ key: 'esignPolicyEnabled', label: '规章制度电子签', desc: '开启后制度签收升级为电子签署,缺省为阅读确认' },
{ key: 'esignPayslipEnabled', label: '工资条电子签', desc: '开启后工资条确认升级为电子签署,缺省为点击确认' },
{ key: 'esignOnboardingEnabled', label: '入职文件电子签', desc: '开启后入职填报时签署入职相关文件,缺省不签' },
].map(item => (
<div key={item.key} className="flex items-center justify-between p-3 rounded-lg bg-gray-50">
<div>
<div className="text-sm font-medium">{item.label}</div>
<div className="text-xs text-gray-500 mt-0.5">{item.desc}</div>
</div>
<button
type="button"
onClick={() => { const v = !form[item.key as keyof typeof form]; setForm({ ...form, [item.key]: v }); onSave({ ...form, [item.key]: v }) }}
className={`relative inline-flex h-6 w-11 items-center rounded-full transition-colors shrink-0 ml-4 ${form[item.key as keyof typeof form] ? 'bg-primary' : 'bg-gray-300'}`}
>
<span className={`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${form[item.key as keyof typeof form] ? 'translate-x-6' : 'translate-x-1'}`} />
</button>
</div>
))}
</div>
</div>
</Card>
)
}
+1
View File
@@ -1559,6 +1559,7 @@ export default function Termination() {
employeeId,
documentTitle: '离职协议',
remark: '离职流程中发起',
scene: 'RESIGNATION',
})
queryClient.invalidateQueries({ queryKey: ['esign-records'] })
toast.success('离职协议电子签署已发起')
+15 -2
View File
@@ -18,6 +18,14 @@ const STATUS_MAP: Record<string, { label: string; color: string; icon: React.Rea
EXPIRED: { label: '已过期', color: 'bg-red-50 text-red-600', icon: <XCircle className="w-3 h-3" /> },
}
const SCENE_LABELS: Record<string, { label: string; color: string }> = {
CONTRACT: { label: '劳动合同', color: 'bg-blue-50 text-blue-600 border border-blue-200' },
RESIGNATION: { label: '离职协议', color: 'bg-orange-50 text-orange-600 border border-orange-200' },
POLICY: { label: '规章制度', color: 'bg-amber-50 text-amber-600 border border-amber-200' },
PAYSLIP: { label: '工资条', color: 'bg-emerald-50 text-emerald-600 border border-emerald-200' },
ONBOARDING: { label: '入职文件', color: 'bg-purple-50 text-purple-600 border border-purple-200' },
}
export default function MyEsign() {
const queryClient = useQueryClient()
const [selectedId, setSelectedId] = useState<string | null>(null)
@@ -101,6 +109,11 @@ export default function MyEsign() {
<FileText className="w-3.5 h-3.5" />
</div>
)}
{detail.scene && SCENE_LABELS[detail.scene] && (
<div className="mb-4">
<span className={`px-2 py-0.5 rounded text-xs ${SCENE_LABELS[detail.scene].color}`}>{SCENE_LABELS[detail.scene].label}</span>
</div>
)}
{/* 签署操作 */}
<div className="border-t pt-4">
@@ -169,8 +182,8 @@ export default function MyEsign() {
<div className="flex-1 min-w-0">
<div className="flex items-center gap-1.5">
<span className="text-sm font-medium truncate min-w-0">{r.documentTitle}</span>
{r.contractId && (
<span className="px-1.5 py-0.5 rounded text-xs bg-blue-50 text-blue-600 border border-blue-200 flex-shrink-0"></span>
{r.scene && SCENE_LABELS[r.scene] && (
<span className={`px-1.5 py-0.5 rounded text-xs flex-shrink-0 ${SCENE_LABELS[r.scene].color}`}>{SCENE_LABELS[r.scene].label}</span>
)}
</div>
<div className="text-xs text-gray-500 mt-1">
@@ -27,6 +27,7 @@ export default function ContractInfo({ employeeId, contracts, hireDate }: { empl
employeeId,
documentTitle: `${data.contractType === 'UNFIXED' ? '无固定期限' : '固定期限'}劳动合同`,
remark: '合同创建时自动发起',
scene: 'CONTRACT',
})
toast.success('合同已保存,电子签署记录已创建')
} catch {