fix: 知识库要素表模板type英文翻译为中文,required布尔判断修复
CI / 后端测试 (push) Has been cancelled
CI / 前端构建 (push) Has been cancelled

This commit is contained in:
selfrelease
2026-09-01 10:32:36 +08:00
parent 835c095403
commit 50a9d028c3
+14 -2
View File
@@ -319,16 +319,28 @@ export function KnowledgeBase() {
{doc.doc_type === 'element_template' && (() => { {doc.doc_type === 'element_template' && (() => {
try { try {
const tmpl = JSON.parse(doc.content) const tmpl = JSON.parse(doc.content)
const TYPE_LABELS: Record<string, string> = {
text: '单行文本',
textarea: '多行文本',
select: '下拉选择',
radio: '单选',
checkbox: '多选',
date: '日期',
number: '数字',
}
return ( return (
<div className="mt-2 rounded border bg-muted/30 p-3 text-xs"> <div className="mt-2 rounded border bg-muted/30 p-3 text-xs">
<p className="font-medium">案由:{tmpl.cause_of_action}</p> <p className="font-medium">案由:{tmpl.cause_of_action}</p>
<p className="mt-0.5 text-muted-foreground">适用:{tmpl.applicable}</p> <p className="mt-0.5 text-muted-foreground">适用:{tmpl.applicable}</p>
<p className="mt-2 font-medium">要素清单({tmpl.elements?.length || 0}项)</p> <p className="mt-2 font-medium">要素清单({tmpl.elements?.length || 0}项)</p>
<div className="mt-1 grid grid-cols-2 gap-x-4 gap-y-1 sm:grid-cols-3"> <div className="mt-1 grid grid-cols-2 gap-x-4 gap-y-1 sm:grid-cols-3">
{tmpl.elements?.map((e: Record<string, string>, i: number) => ( {tmpl.elements?.map((e: Record<string, unknown>, i: number) => (
<div key={i} className="flex items-center justify-between"> <div key={i} className="flex items-center justify-between">
<span className="text-muted-foreground">{e.label}</span> <span className="text-muted-foreground">{e.label}</span>
<span className="font-medium">{e.type}{e.required === '是' ? ' ·必填' : ''}</span> <span className="font-medium">
{TYPE_LABELS[String(e.type)] || String(e.type)}
{e.required === true || e.required === '是' ? ' ·必填' : ''}
</span>
</div> </div>
))} ))}
</div> </div>