Files
GX.O3.WMS/WebApi/.svn/pristine/83/83f4f8ddcd809aa4627cf1c9188b8f935f0dcbe9.svn-base
T

297 lines
13 KiB
Plaintext
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>交付物料风险明细</title>
<link rel="stylesheet" href="../common/nav.css">
<link rel="stylesheet" href="../common/grid.css">
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Microsoft YaHei','PingFang SC',sans-serif; background: #f3f5fa; color: #2c3e50; padding: 14px 18px; }
.head { display: flex; align-items: center; margin-bottom: 12px; gap: 12px; }
.head h2 { font-size: 20px; }
.head .back { padding: 6px 14px; background: #fff; border: 1px solid #dcdfe6; border-radius: 6px; cursor: pointer; font-size: 13px; }
.head .back:hover { border-color: #409eff; color: #409eff; }
.head .meta { font-size: 13px; color: #909399; margin-left: auto; }
.filter { background: #fff; border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.filter span { font-size: 13px; color: #606266; }
.filter input, .filter select { height: 30px; padding: 0 10px; border: 1px solid #dcdfe6; border-radius: 6px; font-size: 13px; outline: none; background: #fff; }
.filter input { width: 220px; }
.filter input:focus, .filter select:focus { border-color: #409eff; }
.filter button { height: 30px; padding: 0 14px; border: 1px solid #409eff; background: #409eff; color: #fff; border-radius: 6px; cursor: pointer; font-size: 13px; }
.filter button:hover { background: #66b1ff; border-color: #66b1ff; }
.filter button.gray { background: #fff; color: #606266; border-color: #dcdfe6; }
.filter button.gray:hover { border-color: #409eff; color: #409eff; }
.filter .spacer { flex: 1; }
.filter .count { font-size: 12px; color: #909399; }
.loading, .empty { text-align: center; padding: 60px 0; color: #909399; font-size: 14px; }
.pagination { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: #fff; border-radius: 0 0 10px 10px; }
.pagination .info { font-size: 12px; color: #909399; }
.pagination .ctrl { display: flex; align-items: center; gap: 6px; }
.pagination button { height: 28px; min-width: 32px; padding: 0 8px; border: 1px solid #dcdfe6; background: #fff; border-radius: 4px; cursor: pointer; font-size: 12px; }
.pagination button:hover { border-color: #409eff; color: #409eff; }
.pagination button.active { background: #409eff; color: #fff; border-color: #409eff; }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination span { font-size: 12px; color: #909399; }
.pagination select { height: 28px; border: 1px solid #dcdfe6; border-radius: 4px; padding: 0 6px; font-size: 12px; }
.pagination input { width: 50px; height: 28px; border: 1px solid #dcdfe6; border-radius: 4px; padding: 0 6px; text-align: center; font-size: 12px; }
</style>
</head>
<body>
<div id="sidebar"></div>
<div class="head">
<button class="back" onclick="window.location.href='delivery_dashboard.html'">← 返回看板</button>
<h2 id="pageTitle">物料明细</h2>
<span class="meta" id="metaInfo"></span>
</div>
<div class="filter">
<span>产品类型:</span>
<select id="filterProductType"><option value="">全部</option></select>
<span>风险:</span>
<select id="filterRisk">
<option value="">全部</option>
<option value="断线">断线</option>
<option value="预警">预警</option>
<option value="安全">安全</option>
</select>
<span>供应商:</span>
<select id="filterSupplier"><option value="">全部</option></select>
<span>采购员:</span>
<select id="filterPurchaser"><option value="">全部</option></select>
<input type="text" id="filterKeyword" placeholder="搜索物料编码/名称/产品编码" />
<button onclick="loadData(1)">查询</button>
<button class="gray" onclick="resetFilter()">重置</button>
<div class="spacer"></div>
<span class="count" id="countInfo"></span>
</div>
<div class="gx-grid" id="grid">
<table>
<thead>
<tr>
<th style="width:48px">序号</th>
<th style="width:110px">物料编码</th>
<th style="width:140px">物料名称</th>
<th style="width:90px">产品类型</th>
<th style="width:140px">供应商</th>
<th style="width:100px">采购员</th>
<th style="width:100px">预计停线日</th>
<th style="width:100px">预计到货日</th>
<th style="width:60px">风险</th>
<th style="width:60px">日需求</th>
<th style="width:75px">震泽库存</th>
<th style="width:75px">晋江库存</th>
<th style="width:75px">资阳库存</th>
<th style="width:75px">可用库存</th>
<th style="width:70px">量产在途</th>
<th style="width:70px">研发在途</th>
<th style="width:70px">线边库存</th>
<th style="width:70px">已收货</th>
<th style="width:100px">交付进度</th>
<th style="width:140px">备注</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
<div id="status" class="loading">加载中...</div>
</div>
<div class="pagination">
<div class="info" id="pageInfo">共 0 条</div>
<div class="ctrl">
<span>每页</span>
<select id="pageSize" onchange="loadData(1)">
<option value="20">20</option>
<option value="50" selected>50</option>
<option value="100">100</option>
<option value="200">200</option>
<option value="500">500</option>
</select>
<span>条</span>
<button onclick="goPage(1)">«</button>
<button onclick="prevPage()">‹ 上一页</button>
<span>第 <input type="text" id="curPage" value="1" /> / <span id="totalPages">1</span> 页</span>
<button onclick="nextPage()">下一页 ›</button>
<button onclick="goPage(-1)">»</button>
</div>
</div>
<script>
const API_BASE = '../../api/Deliver';
let currentPage = 1;
let currentTotal = 0;
let currentPageSize = 50;
let initRisk = '';
let initProductType = '';
const urlParams = new URLSearchParams(window.location.search);
initRisk = urlParams.get('risk') || '';
initProductType = urlParams.get('productType') || '';
const titleMap = { '': '全部物料', '断线': '断线风险物料', '预警': '预警关注物料', '安全': '安全供应物料' };
const titleColorMap = { '': '#303133', '断线': '#f56c6c', '预警': '#e6a23c', '安全': '#67c23a' };
document.getElementById('pageTitle').textContent = titleMap[initRisk] || '物料明细';
document.getElementById('pageTitle').style.color = titleColorMap[initRisk] || '#303133';
document.getElementById('filterRisk').value = initRisk;
function num(v) { return Grid.num(v); }
function loadFilterOptions() {
// 产品类型
fetch(API_BASE + '/GetSchedules?keyword=').then(r => r.json()).then(res => {
if (res.success) {
const sel = document.getElementById('filterProductType');
const set = new Set();
res.data.forEach(s => { if (s.ProductType) set.add(s.ProductType); });
[...set].sort().forEach(t => {
const opt = document.createElement('option');
opt.value = t; opt.textContent = t;
sel.appendChild(opt);
});
sel.value = initProductType;
}
});
// 供应商/采购员(从当前列表数据汇总,所以首次加载完成后再调用)
}
function loadData(page) {
if (page) currentPage = page;
const tbody = document.getElementById('tbody');
const status = document.getElementById('status');
tbody.innerHTML = '';
status.className = 'loading';
status.style.display = 'block';
status.textContent = '加载中...';
currentPageSize = parseInt(document.getElementById('pageSize').value) || 50;
const risk = document.getElementById('filterRisk').value;
const productType = document.getElementById('filterProductType').value;
const supplier = document.getElementById('filterSupplier').value;
const purchaser = document.getElementById('filterPurchaser').value;
const keyword = document.getElementById('filterKeyword').value.trim();
const params = new URLSearchParams();
if (risk) params.append('risk', risk);
if (productType) params.append('productType', productType);
if (supplier) params.append('supplier', supplier);
if (purchaser) params.append('purchaser', purchaser);
if (keyword) params.append('keyword', keyword);
params.append('page', currentPage);
params.append('pageSize', currentPageSize);
fetch(API_BASE + '/GetBoardRiskList?' + params).then(r => r.json()).then(res => {
if (!res.success) {
status.className = 'empty';
status.textContent = '加载失败:' + (res.message || '');
return;
}
currentTotal = res.total || 0;
document.getElementById('curPage').value = currentPage;
const totalPages = Math.max(1, Math.ceil(currentTotal / currentPageSize));
document.getElementById('totalPages').textContent = totalPages;
document.getElementById('pageInfo').textContent = '共 ' + currentTotal + ' 条';
document.getElementById('countInfo').textContent = '当前显示 ' + ((currentPage-1)*currentPageSize+1) + ' - ' + Math.min(currentPage*currentPageSize, currentTotal) + ' 条';
if (res.data.length === 0) {
status.className = 'empty';
status.textContent = '无数据';
tbody.innerHTML = '';
return;
}
status.style.display = 'none';
tbody.innerHTML = res.data.map((m, i) => {
const seqNo = (currentPage - 1) * currentPageSize + i + 1;
return `<tr>
<td>${seqNo}</td>
<td title="${m.ChildMaterialId}"><strong>${m.ChildMaterialId}</strong></td>
<td title="${m.MaterialName || ''}">${m.MaterialName || '<span class="muted">-</span>'}</td>
<td>${m.ProductType || '<span class="muted">-</span>'}</td>
<td title="${m.Supplier || ''}">${m.Supplier || '<span class="muted">-</span>'}</td>
<td>${m.Purchaser || '<span class="muted">-</span>'}</td>
<td>${m.ExpectedStopDate || '<span class="muted">-</span>'}</td>
<td>${m.ExpectedArrivalDate || '<span class="muted">-</span>'}</td>
<td>${Grid.riskTag(m.DeliveryRisk)}</td>
<td>${num(m.DailyRequirement)}</td>
<td>${num(m.ZhenZeStock)}</td>
<td>${num(m.JinJiangStock)}</td>
<td>${num(m.ZiYangStock)}</td>
<td>${num(m.AvailableStock)}</td>
<td>${num(m.MassInTransit)}</td>
<td>${num(m.ResearchInTransit)}</td>
<td>${num(m.LineSideStock)}</td>
<td>${num(m.ReceivedQty)}</td>
<td>${m.DeliveryProgress || '<span class="muted">-</span>'}</td>
<td title="${m.Remark || ''}">${m.Remark || '<span class="muted">-</span>'}</td>
</tr>`;
}).join('');
// 加载完后更新供应商/采购员下拉(用本次数据)
refreshDropdowns(res.data);
});
}
function refreshDropdowns(data) {
const supplierSet = new Set();
const purchaserSet = new Set();
data.forEach(m => { if (m.Supplier) supplierSet.add(m.Supplier); if (m.Purchaser) purchaserSet.add(m.Purchaser); });
const currentSupplier = document.getElementById('filterSupplier').value;
const currentPurchaser = document.getElementById('filterPurchaser').value;
const supplierSel = document.getElementById('filterSupplier');
const purchaserSel = document.getElementById('filterPurchaser');
// 保留当前选中
supplierSel.innerHTML = '<option value="">全部</option>';
purchaserSel.innerHTML = '<option value="">全部</option>';
[...supplierSet].sort().forEach(v => {
const opt = document.createElement('option'); opt.value = v; opt.textContent = v; supplierSel.appendChild(opt);
});
[...purchaserSet].sort().forEach(v => {
const opt = document.createElement('option'); opt.value = v; opt.textContent = v; purchaserSel.appendChild(opt);
});
supplierSel.value = currentSupplier;
purchaserSel.value = currentPurchaser;
}
function prevPage() { if (currentPage > 1) loadData(currentPage - 1); }
function nextPage() {
const totalPages = Math.max(1, Math.ceil(currentTotal / currentPageSize));
if (currentPage < totalPages) loadData(currentPage + 1);
}
function goPage(p) {
const totalPages = Math.max(1, Math.ceil(currentTotal / currentPageSize));
if (p === -1) loadData(totalPages);
else if (p === 1) loadData(1);
else {
const v = parseInt(document.getElementById('curPage').value);
if (!isNaN(v) && v >= 1 && v <= totalPages) loadData(v);
}
}
function resetFilter() {
document.getElementById('filterRisk').value = initRisk;
document.getElementById('filterProductType').value = initProductType;
document.getElementById('filterSupplier').value = '';
document.getElementById('filterPurchaser').value = '';
document.getElementById('filterKeyword').value = '';
document.getElementById('pageSize').value = '50';
loadData(1);
}
document.getElementById('curPage').addEventListener('keydown', e => { if (e.key === 'Enter') goPage(0); });
document.getElementById('filterKeyword').addEventListener('keydown', e => { if (e.key === 'Enter') loadData(1); });
loadFilterOptions();
loadData(1);
setTimeout(() => Grid.bind('grid'), 200);
</script>
<!-- 公共组件 -->
<script src="../common/grid.js"></script>
<script src="../common/nav.js"></script>
</body>
</html>