2026-10-05-contract-plan-line-qty-demo.html 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  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. --bg-page: #f1f5f9;
  20. --table-head: #f8fafc;
  21. --row-alt: #fafafa;
  22. --shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  23. --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.14);
  24. --radius: 10px;
  25. --warn: #d97706;
  26. --warn-bg: #fffbeb;
  27. --danger: #dc2626;
  28. --danger-bg: #fef2f2;
  29. --info: #0284c7;
  30. --info-bg: #f0f9ff;
  31. --info-border: #bae6fd;
  32. }
  33. * { box-sizing: border-box; }
  34. body {
  35. margin: 0;
  36. min-height: 100vh;
  37. font-family: Inter, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  38. font-size: 14px;
  39. line-height: 1.5;
  40. color: var(--text);
  41. background: var(--bg-page);
  42. }
  43. .page { max-width: 1320px; margin: 0 auto; padding: 24px 20px 80px; }
  44. .hero {
  45. background: linear-gradient(135deg, #ecfdf5 0%, #fff 50%, #f0f9ff 100%);
  46. border: 1px solid var(--border);
  47. border-radius: var(--radius);
  48. padding: 20px 22px;
  49. margin-bottom: 14px;
  50. box-shadow: var(--shadow);
  51. }
  52. .hero h1 { margin: 0 0 8px; font-size: 22px; font-weight: 700; }
  53. .hero h1 em { font-style: normal; color: var(--primary-dark); }
  54. .hero p { margin: 0; color: var(--text-muted); max-width: 1040px; }
  55. .pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
  56. .pill {
  57. padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500;
  58. background: var(--primary-bg); color: var(--primary-dark); border: 1px solid #a7f3d0;
  59. }
  60. .pill.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
  61. .pill.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
  62. .pill.muted { background: #f1f5f9; color: var(--text-muted); border-color: #e2e8f0; }
  63. .steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  64. .step-btn {
  65. border: 1px solid var(--border); background: #fff; border-radius: 8px;
  66. padding: 8px 14px; font: inherit; font-weight: 600; font-size: 13px;
  67. color: var(--text-muted); cursor: pointer;
  68. }
  69. .step-btn:hover { border-color: #a7f3d0; color: var(--primary-dark); }
  70. .step-btn.active {
  71. background: var(--primary-bg); border-color: var(--primary); color: var(--primary-dark);
  72. }
  73. .step-btn .n {
  74. display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center;
  75. border-radius: 999px; background: #e2e8f0; color: #475569; font-size: 11px; margin-right: 6px;
  76. }
  77. .step-btn.active .n { background: var(--primary); color: #fff; }
  78. .panel { display: none; }
  79. .panel.active { display: block; }
  80. .callout {
  81. margin-bottom: 12px; padding: 10px 12px; border-radius: 8px; font-size: 13px;
  82. border: 1px solid #a7f3d0; background: var(--primary-bg); color: #047857;
  83. }
  84. .callout.warn { border-color: #fde68a; background: var(--warn-bg); color: #92400e; }
  85. .callout.info { border-color: var(--info-border); background: var(--info-bg); color: #0369a1; }
  86. .callout.danger { border-color: #fecaca; background: var(--danger-bg); color: #991b1b; }
  87. .dialog-sim {
  88. background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  89. box-shadow: var(--shadow-lg); overflow: hidden; max-height: calc(100vh - 120px);
  90. display: flex; flex-direction: column;
  91. }
  92. .dialog-sim__hd {
  93. padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700;
  94. background: linear-gradient(180deg, #ecfdf5, #fff);
  95. display: flex; align-items: center; justify-content: space-between; gap: 12px;
  96. }
  97. .dialog-sim__hd .sub { font-weight: 500; font-size: 12px; color: var(--text-muted); }
  98. .dialog-sim__bd { padding: 16px 18px; overflow: auto; }
  99. .dialog-sim__ft {
  100. padding: 12px 18px; border-top: 1px solid var(--border); background: var(--table-head);
  101. display: flex; justify-content: flex-end; gap: 8px;
  102. }
  103. .sec-title {
  104. margin: 0 0 10px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px;
  105. }
  106. .sec-title::before {
  107. content: ""; width: 3px; height: 14px; background: var(--primary); border-radius: 2px;
  108. }
  109. .form-grid {
  110. display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 12px; margin-bottom: 14px;
  111. }
  112. @media (max-width: 900px) { .form-grid { grid-template-columns: 1fr 1fr; } }
  113. .field label {
  114. display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px;
  115. }
  116. .field .ctl, .field input, .field select {
  117. width: 100%; height: 36px; border: 1px solid var(--border); border-radius: 8px;
  118. padding: 0 10px; font: inherit; background: #fff;
  119. }
  120. .field .ctl.ro { background: #f8fafc; display: flex; align-items: center; color: var(--text-muted); }
  121. .field input:focus, .field select:focus {
  122. outline: none; border-color: var(--primary);
  123. box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
  124. }
  125. table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
  126. table.mini th, table.mini td {
  127. border-bottom: 1px solid #eef2f0; padding: 8px 10px; text-align: left; vertical-align: middle;
  128. }
  129. table.mini th {
  130. background: var(--table-head); color: var(--text-muted); font-weight: 600; font-size: 12px;
  131. }
  132. table.mini tr:nth-child(even) td { background: var(--row-alt); }
  133. table.mini tr.dup td { background: #ecfdf5 !important; box-shadow: inset 3px 0 0 var(--primary); }
  134. table.mini tr.over td { background: #fef2f2 !important; box-shadow: inset 3px 0 0 var(--danger); }
  135. table.mini input[type="number"] {
  136. width: 88px; height: 32px; border: 1px solid var(--border); border-radius: 8px;
  137. padding: 0 8px; font: inherit;
  138. }
  139. table.mini tr.over input { border-color: #fca5a5; background: #fff; }
  140. .tag {
  141. display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 4px;
  142. font-size: 11px; font-weight: 600; background: #059669; color: #fff;
  143. }
  144. .tag.warn { background: #d97706; }
  145. .tag.danger { background: #dc2626; }
  146. .tag.info { background: transparent; color: #1e293b; border: 1px solid #cbd5e1; }
  147. .mono { font-variant-numeric: tabular-nums; }
  148. .muted { color: var(--text-muted); }
  149. .price { color: var(--warn); font-weight: 700; }
  150. .btn {
  151. display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px;
  152. border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text);
  153. font: inherit; font-weight: 600; font-size: 13px; cursor: pointer;
  154. }
  155. .btn:hover { border-color: #a7f3d0; }
  156. .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
  157. .btn.primary:hover { background: var(--primary-dark); }
  158. .btn.ghost { background: var(--primary-bg); border-color: #a7f3d0; color: var(--primary-dark); }
  159. .btn.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
  160. .btn.link { height: auto; padding: 0; border: none; background: none; color: var(--primary-dark); }
  161. .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  162. .toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 10px; }
  163. .chips { display: flex; flex-wrap: wrap; gap: 6px; }
  164. .chip {
  165. display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 6px;
  166. background: var(--primary-bg); border: 1px solid #a7f3d0; font-size: 12px; font-weight: 600;
  167. color: var(--primary-dark);
  168. }
  169. .chip .x {
  170. width: 16px; height: 16px; border: none; border-radius: 4px; background: #fff;
  171. color: var(--text-muted); cursor: pointer; line-height: 1;
  172. }
  173. .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  174. @media (max-width: 980px) { .cols { grid-template-columns: 1fr; } }
  175. .box { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  176. .box-h {
  177. padding: 10px 12px; background: #f8fafc; border-bottom: 1px solid var(--border);
  178. font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; gap: 8px;
  179. }
  180. .box-h.load { border-left: 3px solid var(--primary); }
  181. .box-h.delivery { border-left: 3px solid var(--info); }
  182. .box-b { padding: 10px 12px; }
  183. .mask {
  184. display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35);
  185. z-index: 40; align-items: center; justify-content: center; padding: 20px;
  186. backdrop-filter: none;
  187. }
  188. .mask.show { display: flex; }
  189. .modal {
  190. width: min(640px, 100%); background: #fff; border-radius: var(--radius);
  191. box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px);
  192. display: flex; flex-direction: column; overflow: hidden;
  193. }
  194. .modal-h { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
  195. .modal-b { padding: 16px 18px; overflow: auto; }
  196. .modal-f {
  197. padding: 12px 18px; border-top: 1px solid var(--border); background: var(--table-head);
  198. display: flex; justify-content: flex-end; gap: 8px;
  199. }
  200. .driver {
  201. max-width: 390px; margin: 0 auto; background: #fff; border-radius: 18px;
  202. border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow);
  203. }
  204. .driver-hd {
  205. background: linear-gradient(180deg, #0a9f6d, #087f57); color: #fff; padding: 18px 16px 22px;
  206. border-radius: 0 0 20px 20px;
  207. }
  208. .driver-hd h3 { margin: 0; font-size: 16px; }
  209. .driver-hd p { margin: 4px 0 0; font-size: 12px; opacity: .9; }
  210. .driver-bd { padding: 14px; }
  211. .driver-card {
  212. border: 1px solid #d1fae5; background: #e9f9f2; border-radius: 12px; padding: 12px; margin-bottom: 10px;
  213. }
  214. .driver-card .k { font-size: 12px; color: #087f57; }
  215. .driver-card .v { font-size: 18px; font-weight: 700; }
  216. .toast {
  217. position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(16px);
  218. background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px;
  219. font-size: 13px; opacity: 0; pointer-events: none; transition: .2s; z-index: 70; max-width: 90vw;
  220. }
  221. .toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
  222. .remain.neg { color: var(--danger); font-weight: 700; }
  223. .sum-bar {
  224. margin-top: 8px; font-size: 12px; color: var(--text-muted);
  225. display: flex; flex-wrap: wrap; gap: 12px;
  226. }
  227. .sum-bar.bad { color: var(--danger); font-weight: 600; }
  228. .sum-bar.ok { color: var(--primary-dark); font-weight: 600; }
  229. </style>
  230. </head>
  231. <body>
  232. <div class="page">
  233. <header class="hero">
  234. <h1>合同明细多单价行 × 运输计划绑合同行 × <em>归档确认实际量</em></h1>
  235. <p>
  236. 按 2026-10-05 已定口径:计划员保存时按「合同行 + 目标量」拆行;归档填实际量;超剩余红字高亮并二次确认;
  237. 司机/现场只看产品与数量。本页是界面示意,可点操作,不是现网页面。
  238. </p>
  239. <div class="pills">
  240. <span class="pill warn">同品同包装可多行</span>
  241. <span class="pill warn">装/送货多选合同</span>
  242. <span class="pill">选合同行,不先选产品再拆</span>
  243. <span class="pill info">计划可超剩余 · 安排才硬拦</span>
  244. <span class="pill info">归档超交 · 红字 + 二次确认</span>
  245. <span class="pill muted">司机现场不展示合同</span>
  246. </div>
  247. </header>
  248. <nav class="steps">
  249. <button class="step-btn active" data-step="1"><span class="n">1</span>合同 · 新增/编辑弹窗</button>
  250. <button class="step-btn" data-step="2"><span class="n">2</span>运输计划 · 新增/编辑</button>
  251. <button class="step-btn" data-step="3"><span class="n">3</span>安排运输 · 硬拦</button>
  252. <button class="step-btn" data-step="4"><span class="n">4</span>归档 · 实际量与超交</button>
  253. <button class="step-btn" data-step="5"><span class="n">5</span>司机 / 现场</button>
  254. <button class="step-btn" data-step="6"><span class="n">6</span>合同详情挂量</button>
  255. </nav>
  256. <!-- 1 Contract form -->
  257. <section class="panel active" id="panel-1">
  258. <div class="callout warn">
  259. <strong>相对现状:</strong>现网会提示「同一产品的包装规格不能重复」。下面弹窗允许两行都是「次氯酸钠 / 槽罐车」,单价不同。
  260. </div>
  261. <article class="dialog-sim">
  262. <div class="dialog-sim__hd">
  263. <div>编辑合同 <span class="sub">HT-A · 客户:安徽某某水务</span></div>
  264. </div>
  265. <div class="dialog-sim__bd">
  266. <div class="form-grid">
  267. <div class="field"><label>合同编号</label><div class="ctl ro">HT-A-2026-088</div></div>
  268. <div class="field"><label>客户</label><div class="ctl ro">安徽某某水务</div></div>
  269. <div class="field"><label>合同类型</label><div class="ctl ro">销售合同</div></div>
  270. <div class="field"><label>状态</label><div class="ctl ro"><span class="tag">执行中</span></div></div>
  271. </div>
  272. <h3 class="sec-title">产品明细</h3>
  273. <div class="toolbar">
  274. <button class="btn primary" type="button" id="btn-add-line">+ 添加产品行</button>
  275. <span class="muted" style="font-size:12px">同品同包装允许重复;请用单价 / 数量区分行。</span>
  276. </div>
  277. <table class="mini" id="tbl-contract">
  278. <thead>
  279. <tr>
  280. <th>#</th>
  281. <th>产品</th>
  282. <th>包装规格</th>
  283. <th>合同数量</th>
  284. <th>含税单价</th>
  285. <th>说明</th>
  286. <th></th>
  287. </tr>
  288. </thead>
  289. <tbody></tbody>
  290. </table>
  291. </div>
  292. <div class="dialog-sim__ft">
  293. <button class="btn" type="button">取消</button>
  294. <button class="btn primary" type="button" id="btn-save-contract">确定保存</button>
  295. </div>
  296. </article>
  297. </section>
  298. <!-- 2 Plan form -->
  299. <section class="panel" id="panel-2">
  300. <div class="callout">
  301. <strong>计划员视角:</strong>知道本车对应哪些合同行、各多少目标吨。装货/送货可多选合同;添加产品时直接选「合同行」,不要只选产品名。
  302. </div>
  303. <article class="dialog-sim">
  304. <div class="dialog-sim__hd">
  305. <div>新增运输计划 <span class="sub">PO20261005001 · 直销单</span></div>
  306. </div>
  307. <div class="dialog-sim__bd">
  308. <div class="form-grid">
  309. <div class="field"><label>计划日期</label><div class="ctl ro">2026-10-05</div></div>
  310. <div class="field"><label>单据类型</label><div class="ctl ro">直销单</div></div>
  311. <div class="field"><label>车牌</label><div class="ctl ro">皖 H12xxx</div></div>
  312. <div class="field"><label>本车目标合计</label><div class="ctl ro mono" id="plan-total">0 吨</div></div>
  313. </div>
  314. <h3 class="sec-title">装送货信息</h3>
  315. <div class="cols">
  316. <div class="box">
  317. <div class="box-h load"><span>装货信息</span><span class="muted" style="font-weight:500">客户:安徽某某水务</span></div>
  318. <div class="box-b">
  319. <label class="muted" style="font-size:11px;font-weight:600">合同(可多选)</label>
  320. <div class="chips" id="load-chips" style="margin:6px 0 10px"></div>
  321. <div class="toolbar" style="margin-top:0">
  322. <button class="btn ghost" type="button" id="btn-add-load-row">+ 添加装货产品(选合同行)</button>
  323. </div>
  324. <table class="mini" id="tbl-load"><thead>
  325. <tr><th>合同行</th><th>产品 / 包装</th><th>单价</th><th>剩余</th><th>目标量</th><th></th></tr>
  326. </thead><tbody></tbody></table>
  327. </div>
  328. </div>
  329. <div class="box">
  330. <div class="box-h delivery"><span>送货信息 #1</span><span class="muted" style="font-weight:500">同一客户</span></div>
  331. <div class="box-b">
  332. <label class="muted" style="font-size:11px;font-weight:600">合同(可多选)</label>
  333. <div class="chips" id="delivery-chips" style="margin:6px 0 10px"></div>
  334. <div class="toolbar" style="margin-top:0">
  335. <button class="btn ghost" type="button" id="btn-add-delivery-row">+ 添加送货产品(选合同行)</button>
  336. <button class="btn" type="button" id="btn-sync">从装货同步目标量</button>
  337. </div>
  338. <table class="mini" id="tbl-delivery"><thead>
  339. <tr><th>合同行</th><th>产品 / 包装</th><th>单价</th><th>剩余</th><th>目标量</th><th></th></tr>
  340. </thead><tbody></tbody></table>
  341. </div>
  342. </div>
  343. </div>
  344. <p class="muted" style="margin:10px 0 0;font-size:12px">草稿保存不拦超剩余。下方「保存草稿」可超;「安排运输」会硬拦(见步骤 3)。</p>
  345. </div>
  346. <div class="dialog-sim__ft">
  347. <button class="btn" type="button">取消</button>
  348. <button class="btn" type="button" id="btn-save-draft">保存草稿</button>
  349. <button class="btn primary" type="button" id="btn-go-arrange">安排运输…</button>
  350. </div>
  351. </article>
  352. </section>
  353. <!-- 3 Arrange -->
  354. <section class="panel" id="panel-3">
  355. <div class="callout warn">
  356. <strong>安排运输硬拦:</strong>任一合同行目标量 &gt; 该行剩余时,禁止安排。请先改目标量或换行。不会记到别的同品行。
  357. </div>
  358. <article class="dialog-sim" style="max-width:720px;margin:0 auto">
  359. <div class="dialog-sim__hd">安排运输</div>
  360. <div class="dialog-sim__bd">
  361. <p class="muted" style="margin:0 0 10px">将按当前送货目标量检查合同行剩余。</p>
  362. <table class="mini" id="tbl-arrange-check">
  363. <thead><tr><th>合同行</th><th>目标量</th><th>剩余</th><th>结果</th></tr></thead>
  364. <tbody></tbody>
  365. </table>
  366. </div>
  367. <div class="dialog-sim__ft">
  368. <button class="btn" type="button" data-step="2">返回改目标量</button>
  369. <button class="btn primary" type="button" id="btn-confirm-arrange">确认安排</button>
  370. </div>
  371. </article>
  372. </section>
  373. <!-- 4 Archive -->
  374. <section class="panel" id="panel-4">
  375. <div class="callout info">
  376. <strong>归档:</strong>行结构与计划相同。实际量默认=目标量,可改。地磅实发须等于各行实际合计。某行超过该行剩余时红字,必须二次确认才归档。
  377. </div>
  378. <article class="dialog-sim">
  379. <div class="dialog-sim__hd">
  380. <div>运输计划归档 <span class="sub">PO20261005001 · 已完成运输</span></div>
  381. </div>
  382. <div class="dialog-sim__bd">
  383. <h3 class="sec-title">装卸货归档 · 送货段</h3>
  384. <div class="form-grid" style="grid-template-columns:repeat(3,1fr)">
  385. <div class="field"><label>地磅 / 本车实发</label><input id="weigh-total" type="number" step="0.001" value="30" /></div>
  386. <div class="field"><label>各行实际合计</label><div class="ctl ro mono" id="actual-sum">—</div></div>
  387. <div class="field"><label>对齐结果</label><div class="ctl ro" id="align-result">—</div></div>
  388. </div>
  389. <table class="mini" id="tbl-archive">
  390. <thead>
  391. <tr>
  392. <th>合同行</th>
  393. <th>产品 / 包装</th>
  394. <th>单价</th>
  395. <th>目标量</th>
  396. <th>该行剩余(归档前)</th>
  397. <th>实际量</th>
  398. </tr>
  399. </thead>
  400. <tbody></tbody>
  401. </table>
  402. <div class="sum-bar" id="archive-hint"></div>
  403. <div class="toolbar">
  404. <button class="btn" type="button" id="btn-demo-over">演示超交:行1 实际量改 55,地磅改 75</button>
  405. <span class="muted" style="font-size:12px">用于弹出红字二次确认。行2、行3 仍为 10,合计 75。</span>
  406. </div>
  407. </div>
  408. <div class="dialog-sim__ft">
  409. <button class="btn" type="button">取消</button>
  410. <button class="btn primary" type="button" id="btn-archive">确认归档</button>
  411. </div>
  412. </article>
  413. </section>
  414. <!-- 5 Driver -->
  415. <section class="panel" id="panel-5">
  416. <div class="callout">
  417. <strong>司机 / 现场:</strong>不展示合同号、单价、合同行。只看到产品和大约数量。内部仍按合同行记账。
  418. </div>
  419. <div class="driver">
  420. <div class="driver-hd">
  421. <h3>送货任务</h3>
  422. <p>皖 H12xxx · 安徽某某水务</p>
  423. </div>
  424. <div class="driver-bd">
  425. <div class="driver-card">
  426. <div class="k">产品</div>
  427. <div class="v">次氯酸钠 · 槽罐车</div>
  428. </div>
  429. <div class="driver-card">
  430. <div class="k">本车数量(仅供现场)</div>
  431. <div class="v" id="driver-qty">30 吨</div>
  432. </div>
  433. <p class="muted" style="font-size:12px;margin:0">不会出现 HT-A / HT-B、800 元 / 850 元等合同信息。</p>
  434. </div>
  435. </div>
  436. </section>
  437. <!-- 6 Contract detail -->
  438. <section class="panel" id="panel-6">
  439. <div class="callout warn">
  440. <strong>合同详情:</strong>同品同包装并排两行,各自已归档 / 剩余。超交显示负数或「超交」,绝不合并成一行。
  441. </div>
  442. <article class="dialog-sim">
  443. <div class="dialog-sim__hd">查看合同 HT-A-2026-088</div>
  444. <div class="dialog-sim__bd">
  445. <h3 class="sec-title">产品明细 · 履约数量</h3>
  446. <table class="mini" id="tbl-detail">
  447. <thead>
  448. <tr>
  449. <th>产品</th><th>包装</th><th>单价</th><th>合同量</th>
  450. <th>已归档</th><th>未归档已安排</th><th>剩余</th>
  451. </tr>
  452. </thead>
  453. <tbody></tbody>
  454. </table>
  455. </div>
  456. </article>
  457. </section>
  458. </div>
  459. <!-- pick contract line -->
  460. <div class="mask" id="mask-pick">
  461. <div class="modal">
  462. <div class="modal-h" id="pick-title">选择合同产品行</div>
  463. <div class="modal-b">
  464. <p class="muted" style="margin:0 0 10px;font-size:13px">仅列出本段已选合同中的明细。同品同包装会因单价不同出现多行,请点目标那一行。</p>
  465. <table class="mini" id="tbl-pick">
  466. <thead><tr><th>合同</th><th>产品 / 包装</th><th>单价</th><th>剩余</th><th></th></tr></thead>
  467. <tbody></tbody>
  468. </table>
  469. </div>
  470. <div class="modal-f">
  471. <button class="btn" type="button" data-close="mask-pick">取消</button>
  472. </div>
  473. </div>
  474. </div>
  475. <!-- overage confirm -->
  476. <div class="mask" id="mask-over">
  477. <div class="modal" style="width:min(560px,100%)">
  478. <div class="modal-h" style="color:#991b1b">实际量超过合同行剩余</div>
  479. <div class="modal-b">
  480. <div class="callout danger" style="margin-bottom:12px">
  481. 不会记到其它同品同包装行。确认后超交部分记在下列指定行,剩余将为负(超交)。
  482. </div>
  483. <table class="mini" id="tbl-over">
  484. <thead><tr><th>合同行</th><th>剩余</th><th>实际量</th><th>超出</th></tr></thead>
  485. <tbody></tbody>
  486. </table>
  487. </div>
  488. <div class="modal-f">
  489. <button class="btn" type="button" data-close="mask-over">返回修改</button>
  490. <button class="btn danger" type="button" id="btn-over-ok">我已确认,仍然归档</button>
  491. </div>
  492. </div>
  493. </div>
  494. <div class="toast" id="toast"></div>
  495. <script>
  496. const PRODUCT = { id: 'p-nao', name: '次氯酸钠', pkg: '槽罐车' }
  497. let contractLines = [
  498. { id: '行1', contractId: 'HT-A', contractNo: 'HT-A-2026-088', productId: PRODUCT.id, name: PRODUCT.name, pkg: PRODUCT.pkg, qty: 50, price: 800, arrangedUnarchived: 0, archived: 0, note: '低价行' },
  499. { id: '行2', contractId: 'HT-A', contractNo: 'HT-A-2026-088', productId: PRODUCT.id, name: PRODUCT.name, pkg: PRODUCT.pkg, qty: 40, price: 850, arrangedUnarchived: 0, archived: 0, note: '高价行' },
  500. { id: '行3', contractId: 'HT-B', contractNo: 'HT-B-2026-012', productId: PRODUCT.id, name: PRODUCT.name, pkg: PRODUCT.pkg, qty: 80, price: 820, arrangedUnarchived: 0, archived: 0, note: '另一合同' },
  501. { id: '行4', contractId: 'HT-A', contractNo: 'HT-A-2026-088', productId: 'p-hcl', name: '工业盐酸', pkg: '槽罐车', qty: 100, price: 180, arrangedUnarchived: 0, archived: 0, note: '其它产品' }
  502. ]
  503. const loadContracts = ['HT-A', 'HT-B']
  504. const deliveryContracts = ['HT-A', 'HT-B']
  505. let loadRows = []
  506. let deliveryRows = []
  507. let pickSide = 'load'
  508. let arranged = false
  509. let archivedOk = false
  510. function remaining(line) {
  511. return Math.round((line.qty - line.archived - line.arrangedUnarchived) * 1000) / 1000
  512. }
  513. function toast(msg) {
  514. const el = document.getElementById('toast')
  515. el.textContent = msg
  516. el.classList.add('show')
  517. clearTimeout(toast._t)
  518. toast._t = setTimeout(() => el.classList.remove('show'), 2800)
  519. }
  520. function openMask(id) { document.getElementById(id).classList.add('show') }
  521. function closeMask(id) { document.getElementById(id).classList.remove('show') }
  522. function lineById(id) { return contractLines.find((l) => l.id === id) }
  523. function renderContractForm() {
  524. const tb = document.querySelector('#tbl-contract tbody')
  525. tb.innerHTML = ''
  526. contractLines.filter((l) => l.contractId === 'HT-A').forEach((l, i) => {
  527. const dup = l.productId === PRODUCT.id
  528. const tr = document.createElement('tr')
  529. if (dup) tr.className = 'dup'
  530. tr.innerHTML = `
  531. <td>${i + 1}</td>
  532. <td>${l.name}</td>
  533. <td>${l.pkg}</td>
  534. <td class="mono">${l.qty}</td>
  535. <td class="mono ${dup ? 'price' : ''}">¥ ${l.price}</td>
  536. <td>${dup ? '<span class="tag warn">同品同包装</span> ' : ''}<span class="muted">${l.note}</span></td>
  537. <td>${dup ? '' : ''}</td>`
  538. tb.appendChild(tr)
  539. })
  540. }
  541. function renderChips() {
  542. const html = (ids) => ids.map((id) => {
  543. const no = id === 'HT-A' ? 'HT-A-2026-088' : 'HT-B-2026-012'
  544. return `<span class="chip">${no}<span class="muted" style="font-weight:500">${id === 'HT-A' ? '安徽某某水务' : '安徽某某水务(框架)'}</span></span>`
  545. }).join('')
  546. document.getElementById('load-chips').innerHTML = html(loadContracts)
  547. document.getElementById('delivery-chips').innerHTML = html(deliveryContracts)
  548. }
  549. function renderStopTable(sel, rows) {
  550. const tb = document.querySelector(sel)
  551. tb.innerHTML = ''
  552. if (!rows.length) {
  553. tb.innerHTML = `<tr><td colspan="6" class="muted">尚未添加。点「选合同行」添加目标量。</td></tr>`
  554. return
  555. }
  556. rows.forEach((r, idx) => {
  557. const line = lineById(r.cpId)
  558. const tr = document.createElement('tr')
  559. tr.className = 'dup'
  560. const rem = remaining(line)
  561. const over = r.planQty > rem + 1e-9
  562. tr.innerHTML = `
  563. <td class="mono">${line.contractNo}<div class="muted" style="font-size:11px">${line.id} · ${line.note}</div></td>
  564. <td>${line.name} / ${line.pkg}</td>
  565. <td class="mono price">¥ ${line.price}</td>
  566. <td class="mono">${rem}</td>
  567. <td><input type="number" min="0" step="0.001" value="${r.planQty}" data-side="${sel.includes('load') ? 'load' : 'delivery'}" data-idx="${idx}" /></td>
  568. <td><button class="btn link" type="button" data-del="${sel.includes('load') ? 'load' : 'delivery'}" data-idx="${idx}">删除</button></td>`
  569. if (over) tr.classList.add('over')
  570. tb.appendChild(tr)
  571. })
  572. tb.querySelectorAll('input').forEach((inp) => {
  573. inp.addEventListener('input', () => {
  574. const side = inp.dataset.side
  575. const idx = Number(inp.dataset.idx)
  576. const v = Number(inp.value) || 0
  577. if (side === 'load') loadRows[idx].planQty = v
  578. else deliveryRows[idx].planQty = v
  579. const line = lineById((side === 'load' ? loadRows : deliveryRows)[idx].cpId)
  580. inp.closest('tr').classList.toggle('over', v > remaining(line) + 1e-9)
  581. updatePlanTotal()
  582. })
  583. })
  584. tb.querySelectorAll('[data-del]').forEach((btn) => {
  585. btn.addEventListener('click', () => {
  586. const idx = Number(btn.dataset.idx)
  587. if (btn.dataset.del === 'load') loadRows.splice(idx, 1)
  588. else deliveryRows.splice(idx, 1)
  589. renderPlan()
  590. })
  591. })
  592. }
  593. function updatePlanTotal() {
  594. const sum = deliveryRows.reduce((s, r) => s + (Number(r.planQty) || 0), 0)
  595. document.getElementById('plan-total').textContent = (Math.round(sum * 1000) / 1000) + ' 吨'
  596. document.getElementById('driver-qty').textContent = (Math.round(sum * 1000) / 1000) + ' 吨'
  597. }
  598. function renderPlan() {
  599. renderChips()
  600. renderStopTable('#tbl-load tbody', loadRows)
  601. renderStopTable('#tbl-delivery tbody', deliveryRows)
  602. updatePlanTotal()
  603. }
  604. function openPick(side) {
  605. pickSide = side
  606. document.getElementById('pick-title').textContent = side === 'load' ? '装货 · 选择合同产品行' : '送货 · 选择合同产品行'
  607. const ids = side === 'load' ? loadContracts : deliveryContracts
  608. const used = new Set((side === 'load' ? loadRows : deliveryRows).map((r) => r.cpId))
  609. const tb = document.querySelector('#tbl-pick tbody')
  610. tb.innerHTML = ''
  611. contractLines.filter((l) => ids.includes(l.contractId)).forEach((l) => {
  612. const tr = document.createElement('tr')
  613. if (l.productId === PRODUCT.id) tr.className = 'dup'
  614. const disabled = used.has(l.id)
  615. tr.innerHTML = `
  616. <td>${l.contractNo}</td>
  617. <td>${l.name} / ${l.pkg}</td>
  618. <td class="mono price">¥ ${l.price}</td>
  619. <td class="mono">${remaining(l)}</td>
  620. <td>${disabled ? '<span class="muted">已添加</span>' : `<button class="btn ghost" type="button" data-pick="${l.id}">选用此行</button>`}</td>`
  621. tb.appendChild(tr)
  622. })
  623. tb.querySelectorAll('[data-pick]').forEach((btn) => {
  624. btn.addEventListener('click', () => {
  625. const line = lineById(btn.dataset.pick)
  626. const row = { cpId: line.id, planQty: 10, actualQty: null }
  627. if (pickSide === 'load') loadRows.push(row)
  628. else deliveryRows.push(row)
  629. closeMask('mask-pick')
  630. renderPlan()
  631. toast('已绑定合同行 ' + line.id + ',请改目标量')
  632. })
  633. })
  634. openMask('mask-pick')
  635. }
  636. function seedDemoRows() {
  637. if (loadRows.length) return
  638. loadRows = [
  639. { cpId: '行1', planQty: 10, actualQty: null },
  640. { cpId: '行2', planQty: 10, actualQty: null },
  641. { cpId: '行3', planQty: 10, actualQty: null }
  642. ]
  643. deliveryRows = loadRows.map((r) => ({ ...r }))
  644. }
  645. function renderArrangeCheck() {
  646. const tb = document.querySelector('#tbl-arrange-check tbody')
  647. tb.innerHTML = ''
  648. if (!deliveryRows.length) {
  649. tb.innerHTML = `<tr><td colspan="4" class="muted">请先在步骤 2 添加合同行。</td></tr>`
  650. return
  651. }
  652. deliveryRows.forEach((r) => {
  653. const line = lineById(r.cpId)
  654. const rem = remaining(line)
  655. const ok = r.planQty <= rem + 1e-9
  656. const tr = document.createElement('tr')
  657. if (!ok) tr.className = 'over'
  658. tr.innerHTML = `
  659. <td>${line.contractNo} · ${line.id} · ¥${line.price}</td>
  660. <td class="mono">${r.planQty}</td>
  661. <td class="mono">${rem}</td>
  662. <td>${ok ? '<span class="tag">通过</span>' : '<span class="tag danger">超过剩余,禁止安排</span>'}</td>`
  663. tb.appendChild(tr)
  664. })
  665. }
  666. function arrangeOk() {
  667. return deliveryRows.every((r) => r.planQty <= remaining(lineById(r.cpId)) + 1e-9)
  668. }
  669. function occupyUnarchived() {
  670. contractLines.forEach((l) => { l.arrangedUnarchived = 0 })
  671. deliveryRows.forEach((r) => {
  672. const line = lineById(r.cpId)
  673. line.arrangedUnarchived += r.planQty
  674. })
  675. }
  676. function renderArchive() {
  677. const tb = document.querySelector('#tbl-archive tbody')
  678. tb.innerHTML = ''
  679. if (!deliveryRows.length) {
  680. tb.innerHTML = `<tr><td colspan="6" class="muted">请先完成步骤 2 的拆行。</td></tr>`
  681. return
  682. }
  683. deliveryRows.forEach((r, idx) => {
  684. const line = lineById(r.cpId)
  685. if (r.actualQty == null) r.actualQty = r.planQty
  686. const rem = remaining(line) + (arranged ? r.planQty : 0)
  687. const over = r.actualQty > rem + 1e-9
  688. const tr = document.createElement('tr')
  689. if (over) tr.className = 'over'
  690. tr.innerHTML = `
  691. <td class="mono">${line.contractNo}<div class="muted" style="font-size:11px">${line.id} · ${line.note}</div></td>
  692. <td>${line.name} / ${line.pkg}</td>
  693. <td class="mono price">¥ ${line.price}</td>
  694. <td class="mono">${r.planQty}</td>
  695. <td class="mono">${Math.round(rem * 1000) / 1000}</td>
  696. <td><input type="number" min="0" step="0.001" value="${r.actualQty}" data-idx="${idx}" /></td>`
  697. tb.appendChild(tr)
  698. })
  699. tb.querySelectorAll('input').forEach((inp) => {
  700. inp.addEventListener('input', () => {
  701. const idx = Number(inp.dataset.idx)
  702. deliveryRows[idx].actualQty = Number(inp.value) || 0
  703. const line = lineById(deliveryRows[idx].cpId)
  704. const rem = remaining(line) + (arranged ? deliveryRows[idx].planQty : 0)
  705. inp.closest('tr').classList.toggle('over', deliveryRows[idx].actualQty > rem + 1e-9)
  706. updateArchiveSum()
  707. })
  708. })
  709. updateArchiveSum()
  710. }
  711. function updateArchiveSum() {
  712. const sum = deliveryRows.reduce((s, r) => s + (Number(r.actualQty ?? r.planQty) || 0), 0)
  713. const weigh = Number(document.getElementById('weigh-total').value) || 0
  714. const aligned = Math.abs(sum - weigh) < 0.0005
  715. document.getElementById('actual-sum').textContent = (Math.round(sum * 1000) / 1000) + ' 吨'
  716. const res = document.getElementById('align-result')
  717. res.innerHTML = aligned ? '<span class="tag">已对齐</span>' : '<span class="tag danger">与地磅不一致</span>'
  718. const hint = document.getElementById('archive-hint')
  719. const overs = overageRows()
  720. hint.className = 'sum-bar' + (aligned && !overs.length ? ' ok' : ' bad')
  721. hint.textContent = aligned
  722. ? (overs.length ? `地磅已对齐,但有 ${overs.length} 行超过合同剩余。` : '地磅已对齐,各行未超剩余。')
  723. : `各行实际合计 ${sum} ≠ 地磅 ${weigh},不能归档。`
  724. }
  725. function overageRows() {
  726. return deliveryRows.filter((r) => {
  727. const line = lineById(r.cpId)
  728. const rem = remaining(line) + (arranged ? r.planQty : 0)
  729. return (r.actualQty ?? 0) > rem + 1e-9
  730. }).map((r) => {
  731. const line = lineById(r.cpId)
  732. const rem = remaining(line) + (arranged ? r.planQty : 0)
  733. const actual = r.actualQty ?? 0
  734. return { line, rem, actual, over: Math.round((actual - rem) * 1000) / 1000 }
  735. })
  736. }
  737. function tryArchive() {
  738. const weigh = Number(document.getElementById('weigh-total').value) || 0
  739. const sum = deliveryRows.reduce((s, r) => s + (Number(r.actualQty ?? r.planQty) || 0), 0)
  740. if (Math.abs(sum - weigh) >= 0.0005) {
  741. toast('各行实际合计必须等于地磅实发')
  742. return
  743. }
  744. const overs = overageRows()
  745. if (overs.length) {
  746. const tb = document.querySelector('#tbl-over tbody')
  747. tb.innerHTML = overs.map((o) => `
  748. <tr class="over">
  749. <td>${o.line.contractNo} · ${o.line.id} · ¥${o.line.price}</td>
  750. <td class="mono">${o.rem}</td>
  751. <td class="mono">${o.actual}</td>
  752. <td class="mono remain neg">+${o.over}</td>
  753. </tr>`).join('')
  754. openMask('mask-over')
  755. return
  756. }
  757. commitArchive()
  758. }
  759. function commitArchive() {
  760. closeMask('mask-over')
  761. contractLines.forEach((l) => { l.arrangedUnarchived = 0 })
  762. deliveryRows.forEach((r) => {
  763. const line = lineById(r.cpId)
  764. line.archived += Number(r.actualQty) || 0
  765. })
  766. archivedOk = true
  767. arranged = false
  768. renderDetail()
  769. toast('已归档:实际量记在指定合同行')
  770. gotoStep(6)
  771. }
  772. function renderDetail() {
  773. const tb = document.querySelector('#tbl-detail tbody')
  774. tb.innerHTML = ''
  775. contractLines.filter((l) => l.contractId === 'HT-A').forEach((l) => {
  776. const rem = remaining(l)
  777. const tr = document.createElement('tr')
  778. if (l.productId === PRODUCT.id) tr.className = rem < 0 ? 'over' : 'dup'
  779. tr.innerHTML = `
  780. <td>${l.name}</td>
  781. <td>${l.pkg}</td>
  782. <td class="mono price">¥ ${l.price}</td>
  783. <td class="mono">${l.qty}</td>
  784. <td class="mono">${Math.round(l.archived * 1000) / 1000}</td>
  785. <td class="mono">${Math.round(l.arrangedUnarchived * 1000) / 1000}</td>
  786. <td class="mono ${rem < 0 ? 'remain neg' : ''}">${rem < 0 ? '超交 ' + Math.abs(rem) : rem}</td>`
  787. tb.appendChild(tr)
  788. })
  789. }
  790. function gotoStep(n) {
  791. document.querySelectorAll('.step-btn').forEach((b) => b.classList.toggle('active', b.dataset.step === String(n)))
  792. document.querySelectorAll('.panel').forEach((p) => p.classList.toggle('active', p.id === 'panel-' + n))
  793. if (n === '2' || n === 2) {
  794. seedDemoRows()
  795. renderPlan()
  796. }
  797. if (n === '3' || n === 3) {
  798. seedDemoRows()
  799. renderPlan()
  800. renderArrangeCheck()
  801. }
  802. if (n === '4' || n === 4) {
  803. seedDemoRows()
  804. if (!arranged) {
  805. /* 归档前视为已安排,占用按目标量 */
  806. occupyUnarchived()
  807. arranged = true
  808. }
  809. renderArchive()
  810. }
  811. if (n === '6' || n === 6) renderDetail()
  812. window.scrollTo({ top: 0, behavior: 'smooth' })
  813. }
  814. document.querySelectorAll('.step-btn, [data-step]').forEach((b) => {
  815. if (b._stepBound) return
  816. b._stepBound = true
  817. b.addEventListener('click', () => gotoStep(b.dataset.step))
  818. })
  819. document.querySelectorAll('[data-close]').forEach((b) => b.addEventListener('click', () => closeMask(b.dataset.close)))
  820. document.getElementById('btn-add-line').addEventListener('click', () => {
  821. contractLines.push({
  822. id: '行' + (contractLines.length + 1),
  823. contractId: 'HT-A',
  824. contractNo: 'HT-A-2026-088',
  825. productId: PRODUCT.id,
  826. name: PRODUCT.name,
  827. pkg: PRODUCT.pkg,
  828. qty: 15,
  829. price: 860,
  830. arrangedUnarchived: 0,
  831. archived: 0,
  832. note: '演示再加一行同品同包装'
  833. })
  834. renderContractForm()
  835. toast('已追加同品同包装行(现网会被拦住)')
  836. })
  837. document.getElementById('btn-save-contract').addEventListener('click', () => {
  838. toast('合同已保存:同品同包装多行有效')
  839. gotoStep(2)
  840. })
  841. document.getElementById('btn-add-load-row').addEventListener('click', () => openPick('load'))
  842. document.getElementById('btn-add-delivery-row').addEventListener('click', () => openPick('delivery'))
  843. document.getElementById('btn-sync').addEventListener('click', () => {
  844. deliveryRows = loadRows.map((r) => ({ ...r, actualQty: null }))
  845. renderPlan()
  846. toast('已从装货同步目标量到送货')
  847. })
  848. document.getElementById('btn-save-draft').addEventListener('click', () => {
  849. toast('草稿已保存(允许目标量暂时超过剩余)')
  850. })
  851. document.getElementById('btn-go-arrange').addEventListener('click', () => gotoStep(3))
  852. document.getElementById('btn-confirm-arrange').addEventListener('click', () => {
  853. if (!deliveryRows.length) { toast('请先添加送货合同行'); return }
  854. if (!arrangeOk()) { toast('存在超过剩余的合同行,不能安排'); renderArrangeCheck(); return }
  855. occupyUnarchived()
  856. arranged = true
  857. toast('安排成功:各行按目标量占用额度')
  858. gotoStep(4)
  859. })
  860. document.getElementById('weigh-total').addEventListener('input', updateArchiveSum)
  861. document.getElementById('btn-demo-over').addEventListener('click', () => {
  862. const row = deliveryRows.find((r) => r.cpId === '行1')
  863. if (row) row.actualQty = 55
  864. document.getElementById('weigh-total').value = '75'
  865. renderArchive()
  866. toast('行1 已标红。点「确认归档」会弹出二次确认')
  867. })
  868. document.getElementById('btn-archive').addEventListener('click', tryArchive)
  869. document.getElementById('btn-over-ok').addEventListener('click', commitArchive)
  870. document.getElementById('mask-pick').addEventListener('click', (e) => { if (e.target.id === 'mask-pick') closeMask('mask-pick') })
  871. document.getElementById('mask-over').addEventListener('click', (e) => { if (e.target.id === 'mask-over') closeMask('mask-over') })
  872. renderContractForm()
  873. renderDetail()
  874. </script>
  875. </body>
  876. </html>