fresh-mint-list-toolbar-date-shortcut-demo.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844
  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.0" />
  6. <title>Fresh Mint · 列表工具栏日期快捷展示 Demo</title>
  7. <link rel="preconnect" href="https://fonts.googleapis.com" />
  8. <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  9. <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" />
  10. <style>
  11. :root {
  12. --primary: #10b981;
  13. --primary-dark: #059669;
  14. --primary-bg: #ecfdf5;
  15. --text: #1e293b;
  16. --text-muted: #64748b;
  17. --border: #d9e8e2;
  18. --surface: #ffffff;
  19. --table-head: #f8fafc;
  20. --bg-page: #f8fafc;
  21. --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  22. --radius: 10px;
  23. }
  24. * { box-sizing: border-box; }
  25. body {
  26. margin: 0;
  27. min-height: 100vh;
  28. font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
  29. font-size: 14px;
  30. line-height: 1.5;
  31. color: var(--text);
  32. background: var(--bg-page);
  33. }
  34. .demo-page { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; }
  35. .demo-head { margin-bottom: 28px; }
  36. .demo-head h1 {
  37. margin: 0 0 8px;
  38. font-size: 24px;
  39. font-weight: 700;
  40. letter-spacing: -0.02em;
  41. }
  42. .demo-head h1 span { color: var(--primary); }
  43. .demo-head p { margin: 0; color: var(--text-muted); max-width: 760px; }
  44. .toc {
  45. display: flex;
  46. flex-wrap: wrap;
  47. gap: 8px;
  48. margin: 20px 0 0;
  49. }
  50. .toc a {
  51. display: inline-flex;
  52. align-items: center;
  53. height: 32px;
  54. padding: 0 12px;
  55. border-radius: 8px;
  56. border: 1px solid var(--border);
  57. background: var(--surface);
  58. color: var(--text);
  59. text-decoration: none;
  60. font-size: 13px;
  61. font-weight: 500;
  62. }
  63. .toc a:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-bg); }
  64. .toc a.rec {
  65. border-color: var(--primary);
  66. background: var(--primary-bg);
  67. color: var(--primary-dark);
  68. }
  69. .section { margin-top: 36px; }
  70. .section-head {
  71. display: flex;
  72. align-items: flex-start;
  73. justify-content: space-between;
  74. gap: 16px;
  75. margin-bottom: 12px;
  76. }
  77. .section-head h2 {
  78. margin: 0 0 4px;
  79. font-size: 18px;
  80. font-weight: 700;
  81. }
  82. .section-head p { margin: 0; color: var(--text-muted); font-size: 13px; max-width: 680px; }
  83. .badge {
  84. flex-shrink: 0;
  85. display: inline-flex;
  86. align-items: center;
  87. height: 26px;
  88. padding: 0 10px;
  89. border-radius: 999px;
  90. font-size: 12px;
  91. font-weight: 600;
  92. white-space: nowrap;
  93. }
  94. .badge-ok { background: var(--primary-bg); color: var(--primary-dark); }
  95. .badge-mid { background: #eff6ff; color: #1d4ed8; }
  96. .badge-bad { background: #fef2f2; color: #b91c1c; }
  97. .panel {
  98. background: var(--surface);
  99. border: 1px solid var(--border);
  100. border-radius: var(--radius);
  101. box-shadow: var(--shadow);
  102. overflow: hidden;
  103. }
  104. .panel-top {
  105. padding: 14px 16px;
  106. border-bottom: 1px solid var(--border);
  107. }
  108. .panel-top h3 {
  109. margin: 0;
  110. font-size: 15px;
  111. font-weight: 700;
  112. position: relative;
  113. padding-left: 10px;
  114. }
  115. .panel-top h3::before {
  116. content: "";
  117. position: absolute;
  118. left: 0;
  119. top: 2px;
  120. bottom: 2px;
  121. width: 3px;
  122. border-radius: 2px;
  123. background: var(--primary);
  124. }
  125. .list-toolbar { background: var(--table-head); }
  126. .list-toolbar-row {
  127. display: flex;
  128. flex-wrap: nowrap;
  129. align-items: center;
  130. justify-content: flex-start;
  131. gap: 8px;
  132. padding: 8px 16px;
  133. overflow-x: auto;
  134. -webkit-overflow-scrolling: touch;
  135. }
  136. .list-toolbar-selected {
  137. display: inline-flex;
  138. align-items: center;
  139. min-height: 36px;
  140. padding: 0 10px 0 0;
  141. margin-right: 4px;
  142. border-right: 1px solid var(--border);
  143. font-size: 12px;
  144. font-weight: 600;
  145. color: var(--text-muted);
  146. white-space: nowrap;
  147. flex-shrink: 0;
  148. }
  149. .sel-num { color: var(--primary-dark); font-weight: 700; margin: 0 2px; }
  150. .btn {
  151. display: inline-flex;
  152. align-items: center;
  153. justify-content: center;
  154. gap: 6px;
  155. height: 36px;
  156. padding: 0 14px;
  157. border-radius: 8px;
  158. border: 1px solid var(--border);
  159. background: var(--surface);
  160. color: var(--text);
  161. font-size: 14px;
  162. font-weight: 600;
  163. font-family: inherit;
  164. cursor: pointer;
  165. white-space: nowrap;
  166. flex-shrink: 0;
  167. transition: background .15s, border-color .15s, color .15s;
  168. }
  169. .btn:hover { border-color: #b7d5cb; background: #f8fafc; }
  170. .btn:disabled { opacity: .45; cursor: not-allowed; }
  171. .btn-main {
  172. background: var(--primary);
  173. border-color: var(--primary);
  174. color: #fff;
  175. }
  176. .btn-main:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
  177. .btn-icon {
  178. width: 36px;
  179. min-width: 36px;
  180. padding: 0;
  181. border: none;
  182. background: transparent;
  183. color: var(--text-muted);
  184. }
  185. .btn-icon:hover { background: var(--primary-bg); color: var(--primary-dark); }
  186. .btn svg { width: 16px; height: 16px; flex-shrink: 0; }
  187. .quick-search {
  188. height: 36px;
  189. width: 200px;
  190. max-width: 200px;
  191. flex: 0 0 200px;
  192. padding: 0 12px;
  193. border: 1px solid var(--border);
  194. border-radius: 8px;
  195. background: var(--surface);
  196. font: inherit;
  197. color: var(--text);
  198. outline: none;
  199. }
  200. .quick-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15); }
  201. .list-toolbar-end {
  202. display: flex;
  203. align-items: center;
  204. gap: 4px;
  205. margin-left: auto;
  206. flex-shrink: 0;
  207. padding-left: 8px;
  208. }
  209. .list-body { border-top: 1px solid var(--border); }
  210. .fake-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  211. .fake-table th, .fake-table td {
  212. padding: 10px 14px;
  213. text-align: left;
  214. border-bottom: 1px solid #eef2f7;
  215. }
  216. .fake-table th {
  217. background: #f8fafc;
  218. color: var(--text-muted);
  219. font-weight: 600;
  220. }
  221. .note {
  222. margin: 12px 0 0;
  223. padding: 12px 14px;
  224. border-radius: 8px;
  225. background: #f1f5f9;
  226. color: var(--text-muted);
  227. font-size: 13px;
  228. }
  229. .note strong { color: var(--text); }
  230. .measure {
  231. display: inline-flex;
  232. align-items: center;
  233. gap: 8px;
  234. margin-bottom: 10px;
  235. font-size: 12px;
  236. color: var(--text-muted);
  237. }
  238. .px-tag {
  239. display: inline-flex;
  240. align-items: center;
  241. height: 22px;
  242. padding: 0 8px;
  243. border-radius: 6px;
  244. background: #e2e8f0;
  245. color: #334155;
  246. font-weight: 600;
  247. font-variant-numeric: tabular-nums;
  248. }
  249. .viewport-frame {
  250. border: 1px dashed #cbd5e1;
  251. border-radius: 8px;
  252. overflow: hidden;
  253. resize: horizontal;
  254. max-width: 100%;
  255. min-width: 640px;
  256. width: 100%;
  257. }
  258. /* —— 方案 0:现状五按钮 —— */
  259. .chip-group {
  260. display: inline-flex;
  261. flex-wrap: nowrap;
  262. gap: 6px;
  263. padding-right: 8px;
  264. margin-right: 4px;
  265. border-right: 1px solid var(--border);
  266. flex-shrink: 0;
  267. }
  268. .chip {
  269. height: 32px;
  270. padding: 0 10px;
  271. border-radius: 8px;
  272. border: 1px solid var(--border);
  273. background: var(--surface);
  274. color: var(--text);
  275. font-size: 13px;
  276. font-weight: 600;
  277. font-family: inherit;
  278. cursor: pointer;
  279. white-space: nowrap;
  280. }
  281. .chip:hover { border-color: #b7d5cb; }
  282. .chip.is-active {
  283. border-color: var(--primary);
  284. background: var(--primary-bg);
  285. color: var(--primary-dark);
  286. }
  287. /* —— 方案 A:分段控件 —— */
  288. .seg {
  289. display: inline-flex;
  290. align-items: stretch;
  291. height: 32px;
  292. padding: 2px;
  293. border: 1px solid var(--border);
  294. border-radius: 8px;
  295. background: #f1f5f9;
  296. flex-shrink: 0;
  297. margin-right: 4px;
  298. padding-right: 2px;
  299. }
  300. .seg + .quick-search,
  301. .chip-group + .quick-search,
  302. .date-select-wrap + .quick-search,
  303. .date-trigger-wrap + .quick-search {
  304. margin-left: 4px;
  305. }
  306. .seg-item {
  307. display: inline-flex;
  308. align-items: center;
  309. justify-content: center;
  310. min-width: 40px;
  311. padding: 0 10px;
  312. border: none;
  313. border-radius: 6px;
  314. background: transparent;
  315. color: var(--text-muted);
  316. font-size: 13px;
  317. font-weight: 600;
  318. font-family: inherit;
  319. cursor: pointer;
  320. white-space: nowrap;
  321. }
  322. .seg-item:hover { color: var(--text); }
  323. .seg-item.is-active {
  324. background: var(--surface);
  325. color: var(--primary-dark);
  326. box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  327. }
  328. /* —— 方案 B:下拉选择 —— */
  329. .date-select-wrap {
  330. position: relative;
  331. flex-shrink: 0;
  332. margin-right: 4px;
  333. }
  334. .date-select {
  335. appearance: none;
  336. height: 36px;
  337. min-width: 112px;
  338. padding: 0 32px 0 12px;
  339. border: 1px solid var(--border);
  340. border-radius: 8px;
  341. background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  342. color: var(--text);
  343. font: inherit;
  344. font-weight: 600;
  345. cursor: pointer;
  346. outline: none;
  347. }
  348. .date-select:focus {
  349. border-color: var(--primary);
  350. box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
  351. }
  352. /* —— 方案 C:日历触发 + 弹出菜单 —— */
  353. .date-trigger-wrap {
  354. position: relative;
  355. flex-shrink: 0;
  356. margin-right: 4px;
  357. }
  358. .date-trigger {
  359. display: inline-flex;
  360. align-items: center;
  361. gap: 6px;
  362. height: 36px;
  363. padding: 0 12px;
  364. border: 1px solid var(--border);
  365. border-radius: 8px;
  366. background: var(--surface);
  367. color: var(--text);
  368. font: inherit;
  369. font-weight: 600;
  370. cursor: pointer;
  371. }
  372. .date-trigger:hover { border-color: #b7d5cb; background: #f8fafc; }
  373. .date-trigger svg { width: 16px; height: 16px; color: var(--text-muted); }
  374. .date-trigger .caret { width: 14px; height: 14px; }
  375. .date-menu {
  376. display: none;
  377. position: absolute;
  378. top: calc(100% + 6px);
  379. left: 0;
  380. z-index: 20;
  381. min-width: 140px;
  382. padding: 6px;
  383. border: 1px solid var(--border);
  384. border-radius: 10px;
  385. background: var(--surface);
  386. box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1);
  387. }
  388. .date-trigger-wrap.is-open .date-menu { display: block; }
  389. .date-menu button {
  390. display: flex;
  391. width: 100%;
  392. align-items: center;
  393. height: 34px;
  394. padding: 0 10px;
  395. border: none;
  396. border-radius: 6px;
  397. background: transparent;
  398. color: var(--text);
  399. font: inherit;
  400. font-weight: 500;
  401. text-align: left;
  402. cursor: pointer;
  403. }
  404. .date-menu button:hover { background: #f1f5f9; }
  405. .date-menu button.is-active {
  406. background: var(--primary-bg);
  407. color: var(--primary-dark);
  408. font-weight: 600;
  409. }
  410. .compare {
  411. overflow: auto;
  412. border: 1px solid var(--border);
  413. border-radius: 10px;
  414. background: var(--surface);
  415. }
  416. .compare table { width: 100%; border-collapse: collapse; font-size: 13px; }
  417. .compare th, .compare td {
  418. padding: 12px 14px;
  419. text-align: left;
  420. border-bottom: 1px solid #eef2f7;
  421. vertical-align: top;
  422. }
  423. .compare th {
  424. background: #f8fafc;
  425. color: var(--text-muted);
  426. font-weight: 600;
  427. }
  428. .compare tr:last-child td { border-bottom: none; }
  429. .rec-mark { color: var(--primary-dark); font-weight: 700; }
  430. .pick-bar {
  431. position: sticky;
  432. bottom: 0;
  433. margin-top: 40px;
  434. padding: 14px 16px;
  435. border: 1px solid var(--border);
  436. border-radius: 12px;
  437. background: rgba(255, 255, 255, 0.92);
  438. backdrop-filter: blur(8px);
  439. box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
  440. display: flex;
  441. flex-wrap: wrap;
  442. align-items: center;
  443. gap: 10px;
  444. }
  445. .pick-bar strong { margin-right: 4px; }
  446. .pick-bar label {
  447. display: inline-flex;
  448. align-items: center;
  449. gap: 6px;
  450. height: 34px;
  451. padding: 0 12px;
  452. border: 1px solid var(--border);
  453. border-radius: 8px;
  454. background: var(--surface);
  455. cursor: pointer;
  456. font-weight: 500;
  457. }
  458. .pick-bar label:has(input:checked) {
  459. border-color: var(--primary);
  460. background: var(--primary-bg);
  461. color: var(--primary-dark);
  462. font-weight: 600;
  463. }
  464. .pick-bar input { accent-color: var(--primary); }
  465. </style>
  466. </head>
  467. <body>
  468. <div class="demo-page">
  469. <header class="demo-head">
  470. <h1>日期快捷展示 · <span>Fresh Mint</span></h1>
  471. <p>
  472. 运输计划等业务页把「已选 + 日期快捷 + 检索 + 操作按钮 + 刷新/列设置」收成<strong>一行</strong>时,
  473. 五个独立按钮(全部 / 昨日 / 今日 / 明日 / 本周)最占宽。以下对比三种更省空间的展示,拖拽虚线框右侧可模拟窄屏。
  474. </p>
  475. <nav class="toc">
  476. <a href="#before">现状 · 五按钮</a>
  477. <a class="rec" href="#a">推荐 · 分段控件</a>
  478. <a href="#b">备选 · 下拉选择</a>
  479. <a href="#c">备选 · 触发菜单</a>
  480. <a href="#compare">对比表</a>
  481. </nav>
  482. </header>
  483. <!-- 0 现状 -->
  484. <section class="section" id="before">
  485. <div class="section-head">
  486. <div>
  487. <h2>0. 现状:五个独立描边按钮</h2>
  488. <p>与当前 <code>ListToolbarDateShortcuts</code> 一致。可发现性最好,但水平占位最大。</p>
  489. </div>
  490. <span class="badge badge-bad">占宽大</span>
  491. </div>
  492. <div class="measure">日期区宽约 <span class="px-tag" id="w0">—</span> px</div>
  493. <div class="viewport-frame" style="width: 980px;">
  494. <div class="panel">
  495. <div class="panel-top"><h3>运输计划列表 · 现状</h3></div>
  496. <div class="list-toolbar">
  497. <div class="list-toolbar-row">
  498. <div class="list-toolbar-selected">已选 <span class="sel-num">1</span> 项</div>
  499. <div class="chip-group" id="measure0" data-group>
  500. <button type="button" class="chip is-active" data-v="all">全部</button>
  501. <button type="button" class="chip" data-v="yesterday">昨日</button>
  502. <button type="button" class="chip" data-v="today">今日</button>
  503. <button type="button" class="chip" data-v="tomorrow">明日</button>
  504. <button type="button" class="chip" data-v="week">本周</button>
  505. </div>
  506. <input class="quick-search" placeholder="计划编号/客户名称" />
  507. <button type="button" class="btn btn-main">新增计划</button>
  508. <button type="button" class="btn">编辑</button>
  509. <button type="button" class="btn">安排运输</button>
  510. <button type="button" class="btn">等客户通知</button>
  511. <button type="button" class="btn">打印单据</button>
  512. <button type="button" class="btn">作废</button>
  513. <button type="button" class="btn">删除</button>
  514. <div class="list-toolbar-end">
  515. <button type="button" class="btn btn-icon" title="刷新" aria-label="刷新">
  516. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 0 1 1-2.6-6.3"/><path d="M21 3v6h-6"/></svg>
  517. </button>
  518. <button type="button" class="btn btn-icon" title="列设置" aria-label="列设置">
  519. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
  520. </button>
  521. </div>
  522. </div>
  523. </div>
  524. <div class="list-body">
  525. <table class="fake-table">
  526. <thead><tr><th>计划编号</th><th>计划日期</th><th>客户名称</th></tr></thead>
  527. <tbody><tr><td>YS-2026-001</td><td>2026-07-31</td><td>某某化工</td></tr></tbody>
  528. </table>
  529. </div>
  530. </div>
  531. </div>
  532. <p class="note"><strong>问题:</strong>与大量业务按钮挤同一行时,窄屏必横向滚动或折行;日期快捷本身占约 280~320px。</p>
  533. </section>
  534. <!-- A 分段 -->
  535. <section class="section" id="a">
  536. <div class="section-head">
  537. <div>
  538. <h2>A. 分段控件(Segmented)</h2>
  539. <p>五个选项合成一块控件,仍一眼可见、单击切换;外框共用,去掉按钮间隙与描边重复。</p>
  540. </div>
  541. <span class="badge badge-ok">推荐</span>
  542. </div>
  543. <div class="measure">日期区宽约 <span class="px-tag" id="wA">—</span> px</div>
  544. <div class="viewport-frame" style="width: 980px;">
  545. <div class="panel">
  546. <div class="panel-top"><h3>运输计划列表 · 分段控件</h3></div>
  547. <div class="list-toolbar">
  548. <div class="list-toolbar-row">
  549. <div class="list-toolbar-selected">已选 <span class="sel-num">1</span> 项</div>
  550. <div class="seg" id="measureA" data-group role="group" aria-label="计划日期快捷筛选">
  551. <button type="button" class="seg-item is-active" data-v="all">全部</button>
  552. <button type="button" class="seg-item" data-v="yesterday">昨日</button>
  553. <button type="button" class="seg-item" data-v="today">今日</button>
  554. <button type="button" class="seg-item" data-v="tomorrow">明日</button>
  555. <button type="button" class="seg-item" data-v="week">本周</button>
  556. </div>
  557. <input class="quick-search" placeholder="计划编号/客户名称" />
  558. <button type="button" class="btn btn-main">新增计划</button>
  559. <button type="button" class="btn">编辑</button>
  560. <button type="button" class="btn">安排运输</button>
  561. <button type="button" class="btn">等客户通知</button>
  562. <button type="button" class="btn">打印单据</button>
  563. <button type="button" class="btn">作废</button>
  564. <button type="button" class="btn">删除</button>
  565. <div class="list-toolbar-end">
  566. <button type="button" class="btn btn-icon" title="刷新" aria-label="刷新">
  567. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 0 1 1-2.6-6.3"/><path d="M21 3v6h-6"/></svg>
  568. </button>
  569. <button type="button" class="btn btn-icon" title="列设置" aria-label="列设置">
  570. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
  571. </button>
  572. </div>
  573. </div>
  574. </div>
  575. <div class="list-body">
  576. <table class="fake-table">
  577. <thead><tr><th>计划编号</th><th>计划日期</th><th>客户名称</th></tr></thead>
  578. <tbody><tr><td>YS-2026-001</td><td>2026-07-31</td><td>某某化工</td></tr></tbody>
  579. </table>
  580. </div>
  581. </div>
  582. </div>
  583. <p class="note">
  584. <strong>优点:</strong>仍保持「一眼五档」;比五按钮约省 40~70px,视觉更成组。
  585. <strong>落地:</strong>可直接改 <code>ListToolbarDateShortcuts</code> 样式,API 不变。
  586. </p>
  587. </section>
  588. <!-- B 下拉 -->
  589. <section class="section" id="b">
  590. <div class="section-head">
  591. <div>
  592. <h2>B. 下拉选择(Select)</h2>
  593. <p>收成单个选择器,占宽最小;切换需多点一次。适合按钮极多的页。</p>
  594. </div>
  595. <span class="badge badge-mid">最省宽</span>
  596. </div>
  597. <div class="measure">日期区宽约 <span class="px-tag" id="wB">—</span> px</div>
  598. <div class="viewport-frame" style="width: 980px;">
  599. <div class="panel">
  600. <div class="panel-top"><h3>运输计划列表 · 下拉选择</h3></div>
  601. <div class="list-toolbar">
  602. <div class="list-toolbar-row">
  603. <div class="list-toolbar-selected">已选 <span class="sel-num">1</span> 项</div>
  604. <div class="date-select-wrap" id="measureB">
  605. <select class="date-select" aria-label="计划日期快捷筛选">
  606. <option value="all" selected>全部日期</option>
  607. <option value="yesterday">昨日</option>
  608. <option value="today">今日</option>
  609. <option value="tomorrow">明日</option>
  610. <option value="week">本周</option>
  611. </select>
  612. </div>
  613. <input class="quick-search" placeholder="计划编号/客户名称" />
  614. <button type="button" class="btn btn-main">新增计划</button>
  615. <button type="button" class="btn">编辑</button>
  616. <button type="button" class="btn">安排运输</button>
  617. <button type="button" class="btn">等客户通知</button>
  618. <button type="button" class="btn">打印单据</button>
  619. <button type="button" class="btn">作废</button>
  620. <button type="button" class="btn">删除</button>
  621. <div class="list-toolbar-end">
  622. <button type="button" class="btn btn-icon" title="刷新" aria-label="刷新">
  623. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 0 1 1-2.6-6.3"/><path d="M21 3v6h-6"/></svg>
  624. </button>
  625. <button type="button" class="btn btn-icon" title="列设置" aria-label="列设置">
  626. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
  627. </button>
  628. </div>
  629. </div>
  630. </div>
  631. <div class="list-body">
  632. <table class="fake-table">
  633. <thead><tr><th>计划编号</th><th>计划日期</th><th>客户名称</th></tr></thead>
  634. <tbody><tr><td>YS-2026-001</td><td>2026-07-31</td><td>某某化工</td></tr></tbody>
  635. </table>
  636. </div>
  637. </div>
  638. </div>
  639. <p class="note"><strong>取舍:</strong>占宽约 112px,单行最稳;但当前档位不再「平铺可见」,高频切「今日/明日」略慢。</p>
  640. </section>
  641. <!-- C 触发菜单 -->
  642. <section class="section" id="c">
  643. <div class="section-head">
  644. <div>
  645. <h2>C. 日历触发 + 弹出菜单</h2>
  646. <p>显示当前选中文案(如「今日」),点击展开选项。形态接近 Element <code>el-dropdown</code>。</p>
  647. </div>
  648. <span class="badge badge-mid">备选</span>
  649. </div>
  650. <div class="measure">日期区宽约 <span class="px-tag" id="wC">—</span> px(随当前文案变化)</div>
  651. <div class="viewport-frame" style="width: 980px;">
  652. <div class="panel">
  653. <div class="panel-top"><h3>运输计划列表 · 触发菜单</h3></div>
  654. <div class="list-toolbar">
  655. <div class="list-toolbar-row">
  656. <div class="list-toolbar-selected">已选 <span class="sel-num">1</span> 项</div>
  657. <div class="date-trigger-wrap" id="measureC">
  658. <button type="button" class="date-trigger" id="dateTriggerBtn" aria-haspopup="menu" aria-expanded="false">
  659. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2"/><path d="M16 2v4M8 2v4M3 10h18"/></svg>
  660. <span id="dateTriggerLabel">全部</span>
  661. <svg class="caret" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>
  662. </button>
  663. <div class="date-menu" role="menu">
  664. <button type="button" class="is-active" data-v="all" data-label="全部">全部</button>
  665. <button type="button" data-v="yesterday" data-label="昨日">昨日</button>
  666. <button type="button" data-v="today" data-label="今日">今日</button>
  667. <button type="button" data-v="tomorrow" data-label="明日">明日</button>
  668. <button type="button" data-v="week" data-label="本周">本周</button>
  669. </div>
  670. </div>
  671. <input class="quick-search" placeholder="计划编号/客户名称" />
  672. <button type="button" class="btn btn-main">新增计划</button>
  673. <button type="button" class="btn">编辑</button>
  674. <button type="button" class="btn">安排运输</button>
  675. <button type="button" class="btn">等客户通知</button>
  676. <button type="button" class="btn">打印单据</button>
  677. <button type="button" class="btn">作废</button>
  678. <button type="button" class="btn">删除</button>
  679. <div class="list-toolbar-end">
  680. <button type="button" class="btn btn-icon" title="刷新" aria-label="刷新">
  681. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 12a9 9 0 1 1-2.6-6.3"/><path d="M21 3v6h-6"/></svg>
  682. </button>
  683. <button type="button" class="btn btn-icon" title="列设置" aria-label="列设置">
  684. <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>
  685. </button>
  686. </div>
  687. </div>
  688. </div>
  689. <div class="list-body">
  690. <table class="fake-table">
  691. <thead><tr><th>计划编号</th><th>计划日期</th><th>客户名称</th></tr></thead>
  692. <tbody><tr><td>YS-2026-001</td><td>2026-07-31</td><td>某某化工</td></tr></tbody>
  693. </table>
  694. </div>
  695. </div>
  696. </div>
  697. <p class="note"><strong>适用:</strong>希望保留「当前筛选」可读文案,又不想平铺五档时。交互成本与 B 接近。</p>
  698. </section>
  699. <!-- 对比 -->
  700. <section class="section" id="compare">
  701. <div class="section-head">
  702. <div>
  703. <h2>对比与建议</h2>
  704. <p>工具栏保持单行;优先换日期快捷形态,而不是把业务按钮拆到第二行。</p>
  705. </div>
  706. </div>
  707. <div class="compare">
  708. <table>
  709. <thead>
  710. <tr>
  711. <th>方案</th>
  712. <th>占宽</th>
  713. <th>可发现性</th>
  714. <th>切换成本</th>
  715. <th>改动成本</th>
  716. <th>建议</th>
  717. </tr>
  718. </thead>
  719. <tbody>
  720. <tr>
  721. <td>现状五按钮</td>
  722. <td>大</td>
  723. <td>最高</td>
  724. <td>最低(一击)</td>
  725. <td>—</td>
  726. <td>弃用(单行场景)</td>
  727. </tr>
  728. <tr>
  729. <td>A 分段控件</td>
  730. <td>中</td>
  731. <td>高</td>
  732. <td>低(一击)</td>
  733. <td>低(改组件样式)</td>
  734. <td class="rec-mark">推荐默认</td>
  735. </tr>
  736. <tr>
  737. <td>B 下拉选择</td>
  738. <td>最小</td>
  739. <td>中</td>
  740. <td>中(两击)</td>
  741. <td>低</td>
  742. <td>按钮极多时</td>
  743. </tr>
  744. <tr>
  745. <td>C 触发菜单</td>
  746. <td>小</td>
  747. <td>中高</td>
  748. <td>中</td>
  749. <td>中</td>
  750. <td>备选</td>
  751. </tr>
  752. </tbody>
  753. </table>
  754. </div>
  755. </section>
  756. <div class="pick-bar" id="pickBar">
  757. <strong>选定方案:</strong>
  758. <label><input type="radio" name="pick" value="A" checked /> A 分段控件</label>
  759. <label><input type="radio" name="pick" value="B" /> B 下拉选择</label>
  760. <label><input type="radio" name="pick" value="C" /> C 触发菜单</label>
  761. <span style="margin-left: auto; color: var(--text-muted); font-size: 13px;">
  762. 选定后回复我选项代号即可落地到运输计划页
  763. </span>
  764. </div>
  765. </div>
  766. <script>
  767. function bindGroup(root) {
  768. if (!root) return
  769. root.addEventListener('click', (e) => {
  770. const btn = e.target.closest('[data-v]')
  771. if (!btn || !root.contains(btn)) return
  772. root.querySelectorAll('[data-v]').forEach((el) => el.classList.remove('is-active'))
  773. btn.classList.add('is-active')
  774. })
  775. }
  776. bindGroup(document.getElementById('measure0'))
  777. bindGroup(document.getElementById('measureA'))
  778. const wrapC = document.getElementById('measureC')
  779. const btnC = document.getElementById('dateTriggerBtn')
  780. const labelC = document.getElementById('dateTriggerLabel')
  781. btnC.addEventListener('click', (e) => {
  782. e.stopPropagation()
  783. const open = wrapC.classList.toggle('is-open')
  784. btnC.setAttribute('aria-expanded', open ? 'true' : 'false')
  785. measure()
  786. })
  787. wrapC.querySelectorAll('.date-menu button').forEach((item) => {
  788. item.addEventListener('click', (e) => {
  789. e.stopPropagation()
  790. wrapC.querySelectorAll('.date-menu button').forEach((el) => el.classList.remove('is-active'))
  791. item.classList.add('is-active')
  792. labelC.textContent = item.dataset.label
  793. wrapC.classList.remove('is-open')
  794. btnC.setAttribute('aria-expanded', 'false')
  795. measure()
  796. })
  797. })
  798. document.addEventListener('click', () => {
  799. wrapC.classList.remove('is-open')
  800. btnC.setAttribute('aria-expanded', 'false')
  801. })
  802. function measure() {
  803. const set = (id, el) => {
  804. const tag = document.getElementById(id)
  805. if (tag && el) tag.textContent = Math.round(el.getBoundingClientRect().width)
  806. }
  807. set('w0', document.getElementById('measure0'))
  808. set('wA', document.getElementById('measureA'))
  809. set('wB', document.getElementById('measureB'))
  810. set('wC', document.getElementById('measureC'))
  811. }
  812. measure()
  813. window.addEventListener('resize', measure)
  814. </script>
  815. </body>
  816. </html>