feat: 20260809 系统优化 - 全部28项问题修复(P0×6+P1×16+P2×6)
P0: 福利批量参保/离职证明下载防乱码/考勤模板合并Sheet/补卡修改/附件在线查看删除 P1: 分页pageSize修复/离职导出筛选/撤回删除草稿/加班费自动计算/考勤加班汇总/证据链异常详情/制度催办/模板导入Word/社保封顶保底/校验字段提示/职务字段/社保费用明细/弹窗防误关/身份证查重/证明员工下拉/培训批量 P2: 离职流程去重/社保基数覆盖输入/薪税入口改名/添加员工引导/绩效模板清理
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
import { useState } from "react"
|
||||
import { toast } from "sonner"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { rosterApi } from '../../lib/api-services'
|
||||
import { rosterApi, evidenceApi } from '../../lib/api-services'
|
||||
import { useAuthStore } from "../../store/authStore"
|
||||
import Card from "../../components/ui/Card"
|
||||
import Button from "../../components/ui/Button"
|
||||
import { AlertTriangle, Scale } from "lucide-react"
|
||||
import { AlertTriangle, Scale, ShieldCheck } from "lucide-react"
|
||||
|
||||
// ========== 仲裁证据链 ==========
|
||||
|
||||
export default function EvidenceChain({ employeeId }: { employeeId: string }) {
|
||||
const [verifyResult, setVerifyResult] = useState<any>(null)
|
||||
const [verifying, setVerifying] = useState(false)
|
||||
|
||||
const { data, isLoading } = useQuery<any>({
|
||||
queryKey: ['evidence-chain', employeeId],
|
||||
queryFn: async () => {
|
||||
@@ -16,6 +20,24 @@ export default function EvidenceChain({ employeeId }: { employeeId: string }) {
|
||||
},
|
||||
})
|
||||
|
||||
const handleVerify = async () => {
|
||||
setVerifying(true)
|
||||
try {
|
||||
const records = await evidenceApi.byEmployee(employeeId)
|
||||
const results: any[] = []
|
||||
for (const r of records) {
|
||||
const result = await evidenceApi.verify(r.id)
|
||||
results.push({ id: r.id, category: r.category, refId: r.refId, ...result })
|
||||
}
|
||||
setVerifyResult({ total: records.length, valid: results.filter(r => r.valid).length, invalid: results.filter(r => !r.valid).length, details: results })
|
||||
toast.success(`验证完成:${results.filter(r => r.valid).length}/${results.length} 条有效`)
|
||||
} catch {
|
||||
toast.error('验证失败')
|
||||
} finally {
|
||||
setVerifying(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoading) return <div className="text-center py-8 text-gray-400">生成证据链中...</div>
|
||||
if (!data) return <div className="text-center py-8 text-gray-400">暂无证据链数据,请确保员工已录入合同、薪酬等信息</div>
|
||||
if (!data.evidence || data.evidence.length === 0) return (
|
||||
@@ -104,6 +126,10 @@ export default function EvidenceChain({ employeeId }: { employeeId: string }) {
|
||||
</div>
|
||||
)}
|
||||
<Button onClick={handleExport}>导出证据链</Button>
|
||||
<Button variant="secondary" onClick={handleVerify} disabled={verifying}>
|
||||
<ShieldCheck className="w-4 h-4 mr-1" />
|
||||
{verifying ? '验证中...' : '验证完整性'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -129,6 +155,47 @@ export default function EvidenceChain({ employeeId }: { employeeId: string }) {
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{verifyResult && (
|
||||
<Card>
|
||||
<h3 className="text-xs font-medium mb-3 flex items-center gap-2">
|
||||
<ShieldCheck className="w-4 h-4 text-safe" />
|
||||
证据链验证结果
|
||||
</h3>
|
||||
<div className="flex items-center gap-4 mb-3">
|
||||
<div className="text-xs text-center">
|
||||
<div className="text-gray-500">总记录</div>
|
||||
<div className="text-lg font-bold">{verifyResult.total}</div>
|
||||
</div>
|
||||
<div className="text-xs text-center">
|
||||
<div className="text-gray-500">有效</div>
|
||||
<div className="text-lg font-bold text-safe">{verifyResult.valid}</div>
|
||||
</div>
|
||||
{verifyResult.invalid > 0 && (
|
||||
<div className="text-xs text-center">
|
||||
<div className="text-gray-500">无效</div>
|
||||
<div className="text-lg font-bold text-danger">{verifyResult.invalid}</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{verifyResult.invalid > 0 && (
|
||||
<div className="space-y-1">
|
||||
{verifyResult.details.filter((r: any) => !r.valid).map((r: any, i: number) => (
|
||||
<div key={i} className="text-xs border rounded p-2 bg-red-50 border-red-200 text-red-700">
|
||||
<span className="font-medium">{r.category}</span>
|
||||
{r.refId && <span className="text-xs opacity-70 ml-2">ID: {r.refId}</span>}
|
||||
<div className="mt-0.5 opacity-90">哈希不匹配:预期 {r.expectedHash?.slice(0, 16)}...,实际 {r.actualHash?.slice(0, 16)}...</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{verifyResult.invalid === 0 && (
|
||||
<div className="text-xs text-safe flex items-center gap-1">
|
||||
<ShieldCheck className="w-3.5 h-3.5" /> 所有证据链哈希验证通过,数据完整无篡改
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
{data.evidence.map((e: any, i: number) => (
|
||||
<Card key={i} className={e.riskLevel === 'HIGH' ? 'border-orange-300' : ''}>
|
||||
|
||||
Reference in New Issue
Block a user