2026-09-08-vehicle-cert-batch-zip-demo.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1" />
  6. <title>三方车辆 · 证书附件批量 ZIP 下载 Demo</title>
  7. <style>
  8. :root {
  9. --primary: #10b981;
  10. --primary-dark: #059669;
  11. --primary-bg: #ecfdf5;
  12. --border: #d9e8e2;
  13. --text: #1e293b;
  14. --muted: #64748b;
  15. --page: #f1f5f9;
  16. }
  17. * { box-sizing: border-box; }
  18. body {
  19. margin: 0;
  20. font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  21. background: var(--page);
  22. color: var(--text);
  23. line-height: 1.5;
  24. padding: 24px;
  25. }
  26. h1 { font-size: 22px; margin: 0 0 6px; }
  27. .sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
  28. .panel {
  29. background: #fff;
  30. border: 1px solid var(--border);
  31. border-radius: 10px;
  32. overflow: hidden;
  33. margin-bottom: 20px;
  34. }
  35. .toolbar {
  36. display: flex;
  37. flex-wrap: wrap;
  38. gap: 8px;
  39. align-items: center;
  40. padding: 12px 14px;
  41. border-bottom: 1px solid #e2e8f0;
  42. }
  43. .btn {
  44. height: 32px;
  45. padding: 0 12px;
  46. border-radius: 8px;
  47. border: 1px solid var(--border);
  48. background: #fff;
  49. color: var(--text);
  50. font-size: 13px;
  51. cursor: pointer;
  52. }
  53. .btn:disabled { color: #94a3b8; cursor: not-allowed; }
  54. .btn-main { border: none; background: var(--primary); color: #fff; font-weight: 600; }
  55. .btn-zip {
  56. border-color: #a7f3d0;
  57. background: var(--primary-bg);
  58. color: var(--primary-dark);
  59. font-weight: 600;
  60. }
  61. .btn-zip:disabled { opacity: 0.45; }
  62. .sel { margin-left: auto; font-size: 12px; color: var(--muted); }
  63. .sel b { color: var(--primary); }
  64. table { width: 100%; border-collapse: collapse; font-size: 13px; }
  65. th, td { padding: 12px; text-align: left; border-top: 1px solid #e2e8f0; vertical-align: middle; }
  66. th { background: #f8fafc; color: var(--muted); font-weight: 600; border-top: none; }
  67. tr.selected { background: var(--primary-bg); }
  68. a.plate { color: var(--primary); text-decoration: none; font-weight: 600; }
  69. .thumb {
  70. position: relative;
  71. width: 72px;
  72. height: 42px;
  73. border: 1px solid var(--border);
  74. border-radius: 6px;
  75. background: var(--primary-bg);
  76. display: flex;
  77. align-items: center;
  78. justify-content: center;
  79. color: var(--primary);
  80. font-size: 11px;
  81. }
  82. .thumb.empty { border-style: dashed; background: #f8fafc; color: #94a3b8; font-size: 10px; }
  83. .thumb .dl {
  84. position: absolute; right: 2px; top: 2px; width: 14px; height: 14px;
  85. border-radius: 50%; background: #fff; border: 1px solid #e2e8f0;
  86. font-size: 9px; line-height: 12px; text-align: center;
  87. }
  88. .thumb .cap {
  89. position: absolute; left: 0; right: 0; bottom: 0;
  90. background: rgba(15,23,42,.62); color: #fff; font-size: 9px; text-align: center; padding: 1px 0;
  91. }
  92. .certs { display: flex; gap: 8px; flex-wrap: wrap; }
  93. .tag {
  94. display: inline-block; padding: 2px 8px; border-radius: 4px;
  95. background: var(--primary-dark); color: #fff; font-size: 12px;
  96. }
  97. .tag.warn { background: #d97706; }
  98. .toast {
  99. display: none;
  100. margin: 0 14px 14px;
  101. padding: 12px 14px;
  102. border-radius: 10px;
  103. border: 1px solid #a7f3d0;
  104. background: var(--primary-bg);
  105. color: #065f46;
  106. font-size: 13px;
  107. }
  108. .toast.show { display: block; }
  109. .toast.warn { border-color: #fcd34d; background: #fffbeb; color: #92400e; }
  110. .toast pre {
  111. margin: 6px 0 0;
  112. font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  113. font-size: 12px;
  114. line-height: 1.55;
  115. white-space: pre-wrap;
  116. }
  117. .options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  118. @media (max-width: 900px) { .options { grid-template-columns: 1fr; } }
  119. .opt {
  120. border: 2px solid var(--border);
  121. border-radius: 10px;
  122. padding: 14px;
  123. background: #fff;
  124. cursor: pointer;
  125. }
  126. .opt.active { border-color: var(--primary); background: var(--primary-bg); }
  127. .opt h3 { margin: 0 0 6px; font-size: 15px; }
  128. .opt p { margin: 0; font-size: 13px; color: var(--muted); }
  129. .letter {
  130. display: inline-flex; width: 24px; height: 24px; border-radius: 50%;
  131. align-items: center; justify-content: center;
  132. background: var(--primary); color: #fff; font-size: 12px; font-weight: 700;
  133. margin-bottom: 8px;
  134. }
  135. .split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  136. @media (max-width: 700px) { .split { grid-template-columns: 1fr; } }
  137. .card {
  138. background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  139. }
  140. .card h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
  141. .card pre { margin: 0; font-size: 12px; line-height: 1.6; color: #334155; }
  142. .hint { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
  143. </style>
  144. </head>
  145. <body>
  146. <h1>三方车辆 · 证书附件批量 ZIP 下载 Demo</h1>
  147. <p class="sub">勾选车辆 → 点「批量下载证书 ZIP」→ 下方展示模拟包结构。单个附件仍可在缩略图右上角单独下载。</p>
  148. <div class="panel">
  149. <div class="toolbar" id="toolbar">
  150. <span style="font-size:12px;color:var(--muted)">承运商 ▾</span>
  151. <span class="btn" style="color:#94a3b8;cursor:default">车牌号</span>
  152. <button class="btn" type="button">快速识别创建</button>
  153. <button class="btn btn-main" type="button">+ 新增车辆</button>
  154. <button class="btn" type="button" disabled>编辑</button>
  155. <button class="btn" type="button" disabled style="border-color:#fecaca;color:#fca5a5">删除</button>
  156. <button class="btn" type="button">导出 ▾</button>
  157. <button class="btn btn-zip" id="btn-batch-zip" type="button" onclick="demoDownload()">⬇ 批量下载证书 ZIP</button>
  158. <span class="sel">已选 <b id="sel-count">2</b> 项</span>
  159. </div>
  160. <table>
  161. <thead>
  162. <tr>
  163. <th style="width:40px"><input type="checkbox" id="check-all" onchange="toggleAll(this)" /></th>
  164. <th style="width:48px">序号</th>
  165. <th>车牌号</th>
  166. <th>
  167. 证书附件
  168. <button class="btn btn-zip" id="btn-col-zip" type="button" onclick="demoDownload()" style="display:none;height:24px;padding:0 8px;font-size:11px;margin-left:8px">批量 ZIP</button>
  169. </th>
  170. <th>车辆状态</th>
  171. </tr>
  172. </thead>
  173. <tbody>
  174. <tr class="selected">
  175. <td><input type="checkbox" checked data-plate="皖A·D12345" data-files="主·行驶证.jpg,挂·行驶证.pdf" onchange="syncSel()" /></td>
  176. <td>1</td>
  177. <td><a class="plate" href="#">皖A·D12345 / 挂A8888</a></td>
  178. <td>
  179. <div class="certs">
  180. <div class="thumb">📷<span class="dl">↓</span><span class="cap">主·行驶证</span></div>
  181. <div class="thumb">📷<span class="dl">↓</span><span class="cap">挂·行驶证</span></div>
  182. <div class="thumb empty">未上传<span class="cap">主·道路运输</span></div>
  183. </div>
  184. </td>
  185. <td><span class="tag">正常</span></td>
  186. </tr>
  187. <tr class="selected">
  188. <td><input type="checkbox" checked data-plate="皖B·F67890" data-files="主·行驶证.jpg,主·营运证.pdf" onchange="syncSel()" /></td>
  189. <td>2</td>
  190. <td><a class="plate" href="#">皖B·F67890</a></td>
  191. <td>
  192. <div class="certs">
  193. <div class="thumb">📷<span class="dl">↓</span><span class="cap">主·行驶证</span></div>
  194. <div class="thumb">📷<span class="dl">↓</span><span class="cap">主·营运证</span></div>
  195. </div>
  196. </td>
  197. <td><span class="tag">正常</span></td>
  198. </tr>
  199. <tr>
  200. <td><input type="checkbox" data-plate="皖C·H11111" data-files="" onchange="syncSel()" /></td>
  201. <td>3</td>
  202. <td><a class="plate" href="#">皖C·H11111</a></td>
  203. <td style="color:#94a3b8">—</td>
  204. <td><span class="tag warn">停用</span></td>
  205. </tr>
  206. </tbody>
  207. </table>
  208. <div class="toast" id="toast">
  209. <div id="toast-title" style="font-weight:600"></div>
  210. <pre id="toast-tree"></pre>
  211. </div>
  212. </div>
  213. <p class="hint">入口位置偏好(点击切换上方 Demo 按钮位置):</p>
  214. <div class="options" style="margin-bottom:20px">
  215. <div class="opt active" data-mode="a" onclick="pickEntry(this)">
  216. <div class="letter">A</div>
  217. <h3>工具栏按钮(推荐)</h3>
  218. <p>勾选后点工具栏「批量下载证书 ZIP」,与导出同级。</p>
  219. </div>
  220. <div class="opt" data-mode="b" onclick="pickEntry(this)">
  221. <div class="letter">B</div>
  222. <h3>证书附件列头小按钮</h3>
  223. <p>入口紧贴附件列,语义更近。</p>
  224. </div>
  225. <div class="opt" data-mode="c" onclick="pickEntry(this)">
  226. <div class="letter">C</div>
  227. <h3>两处都有</h3>
  228. <p>发现成本最低,略冗余。</p>
  229. </div>
  230. </div>
  231. <div class="split">
  232. <div class="card">
  233. <h3>勾选 1 辆</h3>
  234. <pre>车辆证书_皖A·D12345.zip
  235. ├── 主·行驶证.jpg
  236. ├── 挂·行驶证.pdf
  237. └── (无附件证书跳过)</pre>
  238. </div>
  239. <div class="card">
  240. <h3>勾选多辆</h3>
  241. <pre>车辆证书批量_2辆_20260908.zip
  242. ├── 皖A·D12345/
  243. │ ├── 主·行驶证.jpg
  244. │ └── 挂·行驶证.pdf
  245. └── 皖B·F67890/
  246. ├── 主·行驶证.jpg
  247. └── 主·营运证.pdf</pre>
  248. </div>
  249. </div>
  250. <script>
  251. function syncSel() {
  252. const boxes = Array.from(document.querySelectorAll('tbody input[type=checkbox]'));
  253. boxes.forEach((b) => {
  254. b.closest('tr').classList.toggle('selected', b.checked);
  255. });
  256. const checked = boxes.filter((b) => b.checked);
  257. document.getElementById('sel-count').textContent = String(checked.length);
  258. const btn = document.getElementById('btn-batch-zip');
  259. const col = document.getElementById('btn-col-zip');
  260. const disabled = checked.length === 0;
  261. btn.disabled = disabled;
  262. col.disabled = disabled;
  263. document.getElementById('check-all').checked = checked.length === boxes.length;
  264. document.getElementById('check-all').indeterminate = checked.length > 0 && checked.length < boxes.length;
  265. }
  266. function toggleAll(el) {
  267. document.querySelectorAll('tbody input[type=checkbox]').forEach((b) => {
  268. b.checked = el.checked;
  269. });
  270. syncSel();
  271. }
  272. function demoDownload() {
  273. const boxes = Array.from(document.querySelectorAll('tbody input[type=checkbox]:checked'));
  274. const toast = document.getElementById('toast');
  275. const title = document.getElementById('toast-title');
  276. const tree = document.getElementById('toast-tree');
  277. toast.classList.add('show');
  278. if (!boxes.length) {
  279. toast.classList.add('warn');
  280. title.textContent = '请先勾选至少一辆车';
  281. tree.textContent = '';
  282. return;
  283. }
  284. toast.classList.remove('warn');
  285. const rows = boxes.map((b) => ({
  286. plate: b.getAttribute('data-plate'),
  287. files: String(b.getAttribute('data-files') || '').split(',').filter(Boolean)
  288. }));
  289. const withFiles = rows.filter((r) => r.files.length);
  290. if (!withFiles.length) {
  291. toast.classList.add('warn');
  292. title.textContent = '所选车辆均无证书附件,无法打包';
  293. tree.textContent = '';
  294. return;
  295. }
  296. if (withFiles.length === 1) {
  297. const r = withFiles[0];
  298. title.textContent = '模拟下载成功 · 单车 ZIP';
  299. tree.textContent =
  300. '车辆证书_' + r.plate + '.zip\n' +
  301. r.files.map((f, i) => (i === r.files.length - 1 ? '└── ' : '├── ') + f).join('\n');
  302. } else {
  303. title.textContent = '模拟下载成功 · 多车 ZIP(按车牌分子目录)';
  304. let out = '车辆证书批量_' + withFiles.length + '辆_20260908.zip\n';
  305. withFiles.forEach((r, i) => {
  306. const last = i === withFiles.length - 1;
  307. out += (last ? '└── ' : '├── ') + r.plate + '/\n';
  308. r.files.forEach((f, j) => {
  309. const lastF = j === r.files.length - 1;
  310. out += (last ? ' ' : '│ ') + (lastF ? '└── ' : '├── ') + f + '\n';
  311. });
  312. });
  313. tree.textContent = out.trimEnd();
  314. }
  315. }
  316. function pickEntry(el) {
  317. document.querySelectorAll('.opt').forEach((o) => o.classList.remove('active'));
  318. el.classList.add('active');
  319. const mode = el.getAttribute('data-mode');
  320. const toolbarBtn = document.getElementById('btn-batch-zip');
  321. const colBtn = document.getElementById('btn-col-zip');
  322. if (mode === 'a') {
  323. toolbarBtn.style.display = 'inline-block';
  324. colBtn.style.display = 'none';
  325. } else if (mode === 'b') {
  326. toolbarBtn.style.display = 'none';
  327. colBtn.style.display = 'inline-block';
  328. } else {
  329. toolbarBtn.style.display = 'inline-block';
  330. colBtn.style.display = 'inline-block';
  331. }
  332. }
  333. syncSel();
  334. </script>
  335. </body>
  336. </html>