Explorar el Código

统一客户文档卡片并突出在用分账号数量

sy hace 3 horas
padre
commit
47654d7c79

+ 67 - 42
web-scaffold/src/pages/CustomerWorkspacePage.tsx

@@ -108,6 +108,13 @@ function metricCount(value: number | undefined, loading: boolean, error: ApiErro
   return <TextCell value={value} />;
 }
 
+function CustomerMaterialCard({ children }: { children: ReactNode }) {
+  return <div className="customer-material-card">
+    <span className="customer-file-thumb" aria-hidden="true"><FileText size={20} /></span>
+    <div className="customer-material-description">{children}</div>
+  </div>;
+}
+
 /**
  * 详情里的单个可编辑项(与合同详情同一交互):非编辑态只渲染值,鼠标移入才显出铅笔;点铅笔切到输入态。
  * 改完点对号(或按 Enter)即提交**该项**:客户写口按字段可选,⛔ 攒到底部统一保存。
@@ -564,7 +571,9 @@ export function CustomerWorkspacePage() {
           <strong>{metricCount(accounts.data?.total, accounts.loading, accounts.error)}</strong>
           <small>
             在用分账号{(accounts.data?.total ?? 0) > accountRows.length ? "(已加载)" : ""}{" "}
-            {metricCount(accounts.data ? accountRows.filter((row) => row.status === "in_use").length : undefined, accounts.loading, accounts.error)}
+            <span className="customer-record-active-count">
+              {metricCount(accounts.data ? accountRows.filter((row) => row.status === "in_use").length : undefined, accounts.loading, accounts.error)}
+            </span>
           </small>
         </dd>
       </div>
@@ -717,51 +726,67 @@ export function CustomerWorkspacePage() {
     </section>
 
     <section className="ops-record-card customer-workspace-panel" id="customer-panel-materials" role="tabpanel" aria-labelledby="customer-tab-materials" hidden={tab !== "materials"}>
-      <div className="customer-panel customer-license-panel">
+      <div className="customer-panel customer-material-panel">
         <h3>登记材料 · 营业执照影像</h3>
-        <div className="customer-license-document">
-          <span className="customer-file-thumb" aria-hidden="true"><FileText size={20} /></span>
-          <div className="customer-license-description">
-            {!licenseApplicable ? <>
-              <strong>不适用</strong>
-              <p>个人和个体工商户无需登记营业执照影像。</p>
-            </> : license?.status === "viewable" ? <>
-              <div className="customer-license-filename"><strong>{license.file_name ?? "营业执照影像"}</strong><OpsStatus tone="success">已登记</OpsStatus></div>
-              <p>{license.view_url ? "查看链接短期有效,失效后请刷新页面。" : "查看链接暂不可用,请刷新页面。"}</p>
-              {license.view_url && <div className="customer-license-links">
-                <a href={license.view_url} target="_blank" rel="noopener noreferrer">查看影像</a>
-                <a href={license.view_url} download={license.file_name ?? ""} target="_blank" rel="noopener noreferrer">下载</a>
-              </div>}
-            </> : license?.status === "expired" ? <>
-              <strong>已超期</strong>
-              <p>影像留存期已满,无法查看或下载。</p>
-            </> : <>
-              <strong>{license ? "未登记影像" : MISSING}</strong>
-              <p>{license ? "营业执照影像为选填材料,可在此补传。" : "暂未获取影像登记状态。"}</p>
-            </>}
-            {licenseApplicable && license?.status !== "expired" && <div className="customer-license-upload">
-              <label className="customer-upload-button customer-license-button">
-                <Upload size={15} aria-hidden="true" />
-                {licenseBusy ? "正在上传…" : license?.status === "viewable" ? "替换影像" : "上传影像"}
-                <input
-                  aria-label="上传营业执照影像"
-                  aria-describedby="customer-license-upload-note"
-                  type="file"
-                  disabled={licenseBusy || busy}
-                  onChange={(event) => {
-                    const file = event.target.files?.[0] ?? null;
-                    event.target.value = "";
-                    void replaceLicense(file);
-                  }}
-                />
-              </label>
-              <small id="customer-license-upload-note">格式和大小以平台限制为准。替换影像后,留存期限仍从建档日起算。</small>
+        <CustomerMaterialCard>
+          {!licenseApplicable ? <>
+            <strong>不适用</strong>
+            <p>个人和个体工商户无需登记营业执照影像。</p>
+          </> : license?.status === "viewable" ? <>
+            <div className="customer-license-filename"><strong>{license.file_name ?? "营业执照影像"}</strong><OpsStatus tone="success">已登记</OpsStatus></div>
+            <p>{license.view_url ? "查看链接短期有效,失效后请刷新页面。" : "查看链接暂不可用,请刷新页面。"}</p>
+            {license.view_url && <div className="customer-material-links">
+              <a href={license.view_url} target="_blank" rel="noopener noreferrer">查看影像</a>
+              <a href={license.view_url} download={license.file_name ?? ""} target="_blank" rel="noopener noreferrer">下载</a>
             </div>}
-          </div>
-        </div>
+          </> : license?.status === "expired" ? <>
+            <strong>已超期</strong>
+            <p>影像留存期已满,无法查看或下载。</p>
+          </> : <>
+            <strong>{license ? "未登记影像" : MISSING}</strong>
+            <p>{license ? "营业执照影像为选填材料,可在此补传。" : "暂未获取影像登记状态。"}</p>
+          </>}
+          {licenseApplicable && license?.status !== "expired" && <div className="customer-license-upload">
+            <label className="customer-upload-button customer-license-button">
+              <Upload size={15} aria-hidden="true" />
+              {licenseBusy ? "正在上传…" : license?.status === "viewable" ? "替换影像" : "上传影像"}
+              <input
+                aria-label="上传营业执照影像"
+                aria-describedby="customer-license-upload-note"
+                type="file"
+                disabled={licenseBusy || busy}
+                onChange={(event) => {
+                  const file = event.target.files?.[0] ?? null;
+                  event.target.value = "";
+                  void replaceLicense(file);
+                }}
+              />
+            </label>
+            <small id="customer-license-upload-note">格式和大小以平台限制为准。替换影像后,留存期限仍从建档日起算。</small>
+          </div>}
+        </CustomerMaterialCard>
         {licenseError && <p className="ops-form-error" role="alert">{licenseError}</p>}
       </div>
-      <div className="customer-panel"><h3>合同文档</h3>{contractFiles.length ? <div className="customer-file-list">{contractFiles.map((document) => <div key={`${document.contractNo}-${document.name}`}><span className="customer-file-thumb"><FileText size={16} /></span><div><strong>{document.name}</strong><p>{document.contractNo}</p></div><Button variant="ghost" onClick={() => navigate(`/contracts/${encodeURIComponent(document.contractNo)}?download=${encodeURIComponent(document.name)}`, { state: outgoingState })}>预览</Button></div>)}</div> : <p className="ops-muted">暂无文档,合同文档随合同登记上传。</p>}</div>
+      <div className="customer-panel customer-material-panel">
+        <h3>合同文档</h3>
+        {contractsLoad.error ? <CustomerMaterialCard>
+          <strong>合同文档读取失败</strong>
+          <FetchError message={contractsLoad.error.message} onRetry={contractsLoad.reload} />
+        </CustomerMaterialCard> : contractsLoad.loading ? <CustomerMaterialCard>
+          <strong>正在读取合同文档…</strong>
+        </CustomerMaterialCard> : contractFiles.length ? <div className="customer-material-list">
+          {contractFiles.map((document) => <CustomerMaterialCard key={`${document.contractNo}-${document.name}`}>
+            <strong>{document.name}</strong>
+            <p>{document.contractNo}</p>
+            <div className="customer-material-links">
+              <Link to={`/contracts/${encodeURIComponent(document.contractNo)}?download=${encodeURIComponent(document.name)}`} state={outgoingState}>预览</Link>
+            </div>
+          </CustomerMaterialCard>)}
+        </div> : <CustomerMaterialCard>
+          <strong>暂无合同文档</strong>
+          <p>文档随合同登记上传。</p>
+        </CustomerMaterialCard>}
+      </div>
       <p className="customer-form-note">应备材料(按主体类型):{subjectText ? customerMaterials(subjectText as "企业" | "个体工商户" | "个人") : <Tri tone="missing" text={MISSING} title={MISSING + ":subject_type"} />};合同文档:{CONTRACT_DOC_NOTE}。</p>
     </section>
 

+ 19 - 8
web-scaffold/src/styles/record-detail.css

@@ -125,6 +125,12 @@
   margin-top: 2px;
 }
 
+.customer-record-active-count {
+  color: var(--primary);
+  font-weight: 700;
+  font-variant-numeric: tabular-nums;
+}
+
 .record-tabs {
   display: flex;
   gap: 4px;
@@ -229,11 +235,16 @@
   margin-top: 12px;
 }
 
-.record-detail .customer-license-panel {
+.record-detail .customer-material-panel {
   background: var(--card);
 }
 
-.customer-license-document {
+.customer-material-list {
+  display: grid;
+  gap: 8px;
+}
+
+.customer-material-card {
   display: flex;
   align-items: flex-start;
   min-width: 0;
@@ -244,20 +255,20 @@
   background: var(--surface-subtle);
 }
 
-.customer-license-document .customer-file-thumb {
+.customer-material-card .customer-file-thumb {
   flex: none;
   width: 42px;
   height: 42px;
   color: var(--primary-soft-foreground);
 }
 
-.customer-license-description {
+.customer-material-description {
   min-width: 0;
   overflow-wrap: anywhere;
   font-size: var(--type-body);
 }
 
-.customer-license-description p {
+.customer-material-description p {
   margin: 3px 0 0;
   color: var(--text-secondary);
   font-size: var(--type-support);
@@ -265,19 +276,19 @@
 }
 
 .customer-license-filename,
-.customer-license-links {
+.customer-material-links {
   display: flex;
   align-items: center;
   flex-wrap: wrap;
   gap: 4px 10px;
 }
 
-.customer-license-links {
+.customer-material-links {
   margin-top: 6px;
   font-size: var(--type-support);
 }
 
-.customer-license-links a {
+.customer-material-links a {
   color: var(--primary-soft-foreground);
   font-weight: 600;
   text-decoration: underline;