From f5ef61a1ce8d1d09bc10c6016ab91cbae51335a2 Mon Sep 17 00:00:00 2001 From: Codex Date: Tue, 28 Jul 2026 12:12:34 +0800 Subject: [PATCH] Move material selection to home flow --- app/globals.css | 57 +++++++++++++++----------- app/page.tsx | 105 +++++++++++++++++++++++++++++++----------------- 2 files changed, 102 insertions(+), 60 deletions(-) diff --git a/app/globals.css b/app/globals.css index 532478d..3b311e4 100644 --- a/app/globals.css +++ b/app/globals.css @@ -61,27 +61,34 @@ button:disabled { cursor: not-allowed; opacity: .55; } .content { flex: 1; display: grid; } footer { min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 38px; border-top: 1px solid var(--line); color: #94a098; font-size: 10px; letter-spacing: .04em; } -.home-view { padding: 64px clamp(44px, 9vw, 110px) 44px; position: relative; background-image: linear-gradient(90deg, transparent 0 63%, rgba(0,127,95,.035) 63%); } -.home-view::after { content: ""; position: absolute; right: 9%; top: 17%; width: 250px; height: 250px; border: 1px solid rgba(0,127,95,.13); border-radius: 50%; box-shadow: 0 0 0 35px rgba(0,127,95,.025), 0 0 0 72px rgba(0,127,95,.018); } -.home-view::before { content: "kg"; position: absolute; right: calc(9% + 80px); top: calc(17% + 76px); z-index: 1; color: rgba(0,127,95,.7); font-size: 70px; font-weight: 200; letter-spacing: -.08em; } +.home-view { padding: 46px clamp(36px, 6vw, 70px) 34px; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr); align-items: center; gap: clamp(36px, 6vw, 74px); position: relative; } +.home-copy { min-width: 0; } .eyebrow, .step-kicker { color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; } .eyebrow { display: flex; align-items: center; gap: 8px; } .eyebrow span { width: 20px; height: 2px; background: #e5a63c; } -h1 { font-size: clamp(48px, 6vw, 70px); line-height: 1.03; letter-spacing: -.06em; margin: 19px 0 24px; max-width: 590px; } +h1 { font-size: clamp(46px, 5.2vw, 64px); line-height: 1.03; letter-spacing: -.06em; margin: 19px 0 21px; max-width: 590px; } h1 em { font-style: normal; color: var(--green); } -.home-view > p { color: var(--muted); line-height: 1.85; font-size: 14px; } -.primary-cta { margin-top: 30px; min-width: 360px; display: flex; align-items: center; gap: 15px; border: 0; border-radius: 14px; padding: 14px 18px; background: var(--green); color: white; box-shadow: 0 15px 32px rgba(0,127,95,.24); text-align: left; transition: .2s ease; } -.primary-cta:hover { transform: translateY(-2px); background: var(--green-dark); } -.primary-cta .cta-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.13); font-size: 21px; } -.primary-cta strong, .primary-cta small { display: block; } -.primary-cta strong { font-size: 16px; margin-bottom: 4px; } -.primary-cta small { font-size: 10px; opacity: .68; } -.primary-cta b { margin-left: auto; font-size: 21px; } +.home-copy > p { color: var(--muted); line-height: 1.85; font-size: 13px; } +.home-start-hint { width: min(390px, 100%); display: flex; align-items: center; gap: 10px; margin-top: 25px; padding: 12px 14px; border: 1px solid #bedacd; border-radius: 12px; background: var(--mint); color: var(--green); font-size: 10px; } +.home-start-hint span { width: 26px; height: 26px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--green); color: white; font-size: 9px; } +.home-start-hint.loading span { animation: pulse 1s ease-in-out infinite; } +@keyframes pulse { 50% { opacity: .45; transform: scale(.92); } } .admin-link { margin-top: 15px; margin-left: 8px; border: 0; background: none; color: #68746e; font-size: 12px; } .admin-link:hover { color: var(--green); } -.home-stats { margin-top: 46px; display: flex; gap: 42px; color: #849088; font-size: 10px; } +.home-notice { width: min(390px, 100%); } +.home-stats { margin-top: 36px; display: flex; gap: 32px; color: #849088; font-size: 9px; } .home-stats span { padding-left: 12px; border-left: 2px solid #e0e6e1; } .home-stats b { display: block; color: var(--ink); font-size: 13px; margin-bottom: 4px; } +.home-material-panel { position: relative; padding: 23px; border: 1px solid rgba(255,255,255,.9); border-radius: 21px; background: rgba(255,255,255,.7); box-shadow: 0 18px 50px rgba(30,56,43,.1), inset 0 1px #fff; } +.home-material-panel::before { content: ""; position: absolute; width: 180px; height: 180px; right: -60px; top: -55px; z-index: -1; border-radius: 50%; background: rgba(0,127,95,.08); box-shadow: 0 0 0 32px rgba(0,127,95,.025); } +.material-panel-heading h2 { margin: 7px 0 5px; font-size: 23px; letter-spacing: -.035em; } +.material-panel-heading p { margin: 0 0 16px; color: var(--muted); font-size: 10px; } +.home-material-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; } +.home-material-grid .material-card { min-height: 73px; } +.material-selection-status { display: flex; align-items: center; gap: 8px; margin-top: 13px; padding: 9px 11px; border-radius: 9px; background: #eef1ee; color: #7c8781; font-size: 9px; font-weight: 700; } +.material-selection-status span { width: 19px; height: 19px; display: grid; place-items: center; border: 1px solid #bfc8c2; border-radius: 50%; font-size: 8px; } +.material-selection-status.ready { background: var(--mint); color: var(--green); } +.material-selection-status.ready span { border-color: var(--green); background: var(--green); color: white; } .panel-view { width: min(760px, calc(100% - 48px)); margin: 0 auto; padding: 35px 0; } .section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 24px; } @@ -112,7 +119,8 @@ h1 em { font-style: normal; color: var(--green); } .weigh-view { padding: 22px 32px 28px; } .weigh-meta { display: flex; gap: 0; border: 1px solid var(--line); background: white; border-radius: 11px; padding: 10px 14px; margin-bottom: 14px; } -.weigh-meta > span { min-width: 210px; padding-right: 20px; margin-right: 20px; border-right: 1px solid var(--line); } +.weigh-meta > span { min-width: 170px; padding-right: 18px; margin-right: 18px; border-right: 1px solid var(--line); } +.weigh-meta > span.material-meta { min-width: 230px; } .weigh-meta small, .weigh-meta b { display: block; } .weigh-meta small { color: #8a958f; font-size: 9px; margin-bottom: 4px; } .weigh-meta b { font-size: 11px; } @@ -139,12 +147,6 @@ h1 em { font-style: normal; color: var(--green); } .scale-tools span, .scale-tools b, .scale-tools small { display: block; } .scale-tools b { color: var(--ink); font-size: 11px; } .scale-tools small { color: #909a94; font-size: 8px; margin-top: 3px; } -.material-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; } -.material-heading span, .material-heading b, .material-heading small { display: block; } -.material-heading b { font-size: 12px; } -.material-heading small { color: #8b9690; font-size: 9px; margin-top: 3px; } -.material-heading em { color: #a16e15; background: #f8eed7; font-style: normal; font-size: 8px; padding: 4px 7px; border-radius: 99px; } -.material-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; } .material-card { min-width: 0; display: flex; align-items: center; gap: 10px; position: relative; border: 1px solid var(--line); border-radius: 11px; background: white; padding: 12px 10px; text-align: left; } .material-card:hover { transform: translateY(-1px); } .material-card.selected { border: 2px solid var(--green); background: #f3faf7; padding: 11px 9px; } @@ -157,6 +159,13 @@ h1 em { font-style: normal; color: var(--green); } .material-card b { font-size: 11px; } .material-card small { margin-top: 4px; color: #9aa39e; font-size: 6px; } .material-card i { margin-left: auto; font-size: 10px; color: var(--green); font-style: normal; } +.selected-material-summary { display: flex; align-items: center; gap: 12px; border: 1px solid #bedacd; border-radius: 12px; background: #f3faf7; padding: 12px 15px; } +.selected-material-summary > span:nth-child(2) { flex: 1; } +.selected-material-summary small, .selected-material-summary b, .selected-material-summary em { display: block; } +.selected-material-summary small { color: #7a8a82; font-size: 8px; } +.selected-material-summary b { margin: 2px 0; font-size: 14px; } +.selected-material-summary em { color: #8c9891; font-size: 7px; font-style: normal; } +.selected-material-summary > i { color: var(--green); font-size: 9px; font-style: normal; font-weight: 800; } .full-primary.upload { margin-top: 18px; } .result-view { width: min(520px, calc(100% - 48px)); margin: auto; padding: 28px 0; text-align: center; } @@ -207,10 +216,10 @@ h1 em { font-style: normal; color: var(--green); } .status-pill { font-size: 0; padding: 9px; } .progress-strip { gap: 12px; padding-inline: 12px; } .progress-item { font-size: 9px; gap: 4px; } - .home-view { padding: 52px 24px 34px; background-image: none; } - .home-view::after, .home-view::before { display: none; } + .home-view { padding: 38px 24px 34px; display: block; } h1 { font-size: 48px; } - .primary-cta { min-width: 0; width: 100%; } + .home-material-panel { margin-top: 30px; } + .home-start-hint { width: 100%; } .home-stats { gap: 15px; justify-content: space-between; } .panel-view { width: calc(100% - 32px); padding: 27px 0; } .section-heading { display: block; } @@ -221,7 +230,7 @@ h1 em { font-style: normal; color: var(--green); } .display-details { gap: 15px; } .scale-tools button { justify-content: center; padding: 10px 5px; } .scale-tools button > span { display: none; } - .material-grid { grid-template-columns: repeat(2, 1fr); } + .weigh-meta > span.material-meta { display: none; } .settings-card label { grid-template-columns: 1fr; gap: 7px; } footer { padding: 0 16px; } } diff --git a/app/page.tsx b/app/page.tsx index e2298e5..088d354 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -40,7 +40,7 @@ export default function Home() { const [zeroOffset, setZeroOffset] = useState(0); const [tare, setTare] = useState(0); const [totalKg, setTotalKg] = useState(0); - const [material, setMaterial] = useState(materials[0]); + const [material, setMaterial] = useState(null); const [stable, setStable] = useState(false); const [stableProgress, setStableProgress] = useState(0); const [countdown, setCountdown] = useState(10); @@ -57,6 +57,7 @@ export default function Home() { const netWeight = Math.max(0, rawWeight - zeroOffset - tare); const displayedWeight = totalKg + netWeight; + const selectedMaterial = material ?? materials[0]; const filteredMachines = useMemo( () => @@ -111,6 +112,7 @@ export default function Home() { function resetToHome() { setStep("home"); + setMaterial(null); setMachine(""); setMachineQuery(""); setTotalKg(0); @@ -121,7 +123,13 @@ export default function Home() { stableSamples.current = []; } - async function fetchIdentity() { + async function fetchIdentity(chosenMaterial?: Material) { + const activeMaterial = chosenMaterial ?? material; + if (!activeMaterial) { + setNotice("请先选择本次称重的废料类型"); + return; + } + if (chosenMaterial) setMaterial(chosenMaterial); setLoading(true); setNotice(""); try { @@ -166,8 +174,8 @@ export default function Home() { employeeName: employee.name, employeeId: employee.id, machineId: machine, - materialType: material.name, - materialTypeId: material.id, + materialType: selectedMaterial.name, + materialTypeId: selectedMaterial.id, weightKg: Number(displayedWeight.toFixed(3)), createdAt: new Date().toISOString(), }; @@ -239,20 +247,49 @@ export default function Home() {
{step === "home" && (
-
安全 · 精准 · 可追溯
-

废料称重,
简单一点。

-

自动识别员工信息,稳定采样并上传记录。
请确认秤台处于空载状态后开始。

- - -
- 0.001 kg显示精度 - 连续采样稳定判断 - 4 种废料分类 +
+
安全 · 精准 · 可追溯
+

废料称重,
简单一点。

+

选择废料类型后开始,系统将自动识别员工信息,
稳定采样并上传称重记录。

+
+ {loading ? "···" : "1"} + {loading ? `正在读取${material?.name ?? ""}称重信息…` : "点击右侧废料类型,即刻开始"} +
+ + {notice &&
ⓘ {notice}
} +
+ 0.001 kg显示精度 + 连续采样稳定判断 + 4 种废料分类 +
+ +
)} @@ -264,7 +301,7 @@ export default function Home() {

确认本次称重信息

人员信息由门禁机自动获取,请选择对应生产机台。

- +
{employee.name ? employee.name.slice(-1) : "?"}
@@ -311,7 +348,8 @@ export default function Home() {
员工{employee.name} · {employee.id} 机台{machine} - + 废料类型{selectedMaterial.name} · {selectedMaterial.id} +
@@ -342,23 +380,18 @@ export default function Home() {
-
选择废料类型点击分类后保存称重记录必选
-
- {materials.map((item) => ( - - ))} +
+ {selectedMaterial.icon} + + 本次废料类型 + {selectedMaterial.name} + TYPE ID · {selectedMaterial.id} + + ✓ 已在首页确认
{notice &&
ⓘ {notice}
}
)} @@ -372,14 +405,14 @@ export default function Home() {
称重凭证{new Date().toLocaleString("zh-CN", { hour12: false })}
- {material.name}{formatWeight(displayedWeight, unit)} {unit} - {material.icon} + {selectedMaterial.name}{formatWeight(displayedWeight, unit)} {unit} + {selectedMaterial.icon}
员工姓名
{employee.name}
员工工号
{employee.id}
生产机台
{machine}
-
废料类型 ID
{material.id}
+
废料类型 ID
{selectedMaterial.id}
上传状态
● 已保存