add:增加区域点位状态看板,看板在docs/点位状态查看.html
This commit is contained in:
441
nladmin-system/docs/点位状态查看.html
Normal file
441
nladmin-system/docs/点位状态查看.html
Normal file
@@ -0,0 +1,441 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>点位状态</title>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: #eef1f4;
|
||||
color: #1f2933;
|
||||
font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
.page {
|
||||
max-width: 1280px;
|
||||
margin: 0 auto;
|
||||
padding: 28px 24px 48px;
|
||||
}
|
||||
h1 {
|
||||
margin: 0 0 6px;
|
||||
font-size: 22px;
|
||||
font-weight: 600;
|
||||
}
|
||||
.hint {
|
||||
margin: 0 0 18px;
|
||||
color: #667085;
|
||||
font-size: 13px;
|
||||
}
|
||||
.panel {
|
||||
margin-top: 24px;
|
||||
background: #fff;
|
||||
border: 1px solid #e4e7ec;
|
||||
border-radius: 10px;
|
||||
padding: 16px;
|
||||
}
|
||||
button.panel-toggle {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
margin: 0;
|
||||
padding: 0 0 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: transparent;
|
||||
color: #1f2933;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
border-radius: 0;
|
||||
}
|
||||
.panel.collapsed button.panel-toggle { padding-bottom: 0; }
|
||||
.chevron {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-right: 2px solid #475467;
|
||||
border-bottom: 2px solid #475467;
|
||||
transform: rotate(45deg);
|
||||
transition: transform 0.15s ease;
|
||||
}
|
||||
.panel.collapsed .chevron { transform: rotate(-135deg); }
|
||||
.panel.collapsed .panel-body { display: none; }
|
||||
label {
|
||||
display: block;
|
||||
margin: 12px 0 8px;
|
||||
font-size: 13px;
|
||||
color: #475467;
|
||||
}
|
||||
.panel-body > label:first-child { margin-top: 0; }
|
||||
textarea, input[type="text"] {
|
||||
width: 100%;
|
||||
border: 1px solid #d0d5dd;
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
background: #fff;
|
||||
}
|
||||
textarea {
|
||||
min-height: 72px;
|
||||
resize: vertical;
|
||||
}
|
||||
textarea:focus, input[type="text"]:focus {
|
||||
outline: 2px solid #bfd4fe;
|
||||
border-color: #84adff;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
margin-top: 12px;
|
||||
}
|
||||
.row input[type="text"] { flex: 1; }
|
||||
button {
|
||||
height: 40px;
|
||||
padding: 0 18px;
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
background: #175cd3;
|
||||
color: #fff;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
button:disabled { opacity: 0.6; cursor: default; }
|
||||
.msg {
|
||||
min-height: 20px;
|
||||
margin: 10px 0 0;
|
||||
font-size: 13px;
|
||||
color: #b42318;
|
||||
}
|
||||
.legend {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
margin: 0 2px 16px;
|
||||
font-size: 13px;
|
||||
color: #475467;
|
||||
}
|
||||
.legend span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.dot {
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #d0d5dd;
|
||||
}
|
||||
.dot.gray { background: #9ca3af; border-color: #9ca3af; }
|
||||
.dot.white { background: #fff; }
|
||||
.dot.red { background: #e53935; border-color: #e53935; }
|
||||
.board {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
.line {
|
||||
display: flex;
|
||||
gap: 16px;
|
||||
}
|
||||
.cell {
|
||||
flex: 1;
|
||||
min-height: 180px;
|
||||
padding: 20px 16px;
|
||||
border-radius: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.cell .region {
|
||||
font-size: 13px;
|
||||
opacity: 0.85;
|
||||
}
|
||||
.cell .code {
|
||||
font-size: 32px;
|
||||
font-weight: 650;
|
||||
word-break: break-all;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.cell .state { font-size: 20px; }
|
||||
.cell .pallet {
|
||||
font-size: 16px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
margin-top: 4px;
|
||||
}
|
||||
.actions button {
|
||||
height: 36px;
|
||||
padding: 0 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.actions .btn-empty {
|
||||
background: #fff;
|
||||
color: #1f2933;
|
||||
border: 1px solid #98a2b3;
|
||||
}
|
||||
.actions .btn-full {
|
||||
background: #c62828;
|
||||
color: #fff;
|
||||
}
|
||||
.actions button:disabled {
|
||||
background: #e4e7ec;
|
||||
color: #98a2b3;
|
||||
border: 1px solid #e4e7ec;
|
||||
cursor: not-allowed;
|
||||
opacity: 1;
|
||||
}
|
||||
.msg.ok { color: #027a48; }
|
||||
.cell.unknown { background: #9ca3af; color: #fff; }
|
||||
.cell.empty {
|
||||
background: #fff;
|
||||
color: #1f2933;
|
||||
border: 1px solid #d0d5dd;
|
||||
}
|
||||
.cell.full { background: #e53935; color: #fff; }
|
||||
.empty-tip {
|
||||
color: #98a2b3;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page">
|
||||
<h1>点位状态</h1>
|
||||
<p class="hint">按点位区域查询。有货需要填写托盘号;点位存在未完成任务时不能修改状态。</p>
|
||||
<div class="legend">
|
||||
<span><i class="dot white"></i>无货</span>
|
||||
<span><i class="dot red"></i>有货</span>
|
||||
</div>
|
||||
<div class="board" id="board">
|
||||
</div>
|
||||
<div class="panel" id="configPanel">
|
||||
<button id="toggleConfig" class="panel-toggle" type="button">
|
||||
<span>查询设置</span>
|
||||
<i class="chevron"></i>
|
||||
</button>
|
||||
<div class="panel-body" id="configBody">
|
||||
<label for="regions">点位区域列表</label>
|
||||
<textarea id="regions" placeholder="例如:RG01,RG02"></textarea>
|
||||
<div class="row">
|
||||
<input id="base" type="text" value="http://127.0.0.1:8011" aria-label="服务地址" />
|
||||
<button id="query" type="button">查询</button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="msg" id="msg"></p>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
const regionsEl = document.getElementById("regions");
|
||||
const baseEl = document.getElementById("base");
|
||||
const configPanel = document.getElementById("configPanel");
|
||||
const msgEl = document.getElementById("msg");
|
||||
const boardEl = document.getElementById("board");
|
||||
const queryBtn = document.getElementById("query");
|
||||
let timer = null;
|
||||
let loading = false;
|
||||
let currentRegions = [];
|
||||
|
||||
const savedRegions = localStorage.getItem("pointStatus.regions");
|
||||
const savedBase = localStorage.getItem("pointStatus.base");
|
||||
if (savedRegions) regionsEl.value = savedRegions;
|
||||
if (savedBase) baseEl.value = savedBase;
|
||||
if (localStorage.getItem("pointStatus.configCollapsed") === "1") {
|
||||
configPanel.classList.add("collapsed");
|
||||
}
|
||||
|
||||
function parseRegions(text) {
|
||||
const seen = new Set();
|
||||
const list = [];
|
||||
text.split(",").forEach(function (part) {
|
||||
const code = part.trim();
|
||||
if (!code || seen.has(code)) return;
|
||||
seen.add(code);
|
||||
list.push(code);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
function classify(item) {
|
||||
const status = item && item.point_status != null ? String(item.point_status) : "";
|
||||
const vehicle = item && item.vehicle_code ? String(item.vehicle_code).trim() : "";
|
||||
if (status === "2" || status === "3" || vehicle) {
|
||||
return { cls: "full", text: "有货", pallet: vehicle };
|
||||
}
|
||||
if (status === "1" || status === "") {
|
||||
return { cls: "empty", text: "无货", pallet: "" };
|
||||
}
|
||||
return { cls: "unknown", text: "状态 " + status, pallet: vehicle };
|
||||
}
|
||||
|
||||
function render(points) {
|
||||
boardEl.innerHTML = "";
|
||||
if (!points.length) {
|
||||
const tip = document.createElement("div");
|
||||
tip.className = "empty-tip";
|
||||
tip.textContent = "未查询到点位";
|
||||
boardEl.appendChild(tip);
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < points.length; i += 4) {
|
||||
const line = document.createElement("div");
|
||||
line.className = "line";
|
||||
points.slice(i, i + 4).forEach(function (item) {
|
||||
const info = classify(item);
|
||||
const cell = document.createElement("div");
|
||||
cell.className = "cell " + info.cls;
|
||||
const regionEl = document.createElement("div");
|
||||
regionEl.className = "region";
|
||||
regionEl.textContent = item.region_name || item.region_code || "";
|
||||
const codeEl = document.createElement("div");
|
||||
codeEl.className = "code";
|
||||
codeEl.textContent = item.point_code || "";
|
||||
const stateEl = document.createElement("div");
|
||||
stateEl.className = "state";
|
||||
stateEl.textContent = info.text;
|
||||
cell.appendChild(regionEl);
|
||||
cell.appendChild(codeEl);
|
||||
cell.appendChild(stateEl);
|
||||
if (info.pallet) {
|
||||
const palletEl = document.createElement("div");
|
||||
palletEl.className = "pallet";
|
||||
palletEl.textContent = info.pallet;
|
||||
cell.appendChild(palletEl);
|
||||
}
|
||||
const actions = document.createElement("div");
|
||||
actions.className = "actions";
|
||||
actions.appendChild(actionButton(item.point_code, "0", "无货", "btn-empty", info.pallet));
|
||||
actions.appendChild(actionButton(item.point_code, "1", "有货", "btn-full", info.pallet));
|
||||
cell.appendChild(actions);
|
||||
line.appendChild(cell);
|
||||
});
|
||||
boardEl.appendChild(line);
|
||||
}
|
||||
}
|
||||
|
||||
function actionButton(code, act, text, cls, pallet) {
|
||||
const btn = document.createElement("button");
|
||||
btn.type = "button";
|
||||
btn.className = "act " + cls;
|
||||
btn.dataset.code = code;
|
||||
btn.dataset.act = act;
|
||||
btn.dataset.pallet = pallet || "";
|
||||
btn.textContent = text;
|
||||
return btn;
|
||||
}
|
||||
|
||||
function apiBase() {
|
||||
return baseEl.value.trim().replace(/\/$/, "");
|
||||
}
|
||||
|
||||
function showMsg(text, ok) {
|
||||
msgEl.textContent = text || "";
|
||||
msgEl.classList.toggle("ok", !!ok);
|
||||
}
|
||||
|
||||
async function readBody(res) {
|
||||
return res.json().catch(function () { return null; });
|
||||
}
|
||||
|
||||
function assertOk(res, body, fallback) {
|
||||
const failed = !res.ok || (body && (body.success === "E" || (body.code && body.code !== 200)));
|
||||
if (failed) {
|
||||
throw new Error((body && (body.message || body.respMsg)) || fallback);
|
||||
}
|
||||
}
|
||||
|
||||
async function maintainStatus(code, hasGoods, vehicleCode) {
|
||||
const payload = { point_code: code, has_goods: hasGoods };
|
||||
if (hasGoods) payload.vehicle_code = vehicleCode;
|
||||
const res = await fetch(apiBase() + "/api/schBasePoint/maintainStatus", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
const body = await readBody(res);
|
||||
assertOk(res, body, "修改点位状态失败");
|
||||
showMsg(code + (hasGoods ? " 已改为有货,托盘 " + vehicleCode : " 已改为无货"), true);
|
||||
fetchStatus();
|
||||
}
|
||||
|
||||
function stopPoll() {
|
||||
if (timer) {
|
||||
clearInterval(timer);
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchStatus() {
|
||||
if (loading || !currentRegions.length) return;
|
||||
loading = true;
|
||||
try {
|
||||
const res = await fetch(apiBase() + "/api/schBasePoint/listByRegions", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(currentRegions)
|
||||
});
|
||||
const body = await readBody(res);
|
||||
assertOk(res, body, "查询失败");
|
||||
const rows = body && Array.isArray(body.data) ? body.data : [];
|
||||
if (!msgEl.classList.contains("ok")) showMsg("");
|
||||
render(rows);
|
||||
} catch (err) {
|
||||
showMsg(err && err.message ? err.message : "查询失败", false);
|
||||
} finally {
|
||||
loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
function confirmRegions() {
|
||||
const regions = parseRegions(regionsEl.value);
|
||||
localStorage.setItem("pointStatus.regions", regionsEl.value);
|
||||
localStorage.setItem("pointStatus.base", baseEl.value.trim());
|
||||
stopPoll();
|
||||
if (!regions.length) {
|
||||
currentRegions = [];
|
||||
showMsg("请输入点位区域,多个区域用英文逗号隔开", false);
|
||||
boardEl.innerHTML = "";
|
||||
return;
|
||||
}
|
||||
currentRegions = regions;
|
||||
showMsg("");
|
||||
fetchStatus();
|
||||
timer = setInterval(fetchStatus, 5000);
|
||||
}
|
||||
|
||||
queryBtn.addEventListener("click", confirmRegions);
|
||||
document.getElementById("toggleConfig").addEventListener("click", function () {
|
||||
configPanel.classList.toggle("collapsed");
|
||||
localStorage.setItem("pointStatus.configCollapsed", configPanel.classList.contains("collapsed") ? "1" : "0");
|
||||
});
|
||||
boardEl.addEventListener("click", function (event) {
|
||||
const btn = event.target.closest("button[data-act]");
|
||||
if (!btn || btn.disabled) return;
|
||||
const code = btn.dataset.code;
|
||||
const hasGoods = btn.dataset.act === "1";
|
||||
let vehicleCode = "";
|
||||
if (hasGoods) {
|
||||
const input = window.prompt("请输入托盘号", btn.dataset.pallet || "");
|
||||
if (input == null) return;
|
||||
vehicleCode = input.trim();
|
||||
if (!vehicleCode) {
|
||||
showMsg("有货必须填写托盘号", false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
btn.disabled = true;
|
||||
maintainStatus(code, hasGoods, vehicleCode).catch(function (err) {
|
||||
showMsg(err && err.message ? err.message : "操作失败", false);
|
||||
}).finally(function () {
|
||||
btn.disabled = false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user