Quellcode durchsuchen

feat(web): 并排展示客户建档材料卡片

sy vor 1 Stunde
Ursprung
Commit
e094f588b5

+ 51 - 27
web-scaffold/src/pages/CustomerEditorPage.tsx

@@ -6,11 +6,11 @@
  * 编辑:`POST /customer/update@v1`(资料)+ `POST /customer/attribution_update@v1`(运营商/合伙人)
  *    + 区域变更时 `POST /customer/move_region@v1`(必填变更依据)。
  * 边界:登记材料(营业执照影像)由浏览器直传平台 `unified-oss`(凭证自取、⛔ 经后端),
- * 建档载荷只回报 `{object_key, file_name}`;合同文档区本期仍无路由(保持禁用并说明)。
+ * 建档载荷只回报 `{object_key, file_name}`;合同文档在合同登记时上传。
  * 错误一律显示后端/平台 `message` 原文。
  */
 import { useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode } from "react";
-import { ArrowLeft, Upload } from "lucide-react";
+import { ArrowLeft, FileText, Upload } from "lucide-react";
 import { Link, useLocation, useNavigate, useParams } from "react-router";
 import { FetchError } from "../components/fetchError";
 import { Button } from "../components/ui/button";
@@ -99,6 +99,7 @@ export function CustomerEditorPage() {
   /** 登记材料:`licenseObj`=已直传成功的对象(建案载荷据此回报);⛔ 存签名 URL/⛔ 存文件本体。 */
   const [licenseObj, setLicenseObj] = useState<UploadedObject | null>(null);
   const [licenseBusy, setLicenseBusy] = useState(false);
+  const [licenseDragging, setLicenseDragging] = useState(false);
   const [licenseError, setLicenseError] = useState("");
   function set<K extends keyof Draft>(key: K, value: Draft[K]) { setDraft((current) => ({ ...current, [key]: value })); setErrors((current) => { const next = { ...current }; delete next[key]; return next; }); }
   function field(key: keyof Draft, label: string, control: ReactNode, required = false, wide = false, hint?: ReactNode) {
@@ -333,38 +334,61 @@ export function CustomerEditorPage() {
           </div>
           <div className="customer-document-grid">
             {draft.subject === "enterprise" ? (
-              <div className="customer-document-picker">
-                <div>
-                  <strong>登记材料 · 营业执照影像</strong>
-                  <label className="customer-upload-button" title="选择后立即直传平台对象存储(字节流不经过本系统)">
-                    <Upload size={15} />{licenseBusy ? "正在上传…" : licenseObj ? "重新选择" : "选择文件"}
-                    <input aria-label="上传登记材料" type="file" disabled={licenseBusy || busy}
-                      onChange={(event) => {
-                        const file = event.target.files?.[0] ?? null;
-                        event.target.value = "";
-                        void pickLicense(file);
-                      }} />
-                  </label>
-                </div>
-                <p>{licenseObj ? `已上传:${licenseObj.file_name}` : licenseBusy ? "正在上传影像…" : "尚未选择文件"}</p>
-                {licenseError && <small className="customer-field-error">{licenseError}</small>}
+              <div
+                className={`contract-license-drop${licenseDragging ? " is-dragging" : ""}`}
+                onDragOver={(event) => {
+                  if (!Array.from(event.dataTransfer.types).includes("Files")) return;
+                  event.preventDefault();
+                  const locked = licenseBusy || busy;
+                  event.dataTransfer.dropEffect = locked ? "none" : "copy";
+                  setLicenseDragging(!locked);
+                }}
+                onDragLeave={(event) => {
+                  if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setLicenseDragging(false);
+                }}
+                onDrop={(event) => {
+                  event.preventDefault();
+                  setLicenseDragging(false);
+                  if (!licenseBusy && !busy) void pickLicense(event.dataTransfer.files[0] ?? null);
+                }}
+              >
+                <span className="contract-license-drop-body">
+                  <Upload size={22} aria-hidden="true" />
+                  <strong>营业执照影像</strong>
+                  <span aria-live="polite" title={licenseObj?.file_name}>
+                    {licenseBusy ? "正在上传影像…" : licenseObj ? `已上传:${licenseObj.file_name}` : "拖入文件,或点击选择"}
+                  </span>
+                </span>
+                <input
+                  className="contract-license-drop-input"
+                  aria-label={licenseObj ? "替换营业执照影像" : "上传登记材料"}
+                  type="file"
+                  disabled={licenseBusy || busy}
+                  onChange={(event) => {
+                    const file = event.target.files?.[0] ?? null;
+                    event.target.value = "";
+                    void pickLicense(file);
+                  }}
+                />
               </div>
             ) : (
-              <div className="customer-document-picker">
-                <div><strong>登记材料</strong></div>
-                <p>不适用(个人与个体工商户不采集证件影像)</p>
+              <div className="contract-license-drop customer-document-readonly">
+                <span className="contract-license-drop-body">
+                  <FileText size={22} aria-hidden="true" />
+                  <strong>营业执照影像</strong>
+                  <span>仅企业客户适用</span>
+                </span>
               </div>
             )}
-            <div className="customer-document-picker">
-              <div>
+            <div className="contract-license-drop customer-document-readonly">
+              <span className="contract-license-drop-body">
+                <FileText size={22} aria-hidden="true" />
                 <strong>合同文档</strong>
-                <label className="customer-upload-button" title="合同文档随合同登记上传(合同详情 → 附件),建档页不采集">
-                  <Upload size={15} />选择文件<input aria-label="上传合同文档" type="file" multiple disabled />
-                </label>
-              </div>
-              <p>合同文档由合同模块登记,本页不采集</p>
+                <span>在登记合同时上传</span>
+              </span>
             </div>
           </div>
+          {licenseError && <small className="customer-field-error" role="alert">{licenseError}</small>}
         </section>
       )}
     </>

+ 10 - 12
web-scaffold/src/styles/customer-onboarding.css

@@ -21,21 +21,19 @@
 .customer-form-note { margin-top:12px; }
 .customer-form-note button { color:var(--primary);font-weight:600;margin-inline:6px;cursor:pointer; }
 .customer-document-grid { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:16px; }
-.customer-document-picker { min-width:0;padding:16px;border:1px solid var(--border);border-radius:var(--radius-control); }
-.customer-document-picker>div { display:flex;align-items:center;justify-content:space-between;gap:12px; }
-.customer-document-picker strong { font-size:var(--type-body); }
+.customer-document-grid .contract-license-drop { min-width:0;min-height:76px; }
+.customer-document-grid .contract-license-drop-body { display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 10px; }
+.customer-document-grid .contract-license-drop-body > svg { grid-row:span 2; }
+.customer-document-grid .contract-license-drop-body > strong { min-width:0;overflow-wrap:anywhere; }
+.customer-document-grid .contract-license-drop-body > span { grid-column:2; }
+.customer-document-grid .contract-license-drop:hover:where(:has(> input:enabled)) { border-color:var(--border-hover); }
+.customer-document-grid .contract-license-drop:focus-within { border-color:var(--ring);box-shadow:0 0 0 3px var(--ring-glow); }
+.customer-document-grid .contract-license-drop.is-dragging { border-color:var(--primary); }
+.customer-document-grid .customer-document-readonly svg { color:var(--icon); }
+.customer-document-grid + .customer-field-error { display:block;margin-top:8px; }
 .customer-upload-button { position:relative;display:inline-flex;align-items:center;gap:6px;flex-shrink:0;border:1px solid var(--border);border-radius:7px;padding:6px 10px;font-size:var(--type-support);cursor:pointer;transition:border-color .15s,box-shadow .15s; }
 .customer-upload-button:focus-within { outline:none;border-color:var(--ring);box-shadow:0 0 0 3px var(--ring-glow); }
 .customer-upload-button input { position:absolute;inset:0;opacity:0;width:100%;cursor:pointer; }
-.customer-editor .customer-upload-button:has(> input:disabled) { background:var(--surface-subtle);color:var(--text-secondary); }
-.customer-editor .customer-upload-button:has(> input:disabled),
-.customer-editor .customer-upload-button > input:disabled { cursor:not-allowed; }
-.customer-document-picker ul { margin:0;padding:0;list-style:none; }
-.customer-document-picker li { display:flex;align-items:center;gap:9px;margin-top:14px;font-size:var(--type-support); }
-.customer-document-picker li>span { min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis; }
-.customer-document-picker li small { display:block;margin-top:3px;color:var(--muted-foreground); }
-.customer-document-picker li button { flex-shrink:0;padding:5px;color:var(--muted-foreground);cursor:pointer; }
-.customer-document-picker>p { margin:20px 0 5px;font-size:var(--type-support);color:var(--muted-foreground); }
 .customer-list-actions { display:flex;flex-wrap:wrap;gap:8px; }
 .customer-file-grid .customer-file-download { text-align:left;border:1px solid var(--border);display:flex;align-items:center;gap:9px;padding:12px;border-radius:var(--radius-control);cursor:pointer;font-size:var(--type-support);min-width:0; }
 .customer-file-download span { flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }