Move material selection to home flow
This commit is contained in:
+33
-24
@@ -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; }
|
||||
}
|
||||
|
||||
+69
-36
@@ -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<Material>(materials[0]);
|
||||
const [material, setMaterial] = useState<Material | null>(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() {
|
||||
<div className="content">
|
||||
{step === "home" && (
|
||||
<div className="home-view">
|
||||
<div className="eyebrow"><span /> 安全 · 精准 · 可追溯</div>
|
||||
<h1>废料称重,<br /><em>简单一点。</em></h1>
|
||||
<p>自动识别员工信息,稳定采样并上传记录。<br />请确认秤台处于空载状态后开始。</p>
|
||||
<button className="primary-cta" onClick={fetchIdentity} disabled={loading}>
|
||||
<span className="cta-icon">↗</span>
|
||||
<span><strong>{loading ? "正在连接…" : "开始称重"}</strong><small>读取门禁人员信息</small></span>
|
||||
<b>→</b>
|
||||
</button>
|
||||
<button className="admin-link" onClick={() => setPasswordOpen(true)}>⚙ 管理员登录</button>
|
||||
<div className="home-stats">
|
||||
<span><b>0.001 kg</b>显示精度</span>
|
||||
<span><b>连续采样</b>稳定判断</span>
|
||||
<span><b>4 种</b>废料分类</span>
|
||||
<div className="home-copy">
|
||||
<div className="eyebrow"><span /> 安全 · 精准 · 可追溯</div>
|
||||
<h1>废料称重,<br /><em>简单一点。</em></h1>
|
||||
<p>选择废料类型后开始,系统将自动识别员工信息,<br />稳定采样并上传称重记录。</p>
|
||||
<div className={loading ? "home-start-hint loading" : "home-start-hint"}>
|
||||
<span>{loading ? "···" : "1"}</span>
|
||||
<b>{loading ? `正在读取${material?.name ?? ""}称重信息…` : "点击右侧废料类型,即刻开始"}</b>
|
||||
</div>
|
||||
<button className="admin-link" onClick={() => setPasswordOpen(true)}>⚙ 管理员登录</button>
|
||||
{notice && <div className="notice home-notice">ⓘ {notice}</div>}
|
||||
<div className="home-stats">
|
||||
<span><b>0.001 kg</b>显示精度</span>
|
||||
<span><b>连续采样</b>稳定判断</span>
|
||||
<span><b>4 种</b>废料分类</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<aside className="home-material-panel">
|
||||
<div className="material-panel-heading">
|
||||
<span className="step-kicker">称重前准备</span>
|
||||
<h2>选择废料类型</h2>
|
||||
<p>请选择本次需要称重的废料</p>
|
||||
</div>
|
||||
<div className="home-material-grid">
|
||||
{materials.map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
className={`material-card ${item.tone} ${material?.id === item.id ? "selected" : ""}`}
|
||||
onClick={() => void fetchIdentity(item)}
|
||||
disabled={loading}
|
||||
aria-pressed={material?.id === item.id}
|
||||
>
|
||||
<span className="material-icon">{item.icon}</span>
|
||||
<span><b>{item.name}</b><small>TYPE ID · {item.id}</small></span>
|
||||
<i>{material?.id === item.id ? "✓" : "→"}</i>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className={material ? "material-selection-status ready" : "material-selection-status"}>
|
||||
<span>{loading ? "···" : material ? "✓" : "1"}</span>
|
||||
{loading ? "正在读取门禁人员信息" : material ? `已选择 ${material.name}` : "请选择一种废料类型,选择后自动进入下一步"}
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -264,7 +301,7 @@ export default function Home() {
|
||||
<h2>确认本次称重信息</h2>
|
||||
<p>人员信息由门禁机自动获取,请选择对应生产机台。</p>
|
||||
</div>
|
||||
<button className="refresh-button" onClick={fetchIdentity} disabled={loading}>↻ 重新获取</button>
|
||||
<button className="refresh-button" onClick={() => void fetchIdentity()} disabled={loading}>↻ 重新获取</button>
|
||||
</div>
|
||||
<div className="identity-card">
|
||||
<div className="avatar">{employee.name ? employee.name.slice(-1) : "?"}</div>
|
||||
@@ -311,7 +348,8 @@ export default function Home() {
|
||||
<div className="weigh-meta">
|
||||
<span><small>员工</small><b>{employee.name} · {employee.id}</b></span>
|
||||
<span><small>机台</small><b>{machine}</b></span>
|
||||
<button onClick={() => setStep("identity")}>修改</button>
|
||||
<span className="material-meta"><small>废料类型</small><b>{selectedMaterial.name} · {selectedMaterial.id}</b></span>
|
||||
<button onClick={() => setStep("identity")}>修改人员/机台</button>
|
||||
</div>
|
||||
|
||||
<div className="scale-display">
|
||||
@@ -342,23 +380,18 @@ export default function Home() {
|
||||
<button onClick={addToTotal}>+<span><b>累计</b><small>加入当前重量</small></span></button>
|
||||
</div>
|
||||
|
||||
<div className="material-heading"><span><b>选择废料类型</b><small>点击分类后保存称重记录</small></span><em>必选</em></div>
|
||||
<div className="material-grid">
|
||||
{materials.map((item) => (
|
||||
<button
|
||||
key={item.id}
|
||||
className={`material-card ${item.tone} ${material.id === item.id ? "selected" : ""}`}
|
||||
onClick={() => setMaterial(item)}
|
||||
>
|
||||
<span className="material-icon">{item.icon}</span>
|
||||
<span><b>{item.name}</b><small>TYPE ID · {item.id}</small></span>
|
||||
<i>{material.id === item.id ? "✓" : "→"}</i>
|
||||
</button>
|
||||
))}
|
||||
<div className={`selected-material-summary ${selectedMaterial.tone}`}>
|
||||
<span className="material-icon">{selectedMaterial.icon}</span>
|
||||
<span>
|
||||
<small>本次废料类型</small>
|
||||
<b>{selectedMaterial.name}</b>
|
||||
<em>TYPE ID · {selectedMaterial.id}</em>
|
||||
</span>
|
||||
<i>✓ 已在首页确认</i>
|
||||
</div>
|
||||
{notice && <div className="notice compact">ⓘ {notice}</div>}
|
||||
<button className="full-primary upload" disabled={!stable || loading} onClick={submitWeight}>
|
||||
{loading ? "正在上传…" : stable ? `保存 ${material.name} 称重数据` : "请等待重量稳定"} <span>→</span>
|
||||
{loading ? "正在上传…" : stable ? `保存 ${selectedMaterial.name} 称重数据` : "请等待重量稳定"} <span>→</span>
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
@@ -372,14 +405,14 @@ export default function Home() {
|
||||
<div className="receipt">
|
||||
<div className="receipt-head"><span>称重凭证</span><small>{new Date().toLocaleString("zh-CN", { hour12: false })}</small></div>
|
||||
<div className="receipt-weight">
|
||||
<span><small>{material.name}</small><b>{formatWeight(displayedWeight, unit)} <em>{unit}</em></b></span>
|
||||
<i>{material.icon}</i>
|
||||
<span><small>{selectedMaterial.name}</small><b>{formatWeight(displayedWeight, unit)} <em>{unit}</em></b></span>
|
||||
<i>{selectedMaterial.icon}</i>
|
||||
</div>
|
||||
<dl>
|
||||
<div><dt>员工姓名</dt><dd>{employee.name}</dd></div>
|
||||
<div><dt>员工工号</dt><dd>{employee.id}</dd></div>
|
||||
<div><dt>生产机台</dt><dd>{machine}</dd></div>
|
||||
<div><dt>废料类型 ID</dt><dd>{material.id}</dd></div>
|
||||
<div><dt>废料类型 ID</dt><dd>{selectedMaterial.id}</dd></div>
|
||||
<div><dt>上传状态</dt><dd className="upload-ok">● 已保存</dd></div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user