baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)
This commit is contained in:
commit
c2b0e7be0d
6522 files changed
+3530643
No files matched your search
Executable
+322
@@ -0,0 +1,322 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>产品BOM主数据维护</title>
|
||||
<!-- 公共侧边栏组件 -->
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<style>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{font-family:'Microsoft YaHei','PingFang SC',sans-serif;background:#f0f2f5;min-height:100vh}
|
||||
.top-bar{background:linear-gradient(135deg,#1a73e8,#1557b0);color:#fff;padding:0 24px;display:flex;align-items:center;height:56px;box-shadow:0 2px 8px rgba(0,0,0,.15);position:sticky;top:0;z-index:100}
|
||||
.top-bar .logo{font-size:18px;font-weight:600;letter-spacing:1px;margin-right:32px}
|
||||
.top-bar .nav-tabs{display:flex;gap:4px;height:100%}
|
||||
.top-bar .nav-tabs a{color:rgba(255,255,255,.75);text-decoration:none;padding:0 16px;display:flex;align-items:center;font-size:13px;border-radius:4px 4px 0 0;transition:all .2s}
|
||||
.top-bar .nav-tabs a:hover{color:#fff;background:rgba(255,255,255,.1)}
|
||||
.top-bar .nav-tabs a.active{color:#fff;background:rgba(255,255,255,.2)}
|
||||
.top-bar .user-info{margin-left:auto;font-size:13px;opacity:.85}
|
||||
.main-container{max-width:1500px;margin:0 auto;padding:16px 20px}
|
||||
.panel{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:16px;margin-bottom:14px}
|
||||
.panel h3{font-size:15px;color:#333;font-weight:600;margin-bottom:12px}
|
||||
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
|
||||
.toolbar input,.toolbar select{height:32px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.toolbar input:focus,.toolbar select:focus{border-color:#1a73e8}
|
||||
.btn{height:32px;padding:0 16px;border:none;border-radius:5px;font-size:12px;font-weight:600;cursor:pointer;transition:all .2s;color:#fff}
|
||||
.btn-primary{background:linear-gradient(135deg,#1a73e8,#1557b0)}
|
||||
.btn-primary:hover{opacity:.92}
|
||||
.btn-green{background:#22c55e}
|
||||
.btn-green:hover{opacity:.92}
|
||||
.btn-orange{background:#f59e0b}
|
||||
.btn-orange:hover{opacity:.92}
|
||||
.btn-red{background:#ef4444}
|
||||
.btn-red:hover{opacity:.92}
|
||||
.btn-outline{background:#fff;color:#666;border:2px solid #e0e0e0}
|
||||
.btn-outline:hover{border-color:#1a73e8;color:#1a73e8}
|
||||
table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
thead th{background:#f8f9fa;color:#555;font-weight:600;padding:9px 12px;text-align:left;border:1px solid #999;border-bottom:2px solid #999;white-space:nowrap}
|
||||
tbody td{padding:9px 12px;border:1px solid #ddd;color:#333}
|
||||
tbody tr:hover{background:#f0f6ff}
|
||||
.badge{display:inline-block;padding:2px 10px;border-radius:12px;font-size:12px;font-weight:500}
|
||||
.badge-success{background:#dcfce7;color:#166534}
|
||||
.badge-muted{background:#f1f5f9;color:#64748b}
|
||||
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:999;justify-content:center;align-items:center;padding:24px}
|
||||
body.with-sidebar:not(.sidebar-collapsed) .modal-overlay{padding-left:240px}
|
||||
body.with-sidebar.sidebar-collapsed .modal-overlay{padding-left:60px}
|
||||
.modal-overlay.show{display:flex}
|
||||
.modal{background:#fff;border-radius:10px;width:560px;max-width:95vw;max-height:90vh;overflow-y:auto;box-shadow:0 20px 60px rgba(0,0,0,.2);padding:24px}
|
||||
.modal h3{font-size:17px;color:#333;margin-bottom:16px}
|
||||
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
|
||||
.form-group{display:flex;flex-direction:column}
|
||||
.form-group.full{grid-column:1/-1}
|
||||
.form-group label{font-size:12px;color:#555;font-weight:600;margin-bottom:4px}
|
||||
.form-group input,.form-group select{height:34px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.form-group input:focus,.form-group select:focus{border-color:#1a73e8}
|
||||
.form-group input.readonly{background:#f8f9fa;color:#999}
|
||||
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:18px}
|
||||
.toast{position:fixed;top:14px;left:50%;transform:translateX(-50%);padding:10px 22px;border-radius:8px;font-size:13px;z-index:1001;box-shadow:0 4px 20px rgba(0,0,0,.15);display:none;min-width:240px;text-align:center}
|
||||
.toast.error{background:#fdeaea;color:#b71c1c;display:block}
|
||||
.toast.success{background:#e6f9ed;color:#1a7a3a;display:block}
|
||||
.detail-table{max-height:60vh;overflow-y:auto}
|
||||
.expand-btn{cursor:pointer;color:#1a73e8;font-weight:600}
|
||||
/* 列表分页 */
|
||||
.pagination{display:flex;justify-content:space-between;align-items:center;padding:10px 4px;border-top:1px solid #f0f0f0;font-size:12px;color:#666}
|
||||
.pagination .btns{display:flex;gap:2px;flex-wrap:wrap}
|
||||
.pagination .btns button,.pagination .size-btn{min-width:30px;height:26px;border:1px solid #e0e0e0;border-radius:4px;background:#fff;color:#555;cursor:pointer;font-size:12px;padding:0 8px}
|
||||
.pagination .btns button:hover,.pagination .size-btn:hover{border-color:#1a73e8;color:#1a73e8}
|
||||
.pagination .btns button.active,.pagination .size-btn.active{background:#1a73e8;color:#fff;border-color:#1a73e8}
|
||||
.pagination .size-group{display:inline-flex;gap:2px;margin-left:8px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sidebar"></div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="panel">
|
||||
<h3>产品BOM主数据维护</h3>
|
||||
<div class="toolbar">
|
||||
<input type="text" id="txtKeyword" placeholder="搜索 产品编码 / 产品名称" style="width:220px">
|
||||
<select id="selStatus">
|
||||
<option value="-1">状态:全部</option>
|
||||
<option value="1">启用</option>
|
||||
<option value="0">禁用</option>
|
||||
</select>
|
||||
<button class="btn btn-primary" onclick="searchList()">查询</button>
|
||||
<button class="btn btn-outline" onclick="resetSearch()">重置</button>
|
||||
<div style="flex:1"></div>
|
||||
<button class="btn btn-green" onclick="openAddModal()">+ 新增产品</button>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>产品编码</th><th>BOM版本</th><th>产品名称</th>
|
||||
<th>状态</th><th>BOM明细数</th><th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyList"></tbody>
|
||||
</table>
|
||||
<div class="pagination" id="pagination" style="display:none">
|
||||
<div><span>共 <em id="totalCnt">0</em> 条</span><span class="size-group" id="sizeBtns"></span></div>
|
||||
<div class="btns" id="pageBtns"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="editModal">
|
||||
<div class="modal">
|
||||
<h3 id="modalTitle">新增产品</h3>
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label>产品编码 <span style="color:#ef4444">*</span></label>
|
||||
<input type="text" id="fProductCode" placeholder="如 KHT10">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>BOM版本 <span style="color:#ef4444">*</span></label>
|
||||
<input type="text" id="fBOMVersion" placeholder="如 V1.0">
|
||||
</div>
|
||||
<div class="form-group full">
|
||||
<label>产品名称</label>
|
||||
<input type="text" id="fProductName" placeholder="产品名称">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>状态</label>
|
||||
<select id="fStatus">
|
||||
<option value="1">启用</option>
|
||||
<option value="0">禁用</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-outline" onclick="closeModal('editModal')">取消</button>
|
||||
<button class="btn btn-primary" onclick="saveBom()">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="detailModal">
|
||||
<div class="modal" style="width:90vw">
|
||||
<h3 id="detailTitle">BOM明细</h3>
|
||||
<div class="toolbar">
|
||||
<button class="btn btn-orange" onclick="expandBom()">从金蝶同步展开BOM</button>
|
||||
<span id="detailCount" style="font-size:13px;color:#666"></span>
|
||||
</div>
|
||||
<div class="detail-table">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>层级</th><th>父物料编码</th><th>子物料编码</th><th>子物料名称</th>
|
||||
<th>规格型号</th><th>单位</th><th>用量</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyDetail"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-outline" onclick="closeModal('detailModal')">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
<script>
|
||||
var curId=0;
|
||||
var curProductCode='';
|
||||
var curPage=1, pageSize=20, totalCnt=0;
|
||||
var pageSizeOptions=[20,50,100,200];
|
||||
|
||||
function toast(msg,tp){var el=document.getElementById('toast');el.textContent=msg;el.className='toast '+tp;clearTimeout(el._timer);el._timer=setTimeout(function(){el.className='toast'},3000)}
|
||||
|
||||
function api(url,method,data,cb){
|
||||
var opts={method:method||'GET',headers:{'Content-Type':'application/json'}};
|
||||
if(data)opts.body=JSON.stringify(data);
|
||||
fetch(url,opts).then(function(r){return r.json()}).then(function(res){
|
||||
if(res&&res.success===false){toast(res.message||'操作失败','error');return}
|
||||
cb&&cb(res);
|
||||
}).catch(function(e){toast('请求失败:'+e.message,'error')});
|
||||
}
|
||||
|
||||
function getApiUrl(){
|
||||
return '../../api/deliver/';
|
||||
}
|
||||
function baseUrl(){
|
||||
return window.location.protocol+'//'+window.location.host;
|
||||
}
|
||||
|
||||
function searchList(){curPage=1;loadList()}
|
||||
|
||||
function loadList(){
|
||||
var kw=document.getElementById('txtKeyword').value.trim();
|
||||
var st=document.getElementById('selStatus').value;
|
||||
api(getApiUrl()+'GetBomMasterList?keyword='+encodeURIComponent(kw)+'&status='+st+'&page='+curPage+'&pageSize='+pageSize,'GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
totalCnt=res.total||0;
|
||||
var html='';
|
||||
if(rows.length===0){html='<tr class="empty"><td colspan="6" style="text-align:center;padding:36px;color:#bbb">暂无数据</td></tr>'}
|
||||
rows.forEach(function(r){
|
||||
var stBadge=r.Status=='1'?'<span class="badge badge-success">启用</span>':'<span class="badge badge-muted">禁用</span>';
|
||||
html+='<tr>'+
|
||||
'<td>'+r.ProductCode+'</td>'+
|
||||
'<td>'+r.BOMVersion+'</td>'+
|
||||
'<td>'+r.ProductName+'</td>'+
|
||||
'<td>'+stBadge+'</td>'+
|
||||
'<td><span class="expand-btn" onclick="openDetail(\''+r.ProductCode+'\',\''+r.BOMVersion+'\')">查看BOM</span></td>'+
|
||||
'<td style="white-space:nowrap">'+
|
||||
'<button class="btn btn-primary" style="height:26px;padding:0 10px;font-size:11px" onclick="openEdit('+r.Id+')">编辑</button> '+
|
||||
'<button class="btn btn-red" style="height:26px;padding:0 10px;font-size:11px" onclick="delBom('+r.Id+')">删除</button>'+
|
||||
'</td></tr>';
|
||||
});
|
||||
document.getElementById('tbodyList').innerHTML=html;
|
||||
renderPagination();
|
||||
});
|
||||
}
|
||||
|
||||
function resetSearch(){document.getElementById('txtKeyword').value='';document.getElementById('selStatus').value='-1';curPage=1;loadList()}
|
||||
|
||||
// ===== 列表分页 =====
|
||||
function renderPagination(){
|
||||
var tp=Math.ceil(totalCnt/pageSize)||1;
|
||||
var pc=document.getElementById('pagination');
|
||||
if(totalCnt<=pageSize){pc.style.display='none';return}
|
||||
pc.style.display='flex';
|
||||
document.getElementById('totalCnt').textContent=totalCnt;
|
||||
document.getElementById('sizeBtns').innerHTML=pageSizeOptions.map(function(s){return '<button class="size-btn'+(s===pageSize?' active':'')+'" onclick="setPageSize('+s+')">'+s+'条</button>'}).join('');
|
||||
var pb=document.getElementById('pageBtns');
|
||||
if(tp<=1){pb.innerHTML='';return}
|
||||
var h='<button '+(curPage<=1?'disabled':'')+' onclick="goPage(1)">首页</button><button '+(curPage<=1?'disabled':'')+' onclick="goPage('+(curPage-1)+')">‹</button>';
|
||||
for(var i=Math.max(1,curPage-2);i<=Math.min(tp,curPage+2);i++)h+='<button class="'+(i===curPage?'active':'')+'" onclick="goPage('+i+')">'+i+'</button>';
|
||||
h+='<button '+(curPage>=tp?'disabled':'')+' onclick="goPage('+(curPage+1)+')">›</button><button '+(curPage>=tp?'disabled':'')+' onclick="goPage('+tp+')">末页</button>';
|
||||
pb.innerHTML=h;
|
||||
}
|
||||
function goPage(p){
|
||||
if(p<1||p>Math.ceil(totalCnt/pageSize))return;
|
||||
curPage=p;
|
||||
loadList();
|
||||
}
|
||||
function setPageSize(s){
|
||||
pageSize=s;curPage=1;loadList();
|
||||
}
|
||||
|
||||
function openAddModal(){
|
||||
curId=0;
|
||||
document.getElementById('modalTitle').textContent='新增产品';
|
||||
document.getElementById('fProductCode').value='';
|
||||
document.getElementById('fBOMVersion').value='';
|
||||
document.getElementById('fProductName').value='';
|
||||
document.getElementById('fStatus').value='1';
|
||||
document.getElementById('editModal').classList.add('show');
|
||||
}
|
||||
|
||||
function openEdit(id){
|
||||
api(getApiUrl()+'GetBomMasterList?keyword=&status=-1&page=1&pageSize=100000','GET',null,function(res){
|
||||
var list=res.data||[];
|
||||
var r=list.find(function(x){return x.Id==id});
|
||||
if(!r){toast('未找到记录','error');return}
|
||||
curId=id;
|
||||
document.getElementById('modalTitle').textContent='编辑产品';
|
||||
document.getElementById('fProductCode').value=r.ProductCode;
|
||||
document.getElementById('fBOMVersion').value=r.BOMVersion;
|
||||
document.getElementById('fProductName').value=r.ProductName;
|
||||
document.getElementById('fStatus').value=r.Status||'1';
|
||||
document.getElementById('editModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function saveBom(){
|
||||
var data={
|
||||
Id:curId,
|
||||
ProductCode:document.getElementById('fProductCode').value.trim(),
|
||||
BOMVersion:document.getElementById('fBOMVersion').value.trim(),
|
||||
ProductName:document.getElementById('fProductName').value.trim(),
|
||||
Status:document.getElementById('fStatus').value
|
||||
};
|
||||
if(!data.ProductCode){toast('请填写产品编码','error');return}
|
||||
if(!data.BOMVersion){toast('请填写BOM版本','error');return}
|
||||
api(getApiUrl()+'SaveBomMaster','POST',data,function(res){
|
||||
if(res.success){toast('保存成功','success');closeModal('editModal');loadList()}
|
||||
});
|
||||
}
|
||||
|
||||
function delBom(id){
|
||||
if(!confirm('确认删除该产品?其BOM明细将一并删除'))return;
|
||||
api(getApiUrl()+'DeleteBomMaster','POST',{Id:id},function(res){
|
||||
if(res.success){toast('删除成功','success');loadList()}
|
||||
});
|
||||
}
|
||||
|
||||
function openDetail(productCode,bomVersion){
|
||||
curProductCode=productCode;
|
||||
document.getElementById('detailTitle').textContent='BOM明细 - '+productCode+' ('+bomVersion+')';
|
||||
document.getElementById('detailModal').classList.add('show');
|
||||
loadDetail();
|
||||
}
|
||||
|
||||
function loadDetail(){
|
||||
api(getApiUrl()+'GetBomDetail?productCode='+encodeURIComponent(curProductCode),'GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
document.getElementById('detailCount').textContent='共 '+rows.length+' 条';
|
||||
var html='';
|
||||
if(rows.length===0)html='<tr><td colspan="7" style="text-align:center;padding:36px;color:#bbb">暂无明细,请点击"从金蝶同步展开BOM"</td></tr>';
|
||||
rows.forEach(function(r){
|
||||
html+='<tr><td>L'+r.Level+'</td><td>'+r.ParentMaterialId+'</td><td>'+r.ChildMaterialId+'</td><td>'+r.MaterialName+'</td><td>'+r.Spec+'</td><td>'+r.Unit+'</td><td>'+r.UsageQty+'</td></tr>';
|
||||
});
|
||||
document.getElementById('tbodyDetail').innerHTML=html;
|
||||
});
|
||||
}
|
||||
|
||||
function expandBom(){
|
||||
var p=prompt('请输入要展开的产品编码(如 KHT10):',curProductCode);
|
||||
if(!p)return;
|
||||
curProductCode=p.trim();
|
||||
api(getApiUrl()+'ExpandBom','POST',{ProductCode:curProductCode,BOMVersion:''},function(res){
|
||||
if(res.success){toast(res.message,'success');document.getElementById('detailTitle').textContent='BOM明细 - '+curProductCode;loadDetail()}
|
||||
});
|
||||
}
|
||||
|
||||
function closeModal(id){document.getElementById(id).classList.remove('show')}
|
||||
|
||||
loadList();
|
||||
</script>
|
||||
<!-- 公共导航栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+297
@@ -0,0 +1,297 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>采购物料交付计划看板</title>
|
||||
<!-- 公共侧边栏组件 -->
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<style>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{font-family:'Microsoft YaHei','PingFang SC',sans-serif;background:#f0f2f5;min-height:100vh}
|
||||
.top-bar{background:linear-gradient(135deg,#1a73e8,#1557b0);color:#fff;padding:0 24px;display:flex;align-items:center;height:56px;box-shadow:0 2px 8px rgba(0,0,0,.15);position:sticky;top:0;z-index:100}
|
||||
.top-bar .logo{font-size:18px;font-weight:600;letter-spacing:1px;margin-right:32px}
|
||||
.top-bar .nav-tabs{display:flex;gap:4px;height:100%}
|
||||
.top-bar .nav-tabs a{color:rgba(255,255,255,.75);text-decoration:none;padding:0 16px;display:flex;align-items:center;font-size:13px;border-radius:4px 4px 0 0;transition:all .2s}
|
||||
.top-bar .nav-tabs a:hover{color:#fff;background:rgba(255,255,255,.1)}
|
||||
.top-bar .nav-tabs a.active{color:#fff;background:rgba(255,255,255,.2)}
|
||||
.top-bar .user-info{margin-left:auto;font-size:13px;opacity:.85}
|
||||
.main-container{max-width:1500px;margin:0 auto;padding:16px 20px}
|
||||
/* 统计卡片 */
|
||||
.stat-cards{display:grid;grid-template-columns:repeat(4,1fr);gap:14px;margin-bottom:16px}
|
||||
.stat-card{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:18px;text-align:center;border-top:3px solid #3b82f6}
|
||||
.stat-card .stat-value{font-size:32px;font-weight:700;margin-bottom:4px}
|
||||
.stat-card .stat-label{font-size:13px;color:#64748b}
|
||||
.stat-card.stat-danger{border-top-color:#ef4444}.stat-card.stat-danger .stat-value{color:#ef4444}
|
||||
.stat-card.stat-warning{border-top-color:#f59e0b}.stat-card.stat-warning .stat-value{color:#f59e0b}
|
||||
.stat-card.stat-safe{border-top-color:#22c55e}.stat-card.stat-safe .stat-value{color:#22c55e}
|
||||
.stat-card.stat-total{border-top-color:#3b82f6}.stat-card.stat-total .stat-value{color:#3b82f6}
|
||||
.panel{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:16px;margin-bottom:14px}
|
||||
.panel h3{font-size:15px;color:#333;font-weight:600;margin-bottom:12px}
|
||||
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
|
||||
.toolbar select,.toolbar input{height:32px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.toolbar select:focus,.toolbar input:focus{border-color:#1a73e8}
|
||||
.btn{height:32px;padding:0 16px;border:none;border-radius:5px;font-size:12px;font-weight:600;cursor:pointer;transition:all .2s;color:#fff}
|
||||
.btn-primary{background:linear-gradient(135deg,#1a73e8,#1557b0)}
|
||||
.btn-primary:hover{opacity:.92}
|
||||
.btn-outline{background:#fff;color:#666;border:2px solid #e0e0e0}
|
||||
.btn-outline:hover{border-color:#1a73e8;color:#1a73e8}
|
||||
/* 分组列表 */
|
||||
.group-row{display:flex;align-items:center;gap:10px;padding:10px 14px;border:1px solid #e2e8f0;border-radius:6px;margin-bottom:8px;cursor:pointer;background:#fff;transition:all .15s}
|
||||
.group-row:hover{background:#f0f6ff}
|
||||
.group-row .expand{font-size:12px;color:#1a73e8;width:16px}
|
||||
.group-row .group-name{font-weight:600;color:#333;min-width:150px}
|
||||
.group-row .group-sub{color:#64748b;font-size:13px;flex:1}
|
||||
.badge{display:inline-block;padding:2px 10px;border-radius:12px;font-size:12px;font-weight:500}
|
||||
.badge-danger{background:#fee2e2;color:#991b1b}
|
||||
.badge-warning{background:#fef3c7;color:#92400e}
|
||||
.badge-success{background:#dcfce7;color:#166534}
|
||||
.badge-info{background:#dbeafe;color:#1e40af}
|
||||
table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
thead th{background:#f8f9fa;color:#555;font-weight:600;padding:9px 12px;text-align:left;border:1px solid #999;border-bottom:2px solid #999;white-space:nowrap}
|
||||
tbody td{padding:9px 12px;border:1px solid #ddd;color:#333}
|
||||
tbody tr:hover{background:#f0f6ff}
|
||||
.pagination{display:flex;justify-content:flex-end;align-items:center;gap:8px;margin-top:12px;font-size:13px;color:#666}
|
||||
.pagination button{min-width:30px;height:30px;border:1px solid #e0e0e0;border-radius:4px;background:#fff;cursor:pointer}
|
||||
.pagination button.active{background:#1a73e8;color:#fff;border-color:#1a73e8}
|
||||
/* 甘特图 */
|
||||
.gantt-container{overflow-x:auto;margin-top:8px}
|
||||
.gantt-grid{display:grid;grid-template-columns:160px repeat(var(--gantt-cols),minmax(36px,1fr));gap:1px;font-size:11px;min-width:100%}
|
||||
.gantt-header{background:#f1f5f9;padding:6px 4px;text-align:center;font-weight:600;color:#64748b;border-bottom:2px solid #e2e8f0}
|
||||
.gantt-header.weekend{background:#e2e8f0;color:#94a3b8}
|
||||
.gantt-name{background:#f8fafc;padding:6px 8px;font-weight:500;border-bottom:1px solid #e2e8f0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
.gantt-cell{padding:4px 2px;text-align:center;border-bottom:1px solid #e2e8f0;min-height:28px}
|
||||
.gantt-cell.req{background:#dbeafe;color:#1e40af;font-weight:600}
|
||||
.gantt-cell.arrival{background:#dcfce7;color:#166534}
|
||||
.gantt-cell.stop{background:#fee2e2;color:#991b1b}
|
||||
.gantt-cell.empty{background:#fff}
|
||||
.toast{position:fixed;top:14px;left:50%;transform:translateX(-50%);padding:10px 22px;border-radius:8px;font-size:13px;z-index:1001;box-shadow:0 4px 20px rgba(0,0,0,.15);display:none;min-width:240px;text-align:center}
|
||||
.toast.error{background:#fdeaea;color:#b71c1c;display:block}
|
||||
.toast.success{background:#e6f9ed;color:#1a7a3a;display:block}
|
||||
.detail-wrap{display:none;margin-bottom:8px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sidebar"></div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="stat-cards">
|
||||
<div class="stat-card stat-total"><div class="stat-value" id="statTotal">0</div><div class="stat-label">物料总数</div></div>
|
||||
<div class="stat-card stat-danger"><div class="stat-value" id="statDanger">0</div><div class="stat-label">断线风险</div></div>
|
||||
<div class="stat-card stat-warning"><div class="stat-value" id="statWarn">0</div><div class="stat-label">预警关注</div></div>
|
||||
<div class="stat-card stat-safe"><div class="stat-value" id="statSafe">0</div><div class="stat-label">安全供应</div></div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h3>物料交付分组(按产品)</h3>
|
||||
<div class="toolbar">
|
||||
<select id="selProductType" style="min-width:140px"><option value="">产品类型:全部</option></select>
|
||||
<select id="selRisk">
|
||||
<option value="">风险:全部</option>
|
||||
<option value="断线">断线</option>
|
||||
<option value="预警">预警</option>
|
||||
<option value="安全">安全</option>
|
||||
</select>
|
||||
<input type="text" id="txtKeyword" placeholder="物料编码/名称" style="min-width:160px">
|
||||
<div style="flex:1"></div>
|
||||
<button class="btn btn-outline" onclick="loadBoard()">刷新</button>
|
||||
</div>
|
||||
<div id="groupList"></div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h3>物料交付明细</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>物料编码</th><th>物料名称</th><th>层级</th><th>产品类型</th><th>日需求</th><th>总需求</th>
|
||||
<th>可用库存</th><th>在途</th><th>已到货</th><th>预计停线日</th><th>预计到货日</th><th>风险</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyDetail"></tbody>
|
||||
</table>
|
||||
<div class="pagination" id="detailPagination"></div>
|
||||
</div>
|
||||
|
||||
<div class="panel">
|
||||
<h3>交付甘特图(需求/到货)</h3>
|
||||
<div class="gantt-container">
|
||||
<div class="gantt-grid" id="ganttGrid"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
<script>
|
||||
var options=null;
|
||||
var currentProductType='';
|
||||
var currentRisk='';
|
||||
var ganttData=[];
|
||||
|
||||
function toast(msg,tp){var el=document.getElementById('toast');el.textContent=msg;el.className='toast '+tp;clearTimeout(el._timer);el._timer=setTimeout(function(){el.className='toast'},3000)}
|
||||
function api(url,method,data,cb){
|
||||
var opts={method:method||'GET',headers:{'Content-Type':'application/json'}};
|
||||
if(data)opts.body=JSON.stringify(data);
|
||||
fetch(url,opts).then(function(r){return r.json()}).then(function(res){
|
||||
if(res&&res.success===false){toast(res.message||'操作失败','error');return}
|
||||
cb&&cb(res);
|
||||
}).catch(function(e){toast('请求失败:'+e.message,'error')});
|
||||
}
|
||||
function getApiUrl(){return '../../api/deliver/'}
|
||||
|
||||
function loadOptions(cb){
|
||||
// 产品类型下拉:从分组接口取
|
||||
api(getApiUrl()+'GetBoardGroups','GET',null,function(res){
|
||||
var h='<option value="">产品类型:全部</option>';
|
||||
(res.data||[]).forEach(function(g){h+='<option value="'+g.ProductType+'">'+g.ProductType+'</option>'});
|
||||
document.getElementById('selProductType').innerHTML=h;
|
||||
cb&&cb();
|
||||
});
|
||||
}
|
||||
|
||||
function loadBoard(){
|
||||
currentProductType=document.getElementById('selProductType').value;
|
||||
currentRisk=document.getElementById('selRisk').value;
|
||||
loadStats();
|
||||
loadGroups();
|
||||
loadDetail();
|
||||
loadGantt();
|
||||
}
|
||||
|
||||
function loadStats(){
|
||||
api(getApiUrl()+'GetBoardStats?productType='+encodeURIComponent(currentProductType)+'&risk='+encodeURIComponent(currentRisk),'GET',null,function(res){
|
||||
var d=res.data||{};
|
||||
document.getElementById('statTotal').textContent=d.total||0;
|
||||
document.getElementById('statDanger').textContent=d.danger||0;
|
||||
document.getElementById('statWarn').textContent=d.warn||0;
|
||||
document.getElementById('statSafe').textContent=d.safe||0;
|
||||
});
|
||||
}
|
||||
|
||||
function loadGroups(){
|
||||
api(getApiUrl()+'GetBoardGroups','GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
var html='';
|
||||
if(rows.length===0)html='<div style="text-align:center;padding:30px;color:#bbb">暂无数据</div>';
|
||||
rows.forEach(function(g){
|
||||
var stClass=g.Status=='需处理'?'badge-danger':(g.Status=='关注'?'badge-warning':'badge-success');
|
||||
html+='<div class="group-row" onclick="toggleGroup(\''+g.ProductType+'\',this)">'+
|
||||
'<span class="expand">▶</span>'+
|
||||
'<span class="group-name">'+g.ProductType+'</span>'+
|
||||
'<span style="color:#64748b;font-size:13px">'+g.MaterialCount+'个物料</span>'+
|
||||
'<span class="badge badge-danger">断线'+g.DangerCount+'</span>'+
|
||||
'<span class="badge badge-warning">预警'+g.WarnCount+'</span>'+
|
||||
'<span class="badge '+stClass+'">'+g.Status+'</span>'+
|
||||
'</div>';
|
||||
});
|
||||
document.getElementById('groupList').innerHTML=html;
|
||||
});
|
||||
}
|
||||
|
||||
function toggleGroup(productType,el){
|
||||
currentProductType=productType;
|
||||
document.getElementById('selProductType').value=productType;
|
||||
var expand=el.querySelector('.expand');
|
||||
if(expand.textContent==='▶'){expand.textContent='▼'}else{expand.textContent='▶'}
|
||||
loadDetail();
|
||||
loadGantt();
|
||||
}
|
||||
|
||||
function loadDetail(page){
|
||||
page=page||1;
|
||||
var kw=document.getElementById('txtKeyword').value.trim();
|
||||
api(getApiUrl()+'GetBoardDetail?productType='+encodeURIComponent(currentProductType)+'&risk='+encodeURIComponent(currentRisk)+'&keyword='+encodeURIComponent(kw)+'&page='+page+'&pageSize=50','GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
var html='';
|
||||
if(rows.length===0)html='<tr><td colspan="12" style="text-align:center;padding:36px;color:#bbb">暂无明细数据</td></tr>';
|
||||
rows.forEach(function(r){
|
||||
var cls=r.DeliveryRisk=='断线'?'badge-danger':(r.DeliveryRisk=='预警'?'badge-warning':'badge-success');
|
||||
html+='<tr>'+
|
||||
'<td>'+r.ChildMaterialId+'</td>'+
|
||||
'<td>'+r.MaterialName+'</td>'+
|
||||
'<td>L'+r.BOMLevel+'</td>'+
|
||||
'<td>'+(r.ProductTypes||'')+'</td>'+
|
||||
'<td>'+r.DailyReq+'</td>'+
|
||||
'<td>'+r.TotalRequirement+'</td>'+
|
||||
'<td>'+r.AvailableStock+'</td>'+
|
||||
'<td>'+r.InTransitQty+'</td>'+
|
||||
'<td>'+r.ArrivedQty+'</td>'+
|
||||
'<td>'+r.ExpectedStopDate+'</td>'+
|
||||
'<td>'+r.ExpectedArrivalDate+'</td>'+
|
||||
'<td><span class="badge '+cls+'">'+r.DeliveryRisk+'</span></td>'+
|
||||
'</tr>';
|
||||
});
|
||||
document.getElementById('tbodyDetail').innerHTML=html;
|
||||
renderPagination(res.total,res.page);
|
||||
});
|
||||
}
|
||||
|
||||
function renderPagination(total,page){
|
||||
var pages=Math.ceil(total/50);
|
||||
if(pages<=1){document.getElementById('detailPagination').innerHTML='';return}
|
||||
var html='';
|
||||
for(var i=1;i<=pages;i++)html+='<button class="'+(i==page?'active':'')+'" onclick="loadDetail('+i+')">'+i+'</button>';
|
||||
document.getElementById('detailPagination').innerHTML=html;
|
||||
}
|
||||
|
||||
function loadGantt(){
|
||||
api(getApiUrl()+'GetGanttData?productType='+encodeURIComponent(currentProductType)+'&risk=断线,预警','GET',null,function(res){
|
||||
ganttData=res.data||[];
|
||||
var start=res.startDate;
|
||||
var end=res.endDate;
|
||||
if(!start||!end){document.getElementById('ganttGrid').innerHTML='<div style="padding:20px;color:#bbb">暂无排程数据</div>';return}
|
||||
renderGantt(start,end,ganttData);
|
||||
});
|
||||
}
|
||||
|
||||
function renderGantt(start,end,data){
|
||||
var dates=[];
|
||||
var cur=new Date(start),last=new Date(end);
|
||||
while(cur<=last){dates.push(formatDate(cur));cur.setDate(cur.getDate()+1)}
|
||||
document.getElementById('ganttGrid').style.setProperty('--gantt-cols',dates.length);
|
||||
|
||||
// 按物料分组
|
||||
var groups={};
|
||||
data.forEach(function(d){
|
||||
var key=d.ChildMaterialId;
|
||||
if(!groups[key])groups[key]={material:d.ChildMaterialId,name:d.MaterialName,risk:d.DeliveryRisk,stop:d.ExpectedStopDate,reqs:{},arrivals:[]};
|
||||
if(d.PlanDate)groups[key].reqs[d.PlanDate]=(groups[key].reqs[d.PlanDate]||0)+(parseFloat(d.DailyRequirement)||0);
|
||||
if(d.ArrivalExpectedDate||d.ActualArrivalDate)groups[key].arrivals.push(d);
|
||||
});
|
||||
|
||||
// 表头
|
||||
var html='<div class="gantt-header" style="grid-column:1">物料</div>';
|
||||
dates.forEach(function(d){
|
||||
var dt=new Date(d);var wk=['日','一','二','三','四','五','六'][dt.getDay()];
|
||||
var isWk=(dt.getDay()==0||dt.getDay()==6);
|
||||
html+='<div class="gantt-header'+(isWk?' weekend':'')+'">'+(d.slice(5))+'<br>周'+wk+'</div>';
|
||||
});
|
||||
|
||||
// 物料行
|
||||
Object.keys(groups).forEach(function(key){
|
||||
var g=groups[key];
|
||||
html+='<div class="gantt-name" title="'+g.name+'">'+g.material+' <span style="color:#94a3b8">L'+(key.split('|')[0]||'')+'</span></div>';
|
||||
dates.forEach(function(d){
|
||||
var cls='empty';
|
||||
var txt='';
|
||||
if(g.stop==d){cls='stop';txt='停'}
|
||||
if(g.reqs[d]){cls=cls=='stop'?'stop':'req';txt=(txt||'')+(g.reqs[d]||'')}
|
||||
// 到货
|
||||
g.arrivals.forEach(function(a){
|
||||
var ad=a.ArrivalExpectedDate;
|
||||
if(ad==d){cls='arrival';txt=(txt||'')+'>'+a.ArrivalQty}
|
||||
});
|
||||
html+='<div class="gantt-cell '+cls+'">'+txt+'</div>';
|
||||
});
|
||||
});
|
||||
document.getElementById('ganttGrid').innerHTML=html;
|
||||
}
|
||||
|
||||
function formatDate(d){var y=d.getFullYear(),m=('0'+(d.getMonth()+1)).slice(-2),dd=('0'+d.getDate()).slice(-2);return y+'-'+m+'-'+dd}
|
||||
|
||||
loadOptions(function(){loadBoard()});
|
||||
</script>
|
||||
<!-- 公共导航栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+444
@@ -0,0 +1,444 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>采购物料交付计划看板</title>
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<style>
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
html, body { height: 100%; }
|
||||
body { font-family: 'Microsoft YaHei','PingFang SC',sans-serif; background: #f3f5fa; color: #2c3e50; padding: 14px 18px; }
|
||||
|
||||
/* 顶部 4 卡片 */
|
||||
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
|
||||
.card { background: #fff; border-radius: 8px; padding: 16px 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; transition: transform .15s, box-shadow .15s; border-left: 4px solid #c0c4cc; }
|
||||
.card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); }
|
||||
.card .label { font-size: 13px; color: #909399; margin-bottom: 6px; }
|
||||
.card .num { font-size: 30px; font-weight: 700; line-height: 1.2; }
|
||||
.card .sub { font-size: 12px; color: #b0b3ba; margin-top: 4px; }
|
||||
.card.total { border-left-color: #409eff; } .card.total .num { color: #409eff; }
|
||||
.card.broken { border-left-color: #f56c6c; } .card.broken .num { color: #f56c6c; }
|
||||
.card.warn { border-left-color: #e6a23c; } .card.warn .num { color: #e6a23c; }
|
||||
.card.safe { border-left-color: #67c23a; } .card.safe .num { color: #67c23a; }
|
||||
.card.active { box-shadow: 0 0 0 2px #409eff, 0 6px 16px rgba(0,0,0,0.1); }
|
||||
|
||||
/* 工具栏 */
|
||||
.toolbar { background: #fff; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
|
||||
.toolbar select, .toolbar button { height: 30px; padding: 0 12px; border: 1px solid #dcdfe6; border-radius: 6px; background: #fff; font-size: 13px; cursor: pointer; }
|
||||
.toolbar select:hover, .toolbar button:hover { border-color: #409eff; color: #409eff; }
|
||||
.toolbar .spacer { flex: 1; }
|
||||
.toolbar .meta { font-size: 12px; color: #909399; }
|
||||
|
||||
/* 甘特图容器 */
|
||||
.gantt-wrap { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); padding: 16px 18px 14px; }
|
||||
.gantt-title { font-size: 16px; font-weight: 600; color: #303133; margin-bottom: 6px; }
|
||||
.gantt-sub { font-size: 12px; color: #909399; margin-bottom: 12px; }
|
||||
.gantt-legend { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; font-size: 12px; color: #606266; }
|
||||
.gantt-legend .item { display: flex; align-items: center; gap: 5px; }
|
||||
.gantt-legend .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }
|
||||
.gantt-legend .dot.req { background: #409eff; }
|
||||
.gantt-legend .dot.arr { background: #67c23a; }
|
||||
.gantt-legend .dot.broken { background: #f56c6c; }
|
||||
.gantt-legend .dot.weekend { background: #f4f4f5; border: 1px solid #dcdfe6; }
|
||||
|
||||
.gantt-scroll { overflow-x: auto; overflow-y: visible; position: relative; padding-bottom: 6px; }
|
||||
.gantt-scroll::-webkit-scrollbar { height: 10px; }
|
||||
.gantt-scroll::-webkit-scrollbar-thumb { background: #c0c4cc; border-radius: 5px; }
|
||||
.gantt-scroll::-webkit-scrollbar-track { background: #f0f2f5; border-radius: 5px; }
|
||||
|
||||
.gantt { position: relative; min-width: 100%; border-collapse: collapse; }
|
||||
.gantt-row { display: flex; border-bottom: 1px solid #f0f2f5; min-height: 50px; max-height: 50px; overflow: hidden; align-items: stretch; }
|
||||
.gantt-row.head { background: #f7f9fc; border-bottom: 1px solid #ebeef5; min-height: 36px; max-height: 36px; align-items: stretch; position: sticky; top: 0; z-index: 10; }
|
||||
.gantt-row:hover:not(.head) { background: #fafbfc; }
|
||||
|
||||
/* 固定左列 */
|
||||
.gantt-fixed { position: sticky; left: 0; z-index: 4; background: #fff; display: flex; flex-shrink: 0; box-shadow: 2px 0 4px rgba(0,0,0,0.04); }
|
||||
.gantt-row.head .gantt-fixed { background: #f7f9fc; z-index: 11; }
|
||||
.gantt-cell { padding: 8px 10px; font-size: 12px; color: #303133; border-right: 1px solid #ebeef5; display: flex; flex-direction: column; justify-content: center; }
|
||||
.gantt-row.head .gantt-cell { font-weight: 600; color: #606266; padding: 6px 10px; }
|
||||
.f-name { width: 160px; min-width: 160px; max-width: 160px; overflow: hidden; }
|
||||
.f-name .nm { font-size: 13px; font-weight: 600; color: #303133; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.f-name .sub { font-size: 11px; color: #909399; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis; line-height: 1.35; }
|
||||
.f-tag { width: 70px; display: flex; align-items: center; }
|
||||
.f-tag .tag { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: 600; text-align: center; }
|
||||
.f-tag .tag.broken { background: #fef0f0; color: #f56c6c; }
|
||||
.f-tag .tag.warn { background: #fdf6ec; color: #e6a23c; }
|
||||
.f-tag .tag.safe { background: #f0f9eb; color: #67c23a; }
|
||||
.f-tag .tag.empty { background: #f4f4f5; color: #909399; }
|
||||
|
||||
/* 时间轴区 */
|
||||
.gantt-timeline { position: relative; flex-shrink: 0; }
|
||||
.gantt-row.head .gantt-timeline { background: #f7f9fc; }
|
||||
.day-col { position: absolute; top: 0; height: 100%; display: flex; align-items: center; justify-content: center; border-right: 1px solid #f0f2f5; font-size: 12px; }
|
||||
.gantt-row.head .day-col { color: #606266; font-weight: 500; }
|
||||
.day-col.weekend { background: #fafafa; color: #909399; }
|
||||
.day-col.past { background: #f5f5f5; color: #c0c4cc; }
|
||||
.day-col.month-end { border-right: 2px solid #c0c4cc; }
|
||||
.day-col.today { background: #ecf5ff; color: #409eff; font-weight: 700; }
|
||||
.day-col .v { position: relative; display: flex; align-items: center; justify-content: center; padding: 4px; }
|
||||
|
||||
/* 单元格内的数据元素 */
|
||||
.cell-num { position: absolute; font-weight: 600; }
|
||||
.cell-num.req { color: #409eff; font-size: 12px; }
|
||||
.cell-num.arr { color: #67c23a; font-size: 12px; }
|
||||
.cell-arr-label { color: #67c23a; font-size: 10px; font-weight: 500; }
|
||||
|
||||
/* 停线标记 - 黄底橙边(预警) */
|
||||
.stop-mark { position: absolute; inset: 6px 4px; border: 2px solid #e6a23c; background: rgba(230, 162, 60, 0.12); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; color: #c8770f; font-weight: 600; }
|
||||
.stop-mark .icon { font-size: 11px; line-height: 1; }
|
||||
|
||||
/* 断线标记 - 红底红边(断线) */
|
||||
.break-mark { position: absolute; inset: 6px 4px; border: 2px solid #f56c6c; background: rgba(245, 108, 108, 0.12); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; color: #f56c6c; font-weight: 600; }
|
||||
|
||||
/* 库存说明(图表下方) */
|
||||
.gantt-summary { margin-top: 10px; padding: 8px 12px; background: #f7f9fc; border-radius: 6px; font-size: 12px; color: #909399; line-height: 1.7; }
|
||||
|
||||
.loading, .empty { text-align: center; padding: 50px 0; color: #909399; font-size: 14px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="sidebar"></div>
|
||||
|
||||
<div class="cards">
|
||||
<div class="card total" data-risk="">
|
||||
<div class="label">物料总数</div>
|
||||
<div class="num" id="cardTotal">-</div>
|
||||
<div class="sub">所有未结束排程物料</div>
|
||||
</div>
|
||||
<div class="card broken" data-risk="断线">
|
||||
<div class="label">断线风险</div>
|
||||
<div class="num" id="cardBroken">-</div>
|
||||
<div class="sub">到货晚于停线(紧急)</div>
|
||||
</div>
|
||||
<div class="card warn" data-risk="预警">
|
||||
<div class="label">预警关注</div>
|
||||
<div class="num" id="cardWarn">-</div>
|
||||
<div class="sub">到货日 = 停线日</div>
|
||||
</div>
|
||||
<div class="card safe" data-risk="安全">
|
||||
<div class="label">安全供应</div>
|
||||
<div class="num" id="cardSafe">-</div>
|
||||
<div class="sub">到货早于停线</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<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>
|
||||
<button id="btnRefresh">刷新</button>
|
||||
<button id="btnAutoRefresh">自动刷新:开</button>
|
||||
<div class="spacer"></div>
|
||||
<span class="meta" id="metaInfo">加载中...</span>
|
||||
</div>
|
||||
|
||||
<div class="gantt-wrap">
|
||||
<div class="gantt-title">物料交付甘特图</div>
|
||||
<div class="gantt-sub">按日展示每个物料的当日需求、到货、停线预警/断线情况</div>
|
||||
<div class="gantt-legend">
|
||||
<div class="item"><span class="dot req"></span> 当日需求</div>
|
||||
<div class="item"><span class="dot arr"></span> 到货</div>
|
||||
<div class="item"><span class="dot broken"></span> 断线</div>
|
||||
<div class="item" style="border:2px solid #e6a23c;border-radius:3px;width:14px;height:12px;background:rgba(230,162,60,.12);"></div> 预警
|
||||
<div class="item"><span class="dot weekend"></span> 周末</div>
|
||||
</div>
|
||||
<div id="ganttContainer" class="gantt-scroll">
|
||||
<div class="loading">加载中...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 公共导航栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
|
||||
<script>
|
||||
const API_BASE = '../../api/Deliver';
|
||||
const DAY_WIDTH = 56; // 每天宽度(按截图样式,约56px/列)
|
||||
const ROW_HEIGHT = 50; // 每行高度
|
||||
const HEAD_HEIGHT = 36; // 表头高度
|
||||
let autoRefreshTimer = null;
|
||||
let currentProductType = '';
|
||||
let currentRisk = '';
|
||||
|
||||
function parseDate(s) {
|
||||
if (!s) return null;
|
||||
const d = new Date(s);
|
||||
if (isNaN(d.getTime())) return null;
|
||||
// 统一归零到本地午夜 —— 避免 API 返回 UTC 字符串(带 Z)+ 东八区 8 小时偏移
|
||||
// 极端情况下会让 dateDiffDays 差 1 天,导致表头/数据列数不匹配
|
||||
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
}
|
||||
function fmtDate(d) {
|
||||
return d.getFullYear() + '-' + String(d.getMonth()+1).padStart(2,'0') + '-' + String(d.getDate()).padStart(2,'0');
|
||||
}
|
||||
function dateDiffDays(a, b) { return Math.round((b - a) / 86400000); }
|
||||
function isWeekend(d) { const w = d.getDay(); return w === 0 || w === 6; }
|
||||
|
||||
function loadSummary() {
|
||||
fetch(API_BASE + '/GetBoardSummary').then(r => r.json()).then(res => {
|
||||
if (res.success) {
|
||||
document.getElementById('cardTotal').textContent = res.total;
|
||||
document.getElementById('cardBroken').textContent = res.broken;
|
||||
document.getElementById('cardWarn').textContent = res.warn;
|
||||
document.getElementById('cardSafe').textContent = res.safe;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadProductTypes() {
|
||||
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);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadGantt() {
|
||||
document.getElementById('ganttContainer').innerHTML = '<div class="loading">加载中...</div>';
|
||||
const params = new URLSearchParams();
|
||||
if (currentProductType) params.append('productType', currentProductType);
|
||||
if (currentRisk) params.append('risk', currentRisk);
|
||||
fetch(API_BASE + '/GetBoardGantt?' + params).then(r => r.json()).then(res => {
|
||||
if (!res.success) {
|
||||
document.getElementById('ganttContainer').innerHTML = '<div class="empty">加载失败:' + (res.message || '') + '</div>';
|
||||
return;
|
||||
}
|
||||
document.getElementById('metaInfo').textContent = '时间范围:' + res.startDate + ' ~ ' + res.endDate + '(共 ' + res.data.length + ' 个物料)';
|
||||
renderGantt(res);
|
||||
});
|
||||
}
|
||||
|
||||
function renderGantt(res) {
|
||||
const data = res.data;
|
||||
if (!data || data.length === 0) {
|
||||
document.getElementById('ganttContainer').innerHTML = '<div class="empty">暂无数据</div>';
|
||||
return;
|
||||
}
|
||||
const startD = parseDate(res.startDate);
|
||||
const endD = parseDate(res.endDate);
|
||||
const today = parseDate(res.today);
|
||||
if (!startD || !endD || endD < startD) {
|
||||
document.getElementById('ganttContainer').innerHTML = '<div class="empty">日期范围无效</div>';
|
||||
return;
|
||||
}
|
||||
const dayCount = dateDiffDays(startD, endD) + 1;
|
||||
const timelineWidth = dayCount * DAY_WIDTH;
|
||||
|
||||
// 计算每个物料的"日均需求"(用于"需求X/天"标注)
|
||||
function getDailyRate(reqMap) {
|
||||
let total = 0, days = 0;
|
||||
Object.values(reqMap).forEach(v => { if (v > 0) { total += v; days++; } });
|
||||
if (days === 0) return 0;
|
||||
// 计算频次
|
||||
const dates = Object.keys(reqMap).filter(d => reqMap[d] > 0).sort();
|
||||
if (dates.length < 2) return dates.length > 0 ? reqMap[dates[0]] : 0;
|
||||
// 频次 = 总需求 / (最后一天 - 第一天的天数)
|
||||
const d1 = parseDate(dates[0]), d2 = parseDate(dates[dates.length-1]);
|
||||
const span = Math.max(1, dateDiffDays(d1, d2) + 1);
|
||||
return Math.round(total / span);
|
||||
}
|
||||
|
||||
const root = document.createElement('div');
|
||||
root.className = 'gantt';
|
||||
root.style.width = (160 + 70 + timelineWidth) + 'px';
|
||||
|
||||
// 表头
|
||||
const head = document.createElement('div');
|
||||
head.className = 'gantt-row head';
|
||||
head.style.height = HEAD_HEIGHT + 'px';
|
||||
const hFixed = document.createElement('div');
|
||||
hFixed.className = 'gantt-fixed';
|
||||
hFixed.innerHTML =
|
||||
'<div class="gantt-cell f-name">物料</div>' +
|
||||
'<div class="gantt-cell f-tag">风险</div>';
|
||||
head.appendChild(hFixed);
|
||||
const hTime = document.createElement('div');
|
||||
hTime.className = 'gantt-timeline';
|
||||
hTime.style.width = timelineWidth + 'px';
|
||||
hTime.style.height = HEAD_HEIGHT + 'px';
|
||||
for (let i = 0; i < dayCount; i++) {
|
||||
const d = new Date(startD); d.setDate(d.getDate() + i);
|
||||
const cell = document.createElement('div');
|
||||
cell.className = 'day-col';
|
||||
if (isWeekend(d)) cell.classList.add('weekend');
|
||||
// 月末
|
||||
const nextD = new Date(d); nextD.setDate(nextD.getDate() + 1);
|
||||
if (nextD.getMonth() !== d.getMonth()) cell.classList.add('month-end');
|
||||
// 今天
|
||||
if (today && fmtDate(d) === fmtDate(today)) cell.classList.add('today');
|
||||
// 今天之前(过期)
|
||||
if (today && d < today && fmtDate(d) !== fmtDate(today)) cell.classList.add('past');
|
||||
cell.style.left = (i * DAY_WIDTH) + 'px';
|
||||
cell.style.width = DAY_WIDTH + 'px';
|
||||
cell.textContent = (d.getMonth() + 1) + '/' + d.getDate();
|
||||
hTime.appendChild(cell);
|
||||
}
|
||||
head.appendChild(hTime);
|
||||
root.appendChild(head);
|
||||
|
||||
// 物料行
|
||||
data.forEach(m => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'gantt-row';
|
||||
row.style.height = ROW_HEIGHT + 'px';
|
||||
|
||||
// 固定列
|
||||
const fx = document.createElement('div');
|
||||
fx.className = 'gantt-fixed';
|
||||
const riskCls = ({'断线':'broken','预警':'warn','安全':'safe'}[m.DeliveryRisk] || 'empty');
|
||||
const dailyRate = getDailyRate(m.Requirement || {});
|
||||
fx.innerHTML =
|
||||
'<div class="gantt-cell f-name"><div class="nm" title="' + m.ChildMaterialId + '">' + m.ChildMaterialId + '</div><div class="sub" title="' + (m.MaterialName || '-') + (dailyRate > 0 ? ' · 需求' + dailyRate + '/天' : '') + '">' + (m.MaterialName || '-') + (dailyRate > 0 ? ' · 需求' + dailyRate + '/天' : '') + '</div></div>' +
|
||||
'<div class="gantt-cell f-tag"><span class="tag ' + riskCls + '">' + (m.DeliveryRisk || '未判定') + '</span></div>';
|
||||
row.appendChild(fx);
|
||||
|
||||
// 时间轴
|
||||
const tl = document.createElement('div');
|
||||
tl.className = 'gantt-timeline';
|
||||
tl.style.width = timelineWidth + 'px';
|
||||
tl.style.height = ROW_HEIGHT + 'px';
|
||||
|
||||
const reqMap = m.Requirement || {};
|
||||
const arrList = m.Arrival || [];
|
||||
const arrByDate = {};
|
||||
arrList.forEach(a => {
|
||||
if (!arrByDate[a.date]) arrByDate[a.date] = 0;
|
||||
arrByDate[a.date] += a.qty;
|
||||
});
|
||||
|
||||
for (let i = 0; i < dayCount; i++) {
|
||||
const d = new Date(startD); d.setDate(d.getDate() + i);
|
||||
const dateStr = fmtDate(d);
|
||||
|
||||
// 周末/今天/过期 背景
|
||||
if (isWeekend(d)) {
|
||||
const bg = document.createElement('div');
|
||||
bg.className = 'day-col weekend';
|
||||
bg.style.left = (i * DAY_WIDTH) + 'px';
|
||||
bg.style.width = DAY_WIDTH + 'px';
|
||||
tl.appendChild(bg);
|
||||
} else if (today && d < today && fmtDate(d) !== fmtDate(today)) {
|
||||
const bg = document.createElement('div');
|
||||
bg.className = 'day-col past';
|
||||
bg.style.left = (i * DAY_WIDTH) + 'px';
|
||||
bg.style.width = DAY_WIDTH + 'px';
|
||||
tl.appendChild(bg);
|
||||
} else if (today && fmtDate(d) === fmtDate(today)) {
|
||||
const bg = document.createElement('div');
|
||||
bg.className = 'day-col today';
|
||||
bg.style.left = (i * DAY_WIDTH) + 'px';
|
||||
bg.style.width = DAY_WIDTH + 'px';
|
||||
tl.appendChild(bg);
|
||||
}
|
||||
const nextD = new Date(d); nextD.setDate(nextD.getDate() + 1);
|
||||
if (nextD.getMonth() !== d.getMonth()) {
|
||||
const bg = document.createElement('div');
|
||||
bg.className = 'day-col month-end';
|
||||
bg.style.left = (i * DAY_WIDTH) + 'px';
|
||||
bg.style.width = DAY_WIDTH + 'px';
|
||||
tl.appendChild(bg);
|
||||
}
|
||||
|
||||
// 内容容器(用于在格子里绝对定位)
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'v';
|
||||
wrap.style.position = 'absolute';
|
||||
wrap.style.left = (i * DAY_WIDTH) + 'px';
|
||||
wrap.style.width = DAY_WIDTH + 'px';
|
||||
wrap.style.height = '100%';
|
||||
|
||||
// 需求
|
||||
const reqQty = reqMap[dateStr] || 0;
|
||||
if (reqQty > 0) {
|
||||
const num = document.createElement('div');
|
||||
num.className = 'cell-num req';
|
||||
num.textContent = reqQty;
|
||||
num.style.top = '4px';
|
||||
num.style.left = '4px';
|
||||
wrap.appendChild(num);
|
||||
}
|
||||
|
||||
// 到货
|
||||
const arrQty = arrByDate[dateStr] || 0;
|
||||
if (arrQty > 0) {
|
||||
// 模拟图样式:到货/60 形式
|
||||
const num = document.createElement('div');
|
||||
num.className = 'cell-num arr';
|
||||
num.innerHTML = '到' + arrQty;
|
||||
num.style.bottom = '4px';
|
||||
num.style.left = '4px';
|
||||
wrap.appendChild(num);
|
||||
}
|
||||
|
||||
// 停线/断线
|
||||
if (m.ExpectedStopDate && dateStr === m.ExpectedStopDate) {
|
||||
const mark = document.createElement('div');
|
||||
if (m.DeliveryRisk === '断线') {
|
||||
mark.className = 'break-mark';
|
||||
mark.innerHTML = '<div class="icon">停</div><div>断线</div>';
|
||||
} else {
|
||||
mark.className = 'stop-mark';
|
||||
mark.innerHTML = '<div class="icon">停</div><div>预警</div>';
|
||||
}
|
||||
wrap.appendChild(mark);
|
||||
}
|
||||
|
||||
tl.appendChild(wrap);
|
||||
}
|
||||
row.appendChild(tl);
|
||||
root.appendChild(row);
|
||||
});
|
||||
|
||||
document.getElementById('ganttContainer').innerHTML = '';
|
||||
document.getElementById('ganttContainer').appendChild(root);
|
||||
|
||||
// 滚动到今天
|
||||
if (today) {
|
||||
const offset = dateDiffDays(startD, today) * DAY_WIDTH;
|
||||
const wrap = document.getElementById('ganttContainer');
|
||||
setTimeout(() => { wrap.scrollLeft = Math.max(0, offset - 100); }, 50);
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelectorAll('.card').forEach(card => {
|
||||
card.addEventListener('click', () => {
|
||||
const risk = card.dataset.risk;
|
||||
const params = new URLSearchParams();
|
||||
if (risk) params.append('risk', risk);
|
||||
if (currentProductType) params.append('productType', currentProductType);
|
||||
window.location.href = 'delivery_dashboard_risk.html?' + params.toString();
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('filterProductType').addEventListener('change', e => { currentProductType = e.target.value; loadGantt(); });
|
||||
document.getElementById('filterRisk').addEventListener('change', e => { currentRisk = e.target.value; loadGantt(); });
|
||||
document.getElementById('btnRefresh').addEventListener('click', () => { loadSummary(); loadGantt(); });
|
||||
let autoOn = true;
|
||||
document.getElementById('btnAutoRefresh').addEventListener('click', e => {
|
||||
autoOn = !autoOn;
|
||||
e.target.textContent = '自动刷新:' + (autoOn ? '开' : '关');
|
||||
if (autoOn) startAuto(); else stopAuto();
|
||||
});
|
||||
function startAuto() { stopAuto(); autoRefreshTimer = setInterval(() => { loadSummary(); loadGantt(); }, 600000); }
|
||||
function stopAuto() { if (autoRefreshTimer) { clearInterval(autoRefreshTimer); autoRefreshTimer = null; } }
|
||||
|
||||
loadSummary();
|
||||
loadProductTypes();
|
||||
loadGantt();
|
||||
startAuto();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
+358
@@ -0,0 +1,358 @@
|
||||
<!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">
|
||||
<script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
|
||||
<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; }
|
||||
.filter button.export { background: linear-gradient(135deg,#34a853,#1e8e3e); border-color: #34a853; }
|
||||
.filter button.export:hover { opacity: .9; background: #34a853; border-color: #34a853; }
|
||||
|
||||
.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>
|
||||
<button class="export" onclick="exportExcel()">导出Excel</button>
|
||||
<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:80px">库存</th>
|
||||
<th style="width:80px">在途</th>
|
||||
<th style="width:90px">到货计划</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>${num(m.StockQty)}</td>
|
||||
<td>${num(m.InTransitQty)}</td>
|
||||
<td>${num(m.ArrivalPlanQty)}</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);
|
||||
}
|
||||
|
||||
// ===== 导出Excel =====
|
||||
const exportHeaders = ['序号', '物料编码', '物料名称', '产品类型', '供应商', '采购员', '预计停线日', '预计到货日', '风险', '日需求', '震泽库存', '晋江库存', '资阳库存','库存在途合计','量产在途','研发在途','线边库存','已收货','库存','在途','到货计划','备注'];
|
||||
const exportKeys = ['','ChildMaterialId','MaterialName','ProductType','Supplier','Purchaser','ExpectedStopDate','ExpectedArrivalDate','DeliveryRisk','DailyRequirement','ZhenZeStock','JinJiangStock','ZiYangStock','AvailableStock','MassInTransit','ResearchInTransit','LineSideStock','ReceivedQty','StockQty','InTransitQty','ArrivalPlanQty','Remark'];
|
||||
|
||||
function exportExcel() {
|
||||
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', 1);
|
||||
params.append('pageSize', 100000);
|
||||
|
||||
const btn = document.querySelector('.filter button.export');
|
||||
const oldText = btn.textContent;
|
||||
btn.textContent = '导出中...';
|
||||
btn.disabled = true;
|
||||
fetch(API_BASE + '/GetBoardRiskList?' + params).then(r => r.json()).then(res => {
|
||||
btn.textContent = oldText;
|
||||
btn.disabled = false;
|
||||
if (!res.success) { alert('导出失败:' + (res.message || '未知错误')); return; }
|
||||
const rows = res.data || [];
|
||||
if (!rows.length) { alert('当前条件下没有可导出的数据'); return; }
|
||||
|
||||
const data = [exportHeaders];
|
||||
rows.forEach((m, i) => {
|
||||
const row = [i + 1];
|
||||
for (let k = 1; k < exportKeys.length; k++) row.push(m[exportKeys[k]] == null ? '' : m[exportKeys[k]]);
|
||||
data.push(row);
|
||||
});
|
||||
const wscols = exportHeaders.map((h, i) => {
|
||||
let max = i === 0 ? Math.max(h.length, String(rows.length).length) : h.length;
|
||||
rows.forEach(r => { const v = String(r[exportKeys[i]] || ''); if (v.length > max) max = v.length; });
|
||||
return { wch: Math.min(max + 2, 40) };
|
||||
});
|
||||
const ws = XLSX.utils.aoa_to_sheet(data);
|
||||
ws['!cols'] = wscols;
|
||||
const wb = XLSX.utils.book_new();
|
||||
XLSX.utils.book_append_sheet(wb, ws, '交付物料风险明细');
|
||||
const riskName = ({'': '全部', '断线': '断线', '预警': '预警', '安全': '安全'})[risk] || '';
|
||||
XLSX.writeFile(wb, '交付物料风险明细' + riskName + '_' + new Date().toISOString().slice(0, 10) + '.xlsx');
|
||||
}).catch(() => {
|
||||
btn.textContent = oldText;
|
||||
btn.disabled = false;
|
||||
alert('导出失败:网络错误');
|
||||
});
|
||||
}
|
||||
|
||||
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>
|
||||
Executable
+630
@@ -0,0 +1,630 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>物料交付维护</title>
|
||||
<!-- 公共侧边栏组件 -->
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<style>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{font-family:'Microsoft YaHei','PingFang SC',sans-serif;background:#f0f2f5;min-height:100vh}
|
||||
.top-bar{background:linear-gradient(135deg,#1a73e8,#1557b0);color:#fff;padding:0 24px;display:flex;align-items:center;height:56px;box-shadow:0 2px 8px rgba(0,0,0,.15);position:sticky;top:0;z-index:100}
|
||||
.top-bar .logo{font-size:18px;font-weight:600;letter-spacing:1px;margin-right:32px}
|
||||
.top-bar .nav-tabs{display:flex;gap:4px;height:100%}
|
||||
.top-bar .nav-tabs a{color:rgba(255,255,255,.75);text-decoration:none;padding:0 16px;display:flex;align-items:center;font-size:13px;border-radius:4px 4px 0 0;transition:all .2s}
|
||||
.top-bar .nav-tabs a:hover{color:#fff;background:rgba(255,255,255,.1)}
|
||||
.top-bar .nav-tabs a.active{color:#fff;background:rgba(255,255,255,.2)}
|
||||
.top-bar .user-info{margin-left:auto;font-size:13px;opacity:.85}
|
||||
.main-container{max-width:1500px;margin:0 auto;padding:16px 20px}
|
||||
.panel{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:16px;margin-bottom:14px}
|
||||
.panel h3{font-size:15px;color:#333;font-weight:600;margin-bottom:12px}
|
||||
.toolbar{display:flex;flex-direction:column;gap:10px;margin-bottom:12px}
|
||||
.toolbar-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
|
||||
.toolbar input,.toolbar select{height:32px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.toolbar select{width:140px;max-width:140px;flex-shrink:0}
|
||||
#selProductType{width:130px}
|
||||
#selSupplier{width:160px}
|
||||
#selPurchaser{width:130px}
|
||||
#selRisk{width:100px}
|
||||
.toolbar input:focus,.toolbar select:focus{border-color:#1a73e8}
|
||||
.btn{height:32px;padding:0 16px;border:none;border-radius:5px;font-size:12px;font-weight:600;cursor:pointer;transition:all .2s;color:#fff}
|
||||
.btn-primary{background:linear-gradient(135deg,#1a73e8,#1557b0)}
|
||||
.btn-primary:hover{opacity:.92}
|
||||
.btn-green{background:#22c55e}
|
||||
.btn-green:hover{opacity:.92}
|
||||
.btn-red{background:#ef4444}
|
||||
.btn-red:hover{opacity:.92}
|
||||
.btn-blue{background:#3b82f6}
|
||||
.btn-blue:hover{opacity:.92}
|
||||
.btn-warning{background:#f59e0b}
|
||||
.btn-warning:hover{opacity:.92}
|
||||
.btn-outline{background:#fff;color:#666;border:2px solid #e0e0e0}
|
||||
.btn-outline:hover{border-color:#1a73e8;color:#1a73e8}
|
||||
table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
thead th{background:#f8f9fa;color:#555;font-weight:600;padding:9px 12px;text-align:left;border:1px solid #999;border-bottom:2px solid #999;white-space:nowrap}
|
||||
tbody td{padding:9px 12px;border:1px solid #ddd;color:#333}
|
||||
tbody tr:hover{background:#f0f6ff}
|
||||
.badge{display:inline-block;padding:2px 10px;border-radius:12px;font-size:12px;font-weight:500}
|
||||
.badge-danger{background:#fee2e2;color:#991b1b}
|
||||
.badge-warning{background:#fef3c7;color:#92400e}
|
||||
.badge-success{background:#dcfce7;color:#166534}
|
||||
.badge-info{background:#dbeafe;color:#1e40af}
|
||||
.pagination{display:flex;justify-content:flex-end;align-items:center;gap:8px;margin-top:12px;font-size:13px;color:#666}
|
||||
.pagination button{min-width:30px;height:30px;border:1px solid #e0e0e0;border-radius:4px;background:#fff;cursor:pointer}
|
||||
.pagination button.active{background:#1a73e8;color:#fff;border-color:#1a73e8}
|
||||
.pagination button:disabled{opacity:.4;cursor:not-allowed}
|
||||
.pagination select{height:28px;border:1px solid #e0e0e0;border-radius:4px;padding:0 4px}
|
||||
.table-wrap{overflow-x:auto;width:100%}
|
||||
#tblList{table-layout:fixed;min-width:1600px}
|
||||
#tblList th{position:relative;padding:9px 8px}
|
||||
#tblList tbody td{padding:8px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
#tblList tbody td:last-child{overflow:visible}
|
||||
.col-resizer{position:absolute;right:-3px;top:0;width:8px;height:100%;cursor:col-resize;z-index:5}
|
||||
.col-resizer:hover{background:rgba(26,115,232,.25)}
|
||||
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:999;justify-content:center;align-items:center}
|
||||
.modal-overlay.show{display:flex}
|
||||
.modal{background:#fff;border-radius:10px;width:760px;max-width:95vw;max-height:90vh;overflow-y:auto;box-shadow:0 20px 60px rgba(0,0,0,.2);padding:24px}
|
||||
.modal h3{font-size:17px;color:#333;margin-bottom:16px}
|
||||
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}
|
||||
.form-group{display:flex;flex-direction:column}
|
||||
.form-group.full{grid-column:1/-1}
|
||||
.form-group label{font-size:12px;color:#555;font-weight:600;margin-bottom:4px}
|
||||
.form-group input,.form-group select,.form-group textarea{height:34px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.form-group textarea{height:60px;resize:vertical;padding:6px 10px}
|
||||
.form-group input:focus,.form-group select:focus,.form-group textarea:focus{border-color:#1a73e8}
|
||||
.form-group input.readonly{background:#f8f9fa;color:#999}
|
||||
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:18px}
|
||||
.arrival-table{width:100%;border-collapse:collapse;font-size:12px;margin-top:10px}
|
||||
.arrival-table th{background:#f1f5f9;padding:6px;border:1px solid #e2e8f0;font-weight:600;color:#64748b}
|
||||
.arrival-table td{padding:4px;border:1px solid #e2e8f0;text-align:center}
|
||||
.arrival-table input,.arrival-table select{width:110px;border:1px solid #ddd;border-radius:4px;padding:2px 4px;font-size:12px}
|
||||
.toast{position:fixed;top:14px;left:50%;transform:translateX(-50%);padding:10px 22px;border-radius:8px;font-size:13px;z-index:1001;box-shadow:0 4px 20px rgba(0,0,0,.15);display:none;min-width:240px;text-align:center}
|
||||
.toast.error{background:#fdeaea;color:#b71c1c;display:block}
|
||||
.toast.success{background:#e6f9ed;color:#1a7a3a;display:block}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sidebar"></div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="panel">
|
||||
<h3>物料交付维护</h3>
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-row">
|
||||
<select id="selProductType"><option value="">产品类型:全部</option></select>
|
||||
<select id="selSupplier"><option value="">供应商:全部</option></select>
|
||||
<select id="selPurchaser"><option value="">采购员:全部</option></select>
|
||||
<select id="selRisk">
|
||||
<option value="">风险:全部</option>
|
||||
<option value="断线">断线</option>
|
||||
<option value="预警">预警</option>
|
||||
<option value="安全">安全</option>
|
||||
</select>
|
||||
<input type="text" id="txtKeyword" placeholder="搜索 物料编码 / 物料名称" style="width:200px">
|
||||
<button class="btn btn-primary" onclick="loadList()">查询</button>
|
||||
<button class="btn btn-outline" onclick="resetSearch()">重置</button>
|
||||
</div>
|
||||
<div class="toolbar-row">
|
||||
<button class="btn btn-primary" onclick="startDeliveryCalc()" id="btnRecalcDelivery">🔄 重算交付数据</button>
|
||||
<button class="btn btn-blue" onclick="downloadBatchArrivalTpl()">📄 到货计划模板</button>
|
||||
<button class="btn btn-outline" onclick="document.getElementById('batchArrivalFile').click()">📥 导入到货计划</button>
|
||||
<input type="file" id="batchArrivalFile" accept=".xls,.xlsx" style="display:none" onchange="importBatchArrivalExcel(this)">
|
||||
<span style="font-size:13px;color:#666;margin-left:8px" id="totalCount"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="calcProgressWrap" style="display:none;margin-bottom:12px">
|
||||
<div style="background:#e5e7eb;border-radius:4px;height:18px;overflow:hidden">
|
||||
<div id="calcProgressBar" style="background:linear-gradient(135deg,#10b981,#059669);height:100%;width:0%;transition:width .3s"></div>
|
||||
</div>
|
||||
<div style="display:flex;justify-content:space-between;margin-top:4px">
|
||||
<span id="calcProgressText" style="font-size:12px;color:#666"></span>
|
||||
<span id="calcProgressPercent" style="font-size:12px;color:#059669;font-weight:600"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
<table id="tblList">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:48px">序号</th>
|
||||
<th style="width:130px">操作</th>
|
||||
<th style="width:110px">物料编码</th><th style="width:120px">物料名称</th><th style="width:80px">产品类型</th><th style="width:150px">供应商</th><th style="width:110px">采购员</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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination" id="pagination"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="editModal">
|
||||
<div class="modal">
|
||||
<h3>物料交付 - 编辑</h3>
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label>产品编码</label>
|
||||
<input type="text" id="fProductCode" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>BOM版本</label>
|
||||
<input type="text" id="fBOMVersion" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>物料编码</label>
|
||||
<input type="text" id="fChildMaterialId" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>物料名称</label>
|
||||
<input type="text" id="fMaterialName" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>供应商</label>
|
||||
<input type="text" id="fSupplier">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>采购员</label>
|
||||
<input type="text" id="fPurchaser">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>预计停线日期 <span style="color:#94a3b8;font-weight:400">(系统自动计算)</span></label>
|
||||
<input type="date" id="fExpectedStopDate" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>预计到货日期 <span style="color:#94a3b8;font-weight:400">(最近未到货批次)</span></label>
|
||||
<input type="date" id="fExpectedArrivalDate" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>交付风险</label>
|
||||
<select id="fDeliveryRisk">
|
||||
<option value="">自动判定</option>
|
||||
<option value="安全">安全</option>
|
||||
<option value="预警">预警</option>
|
||||
<option value="断线">断线</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>震泽库存</label>
|
||||
<input type="text" id="fZhenZeStock" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>晋江库存</label>
|
||||
<input type="text" id="fJinJiangStock" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>资阳库存</label>
|
||||
<input type="text" id="fZiYangStock" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>量产在途</label>
|
||||
<input type="text" id="fMassInTransit" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>研发在途</label>
|
||||
<input type="text" id="fResearchInTransit" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>线边库存</label>
|
||||
<input type="text" id="fLineSideStock" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>已收货(上月1号至今)</label>
|
||||
<input type="text" id="fReceivedQty" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>可用库存</label>
|
||||
<input type="text" id="fAvailableStock" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group full">
|
||||
<label>交付进度及后续交付计划</label>
|
||||
<textarea id="fDeliveryProgress" placeholder="如:8/20到货500PCS,8/25剩余300PCS"></textarea>
|
||||
</div>
|
||||
<div class="form-group full">
|
||||
<label>备注</label>
|
||||
<textarea id="fRemark"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-outline" onclick="closeModal('editModal')">取消</button>
|
||||
<button class="btn btn-primary" onclick="saveDelivery()">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="arrivalModal">
|
||||
<div class="modal">
|
||||
<h3>到货计划管理 - <span id="arrivalMaterialName"></span></h3>
|
||||
<div class="toolbar">
|
||||
<button class="btn btn-green" onclick="addArrivalRow()">+ 新增批次</button>
|
||||
</div>
|
||||
<table class="arrival-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>序号</th><th>预计到货日</th><th>到货数量</th><th>删除行</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="arrivalBody"></tbody>
|
||||
</table>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-green" onclick="saveAllArrival()">保存全部批次</button>
|
||||
<button class="btn btn-outline" onclick="closeModal('arrivalModal')">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
<script>
|
||||
var curDeliveryId=0;
|
||||
var curDelivery={};
|
||||
var options=null;
|
||||
var arrivals=[];
|
||||
|
||||
function toast(msg,tp){var el=document.getElementById('toast');el.textContent=msg;el.className='toast '+tp;clearTimeout(el._timer);el._timer=setTimeout(function(){el.className='toast'},3000)}
|
||||
function api(url,method,data,cb){
|
||||
var opts={method:method||'GET',headers:{'Content-Type':'application/json'}};
|
||||
if(data)opts.body=JSON.stringify(data);
|
||||
fetch(url,opts).then(function(r){return r.json()}).then(function(res){
|
||||
if(res&&res.success===false){toast(res.message||'操作失败','error');return}
|
||||
cb&&cb(res);
|
||||
}).catch(function(e){toast('请求失败:'+e.message,'error')});
|
||||
}
|
||||
function getApiUrl(){return '../../api/deliver/'}
|
||||
|
||||
function loadOptions(cb){
|
||||
api(getApiUrl()+'GetOptions','GET',null,function(res){
|
||||
options=res.data||{};
|
||||
var h='<option value="">产品类型:全部</option>';
|
||||
(options.productTypes||[]).forEach(function(t){h+='<option value="'+t+'">'+t+'</option>'});
|
||||
document.getElementById('selProductType').innerHTML=h;
|
||||
var h2='<option value="">供应商:全部</option>';
|
||||
(options.suppliers||[]).forEach(function(s){h2+='<option value="'+s+'">'+s+'</option>'});
|
||||
document.getElementById('selSupplier').innerHTML=h2;
|
||||
var h3='<option value="">采购员:全部</option>';
|
||||
(options.purchasers||[]).forEach(function(p){h3+='<option value="'+p+'">'+p+'</option>'});
|
||||
document.getElementById('selPurchaser').innerHTML=h3;
|
||||
cb&&cb();
|
||||
});
|
||||
}
|
||||
|
||||
function getFilters(){
|
||||
var t=document.getElementById('selProductType').value;
|
||||
var s=document.getElementById('selSupplier').value;
|
||||
var pu=document.getElementById('selPurchaser').value;
|
||||
var r=document.getElementById('selRisk').value;
|
||||
var kw=document.getElementById('txtKeyword').value.trim();
|
||||
return {t:t,s:s,pu:pu,r:r,kw:kw};
|
||||
}
|
||||
|
||||
var curPage=1,curPageSize=50,curList=[];
|
||||
function loadList(page){
|
||||
page=page||1;
|
||||
curPage=page;
|
||||
var f=getFilters();
|
||||
var url=getApiUrl()+'GetDeliveryList?productType='+encodeURIComponent(f.t)+'&supplier='+encodeURIComponent(f.s)+'&purchaser='+encodeURIComponent(f.pu)+'&risk='+encodeURIComponent(f.r)+'&keyword='+encodeURIComponent(f.kw)+'&page='+page+'&pageSize='+curPageSize;
|
||||
api(url,'GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
curList=rows;
|
||||
var html='';
|
||||
if(rows.length===0)html='<tr><td colspan="18" style="text-align:center;padding:36px;color:#bbb">暂无数据</td></tr>';
|
||||
rows.forEach(function(r,i){
|
||||
var seq=(curPage-1)*curPageSize+i+1;
|
||||
var rk=r.DeliveryRisk||'安全';
|
||||
var cls=rk=='断线'?'badge-danger':(rk=='预警'?'badge-warning':'badge-success');
|
||||
html+='<tr>'+
|
||||
'<td>'+seq+'</td>'+
|
||||
'<td style="white-space:nowrap">'+
|
||||
'<button class="btn btn-primary" style="height:26px;padding:0 8px;font-size:11px" onclick="openEdit('+r.Id+')">编辑</button> '+
|
||||
'<button class="btn btn-blue" style="height:26px;padding:0 8px;font-size:11px" onclick="openArrival('+r.Id+',\''+r.MaterialName+'\')">到货计划</button>'+
|
||||
'</td>'+
|
||||
'<td>'+r.ChildMaterialId+'</td>'+
|
||||
'<td>'+r.MaterialName+'</td>'+
|
||||
'<td>'+(r.ProductTypes||'')+'</td>'+
|
||||
'<td>'+r.Supplier+'</td>'+
|
||||
'<td>'+r.Purchaser+'</td>'+
|
||||
'<td>'+r.ExpectedStopDate+'</td>'+
|
||||
'<td>'+r.ExpectedArrivalDate+'</td>'+
|
||||
'<td><span class="badge '+cls+'">'+rk+'</span></td>'+
|
||||
'<td>'+r.DailyRequirement+'</td>'+
|
||||
'<td>'+r.ZhenZeStock+'</td>'+
|
||||
'<td>'+r.JinJiangStock+'</td>'+
|
||||
'<td>'+r.ZiYangStock+'</td>'+
|
||||
'<td>'+r.AvailableStock+'</td>'+
|
||||
'<td>'+r.MassInTransit+'</td>'+
|
||||
'<td>'+r.ResearchInTransit+'</td>'+
|
||||
'<td>'+r.LineSideStock+'</td>'+
|
||||
'<td>'+r.ReceivedQty+'</td>'+
|
||||
'</tr>';
|
||||
});
|
||||
document.getElementById('tbodyList').innerHTML=html;
|
||||
document.getElementById('totalCount').textContent='共 '+res.total+' 条';
|
||||
renderPagination(res.total,res.page);
|
||||
});
|
||||
}
|
||||
|
||||
function renderPagination(total,page){
|
||||
var pages=Math.ceil(total/curPageSize)||1;
|
||||
var sizeOpts=[20,50,100,200].map(function(s){
|
||||
return '<option value="'+s+'"'+(s==curPageSize?' selected':'')+'>'+s+'</option>';
|
||||
}).join('');
|
||||
var html='<span>每页 <select onchange="changePageSize(this.value)">'+sizeOpts+'</select> 条</span>';
|
||||
html+='<button '+(page<=1?'disabled':'')+' onclick="loadList(1)">首页</button>';
|
||||
html+='<button '+(page<=1?'disabled':'')+' onclick="loadList('+(page-1)+')">上一页</button>';
|
||||
var start=Math.max(1,page-2),end=Math.min(pages,page+2);
|
||||
for(var i=start;i<=end;i++){
|
||||
html+='<button class="'+(i==page?'active':'')+'" onclick="loadList('+i+')">'+i+'</button>';
|
||||
}
|
||||
html+='<button '+(page>=pages?'disabled':'')+' onclick="loadList('+(page+1)+')">下一页</button>';
|
||||
html+='<button '+(page>=pages?'disabled':'')+' onclick="loadList('+pages+')">末页</button>';
|
||||
html+='<span>第 '+page+' / '+pages+' 页,共 '+total+' 条</span>';
|
||||
document.getElementById('pagination').innerHTML=html;
|
||||
}
|
||||
|
||||
function changePageSize(v){
|
||||
curPageSize=parseInt(v)||50;
|
||||
loadList(1);
|
||||
}
|
||||
|
||||
// 表头列宽左右拖动
|
||||
function initColResize(){
|
||||
var table=document.getElementById('tblList');
|
||||
if(!table)return;
|
||||
var ths=table.querySelectorAll('thead th');
|
||||
[].forEach.call(ths,function(th){
|
||||
if(th.querySelector('.col-resizer'))return;
|
||||
var grip=document.createElement('div');
|
||||
grip.className='col-resizer';
|
||||
th.appendChild(grip);
|
||||
grip.addEventListener('mousedown',function(e){
|
||||
e.preventDefault();e.stopPropagation();
|
||||
var startX=e.clientX,startW=th.offsetWidth;
|
||||
function onMove(ev){
|
||||
var w=Math.max(40,startW+(ev.clientX-startX));
|
||||
th.style.width=w+'px';
|
||||
}
|
||||
function onUp(){
|
||||
document.removeEventListener('mousemove',onMove);
|
||||
document.removeEventListener('mouseup',onUp);
|
||||
}
|
||||
document.addEventListener('mousemove',onMove);
|
||||
document.addEventListener('mouseup',onUp);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function resetSearch(){
|
||||
document.getElementById('selProductType').value='';
|
||||
document.getElementById('selSupplier').value='';
|
||||
document.getElementById('selPurchaser').value='';
|
||||
document.getElementById('selRisk').value='';
|
||||
document.getElementById('txtKeyword').value='';
|
||||
loadList();
|
||||
}
|
||||
|
||||
function openEdit(id){
|
||||
api(getApiUrl()+'GetDeliveryDetail?id='+id,'GET',null,function(res){
|
||||
if(!res.success||!res.data){toast('未找到记录','error');return}
|
||||
var d=res.data;
|
||||
curDeliveryId=d.Id;
|
||||
curDelivery=d;
|
||||
document.getElementById('fProductCode').value=d.ProductCode;
|
||||
document.getElementById('fBOMVersion').value=d.BOMVersion;
|
||||
document.getElementById('fChildMaterialId').value=d.ChildMaterialId;
|
||||
document.getElementById('fMaterialName').value=d.MaterialName;
|
||||
document.getElementById('fSupplier').value=d.Supplier;
|
||||
document.getElementById('fPurchaser').value=d.Purchaser;
|
||||
document.getElementById('fExpectedStopDate').value=d.ExpectedStopDate;
|
||||
document.getElementById('fExpectedArrivalDate').value=d.ExpectedArrivalDate;
|
||||
document.getElementById('fDeliveryRisk').value=d.DeliveryRisk;
|
||||
document.getElementById('fZhenZeStock').value=d.ZhenZeStock||0;
|
||||
document.getElementById('fJinJiangStock').value=d.JinJiangStock||0;
|
||||
document.getElementById('fZiYangStock').value=d.ZiYangStock||0;
|
||||
document.getElementById('fMassInTransit').value=d.MassInTransit||0;
|
||||
document.getElementById('fResearchInTransit').value=d.ResearchInTransit||0;
|
||||
document.getElementById('fLineSideStock').value=d.LineSideStock;
|
||||
document.getElementById('fReceivedQty').value=d.ReceivedQty||0;
|
||||
calcAvailable();
|
||||
document.getElementById('fDeliveryProgress').value=d.DeliveryProgress;
|
||||
document.getElementById('fRemark').value=d.Remark;
|
||||
document.getElementById('editModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function calcAvailable(){
|
||||
var z=parseFloat(document.getElementById('fZhenZeStock').value)||0;
|
||||
var j=parseFloat(document.getElementById('fJinJiangStock').value)||0;
|
||||
var t=parseFloat(document.getElementById('fZiYangStock').value)||0;
|
||||
var m=parseFloat(document.getElementById('fMassInTransit').value)||0;
|
||||
var r=parseFloat(document.getElementById('fResearchInTransit').value)||0;
|
||||
var l=parseFloat(document.getElementById('fLineSideStock').value)||0;
|
||||
document.getElementById('fAvailableStock').value=(z+j+t+m+r+l);
|
||||
}
|
||||
|
||||
function saveDelivery(){
|
||||
var data={
|
||||
Id:curDeliveryId,
|
||||
Supplier:document.getElementById('fSupplier').value.trim(),
|
||||
Purchaser:document.getElementById('fPurchaser').value.trim(),
|
||||
DeliveryRisk:document.getElementById('fDeliveryRisk').value,
|
||||
LineSideStock:document.getElementById('fLineSideStock').value,
|
||||
DeliveryProgress:document.getElementById('fDeliveryProgress').value,
|
||||
Remark:document.getElementById('fRemark').value
|
||||
};
|
||||
api(getApiUrl()+'SaveDelivery','POST',data,function(res){
|
||||
if(res.success){toast('保存成功,停线日已自动计算','success');closeModal('editModal');loadList()}
|
||||
});
|
||||
}
|
||||
|
||||
function openArrival(id,materialName){
|
||||
curDeliveryId=id;
|
||||
curDelivery={Id:id,MaterialName:materialName,ChildMaterialId:''};
|
||||
for(var i=0;i<curList.length;i++){if(curList[i].Id===id){curDelivery.ChildMaterialId=curList[i].ChildMaterialId;curDelivery.MaterialName=curList[i].MaterialName;break}}
|
||||
document.getElementById('arrivalMaterialName').textContent=materialName;
|
||||
loadArrival(id);
|
||||
document.getElementById('arrivalModal').classList.add('show');
|
||||
}
|
||||
|
||||
function loadArrival(id){
|
||||
api(getApiUrl()+'GetDeliveryDetail?id='+id,'GET',null,function(res){
|
||||
if(!res.data)return;
|
||||
arrivals=(res.data.arrivals||[]).map(function(a){
|
||||
return {Id:a.Id,BatchNo:a.BatchNo,ExpectedArrivalDate:a.ExpectedArrivalDate,ActualArrivalDate:a.ActualArrivalDate,ArrivalQty:a.ArrivalQty,Status:a.Status};
|
||||
});
|
||||
renderArrival();
|
||||
});
|
||||
}
|
||||
|
||||
function renderArrival(){
|
||||
var html='';
|
||||
if(arrivals.length===0)html='<tr><td colspan="4" style="padding:20px;color:#bbb">暂无到货计划</td></tr>';
|
||||
arrivals.forEach(function(a,i){
|
||||
html+='<tr>'+
|
||||
'<td>'+(i+1)+'</td>'+
|
||||
'<td><input type="date" value="'+a.ExpectedArrivalDate+'" onchange="arrivals['+i+'].ExpectedArrivalDate=this.value"></td>'+
|
||||
'<td><input type="number" value="'+a.ArrivalQty+'" onchange="arrivals['+i+'].ArrivalQty=this.value"></td>'+
|
||||
'<td><button class="btn btn-red" style="height:24px;padding:0 8px;font-size:11px" onclick="delArrival('+i+','+a.Id+')">删除</button></td>'+
|
||||
'</tr>';
|
||||
});
|
||||
document.getElementById('arrivalBody').innerHTML=html;
|
||||
}
|
||||
|
||||
function addArrivalRow(){
|
||||
arrivals.push({Id:0,BatchNo:arrivals.length+1,ExpectedArrivalDate:'',ArrivalQty:'',Status:'待发货'});
|
||||
renderArrival();
|
||||
}
|
||||
|
||||
// 列表页:下载批量到货计划导入模板
|
||||
function downloadBatchArrivalTpl(){
|
||||
var url=getApiUrl()+'DownloadBatchArrivalTemplate';
|
||||
var a=document.createElement('a');
|
||||
a.href=url;a.download='到货计划导入模板.xls';a.style.display='none';
|
||||
document.body.appendChild(a);a.click();
|
||||
setTimeout(function(){document.body.removeChild(a)},100);
|
||||
}
|
||||
|
||||
// 列表页:导入批量到货计划
|
||||
function importBatchArrivalExcel(input){
|
||||
var file=input.files[0];if(!file)return;
|
||||
if(file.size>10*1024*1024){toast('文件不能超过10MB','error');input.value='';return}
|
||||
var reader=new FileReader();
|
||||
reader.onload=function(e){
|
||||
var b64=e.target.result.split(',')[1];
|
||||
api(getApiUrl()+'ImportBatchArrivalPlan','POST',{FileBase64:b64},function(res){
|
||||
if(res.success){
|
||||
toast(res.message||'导入成功','success');
|
||||
loadList(curPage);
|
||||
}else{
|
||||
toast(res.message||'导入失败','error');
|
||||
}
|
||||
input.value='';
|
||||
});
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
function saveAllArrival(){
|
||||
var saved=0,err=0;
|
||||
var list=arrivals.map(function(a){return a});
|
||||
// 串行保存
|
||||
function saveNext(i){
|
||||
if(i>=list.length){closeModal('arrivalModal');loadArrival(curDeliveryId);toast('到货计划保存完成,共保存'+saved+'个批次','success');return}
|
||||
var a=list[i];
|
||||
if(!a.ExpectedArrivalDate&&!a.ActualArrivalDate&&a.ArrivalQty===''){
|
||||
// 空行跳过
|
||||
saveNext(i+1);return;
|
||||
}
|
||||
var data={Id:a.Id,DeliveryId:curDeliveryId,BatchNo:a.BatchNo,ExpectedArrivalDate:a.ExpectedArrivalDate,ActualArrivalDate:a.ActualArrivalDate,ArrivalQty:a.ArrivalQty,Status:a.Status};
|
||||
api(getApiUrl()+'SaveArrivalPlan','POST',data,function(res){
|
||||
if(res.success){saved++}else{err++}
|
||||
saveNext(i+1);
|
||||
});
|
||||
}
|
||||
saveNext(0);
|
||||
}
|
||||
|
||||
function delArrival(idx,id){
|
||||
if(id>0){
|
||||
if(!confirm('确认删除该批次?'))return;
|
||||
api(getApiUrl()+'DeleteArrivalPlan','POST',{Id:id},function(res){
|
||||
if(res.success){toast('删除成功','success');loadArrival(curDeliveryId)}
|
||||
});
|
||||
}else{
|
||||
arrivals.splice(idx,1);
|
||||
renderArrival();
|
||||
}
|
||||
}
|
||||
|
||||
// 保存全部到货批次
|
||||
document.addEventListener('click',function(e){
|
||||
if(e.target.id==='')return;
|
||||
});
|
||||
|
||||
function closeModal(id){document.getElementById(id).classList.remove('show')}
|
||||
|
||||
loadOptions(function(){loadList();checkRunningCalc();});
|
||||
initColResize();
|
||||
|
||||
var _calcTimer=null;
|
||||
function startDeliveryCalc(){
|
||||
if(!confirm('确定要重新计算物料交付数据吗?\n\n该操作会:\n1. 收集计划完成日>=当天的生产排程\n2. 补展开缺失的BOM\n3. 重算物料需求\n4. 同步物料交付主表\n5. 同步金蝶三地库存\n6. 计算预计停线日与交付风险\n\n数据量大时可能需要几分钟,请稍候。'))return;
|
||||
var btn=document.getElementById('btnRecalcDelivery');
|
||||
btn.disabled=true;btn.textContent='计算中...';
|
||||
document.getElementById('calcProgressWrap').style.display='block';
|
||||
document.getElementById('calcProgressBar').style.width='0%';
|
||||
document.getElementById('calcProgressText').textContent='正在启动...';
|
||||
document.getElementById('calcProgressPercent').textContent='0%';
|
||||
api(getApiUrl()+'RecalcDelivery','POST',null,function(res){
|
||||
if(res.success){
|
||||
toast('已开始重算物料交付数据','success');
|
||||
pollCalcProgress();
|
||||
}else{
|
||||
btn.disabled=false;btn.textContent='🔄 重算交付数据';
|
||||
toast(res.message||'启动失败','error');
|
||||
}
|
||||
});
|
||||
}
|
||||
function pollCalcProgress(){
|
||||
if(_calcTimer)clearInterval(_calcTimer);
|
||||
_calcTimer=setInterval(function(){
|
||||
api(getApiUrl()+'GetDeliveryCalcProgress','GET',null,function(res){
|
||||
if(!res||res.success===false)return;
|
||||
var p=res.percent||0;
|
||||
var bar=document.getElementById('calcProgressBar');
|
||||
var txt=document.getElementById('calcProgressText');
|
||||
var pct=document.getElementById('calcProgressPercent');
|
||||
bar.style.width=p+'%';
|
||||
pct.textContent=p+'%';
|
||||
txt.textContent=(res.stage||'')+(res.message?' - ':'')+(res.message||'');
|
||||
if(res.status==='success'){
|
||||
clearInterval(_calcTimer);_calcTimer=null;
|
||||
document.getElementById('btnRecalcDelivery').disabled=false;
|
||||
document.getElementById('btnRecalcDelivery').textContent='🔄 重算交付数据';
|
||||
toast(res.message||'重算完成','success');
|
||||
loadList();
|
||||
}else if(res.status==='error'){
|
||||
clearInterval(_calcTimer);_calcTimer=null;
|
||||
document.getElementById('btnRecalcDelivery').disabled=false;
|
||||
document.getElementById('btnRecalcDelivery').textContent='🔄 重算交付数据';
|
||||
toast((res.stage||'')+' - '+(res.message||'失败'),'error');
|
||||
}
|
||||
});
|
||||
},1500);
|
||||
}
|
||||
function checkRunningCalc(){
|
||||
api(getApiUrl()+'GetDeliveryCalcProgress','GET',null,function(res){
|
||||
if(res&&res.status==='running'){
|
||||
document.getElementById('calcProgressWrap').style.display='block';
|
||||
document.getElementById('calcProgressBar').style.width=(res.percent||0)+'%';
|
||||
document.getElementById('calcProgressPercent').textContent=(res.percent||0)+'%';
|
||||
document.getElementById('calcProgressText').textContent=(res.stage||'')+(res.message?' - ':'')+(res.message||'');
|
||||
document.getElementById('btnRecalcDelivery').disabled=true;
|
||||
document.getElementById('btnRecalcDelivery').textContent='计算中...';
|
||||
pollCalcProgress();
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<!-- 公共导航栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+534
@@ -0,0 +1,534 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>生产交付 - GX-WMS</title>
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<link rel="stylesheet" href="../common/style.css">
|
||||
<style>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{font-family:'Microsoft YaHei','PingFang SC',sans-serif;background:#f0f2f5;min-height:100vh}
|
||||
.main-content{max-width:1500px;margin:0 auto;padding:16px 20px}
|
||||
.panel{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:16px;margin-bottom:14px}
|
||||
.panel h3{font-size:15px;color:#333;font-weight:600;margin-bottom:12px}
|
||||
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
|
||||
.toolbar input,.toolbar select{height:32px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.toolbar input:focus,.toolbar select:focus{border-color:#1a73e8}
|
||||
.btn{height:32px;padding:0 16px;border:none;border-radius:5px;font-size:12px;font-weight:600;cursor:pointer;transition:all .2s;color:#fff;white-space:nowrap}
|
||||
.btn-primary{background:linear-gradient(135deg,#1a73e8,#1557b0)}
|
||||
.btn-primary:hover{opacity:.92}
|
||||
.btn-green{background:#22c55e}
|
||||
.btn-green:hover{opacity:.92}
|
||||
.btn-red{background:#ef4444}
|
||||
.btn-red:hover{opacity:.92}
|
||||
.btn-outline{background:#fff;color:#475569;border:1px solid #d1d5db}
|
||||
.btn-outline:hover{background:#f8fafc}
|
||||
.btn-blue{background:#3b82f6}
|
||||
.btn-blue:hover{opacity:.92}
|
||||
.btn-warning{background:#f59e0b}
|
||||
.btn-warning:hover{opacity:.92}
|
||||
.table-wrap{overflow-x:auto;width:100%}
|
||||
table{width:100%;border-collapse:collapse;font-size:13px;table-layout:fixed;min-width:900px}
|
||||
th{background:#f1f5f9;padding:9px 8px;border-bottom:2px solid #e2e8f0;font-weight:600;color:#475569;text-align:left;white-space:nowrap;position:relative}
|
||||
td{padding:8px;border-bottom:1px solid #f1f5f9;color:#334155;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
tr:hover{background:#f8fafc}
|
||||
.pagination{display:flex;gap:6px;justify-content:center;align-items:center;margin-top:14px;font-size:13px;color:#475569;flex-wrap:wrap}
|
||||
.pagination button{min-width:32px;height:32px;border:1px solid #e2e8f0;background:#fff;border-radius:5px;cursor:pointer;font-size:13px;color:#475569}
|
||||
.pagination button.active{background:#1a73e8;color:#fff;border-color:#1a73e8}
|
||||
.pagination button:disabled{opacity:.4;cursor:not-allowed}
|
||||
.pagination select{height:28px;border:1px solid #e2e8f0;border-radius:5px;padding:0 4px;font-size:13px}
|
||||
.col-resizer{position:absolute;right:-3px;top:0;width:8px;height:100%;cursor:col-resize;z-index:5}
|
||||
.col-resizer:hover{background:rgba(26,115,232,.25)}
|
||||
.modal-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.45);display:none;align-items:center;justify-content:center;z-index:1000}
|
||||
.modal-overlay.show{display:flex}
|
||||
.modal{background:#fff;border-radius:10px;width:520px;max-width:95vw;max-height:90vh;overflow:auto;box-shadow:0 10px 40px rgba(0,0,0,.18)}
|
||||
.modal-header{padding:16px 20px;border-bottom:1px solid #e2e8f0;display:flex;align-items:center;justify-content:space-between}
|
||||
.modal-header h3{font-size:15px;color:#333;font-weight:600}
|
||||
.modal-close{background:none;border:none;font-size:22px;color:#94a3b8;cursor:pointer;line-height:1}
|
||||
.modal-close:hover{color:#334155}
|
||||
.modal-body{padding:20px}
|
||||
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px}
|
||||
.form-group{display:flex;flex-direction:column;gap:5px}
|
||||
.form-group label{font-size:12px;color:#64748b;font-weight:600}
|
||||
.form-group input,.form-group select{height:34px;padding:0 10px;border:1px solid #d1d5db;border-radius:5px;font-size:13px;outline:none}
|
||||
.input-with-picker{position:relative}
|
||||
.input-with-picker input{padding-right:34px;cursor:pointer}
|
||||
.input-with-picker .picker-btn{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;background:transparent;color:#94a3b8;cursor:pointer;font-size:14px;display:flex;align-items:center;justify-content:center;border-radius:4px}
|
||||
.input-with-picker .picker-btn:hover{background:#f1f5f9;color:#1a73e8}
|
||||
|
||||
/* ===== 物料查询弹窗(仿金蝶) ===== */
|
||||
#materialPicker{z-index:1100}
|
||||
.picker-modal{width:1100px;max-width:95vw;height:80vh}
|
||||
.picker-toolbar{padding:10px 16px;background:#f8fafc;border-bottom:1px solid #e2e8f0;display:flex;gap:10px;align-items:center;flex-shrink:0}
|
||||
.picker-toolbar select,.picker-toolbar input{height:30px;padding:0 10px;border:1px solid #d1d5db;border-radius:4px;font-size:12px;outline:none;min-width:130px}
|
||||
.picker-toolbar input{min-width:180px}
|
||||
.picker-toolbar label{font-size:12px;color:#475569;margin-right:4px}
|
||||
.picker-toolbar .cond-row{display:flex;gap:6px;align-items:center;margin-right:12px}
|
||||
.picker-toolbar .actions{margin-left:auto;display:flex;gap:8px}
|
||||
.picker-toolbar .btn{height:30px;padding:0 14px;font-size:12px;border-radius:4px}
|
||||
.picker-table-wrap{flex:1;overflow:auto}
|
||||
.picker-table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
.picker-table thead th{position:sticky;top:0;z-index:1;background:#f1f5f9;color:#475569;font-weight:600;padding:9px 10px;text-align:left;border-bottom:2px solid #cbd5e1;white-space:nowrap}
|
||||
.picker-table tbody td{padding:7px 10px;border-bottom:1px solid #f1f5f9;color:#334155}
|
||||
.picker-table tbody tr:hover{background:#eff6ff;cursor:pointer}
|
||||
.picker-table tbody tr.selected{background:#dbeafe}
|
||||
.picker-table .col-check{width:36px;text-align:center}
|
||||
.picker-table .filter-input{width:100%;padding:3px 6px;border:1px solid #e2e8f0;border-radius:3px;font-size:11px;margin-top:3px;outline:none}
|
||||
.picker-table .filter-input:focus{border-color:#3b82f6}
|
||||
.picker-pagination{padding:8px 16px;background:#f8fafc;border-top:1px solid #e2e8f0;display:flex;justify-content:space-between;align-items:center;font-size:12px;color:#64748b;flex-shrink:0}
|
||||
.picker-pagination .pages{display:flex;gap:4px}
|
||||
.picker-pagination .pages button{min-width:26px;height:26px;border:1px solid #d1d5db;background:#fff;border-radius:3px;cursor:pointer;font-size:12px;color:#475569}
|
||||
.picker-pagination .pages button.active{background:#3b82f6;color:#fff;border-color:#3b82f6}
|
||||
.picker-pagination .pages button:hover:not(.active){border-color:#3b82f6;color:#3b82f6}
|
||||
.form-group input:focus,.form-group select:focus{border-color:#1a73e8;box-shadow:0 0 0 2px rgba(26,115,232,.1)}
|
||||
.form-group input.readonly{background:#f8f9fa;color:#94a3b8}
|
||||
.modal-actions{display:flex;gap:8px;justify-content:flex-end;margin-top:18px}
|
||||
.toast{position:fixed;top:14px;left:50%;transform:translateX(-50%);padding:10px 22px;border-radius:8px;font-size:13px;z-index:1001;box-shadow:0 4px 20px rgba(0,0,0,.15);display:none;min-width:240px;text-align:center}
|
||||
.toast.error{background:#fdeaea;color:#b71c1c;display:block}
|
||||
.toast.success{background:#e6f9ed;color:#1a7a3a;display:block}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sidebar"></div>
|
||||
<!-- 物料查询弹窗(仿金蝶数据查询) -->
|
||||
<div class="modal-overlay" id="materialPicker">
|
||||
<div class="modal picker-modal">
|
||||
<div class="modal-header">
|
||||
<h3>📋 物料查询(数据查询)</h3>
|
||||
<button class="modal-close" onclick="closeModal('materialPicker')">×</button>
|
||||
</div>
|
||||
<div class="picker-toolbar">
|
||||
<div class="cond-row">
|
||||
<label>物料代码</label>
|
||||
<select id="pkCodeOp" style="width:90px">
|
||||
<option>包含</option><option>不包含</option><option>等于</option><option>不等于</option><option>开始于</option><option>结束于</option><option>为空</option><option>不为空</option>
|
||||
</select>
|
||||
<input type="text" id="pkCodeVal" placeholder="输入物料代码" style="min-width:160px">
|
||||
</div>
|
||||
<div class="cond-row">
|
||||
<label>物料名称</label>
|
||||
<select id="pkNameOp" style="width:90px">
|
||||
<option>包含</option><option>不包含</option><option>等于</option><option>不等于</option><option>开始于</option><option>结束于</option><option>为空</option><option>不为空</option>
|
||||
</select>
|
||||
<input type="text" id="pkNameVal" placeholder="输入物料名称" style="min-width:160px">
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn btn-primary" onclick="doSearch()">🔍 搜索</button>
|
||||
<button class="btn btn-outline" onclick="resetSearchPK()">重置</button>
|
||||
<button class="btn btn-green" onclick="addSelectedMaterial()">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="picker-table-wrap">
|
||||
<table class="picker-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-check"><input type="checkbox" id="pkCheckAll" onchange="toggleCheckAll(this.checked)"></th>
|
||||
<th>物料代码 <input class="filter-input" id="pkFilterCode" oninput="doSearch()"></th>
|
||||
<th>物料名称 <input class="filter-input" id="pkFilterName" oninput="doSearch()"></th>
|
||||
<th>规格型号 <input class="filter-input" id="pkFilterSpec" oninput="doSearch()"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="pkBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="picker-pagination">
|
||||
<span>共 <span id="pkTotal">0</span> 条 每页 <span id="pkPageSize">2000</span> 条</span>
|
||||
<div class="pages" id="pkPages"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="toast" class="toast"></div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="panel">
|
||||
<h3>生产交付 - 线边仓库存维护</h3>
|
||||
<div class="toolbar">
|
||||
<input type="text" id="txtKeyword" placeholder="搜索 物料编号 / 物料名称" style="width:220px">
|
||||
<input type="date" id="dateStart" style="width:140px">
|
||||
<span style="color:#64748b;font-size:12px">至</span>
|
||||
<input type="date" id="dateEnd" style="width:140px">
|
||||
<button class="btn btn-primary" onclick="loadList()">查询</button>
|
||||
<button class="btn btn-outline" onclick="resetSearch()">重置</button>
|
||||
<span style="flex:1"></span>
|
||||
<button class="btn btn-green" onclick="exportExcel()">导出Excel</button>
|
||||
<button class="btn btn-blue" onclick="document.getElementById('fileImport').click()">导入Excel</button>
|
||||
<input type="file" id="fileImport" accept=".xls,.xlsx" style="display:none" onchange="importExcel(this)">
|
||||
<button class="btn btn-outline" onclick="downloadTemplate()">下载模板</button>
|
||||
<button class="btn btn-red" onclick="batchDelete()">删除选中</button>
|
||||
<button class="btn btn-primary" onclick="openEdit(0)">+ 新增</button>
|
||||
<span style="font-size:13px;color:#666;margin-left:8px" id="totalCount"></span>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:32px"><input type="checkbox" id="chkAll" onclick="toggleAll(this)"></th>
|
||||
<th style="width:48px">序号</th>
|
||||
<th style="width:130px">物料编号</th><th style="width:180px">物料名称</th><th style="width:120px">线边仓库存数</th><th style="width:110px">日期</th><th style="width:160px">更新时间</th><th style="width:130px">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination" id="pagination"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-overlay" id="editModal">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<h3 id="modalTitle">新增生产交付</h3>
|
||||
<button class="modal-close" onclick="closeModal('editModal')">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label>物料编号 <span style="color:#ef4444">*</span></label>
|
||||
<div class="input-with-picker">
|
||||
<input type="text" id="fMaterialCode" placeholder="点击选择物料" readonly onclick="openMaterialPicker()">
|
||||
<button type="button" class="picker-btn" onclick="openMaterialPicker()">🔍</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>物料名称</label>
|
||||
<input type="text" id="fMaterialName" placeholder="请输入物料名称">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>线边仓库存数 <span style="color:#ef4444">*</span></label>
|
||||
<input type="number" id="fLineSideStock" placeholder="0" step="0.01">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>日期</label>
|
||||
<input type="date" id="fStockDate">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-outline" onclick="closeModal('editModal')">取消</button>
|
||||
<button class="btn btn-primary" onclick="save()">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var curId=0;
|
||||
|
||||
function toast(msg,tp){var el=document.getElementById('toast');el.textContent=msg;el.className='toast '+tp;clearTimeout(el._timer);el._timer=setTimeout(function(){el.className='toast'},3000)}
|
||||
function api(url,method,data,cb){
|
||||
var opts={method:method||'GET',headers:{'Content-Type':'application/json'}};
|
||||
if(data)opts.body=JSON.stringify(data);
|
||||
fetch(url,opts).then(function(r){return r.json()}).then(function(res){
|
||||
if(res&&res.success===false){toast(res.message||'操作失败','error');return}
|
||||
cb&&cb(res);
|
||||
}).catch(function(e){toast('请求失败:'+e.message,'error')});
|
||||
}
|
||||
function getApiUrl(){return '../../api/deliver/'}
|
||||
|
||||
function getFilters(){
|
||||
var kw=document.getElementById('txtKeyword').value.trim();
|
||||
var ds=document.getElementById('dateStart').value;
|
||||
var de=document.getElementById('dateEnd').value;
|
||||
return {kw:kw,ds:ds,de:de};
|
||||
}
|
||||
|
||||
var curPage=1,curPageSize=50;
|
||||
function loadList(page){
|
||||
page=page||1;
|
||||
curPage=page;
|
||||
var f=getFilters();
|
||||
var url=getApiUrl()+'GetProductionDeliveryList?keyword='+encodeURIComponent(f.kw)+'&dateStart='+encodeURIComponent(f.ds)+'&dateEnd='+encodeURIComponent(f.de)+'&page='+page+'&pageSize='+curPageSize;
|
||||
api(url,'GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
var html='';
|
||||
if(rows.length===0)html='<tr><td colspan="8" style="text-align:center;padding:36px;color:#bbb">暂无数据</td></tr>';
|
||||
rows.forEach(function(r,i){
|
||||
var seq=(curPage-1)*curPageSize+i+1;
|
||||
html+='<tr>'+
|
||||
'<td><input type="checkbox" class="chkRow" data-id="'+r.Id+'"></td>'+
|
||||
'<td>'+seq+'</td>'+
|
||||
'<td>'+r.MaterialCode+'</td>'+
|
||||
'<td>'+r.MaterialName+'</td>'+
|
||||
'<td>'+r.LineSideStock+'</td>'+
|
||||
'<td>'+(r.StockDate||'')+'</td>'+
|
||||
'<td>'+(r.UpdateTime||'')+'</td>'+
|
||||
'<td style="white-space:nowrap">'+
|
||||
'<button class="btn btn-primary" style="height:26px;padding:0 10px;font-size:11px" onclick="openEdit('+r.Id+')">编辑</button> '+
|
||||
'<button class="btn btn-red" style="height:26px;padding:0 10px;font-size:11px" onclick="delOne('+r.Id+')">删除</button>'+
|
||||
'</td></tr>';
|
||||
});
|
||||
document.getElementById('tbodyList').innerHTML=html;
|
||||
document.getElementById('totalCount').textContent='共 '+res.total+' 条';
|
||||
renderPagination(res.total,res.page);
|
||||
});
|
||||
}
|
||||
|
||||
function renderPagination(total,page){
|
||||
var pages=Math.ceil(total/curPageSize)||1;
|
||||
var sizeOpts=[20,50,100,200].map(function(s){
|
||||
return '<option value="'+s+'"'+(s==curPageSize?' selected':'')+'>'+s+'</option>';
|
||||
}).join('');
|
||||
var html='<span>每页 <select onchange="changePageSize(this.value)">'+sizeOpts+'</select> 条</span>';
|
||||
html+='<button '+(page<=1?'disabled':'')+' onclick="loadList(1)">首页</button>';
|
||||
html+='<button '+(page<=1?'disabled':'')+' onclick="loadList('+(page-1)+')">上一页</button>';
|
||||
var start=Math.max(1,page-2),end=Math.min(pages,page+2);
|
||||
for(var i=start;i<=end;i++){
|
||||
html+='<button class="'+(i==page?'active':'')+'" onclick="loadList('+i+')">'+i+'</button>';
|
||||
}
|
||||
html+='<button '+(page>=pages?'disabled':'')+' onclick="loadList('+(page+1)+')">下一页</button>';
|
||||
html+='<button '+(page>=pages?'disabled':'')+' onclick="loadList('+pages+')">末页</button>';
|
||||
html+='<span>第 '+page+' / '+pages+' 页,共 '+total+' 条</span>';
|
||||
document.getElementById('pagination').innerHTML=html;
|
||||
}
|
||||
|
||||
function changePageSize(v){
|
||||
curPageSize=parseInt(v)||50;
|
||||
loadList(1);
|
||||
}
|
||||
|
||||
// 表头列宽左右拖动
|
||||
function initColResize(){
|
||||
var table=document.querySelector('.panel table');
|
||||
if(!table)return;
|
||||
var ths=table.querySelectorAll('thead th');
|
||||
[].forEach.call(ths,function(th){
|
||||
if(th.querySelector('.col-resizer'))return;
|
||||
var grip=document.createElement('div');
|
||||
grip.className='col-resizer';
|
||||
th.appendChild(grip);
|
||||
grip.addEventListener('mousedown',function(e){
|
||||
e.preventDefault();e.stopPropagation();
|
||||
var startX=e.clientX,startW=th.offsetWidth;
|
||||
function onMove(ev){
|
||||
var w=Math.max(40,startW+(ev.clientX-startX));
|
||||
th.style.width=w+'px';
|
||||
}
|
||||
function onUp(){
|
||||
document.removeEventListener('mousemove',onMove);
|
||||
document.removeEventListener('mouseup',onUp);
|
||||
}
|
||||
document.addEventListener('mousemove',onMove);
|
||||
document.addEventListener('mouseup',onUp);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function resetSearch(){
|
||||
document.getElementById('txtKeyword').value='';
|
||||
document.getElementById('dateStart').value='';
|
||||
document.getElementById('dateEnd').value='';
|
||||
loadList();
|
||||
}
|
||||
|
||||
function openEdit(id){
|
||||
curId=id;
|
||||
document.getElementById('modalTitle').textContent=id>0?'编辑生产交付':'新增生产交付';
|
||||
if(id>0){
|
||||
api(getApiUrl()+'GetProductionDeliveryList?keyword=&page=1&pageSize=1','GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
var found=rows.find(function(r){return r.Id==id;});
|
||||
if(found){
|
||||
document.getElementById('fMaterialCode').value=found.MaterialCode;
|
||||
document.getElementById('fMaterialName').value=found.MaterialName;
|
||||
document.getElementById('fLineSideStock').value=found.LineSideStock;
|
||||
document.getElementById('fStockDate').value=found.StockDate||'';
|
||||
}
|
||||
});
|
||||
}else{
|
||||
document.getElementById('fMaterialCode').value='';
|
||||
document.getElementById('fMaterialName').value='';
|
||||
document.getElementById('fLineSideStock').value='';
|
||||
document.getElementById('fStockDate').value=new Date().toISOString().slice(0,10);
|
||||
}
|
||||
document.getElementById('editModal').classList.add('show');
|
||||
}
|
||||
|
||||
function closeModal(id){
|
||||
document.getElementById(id).classList.remove('show');
|
||||
}
|
||||
|
||||
// ===== 物料开窗选择(与生产排程页一致) =====
|
||||
var pkPage=1, pkPageSize=2000, pkTotal=0;
|
||||
|
||||
function openMaterialPicker(){
|
||||
pkPage=1;
|
||||
document.getElementById('materialPicker').classList.add('show');
|
||||
doSearch();
|
||||
}
|
||||
|
||||
function resetSearchPK(){
|
||||
document.getElementById('pkCodeOp').value='包含';
|
||||
document.getElementById('pkCodeVal').value='';
|
||||
document.getElementById('pkNameOp').value='包含';
|
||||
document.getElementById('pkNameVal').value='';
|
||||
document.getElementById('pkFilterCode').value='';
|
||||
document.getElementById('pkFilterName').value='';
|
||||
document.getElementById('pkFilterSpec').value='';
|
||||
document.getElementById('pkCheckAll').checked=false;
|
||||
pkPage=1;
|
||||
doSearch();
|
||||
}
|
||||
|
||||
function doSearch(){
|
||||
var codeOp=encodeURIComponent(document.getElementById('pkCodeOp').value);
|
||||
var codeVal=document.getElementById('pkCodeVal').value.trim();
|
||||
var nameOp=encodeURIComponent(document.getElementById('pkNameOp').value);
|
||||
var nameVal=document.getElementById('pkNameVal').value.trim();
|
||||
var fc=document.getElementById('pkFilterCode').value.trim().toLowerCase();
|
||||
var fn=document.getElementById('pkFilterName').value.trim().toLowerCase();
|
||||
var fs=document.getElementById('pkFilterSpec').value.trim().toLowerCase();
|
||||
var url=getApiUrl()+'GetKingdeeMaterials?codeOp='+codeOp+'&codeVal='+encodeURIComponent(codeVal)+'&nameOp='+nameOp+'&nameVal='+encodeURIComponent(nameVal)+'&page='+pkPage+'&pageSize='+pkPageSize;
|
||||
api(url,'GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
var html='';
|
||||
rows.forEach(function(m){
|
||||
if(fc && (m.code||'').toLowerCase().indexOf(fc)<0)return;
|
||||
if(fn && (m.name||'').toLowerCase().indexOf(fn)<0)return;
|
||||
if(fs && (m.spec||'').toLowerCase().indexOf(fs)<0)return;
|
||||
html+='<tr onclick="selectMaterialRow(this)" data-code="'+m.code+'" data-name="'+m.name+'" data-spec="'+(m.spec||'')+'">'+
|
||||
'<td class="col-check"><input type="checkbox" class="pkChk"></td>'+
|
||||
'<td>'+m.code+'</td>'+
|
||||
'<td>'+m.name+'</td>'+
|
||||
'<td>'+(m.spec||'')+'</td>'+
|
||||
'</tr>';
|
||||
});
|
||||
if(!html)html='<tr><td colspan="4" style="text-align:center;padding:30px;color:#bbb">暂无数据</td></tr>';
|
||||
document.getElementById('pkBody').innerHTML=html;
|
||||
pkTotal=res.total||0;
|
||||
document.getElementById('pkTotal').textContent=pkTotal;
|
||||
document.getElementById('pkPageSize').textContent=res.pageSize||pkPageSize;
|
||||
renderPkPages(pkTotal,res.page||pkPage,res.pageSize||pkPageSize);
|
||||
});
|
||||
}
|
||||
|
||||
function renderPkPages(total,page,pageSize){
|
||||
var pages=Math.ceil(total/pageSize);
|
||||
var h='<button onclick="pkGoto('+(page-1)+')" '+(page<=1?'disabled':'')+'>‹</button>';
|
||||
for(var i=1;i<=Math.min(pages,10);i++){
|
||||
h+='<button class="'+(i==page?'active':'')+'" onclick="pkGoto('+i+')">'+i+'</button>';
|
||||
}
|
||||
if(pages>10)h+='<span style="padding:0 4px;">...</span><button class="'+(pages==page?'active':'')+'" onclick="pkGoto('+pages+')">'+pages+'</button>';
|
||||
h+='<button onclick="pkGoto('+(page+1)+')" '+(page>=pages?'disabled':'')+'>›</button>';
|
||||
document.getElementById('pkPages').innerHTML=h;
|
||||
}
|
||||
|
||||
function pkGoto(p){
|
||||
if(p<1)return;
|
||||
var pages=Math.ceil(pkTotal/pkPageSize);
|
||||
if(p>pages)return;
|
||||
pkPage=p;
|
||||
doSearch();
|
||||
}
|
||||
|
||||
function toggleCheckAll(checked){
|
||||
var cks=document.querySelectorAll('.pkChk');
|
||||
for(var i=0;i<cks.length;i++)cks[i].checked=checked;
|
||||
}
|
||||
|
||||
function selectMaterialRow(tr){
|
||||
var cks=document.querySelectorAll('.pkChk');
|
||||
cks.forEach(function(c){c.checked=false;});
|
||||
var chk=tr.querySelector('.pkChk');
|
||||
if(chk)chk.checked=true;
|
||||
document.querySelectorAll('.picker-table tbody tr').forEach(function(r){r.classList.remove('selected');});
|
||||
tr.classList.add('selected');
|
||||
}
|
||||
|
||||
function addSelectedMaterial(){
|
||||
var chks=document.querySelectorAll('.pkChk:checked');
|
||||
if(chks.length===0){toast('请先勾选一条物料','error');return}
|
||||
if(chks.length>1){toast('每次只能选择一个物料','error');return}
|
||||
var tr=chks[0].parentElement.parentElement;
|
||||
// 回填:编号+名称自动带出
|
||||
document.getElementById('fMaterialCode').value=tr.getAttribute('data-code');
|
||||
document.getElementById('fMaterialName').value=tr.getAttribute('data-name');
|
||||
closeModal('materialPicker');
|
||||
toast('已选择物料:'+tr.getAttribute('data-code'),'success');
|
||||
}
|
||||
|
||||
function save(){
|
||||
var code=document.getElementById('fMaterialCode').value.trim();
|
||||
var name=document.getElementById('fMaterialName').value.trim();
|
||||
var stock=document.getElementById('fLineSideStock').value;
|
||||
var date=document.getElementById('fStockDate').value;
|
||||
if(!code){toast('物料编号不能为空','error');return}
|
||||
if(!stock && stock!=='0'){toast('线边仓库存数不能为空','error');return}
|
||||
|
||||
var data={MaterialCode:code,MaterialName:name,LineSideStock:stock,StockDate:date};
|
||||
if(curId>0) data.Id=curId;
|
||||
|
||||
api(getApiUrl()+'SaveProductionDelivery','POST',data,function(res){
|
||||
toast(res.message||'保存成功','success');
|
||||
closeModal('editModal');
|
||||
loadList();
|
||||
});
|
||||
}
|
||||
|
||||
function delOne(id){
|
||||
if(!confirm('确定删除该记录?'))return;
|
||||
api(getApiUrl()+'DeleteProductionDelivery','POST',{Ids:[id]},function(res){
|
||||
toast(res.message||'删除成功','success');
|
||||
loadList();
|
||||
});
|
||||
}
|
||||
|
||||
function toggleAll(el){
|
||||
document.querySelectorAll('.chkRow').forEach(function(c){c.checked=el.checked});
|
||||
}
|
||||
|
||||
function batchDelete(){
|
||||
var ids=[];
|
||||
document.querySelectorAll('.chkRow:checked').forEach(function(c){ids.push(parseInt(c.getAttribute('data-id')))});
|
||||
if(ids.length===0){toast('请先选择要删除的记录','error');return}
|
||||
if(!confirm('确定删除选中的 '+ids.length+' 条记录?'))return;
|
||||
api(getApiUrl()+'DeleteProductionDelivery','POST',{Ids:ids},function(res){
|
||||
toast(res.message||'删除成功','success');
|
||||
loadList();
|
||||
});
|
||||
}
|
||||
|
||||
function downloadTemplate(){
|
||||
var a=document.createElement('a');
|
||||
a.href=getApiUrl()+'DownloadProductionDeliveryTemplate';
|
||||
a.download='生产交付导入模板.xls';
|
||||
a.style.display='none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
setTimeout(function(){document.body.removeChild(a)},100);
|
||||
}
|
||||
|
||||
function exportExcel(){
|
||||
var f=getFilters();
|
||||
var url=getApiUrl()+'ExportProductionDeliveryExcel?keyword='+encodeURIComponent(f.kw)+'&dateStart='+encodeURIComponent(f.ds)+'&dateEnd='+encodeURIComponent(f.de);
|
||||
toast('正在导出,请稍候...','success');
|
||||
fetch(url).then(function(r){return r.blob()}).then(function(blob){
|
||||
var a=document.createElement('a');
|
||||
a.href=URL.createObjectURL(blob);
|
||||
a.download='生产交付_'+new Date().toISOString().slice(0,10)+'.xls';
|
||||
a.click();
|
||||
}).catch(function(e){toast('导出失败:'+e.message,'error')});
|
||||
}
|
||||
|
||||
function importExcel(input){
|
||||
var file=input.files[0];
|
||||
if(!file)return;
|
||||
var reader=new FileReader();
|
||||
reader.onload=function(e){
|
||||
var base64=e.target.result.split(',')[1];
|
||||
api(getApiUrl()+'ImportProductionDelivery','POST',{FileContent:base64,FileName:file.name},function(res){
|
||||
toast(res.message||'导入完成','success');
|
||||
loadList();
|
||||
});
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
input.value='';
|
||||
}
|
||||
|
||||
// 初始化
|
||||
loadList();
|
||||
initColResize();
|
||||
</script>
|
||||
<!-- 公共导航栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+792
@@ -0,0 +1,792 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>生产计划排程维护</title>
|
||||
<!-- 公共侧边栏组件 -->
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<style>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{font-family:'Microsoft YaHei','PingFang SC',sans-serif;background:#f0f2f5;min-height:100vh}
|
||||
.main-content{max-width:1500px;margin:0 auto;padding:16px 20px}
|
||||
.panel{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:16px;margin-bottom:14px}
|
||||
.panel h3{font-size:15px;color:#333;font-weight:600;margin-bottom:12px}
|
||||
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
|
||||
.toolbar input,.toolbar select{height:32px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.toolbar input:focus,.toolbar select:focus{border-color:#1a73e8}
|
||||
.btn{height:32px;padding:0 16px;border:none;border-radius:5px;font-size:12px;font-weight:600;cursor:pointer;transition:all .2s;color:#fff}
|
||||
.btn-primary{background:linear-gradient(135deg,#1a73e8,#1557b0)}
|
||||
.btn-primary:hover{opacity:.92}
|
||||
.btn-green{background:#22c55e}
|
||||
.btn-green:hover{opacity:.92}
|
||||
.btn-red{background:#ef4444}
|
||||
.btn-red:hover{opacity:.92}
|
||||
.btn-blue{background:#3b82f6}
|
||||
.btn-blue:hover{opacity:.92}
|
||||
.btn-outline{background:#fff;color:#666;border:2px solid #e0e0e0}
|
||||
.btn-outline:hover{border-color:#1a73e8;color:#1a73e8}
|
||||
table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
thead th{background:#f8f9fa;color:#555;font-weight:600;padding:9px 12px;text-align:left;border:1px solid #999;border-bottom:2px solid #999;white-space:nowrap}
|
||||
tbody td{padding:9px 12px;border:1px solid #ddd;color:#333}
|
||||
tbody tr:hover{background:#f0f6ff}
|
||||
/* 宽松:列表区留白 + 左右可滑动 */
|
||||
.table-wrap{overflow-x:auto;overflow-y:auto;max-height:680px;border:1px solid #e2e8f0;border-radius:8px;background:#fff}
|
||||
.table-wrap table{min-width:1480px}
|
||||
.table-wrap thead th{position:sticky;top:0;z-index:2;background:#f8f9fa}
|
||||
/* 固定列:序号 / 选中 / 操作 */
|
||||
.col-num,.col-check,.col-op{position:sticky;left:0;z-index:3;background:#fff;box-shadow:1px 0 0 #e2e8f0}
|
||||
.col-num{width:50px;text-align:center}
|
||||
.col-check{width:44px;text-align:center}
|
||||
.col-op{width:130px;text-align:center}
|
||||
.col-num,.col-check input{cursor:pointer}
|
||||
/* 行 hover 时固定列同步变色,避免横向滚动透出底色 */
|
||||
.table-wrap tbody tr:hover .col-num,
|
||||
.table-wrap tbody tr:hover .col-check,
|
||||
.table-wrap tbody tr:hover .col-op{background:#f0f6ff}
|
||||
.table-wrap tbody tr{cursor:pointer}
|
||||
/* 批量操作栏 */
|
||||
.batch-bar{display:flex;align-items:center;gap:10px;padding:10px 16px;background:#fef2f2;border:1px solid #fecaca;border-radius:8px;margin-top:10px;font-size:13px}
|
||||
.badge{display:inline-block;padding:2px 10px;border-radius:12px;font-size:12px;font-weight:500}
|
||||
.badge-success{background:#dcfce7;color:#166534}
|
||||
.badge-warning{background:#fef3c7;color:#92400e}
|
||||
.badge-info{background:#dbeafe;color:#1e40af}
|
||||
.badge-muted{background:#f1f5f9;color:#64748b}
|
||||
.toast{position:fixed;top:14px;left:50%;transform:translateX(-50%);padding:10px 22px;border-radius:8px;font-size:13px;z-index:1001;box-shadow:0 4px 20px rgba(0,0,0,.15);display:none;min-width:240px;text-align:center}
|
||||
.toast.error{background:#fdeaea;color:#b71c1c;display:block}
|
||||
.toast.success{background:#e6f9ed;color:#1a7a3a;display:block}
|
||||
|
||||
/* ===== 排程弹窗(铺满、宽屏、多列)===== */
|
||||
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:999;justify-content:center;align-items:center;padding:24px}
|
||||
body.with-sidebar:not(.sidebar-collapsed) .modal-overlay{padding-left:240px}
|
||||
body.with-sidebar.sidebar-collapsed .modal-overlay{padding-left:60px}
|
||||
.modal-overlay.show{display:flex}
|
||||
.modal{background:#fff;border-radius:10px;width:1200px;max-width:96vw;height:88vh;display:flex;flex-direction:column;box-shadow:0 20px 60px rgba(0,0,0,.2);overflow:hidden}
|
||||
.modal-header{padding:18px 24px;border-bottom:1px solid #e2e8f0;background:linear-gradient(135deg,#f8fafc,#f1f5f9);display:flex;align-items:center;justify-content:space-between;flex-shrink:0}
|
||||
.modal-header h3{font-size:17px;color:#0f172a;font-weight:600;letter-spacing:.5px}
|
||||
.modal-close{background:transparent;border:none;font-size:20px;color:#94a3b8;cursor:pointer;padding:4px 8px;line-height:1}
|
||||
.modal-close:hover{color:#ef4444}
|
||||
.modal-body{padding:20px 24px;flex:1;overflow-y:auto}
|
||||
.modal-footer{padding:14px 24px;border-top:1px solid #e2e8f0;background:#f8fafc;display:flex;justify-content:flex-end;gap:8px;flex-shrink:0}
|
||||
.form-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:16px}
|
||||
.form-group{display:flex;flex-direction:column}
|
||||
.form-group.full{grid-column:1/-1}
|
||||
.form-group label{font-size:12px;color:#475569;font-weight:600;margin-bottom:6px}
|
||||
.form-group label .req{color:#ef4444;margin-left:2px}
|
||||
.form-group input,.form-group select{height:36px;padding:0 12px;border:2px solid #e2e8f0;border-radius:6px;font-size:13px;outline:none;background:#fff;transition:all .15s}
|
||||
.form-group input:focus,.form-group select:focus{border-color:#3b82f6;box-shadow:0 0 0 3px rgba(59,130,246,.1)}
|
||||
.form-group input.readonly{background:#f1f5f9;color:#64748b;cursor:not-allowed}
|
||||
.form-group input[readonly]{background:#f1f5f9;color:#64748b}
|
||||
.input-with-picker{position:relative}
|
||||
.input-with-picker input{padding-right:34px;cursor:pointer}
|
||||
.input-with-picker .picker-btn{position:absolute;right:6px;top:50%;transform:translateY(-50%);width:24px;height:24px;border:none;background:transparent;color:#94a3b8;cursor:pointer;font-size:14px;display:flex;align-items:center;justify-content:center;border-radius:4px}
|
||||
.input-with-picker .picker-btn:hover{background:#f1f5f9;color:#1a73e8}
|
||||
.section-divider{margin:24px 0 16px;padding:8px 12px;background:linear-gradient(90deg,#eff6ff,transparent);border-left:3px solid #3b82f6;color:#1e40af;font-size:13px;font-weight:600;border-radius:0 4px 4px 0}
|
||||
|
||||
/* 每日生产计划表 */
|
||||
.daily-table{width:100%;border-collapse:collapse;font-size:12px;background:#fff;border-radius:6px;overflow:hidden}
|
||||
.daily-table th{background:#f1f5f9;padding:8px 6px;border-bottom:1px solid #e2e8f0;font-weight:600;color:#64748b;white-space:nowrap}
|
||||
.daily-table td{padding:6px;border-bottom:1px solid #f1f5f9;text-align:center}
|
||||
.daily-table .weekend{background:#fafbfc;color:#cbd5e1}
|
||||
.daily-table .weekend input{background:#fafbfc;color:#cbd5e1}
|
||||
.daily-table input{width:90%;text-align:right;border:1px solid #e2e8f0;border-radius:4px;padding:5px 8px;font-size:12px;outline:none}
|
||||
.daily-table input:focus{border-color:#3b82f6;box-shadow:0 0 0 2px rgba(59,130,246,.1)}
|
||||
.daily-table tr:hover{background:#f8fafc}
|
||||
.daily-scroll{overflow-x:auto;max-height:340px;border:1px solid #e2e8f0;border-radius:6px}
|
||||
|
||||
/* ===== 物料查询弹窗(仿金蝶) ===== */
|
||||
#materialPicker{z-index:1100}
|
||||
.picker-modal{width:1100px;max-width:95vw;height:80vh}
|
||||
.picker-toolbar{padding:10px 16px;background:#f8fafc;border-bottom:1px solid #e2e8f0;display:flex;gap:10px;align-items:center;flex-shrink:0}
|
||||
.picker-toolbar select,.picker-toolbar input{height:30px;padding:0 10px;border:1px solid #d1d5db;border-radius:4px;font-size:12px;outline:none;min-width:130px}
|
||||
.picker-toolbar input{min-width:180px}
|
||||
.picker-toolbar label{font-size:12px;color:#475569;margin-right:4px}
|
||||
.picker-toolbar .cond-row{display:flex;gap:6px;align-items:center;margin-right:12px}
|
||||
.picker-toolbar .remove-cond{color:#ef4444;background:transparent;border:none;cursor:pointer;font-size:14px;padding:0 4px;line-height:1}
|
||||
.picker-toolbar .actions{margin-left:auto;display:flex;gap:8px}
|
||||
.picker-toolbar .btn{height:30px;padding:0 14px;font-size:12px;border-radius:4px}
|
||||
.picker-table-wrap{flex:1;overflow:auto}
|
||||
.picker-table{width:100%;border-collapse:collapse;font-size:13px}
|
||||
.picker-table thead th{position:sticky;top:0;z-index:1;background:#f1f5f9;color:#475569;font-weight:600;padding:9px 10px;text-align:left;border-bottom:2px solid #cbd5e1;white-space:nowrap}
|
||||
.picker-table tbody td{padding:7px 10px;border-bottom:1px solid #f1f5f9;color:#334155}
|
||||
.picker-table tbody tr:hover{background:#eff6ff;cursor:pointer}
|
||||
.picker-table tbody tr.selected{background:#dbeafe}
|
||||
.picker-table .col-check{width:36px;text-align:center}
|
||||
.picker-table .filter-input{width:100%;padding:3px 6px;border:1px solid #e2e8f0;border-radius:3px;font-size:11px;margin-top:3px;outline:none}
|
||||
.picker-table .filter-input:focus{border-color:#3b82f6}
|
||||
.picker-pagination{padding:8px 16px;background:#f8fafc;border-top:1px solid #e2e8f0;display:flex;justify-content:space-between;align-items:center;font-size:12px;color:#64748b;flex-shrink:0}
|
||||
.picker-pagination .pages{display:flex;gap:4px}
|
||||
.picker-pagination .pages button{min-width:26px;height:26px;border:1px solid #d1d5db;background:#fff;border-radius:3px;cursor:pointer;font-size:12px;color:#475569}
|
||||
.picker-pagination .pages button.active{background:#3b82f6;color:#fff;border-color:#3b82f6}
|
||||
.picker-pagination .pages button:hover:not(.active){border-color:#3b82f6;color:#3b82f6}
|
||||
/* 列表分页 */
|
||||
.pagination{display:flex;justify-content:space-between;align-items:center;padding:10px 4px;border-top:1px solid #f0f0f0;font-size:12px;color:#666}
|
||||
.pagination .btns{display:flex;gap:2px;flex-wrap:wrap}
|
||||
.pagination .btns button,.pagination .size-btn{min-width:30px;height:26px;border:1px solid #e0e0e0;border-radius:4px;background:#fff;color:#555;cursor:pointer;font-size:12px;padding:0 8px}
|
||||
.pagination .btns button:hover,.pagination .size-btn:hover{border-color:#1a73e8;color:#1a73e8}
|
||||
.pagination .btns button.active,.pagination .size-btn.active{background:#1a73e8;color:#fff;border-color:#1a73e8}
|
||||
.pagination .size-group{display:inline-flex;gap:2px;margin-left:8px}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sidebar"></div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="panel">
|
||||
<h3>生产计划排程 - 维护</h3>
|
||||
<div class="toolbar">
|
||||
<select id="selProduct" style="min-width:120px"><option value="">产品编码:全部</option></select>
|
||||
<select id="selVersion" style="min-width:100px"><option value="">BOM版本:全部</option></select>
|
||||
<select id="selProductType" style="min-width:120px"><option value="">产品类型:全部</option></select>
|
||||
<select id="selStatus" style="min-width:100px">
|
||||
<option value="">状态:全部</option>
|
||||
<option value="待开始">待开始</option>
|
||||
<option value="进行中">进行中</option>
|
||||
<option value="已完成">已完成</option>
|
||||
<option value="已暂停">已暂停</option>
|
||||
</select>
|
||||
<input type="text" id="txtKeyword" placeholder="搜索 产品编码 / 产品名称" style="width:200px">
|
||||
<button class="btn btn-primary" onclick="searchList()">查询</button>
|
||||
<button class="btn btn-outline" onclick="resetSearch()">重置</button>
|
||||
<div style="flex:1"></div>
|
||||
<button class="btn btn-outline" onclick="downloadTemplate()">📄 下载导入模板</button>
|
||||
<button class="btn btn-green" onclick="triggerImport()">📥 导入Excel</button>
|
||||
<button class="btn btn-primary" onclick="openAddModal()">+ 新建排程任务</button>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
<div class="batch-bar" id="batchBar" style="display:none">
|
||||
<span>已选中 <b id="selCount">0</b> 项</span>
|
||||
<button class="btn btn-red" onclick="delSelected()">🗑 删除选中</button>
|
||||
<button class="btn btn-outline" onclick="clearSelection()">取消选择</button>
|
||||
</div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-num">序号</th>
|
||||
<th class="col-check"><input type="checkbox" id="chkAll" onchange="toggleCheckAllRows(this.checked)"></th>
|
||||
<th class="col-op">操作</th>
|
||||
<th>产品编码</th><th>BOM版本</th><th>产品名称</th><th>产品类型</th>
|
||||
<th>工厂</th><th>区域</th><th>国家</th>
|
||||
<th>计划开始日</th><th>计划完成日</th><th>总产量</th><th>状态</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyList"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pagination" id="pagination" style="display:none">
|
||||
<div><span>共 <em id="totalCnt">0</em> 条</span><span class="size-group" id="sizeBtns"></span></div>
|
||||
<div class="btns" id="pageBtns"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 排程编辑弹窗 -->
|
||||
<div class="modal-overlay" id="editModal">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<h3 id="modalTitle">新建排程任务</h3>
|
||||
<button class="modal-close" onclick="closeModal('editModal')">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-grid">
|
||||
<div class="form-group">
|
||||
<label>产品编码 <span class="req">*</span></label>
|
||||
<div class="input-with-picker">
|
||||
<input type="text" id="fProductCode" placeholder="点击右侧图标选择产品" readonly>
|
||||
<button type="button" class="picker-btn" onclick="openMaterialPicker()" title="选择产品">🔍</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>BOM版本 <span class="req">*</span></label>
|
||||
<input type="text" id="fBOMVersion" placeholder="选产品后自动带出,无BOM版本可手动输入">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>产品名称</label>
|
||||
<input type="text" id="fProductName" class="readonly" readonly>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>产品类型</label>
|
||||
<input type="text" id="fProductType" placeholder="如:标准机 / 定制机 / 样机(人为维护)">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>工厂</label>
|
||||
<input type="text" id="fFactory" placeholder="工厂">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>区域</label>
|
||||
<input type="text" id="fRegion" placeholder="区域">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>国家</label>
|
||||
<input type="text" id="fCountry" placeholder="国家">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>计划开始日 <span class="req">*</span></label>
|
||||
<input type="date" id="fPlanStart" onchange="genDaily()">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>计划完成日 <span class="req">*</span></label>
|
||||
<input type="date" id="fPlanEnd" onchange="genDaily()">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>状态 <span class="req">*</span></label>
|
||||
<select id="fStatus">
|
||||
<option value="待开始">待开始</option>
|
||||
<option value="进行中" selected>进行中</option>
|
||||
<option value="已完成">已完成</option>
|
||||
<option value="已暂停">已暂停</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>备注</label>
|
||||
<input type="text" id="fRemark" placeholder="排程调整原因...">
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-divider">每日生产计划(计划人员只维护成品每日产量,周末自动标记无产量)</div>
|
||||
<div class="daily-scroll">
|
||||
<table class="daily-table" id="dailyTable">
|
||||
<thead id="dailyHeader"><tr><th>日期</th><th>星期</th><th>日产量</th></tr></thead>
|
||||
<tbody id="dailyBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-outline" onclick="closeModal('editModal')">取消</button>
|
||||
<button class="btn btn-primary" onclick="saveSchedule()">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 物料查询弹窗(仿金蝶数据查询) -->
|
||||
<div class="modal-overlay" id="materialPicker">
|
||||
<div class="modal picker-modal">
|
||||
<div class="modal-header">
|
||||
<h3>📋 物料查询(数据查询)</h3>
|
||||
<button class="modal-close" onclick="closeModal('materialPicker')">×</button>
|
||||
</div>
|
||||
<div class="picker-toolbar">
|
||||
<div class="cond-row">
|
||||
<label>物料代码</label>
|
||||
<select id="pkCodeOp" style="width:90px">
|
||||
<option>包含</option><option>不包含</option><option>等于</option><option>不等于</option><option>开始于</option><option>结束于</option><option>为空</option><option>不为空</option>
|
||||
</select>
|
||||
<input type="text" id="pkCodeVal" placeholder="输入物料代码" style="min-width:160px">
|
||||
</div>
|
||||
<div class="cond-row">
|
||||
<label>物料名称</label>
|
||||
<select id="pkNameOp" style="width:90px">
|
||||
<option>包含</option><option>不包含</option><option>等于</option><option>不等于</option><option>开始于</option><option>结束于</option><option>为空</option><option>不为空</option>
|
||||
</select>
|
||||
<input type="text" id="pkNameVal" placeholder="输入物料名称" style="min-width:160px">
|
||||
</div>
|
||||
<div class="actions">
|
||||
<button class="btn btn-primary" onclick="doSearch()">🔍 搜索</button>
|
||||
<button class="btn btn-outline" onclick="resetSearchPK()">重置</button>
|
||||
<button class="btn btn-green" onclick="addSelectedMaterial()">添加</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="picker-table-wrap">
|
||||
<table class="picker-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-check"><input type="checkbox" id="pkCheckAll" onchange="toggleCheckAll(this.checked)"></th>
|
||||
<th>物料代码 <input class="filter-input" id="pkFilterCode" oninput="doSearch()"></th>
|
||||
<th>物料名称 <input class="filter-input" id="pkFilterName" oninput="doSearch()"></th>
|
||||
<th>规格型号 <input class="filter-input" id="pkFilterSpec" oninput="doSearch()"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="pkBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="picker-pagination">
|
||||
<span>共 <span id="pkTotal">0</span> 条 每页 <span id="pkPageSize">2000</span> 条</span>
|
||||
<div class="pages" id="pkPages"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
<script>
|
||||
var curId=0;
|
||||
var options=null;
|
||||
var dailyData=[];
|
||||
var pkPage=1, pkPageSize=2000;
|
||||
var pkTotal=0;
|
||||
var selectedMaterial=null; // {code, name, spec, bomVersion}
|
||||
var curPage=1, pageSize=20, totalCnt=0;
|
||||
var pageSizeOptions=[20,50,100,200];
|
||||
|
||||
function toast(msg,tp){var el=document.getElementById('toast');el.textContent=msg;el.className='toast '+tp;clearTimeout(el._timer);el._timer=setTimeout(function(){el.className='toast'},3000)}
|
||||
function api(url,method,data,cb){
|
||||
var opts={method:method||'GET',headers:{'Content-Type':'application/json'}};
|
||||
if(data)opts.body=JSON.stringify(data);
|
||||
fetch(url,opts).then(function(r){return r.json()}).then(function(res){
|
||||
if(res&&res.success===false){toast(res.message||'操作失败','error');return}
|
||||
cb&&cb(res);
|
||||
}).catch(function(e){toast('请求失败:'+e.message,'error')});
|
||||
}
|
||||
function getApiUrl(){return '../../api/deliver/'}
|
||||
|
||||
function loadOptions(cb){
|
||||
api(getApiUrl()+'GetOptions','GET',null,function(res){
|
||||
options=res.data||{};
|
||||
var h='<option value="">产品编码:全部</option>';
|
||||
(options.products||[]).forEach(function(p){h+='<option value="'+p+'">'+p+'</option>'});
|
||||
document.getElementById('selProduct').innerHTML=h;
|
||||
var h2='<option value="">BOM版本:全部</option>';
|
||||
(options.versions||[]).forEach(function(v){h2+='<option value="'+v+'">'+v+'</option>'});
|
||||
document.getElementById('selVersion').innerHTML=h2;
|
||||
var h3='<option value="">产品类型:全部</option>';
|
||||
(options.productTypes||[]).forEach(function(t){h3+='<option value="'+t+'">'+t+'</option>'});
|
||||
document.getElementById('selProductType').innerHTML=h3;
|
||||
cb&&cb();
|
||||
});
|
||||
}
|
||||
|
||||
function searchList(){curPage=1;loadList()}
|
||||
|
||||
function loadList(){
|
||||
var p=document.getElementById('selProduct').value;
|
||||
var v=document.getElementById('selVersion').value;
|
||||
var t=document.getElementById('selProductType').value;
|
||||
var s=document.getElementById('selStatus').value;
|
||||
var kw=document.getElementById('txtKeyword').value.trim();
|
||||
var url=getApiUrl()+'GetScheduleList?productCode='+encodeURIComponent(p)+'&bomVersion='+encodeURIComponent(v)+'&productType='+encodeURIComponent(t)+'&status='+encodeURIComponent(s)+'&keyword='+encodeURIComponent(kw)+'&page='+curPage+'&pageSize='+pageSize;
|
||||
api(url,'GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
totalCnt=res.total||0;
|
||||
var html='';
|
||||
if(rows.length===0)html='<tr><td colspan="14" style="text-align:center;padding:36px;color:#bbb">暂无数据</td></tr>';
|
||||
rows.forEach(function(r,idx){
|
||||
var stClass=r.Status=='进行中'?'badge-success':(r.Status=='待开始'?'badge-warning':(r.Status=='已完成'?'badge-info':'badge-muted'));
|
||||
var rowNo=(curPage-1)*pageSize+idx+1;
|
||||
html+='<tr data-id="'+r.Id+'" onclick="openEdit('+r.Id+')">'+
|
||||
'<td class="col-num">'+rowNo+'</td>'+
|
||||
'<td class="col-check" onclick="event.stopPropagation()"><input type="checkbox" class="rowChk" onchange="updateSelCount()"></td>'+
|
||||
'<td class="col-op" style="white-space:nowrap" onclick="event.stopPropagation()">'+
|
||||
'<button class="btn btn-blue" style="height:26px;padding:0 10px;font-size:11px" onclick="recalc('+r.Id+')">重算需求</button>'+
|
||||
'</td>'+
|
||||
'<td>'+r.ProductCode+'</td>'+
|
||||
'<td><span class="badge badge-info">'+r.BOMVersion+'</span></td>'+
|
||||
'<td>'+r.ProductName+'</td>'+
|
||||
'<td>'+(r.ProductType||'')+'</td>'+
|
||||
'<td>'+(r.Factory||'')+'</td>'+
|
||||
'<td>'+(r.Region||'')+'</td>'+
|
||||
'<td>'+(r.Country||'')+'</td>'+
|
||||
'<td>'+r.PlanStartDate+'</td>'+
|
||||
'<td>'+r.PlanEndDate+'</td>'+
|
||||
'<td>'+r.TotalOutput+'</td>'+
|
||||
'<td><span class="badge '+stClass+'">'+r.Status+'</span></td>'+
|
||||
'</tr>';
|
||||
});
|
||||
document.getElementById('tbodyList').innerHTML=html;
|
||||
renderPagination();
|
||||
});
|
||||
}
|
||||
|
||||
function resetSearch(){
|
||||
document.getElementById('selProduct').value='';
|
||||
document.getElementById('selVersion').value='';
|
||||
document.getElementById('selProductType').value='';
|
||||
document.getElementById('selStatus').value='';
|
||||
document.getElementById('txtKeyword').value='';
|
||||
curPage=1;
|
||||
loadList();
|
||||
}
|
||||
|
||||
// ===== 列表分页 =====
|
||||
function renderPagination(){
|
||||
var tp=Math.ceil(totalCnt/pageSize)||1;
|
||||
var pc=document.getElementById('pagination');
|
||||
if(totalCnt<=pageSize){pc.style.display='none';return}
|
||||
pc.style.display='flex';
|
||||
document.getElementById('totalCnt').textContent=totalCnt;
|
||||
document.getElementById('sizeBtns').innerHTML=pageSizeOptions.map(function(s){return '<button class="size-btn'+(s===pageSize?' active':'')+'" onclick="setPageSize('+s+')">'+s+'条</button>'}).join('');
|
||||
var pb=document.getElementById('pageBtns');
|
||||
if(tp<=1){pb.innerHTML='';return}
|
||||
var h='<button '+(curPage<=1?'disabled':'')+' onclick="goPage(1)">首页</button><button '+(curPage<=1?'disabled':'')+' onclick="goPage('+(curPage-1)+')">‹</button>';
|
||||
for(var i=Math.max(1,curPage-2);i<=Math.min(tp,curPage+2);i++)h+='<button class="'+(i===curPage?'active':'')+'" onclick="goPage('+i+')">'+i+'</button>';
|
||||
h+='<button '+(curPage>=tp?'disabled':'')+' onclick="goPage('+(curPage+1)+')">›</button><button '+(curPage>=tp?'disabled':'')+' onclick="goPage('+tp+')">末页</button>';
|
||||
pb.innerHTML=h;
|
||||
}
|
||||
function goPage(p){
|
||||
if(p<1||p>Math.ceil(totalCnt/pageSize))return;
|
||||
curPage=p;
|
||||
loadList();
|
||||
}
|
||||
function setPageSize(s){
|
||||
pageSize=s;curPage=1;loadList();
|
||||
}
|
||||
|
||||
function openAddModal(){
|
||||
curId=0;
|
||||
document.getElementById('modalTitle').textContent='新建排程任务';
|
||||
document.getElementById('fProductCode').value='';
|
||||
document.getElementById('fBOMVersion').value='';
|
||||
document.getElementById('fProductName').value='';
|
||||
document.getElementById('fProductType').value='';
|
||||
document.getElementById('fFactory').value='';
|
||||
document.getElementById('fRegion').value='';
|
||||
document.getElementById('fCountry').value='';
|
||||
document.getElementById('fPlanStart').value='';
|
||||
document.getElementById('fPlanEnd').value='';
|
||||
document.getElementById('fStatus').value='进行中';
|
||||
document.getElementById('fRemark').value='';
|
||||
selectedMaterial=null;
|
||||
dailyData=[];
|
||||
renderDaily();
|
||||
document.getElementById('editModal').classList.add('show');
|
||||
}
|
||||
|
||||
// 打开物料查询弹窗
|
||||
function openMaterialPicker(){
|
||||
pkPage=1;
|
||||
document.getElementById('materialPicker').classList.add('show');
|
||||
doSearch();
|
||||
}
|
||||
|
||||
// 重置查询条件
|
||||
function resetSearchPK(){
|
||||
document.getElementById('pkCodeOp').value='包含';
|
||||
document.getElementById('pkCodeVal').value='';
|
||||
document.getElementById('pkNameOp').value='包含';
|
||||
document.getElementById('pkNameVal').value='';
|
||||
document.getElementById('pkFilterCode').value='';
|
||||
document.getElementById('pkFilterName').value='';
|
||||
document.getElementById('pkFilterSpec').value='';
|
||||
document.getElementById('pkCheckAll').checked=false;
|
||||
pkPage=1;
|
||||
doSearch();
|
||||
}
|
||||
|
||||
// 搜索物料
|
||||
function doSearch(){
|
||||
var codeOp=encodeURIComponent(document.getElementById('pkCodeOp').value);
|
||||
var codeVal=document.getElementById('pkCodeVal').value.trim();
|
||||
var nameOp=encodeURIComponent(document.getElementById('pkNameOp').value);
|
||||
var nameVal=document.getElementById('pkNameVal').value.trim();
|
||||
// 列表内过滤(叠加在服务器条件之上)
|
||||
var fc=document.getElementById('pkFilterCode').value.trim().toLowerCase();
|
||||
var fn=document.getElementById('pkFilterName').value.trim().toLowerCase();
|
||||
var fs=document.getElementById('pkFilterSpec').value.trim().toLowerCase();
|
||||
var url=getApiUrl()+'GetKingdeeMaterials?codeOp='+codeOp+'&codeVal='+encodeURIComponent(codeVal)+'&nameOp='+nameOp+'&nameVal='+encodeURIComponent(nameVal)+'&page='+pkPage+'&pageSize='+pkPageSize;
|
||||
api(url,'GET',null,function(res){
|
||||
var rows=res.data||[];
|
||||
var html='';
|
||||
rows.forEach(function(m){
|
||||
if(fc && (m.code||'').toLowerCase().indexOf(fc)<0)return;
|
||||
if(fn && (m.name||'').toLowerCase().indexOf(fn)<0)return;
|
||||
if(fs && (m.spec||'').toLowerCase().indexOf(fs)<0)return;
|
||||
html+='<tr onclick="selectMaterialRow(this)" data-code="'+m.code+'" data-name="'+m.name+'" data-spec="'+(m.spec||'')+'" data-bom="'+m.bomVersion+'">'+
|
||||
'<td class="col-check"><input type="checkbox" class="pkChk"></td>'+
|
||||
'<td>'+m.code+'</td>'+
|
||||
'<td>'+m.name+'</td>'+
|
||||
'<td>'+(m.spec||'')+'</td>'+
|
||||
'</tr>';
|
||||
});
|
||||
if(!html)html='<tr><td colspan="4" style="text-align:center;padding:30px;color:#bbb">暂无数据</td></tr>';
|
||||
document.getElementById('pkBody').innerHTML=html;
|
||||
pkTotal=res.total||0;
|
||||
document.getElementById('pkTotal').textContent=pkTotal;
|
||||
document.getElementById('pkPageSize').textContent=res.pageSize||pkPageSize;
|
||||
renderPkPages(pkTotal,res.page||pkPage,res.pageSize||pkPageSize);
|
||||
});
|
||||
}
|
||||
|
||||
function renderPkPages(total,page,pageSize){
|
||||
var pages=Math.ceil(total/pageSize);
|
||||
var h='<button onclick="pkGoto('+(page-1)+')" '+(page<=1?'disabled':'')+'>‹</button>';
|
||||
for(var i=1;i<=Math.min(pages,10);i++){
|
||||
h+='<button class="'+(i==page?'active':'')+'" onclick="pkGoto('+i+')">'+i+'</button>';
|
||||
}
|
||||
if(pages>10)h+='<span style="padding:0 4px;">...</span><button class="'+(pages==page?'active':'')+'" onclick="pkGoto('+pages+')">'+pages+'</button>';
|
||||
h+='<button onclick="pkGoto('+(page+1)+')" '+(page>=pages?'disabled':'')+'>›</button>';
|
||||
document.getElementById('pkPages').innerHTML=h;
|
||||
}
|
||||
|
||||
function pkGoto(p){
|
||||
if(p<1)return;
|
||||
var pages=Math.ceil(pkTotal/pkPageSize);
|
||||
if(p>pages)return;
|
||||
pkPage=p;
|
||||
doSearch();
|
||||
}
|
||||
|
||||
function toggleCheckAll(checked){
|
||||
var cks=document.querySelectorAll('.pkChk');
|
||||
for(var i=0;i<cks.length;i++)cks[i].checked=checked;
|
||||
}
|
||||
|
||||
function selectMaterialRow(tr){
|
||||
var cks=document.querySelectorAll('.pkChk');
|
||||
cks.forEach(function(c){c.checked=false;});
|
||||
cks.forEach(function(c){if(c.parentElement.parentElement===tr)c.checked=true;});
|
||||
var chk=tr.querySelector('.pkChk');
|
||||
if(chk)chk.checked=true;
|
||||
document.querySelectorAll('.picker-table tbody tr').forEach(function(r){r.classList.remove('selected');});
|
||||
tr.classList.add('selected');
|
||||
// 双击行直接添加(提升体验)
|
||||
// 单击选中,多选/添加走按钮
|
||||
}
|
||||
|
||||
function addSelectedMaterial(){
|
||||
var chks=document.querySelectorAll('.pkChk:checked');
|
||||
if(chks.length===0){toast('请先勾选一条物料','error');return}
|
||||
if(chks.length>1){toast('每次只能选择一个产品','error');return}
|
||||
var tr=chks[0].parentElement.parentElement;
|
||||
selectedMaterial={
|
||||
code:tr.getAttribute('data-code'),
|
||||
name:tr.getAttribute('data-name'),
|
||||
spec:tr.getAttribute('data-spec'),
|
||||
bomVersion:tr.getAttribute('data-bom')||''
|
||||
};
|
||||
// 回填到排程表单
|
||||
document.getElementById('fProductCode').value=selectedMaterial.code;
|
||||
document.getElementById('fBOMVersion').value=selectedMaterial.bomVersion;
|
||||
document.getElementById('fProductName').value=selectedMaterial.name;
|
||||
closeModal('materialPicker');
|
||||
toast('已选择产品:'+selectedMaterial.code+(selectedMaterial.bomVersion?('(BOM版本:'+selectedMaterial.bomVersion+')'):''),'success');
|
||||
}
|
||||
|
||||
function openEdit(id){
|
||||
api(getApiUrl()+'GetScheduleDetail?id='+id,'GET',null,function(res){
|
||||
if(!res.success||!res.data){toast('未找到记录','error');return}
|
||||
var d=res.data;
|
||||
curId=d.Id;
|
||||
document.getElementById('modalTitle').textContent='编辑排程任务 - '+d.ProductCode;
|
||||
document.getElementById('fProductCode').value=d.ProductCode||'';
|
||||
document.getElementById('fBOMVersion').value=d.BOMVersion||'';
|
||||
document.getElementById('fProductName').value=d.ProductName||'';
|
||||
document.getElementById('fProductType').value=d.ProductType||'';
|
||||
document.getElementById('fFactory').value=d.Factory||'';
|
||||
document.getElementById('fRegion').value=d.Region||'';
|
||||
document.getElementById('fCountry').value=d.Country||'';
|
||||
document.getElementById('fPlanStart').value=d.PlanStartDate||'';
|
||||
document.getElementById('fPlanEnd').value=d.PlanEndDate||'';
|
||||
document.getElementById('fStatus').value=d.Status||'待开始';
|
||||
document.getElementById('fRemark').value=d.Remark||'';
|
||||
selectedMaterial={code:d.ProductCode,name:d.ProductName,bomVersion:d.BOMVersion};
|
||||
dailyData=(d.daily||[]).map(function(x){return {date:x.PlanDate,output:x.DailyOutput||'0'}});
|
||||
renderDaily();
|
||||
document.getElementById('editModal').classList.add('show');
|
||||
});
|
||||
}
|
||||
|
||||
function genDaily(){
|
||||
var start=document.getElementById('fPlanStart').value;
|
||||
var end=document.getElementById('fPlanEnd').value;
|
||||
if(!start||!end)return;
|
||||
if(end<start){toast('计划完成日不能早于开始日','error');return}
|
||||
var dates=[];
|
||||
var cur=new Date(start);
|
||||
var last=new Date(end);
|
||||
while(cur<=last){
|
||||
dates.push({date:formatDate(cur),output:''});
|
||||
cur.setDate(cur.getDate()+1);
|
||||
}
|
||||
dailyData=dates;
|
||||
renderDaily();
|
||||
}
|
||||
|
||||
function formatDate(d){
|
||||
var y=d.getFullYear(),m=('0'+(d.getMonth()+1)).slice(-2),dd=('0'+d.getDate()).slice(-2);
|
||||
return y+'-'+m+'-'+dd;
|
||||
}
|
||||
|
||||
function renderDaily(){
|
||||
var header='<tr><th>日期</th><th>星期</th><th>日产量</th></tr>';
|
||||
var body='';
|
||||
dailyData.forEach(function(item,i){
|
||||
var d=new Date(item.date);
|
||||
var week=['日','一','二','三','四','五','六'][d.getDay()];
|
||||
var isWeekend=(d.getDay()==0||d.getDay()==6);
|
||||
var cls=isWeekend?'weekend':'';
|
||||
body+='<tr class="'+cls+'">'+
|
||||
'<td>'+item.date+'</td>'+
|
||||
'<td>周'+week+'</td>'+
|
||||
'<td><input type="number" data-idx="'+i+'" value="'+item.output+'" oninput="updateOutput(this)"></td>'+
|
||||
'</tr>';
|
||||
});
|
||||
document.getElementById('dailyHeader').innerHTML=header;
|
||||
document.getElementById('dailyBody').innerHTML=body;
|
||||
}
|
||||
|
||||
function updateOutput(el){
|
||||
var idx=el.getAttribute('data-idx');
|
||||
dailyData[idx].output=el.value;
|
||||
}
|
||||
|
||||
function saveSchedule(){
|
||||
var data={
|
||||
Id:curId,
|
||||
ProductCode:document.getElementById('fProductCode').value.trim(),
|
||||
BOMVersion:document.getElementById('fBOMVersion').value.trim(),
|
||||
ProductName:document.getElementById('fProductName').value.trim(),
|
||||
ProductType:document.getElementById('fProductType').value.trim(),
|
||||
Factory:document.getElementById('fFactory').value.trim(),
|
||||
Region:document.getElementById('fRegion').value.trim(),
|
||||
Country:document.getElementById('fCountry').value.trim(),
|
||||
PlanStartDate:document.getElementById('fPlanStart').value,
|
||||
PlanEndDate:document.getElementById('fPlanEnd').value,
|
||||
Status:document.getElementById('fStatus').value,
|
||||
Remark:document.getElementById('fRemark').value,
|
||||
CreateUser:(function(){try{var u=JSON.parse(sessionStorage.getItem('gx_user'));return u.userId||''}catch(e){return ''}})()
|
||||
};
|
||||
if(!data.ProductCode){toast('请先选择产品编码','error');return}
|
||||
if(!data.BOMVersion){toast('所选产品没有BOM版本,请在物料查询中选择已建立BOM的物料','error');return}
|
||||
if(!data.PlanStartDate||!data.PlanEndDate){toast('请选择计划开始日和完成日','error');return}
|
||||
// 保存前从DOM同步最新输入值,确保oninput/onchange都能捕获
|
||||
var inputs=document.querySelectorAll('#dailyBody input[type="number"]');
|
||||
inputs.forEach(function(el){updateOutput(el)});
|
||||
data.daily=dailyData.filter(function(x){return x.output&&parseFloat(x.output)>0}).map(function(x){return {PlanDate:x.date,DailyOutput:x.output}});
|
||||
// 关闭按钮防止重复提交
|
||||
var saveBtn=document.querySelector('.modal-footer .btn-primary');
|
||||
if(saveBtn)saveBtn.disabled=true;
|
||||
try{
|
||||
api(getApiUrl()+'SaveSchedule','POST',data,function(res){
|
||||
if(saveBtn)saveBtn.disabled=false;
|
||||
if(res.success){toast('排程保存成功,已自动登记到BOM主数据','success');closeModal('editModal');loadList()}
|
||||
});
|
||||
}catch(e){if(saveBtn)saveBtn.disabled=false;}
|
||||
}
|
||||
|
||||
// 下载导入模板
|
||||
function downloadTemplate(){
|
||||
var a=document.createElement('a');
|
||||
a.href=getApiUrl()+'DownloadScheduleTemplate';
|
||||
a.download='生产排程导入模板.xls';
|
||||
a.style.display='none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
setTimeout(function(){document.body.removeChild(a)},100);
|
||||
}
|
||||
|
||||
function recalc(id){
|
||||
if(!confirm('确认重新计算该排程的物料需求?'))return;
|
||||
api(getApiUrl()+'RecalcSchedule','POST',{ScheduleId:id},function(res){
|
||||
if(res.success){showRecalcProgress(id)}
|
||||
else if(res.message&&res.message.indexOf('正在重算')>=0){showRecalcProgress(id)}
|
||||
});
|
||||
}
|
||||
|
||||
// 显示重算进度条并轮询后端进度
|
||||
function showRecalcProgress(id){
|
||||
var modal=document.getElementById('recalcModal');
|
||||
if(!modal){
|
||||
modal=document.createElement('div');
|
||||
modal.id='recalcModal';
|
||||
modal.style.cssText='position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.45);z-index:99999;display:none;align-items:center;justify-content:center;';
|
||||
modal.innerHTML=
|
||||
'<div style="background:#fff;border-radius:10px;padding:26px 32px;width:440px;box-shadow:0 8px 30px rgba(0,0,0,0.25);">'+
|
||||
'<h4 style="margin:0 0 18px;font-size:16px;color:#303133;">物料需求重算中</h4>'+
|
||||
'<div style="height:10px;background:#ebeef5;border-radius:5px;overflow:hidden;">'+
|
||||
'<div id="recalcBar" style="height:100%;width:0%;background:linear-gradient(90deg,#409eff,#79bbff);border-radius:5px;transition:width 0.5s;"></div></div>'+
|
||||
'<div style="margin-top:12px;font-size:13px;color:#606266;display:flex;justify-content:space-between;">'+
|
||||
'<span id="recalcStage">准备中...</span><span id="recalcPercent" style="font-weight:bold;color:#409eff;">0%</span></div>'+
|
||||
'<div id="recalcMsg" style="margin-top:10px;font-size:12px;color:#909399;"></div>'+
|
||||
'</div>';
|
||||
document.body.appendChild(modal);
|
||||
}
|
||||
modal.style.display='flex';
|
||||
document.getElementById('recalcBar').style.width='0%';
|
||||
document.getElementById('recalcPercent').textContent='0%';
|
||||
document.getElementById('recalcStage').textContent='准备中...';
|
||||
document.getElementById('recalcMsg').textContent='';
|
||||
|
||||
var timer=setInterval(function(){
|
||||
fetch(getApiUrl()+'GetRecalcProgress?scheduleId='+id,{method:'GET'})
|
||||
.then(function(r){return r.json()})
|
||||
.then(function(res){
|
||||
if(!res||res.success===false){clearInterval(timer);hideRecalcModal();toast((res&&res.message)||'获取进度失败','error');return;}
|
||||
document.getElementById('recalcBar').style.width=res.percent+'%';
|
||||
document.getElementById('recalcPercent').textContent=res.percent+'%';
|
||||
document.getElementById('recalcStage').textContent=res.stage||'';
|
||||
document.getElementById('recalcMsg').textContent=res.message||'';
|
||||
if(res.status==='success'){
|
||||
clearInterval(timer);
|
||||
setTimeout(function(){hideRecalcModal();toast(res.message||'重算完成','success');loadList();},600);
|
||||
}else if(res.status==='error'){
|
||||
clearInterval(timer);
|
||||
setTimeout(function(){hideRecalcModal();toast(res.message||'重算失败','error');},600);
|
||||
}
|
||||
})
|
||||
.catch(function(e){clearInterval(timer);hideRecalcModal();toast('获取进度失败:'+e.message,'error');});
|
||||
},1000);
|
||||
}
|
||||
|
||||
function hideRecalcModal(){
|
||||
var modal=document.getElementById('recalcModal');
|
||||
if(modal)modal.style.display='none';
|
||||
}
|
||||
|
||||
function delSchedule(id){
|
||||
if(!confirm('确认删除该排程?相关需求明细将一并删除'))return;
|
||||
api(getApiUrl()+'DeleteSchedule','POST',{Id:id},function(res){
|
||||
if(res.success){toast('删除成功','success');loadList()}
|
||||
});
|
||||
}
|
||||
|
||||
// ===== 列表多选 / 批量删除 =====
|
||||
function getCheckedIds(){
|
||||
var ids=[];
|
||||
document.querySelectorAll('#tbodyList .rowChk:checked').forEach(function(c){
|
||||
var tr=c.closest('tr');
|
||||
if(tr&&tr.dataset.id)ids.push(Number(tr.dataset.id));
|
||||
});
|
||||
return ids;
|
||||
}
|
||||
function toggleCheckAllRows(checked){
|
||||
document.querySelectorAll('#tbodyList .rowChk').forEach(function(c){c.checked=checked;});
|
||||
updateSelCount();
|
||||
}
|
||||
function updateSelCount(){
|
||||
var ids=getCheckedIds();
|
||||
var bar=document.getElementById('batchBar');
|
||||
if(ids.length>0){
|
||||
bar.style.display='flex';
|
||||
document.getElementById('selCount').textContent=ids.length;
|
||||
}else{
|
||||
bar.style.display='none';
|
||||
}
|
||||
}
|
||||
function clearSelection(){
|
||||
document.querySelectorAll('#tbodyList .rowChk').forEach(function(c){c.checked=false;});
|
||||
updateSelCount();
|
||||
}
|
||||
function delSelected(){
|
||||
var ids=getCheckedIds();
|
||||
if(ids.length===0){toast('请选择要删除的行','error');return}
|
||||
if(!confirm('确认批量删除选中的 '+ids.length+' 条排程?'))return;
|
||||
api(getApiUrl()+'DeleteSchedule','POST',{Ids:ids},function(res){
|
||||
if(res.success){toast('批量删除完成','success');loadList()}
|
||||
});
|
||||
}
|
||||
|
||||
function triggerImport(){
|
||||
var input=document.createElement('input');
|
||||
input.type='file';
|
||||
input.accept='.xls,.xlsx';
|
||||
input.onchange=function(){
|
||||
var file=input.files[0];
|
||||
if(!file)return;
|
||||
var reader=new FileReader();
|
||||
reader.onload=function(){
|
||||
var base64=reader.result.split(',')[1];
|
||||
api(getApiUrl()+'ImportScheduleExcel','POST',{FileName:file.name,FileContent:base64},function(res){
|
||||
if(res.success){toast(res.message,'success');loadList()}
|
||||
});
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
};
|
||||
input.click();
|
||||
}
|
||||
|
||||
function closeModal(id){document.getElementById(id).classList.remove('show')}
|
||||
|
||||
loadOptions(function(){loadList()});
|
||||
</script>
|
||||
<!-- 公共侧边栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+325
@@ -0,0 +1,325 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>生产计划排程看板</title>
|
||||
<!-- 公共侧边栏组件 -->
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<style>
|
||||
*{margin:0;padding:0;box-sizing:border-box}
|
||||
body{font-family:'Microsoft YaHei','PingFang SC',sans-serif;background:#f0f2f5;min-height:100vh}
|
||||
.main-content{max-width:100%;margin:0 auto;padding:16px 20px}
|
||||
.panel{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:16px;margin-bottom:14px}
|
||||
.panel h3{font-size:15px;color:#333;font-weight:600;margin-bottom:4px}
|
||||
.panel .sub{font-size:12px;color:#94a3b8;margin-bottom:12px}
|
||||
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap;margin-bottom:12px}
|
||||
.toolbar select,.toolbar input{height:32px;padding:0 10px;border:2px solid #e0e0e0;border-radius:5px;font-size:13px;outline:none}
|
||||
.toolbar select:focus,.toolbar input:focus{border-color:#1a73e8}
|
||||
.btn{height:32px;padding:0 16px;border:none;border-radius:5px;font-size:12px;font-weight:600;cursor:pointer;transition:all .2s;color:#fff}
|
||||
.btn-primary{background:linear-gradient(135deg,#1a73e8,#1557b0)}
|
||||
.btn-primary:hover{opacity:.92}
|
||||
.btn-outline{background:#fff;color:#666;border:2px solid #e0e0e0}
|
||||
.btn-outline:hover{border-color:#1a73e8;color:#1a73e8}
|
||||
.toast{position:fixed;top:14px;left:50%;transform:translateX(-50%);padding:10px 22px;border-radius:8px;font-size:13px;z-index:1001;box-shadow:0 4px 20px rgba(0,0,0,.15);display:none;min-width:240px;text-align:center}
|
||||
.toast.error{background:#fdeaea;color:#b71c1c;display:block}
|
||||
.toast.success{background:#e6f9ed;color:#1a7a3a;display:block}
|
||||
.badge{display:inline-block;padding:2px 10px;border-radius:12px;font-size:12px;font-weight:500}
|
||||
.badge-success{background:#dcfce7;color:#166534}
|
||||
.badge-warning{background:#fef3c7;color:#92400e}
|
||||
.badge-info{background:#dbeafe;color:#1e40af}
|
||||
.badge-muted{background:#f1f5f9;color:#64748b}
|
||||
|
||||
/* ===== 看板:左侧固定信息列 + 右侧横向日期甘特 ===== */
|
||||
.board-wrap{overflow:auto;border:1px solid #e2e8f0;border-radius:8px;background:#fff;max-height:75vh}
|
||||
.board-table{border-collapse:separate;border-spacing:0;font-size:12px;min-width:100%}
|
||||
.board-table thead th{position:sticky;top:0;z-index:4;background:#f8f9fa;color:#555;font-weight:600;padding:9px 10px;text-align:center;border-bottom:2px solid #cbd5e1;border-right:1px solid #e2e8f0;white-space:nowrap}
|
||||
.board-table tbody td{padding:7px 10px;border-bottom:1px solid #f1f5f9;border-right:1px solid #f1f5f9;color:#334155;text-align:center}
|
||||
.board-table tbody tr:hover{background:#f0f6ff}
|
||||
|
||||
/* 左侧信息列固定 */
|
||||
.col-fix1{position:sticky;left:0;z-index:3;background:#fff;text-align:left!important;min-width:110px;box-shadow:1px 0 0 #e2e8f0}
|
||||
thead .col-fix1{background:#f8f9fa;z-index:5}
|
||||
.col-fix2{position:sticky;left:110px;z-index:3;background:#fff;text-align:left!important;min-width:130px;box-shadow:1px 0 0 #e2e8f0}
|
||||
thead .col-fix2{background:#f8f9fa;z-index:5}
|
||||
.col-fix3{position:sticky;left:240px;z-index:3;background:#fff;text-align:left!important;min-width:150px;box-shadow:1px 0 0 #e2e8f0}
|
||||
thead .col-fix3{background:#f8f9fa;z-index:5}
|
||||
.col-fix4{position:sticky;left:390px;z-index:3;background:#fff;text-align:left!important;min-width:150px;box-shadow:1px 0 0 #e2e8f0}
|
||||
thead .col-fix4{background:#f8f9fa;z-index:5}
|
||||
.board-table tbody tr:hover .col-fix1,
|
||||
.board-table tbody tr:hover .col-fix2,
|
||||
.board-table tbody tr:hover .col-fix3,
|
||||
.board-table tbody tr:hover .col-fix4{background:#f0f6ff}
|
||||
/* 合计行 */
|
||||
.board-table tbody tr.total-row{background:#fef3c7;font-weight:600}
|
||||
.board-table tbody tr.total-row td{color:#92400e}
|
||||
.board-table tbody tr.type-row{background:#f1f5f9;font-weight:600}
|
||||
.board-table tbody tr.type-row td{color:#475569}
|
||||
|
||||
/* 日期格子 */
|
||||
.cell-date{text-align:center;padding:4px 2px;min-width:44px}
|
||||
.cell-date .day{font-size:10px;color:#94a3b8;display:block;margin-bottom:2px}
|
||||
.cell-date .qty{display:inline-block;min-width:30px;padding:2px 6px;border-radius:4px;font-size:12px;font-weight:600;color:#fff;background:transparent}
|
||||
.cell-date.has .qty{background:linear-gradient(135deg,#3b82f6,#2563eb)}
|
||||
.cell-date.today{background:#fef9c3}
|
||||
.weekend{background:#fafbfc}
|
||||
.legend{display:flex;gap:16px;align-items:center;font-size:12px;color:#64748b;margin-top:8px}
|
||||
.legend .dot{display:inline-block;width:12px;height:12px;border-radius:3px;margin-right:4px;vertical-align:middle}
|
||||
.legend .dot.blue{background:#3b82f6}
|
||||
.legend .dot.yellow{background:#fef9c3;border:1px solid #eab308}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="sidebar"></div>
|
||||
|
||||
<div class="main-content">
|
||||
<div class="panel">
|
||||
<h3>生产计划排程 - 看板</h3>
|
||||
<div class="sub">横向展示各排程在每日的产量分布(数据来源:生产计划排程)</div>
|
||||
<div class="toolbar">
|
||||
<select id="selFactory" style="min-width:120px"><option value="">工厂:全部</option></select>
|
||||
<select id="selProductType" style="min-width:120px"><option value="">产品类型:全部</option></select>
|
||||
<select id="selRegion" style="min-width:120px"><option value="">区域:全部</option></select>
|
||||
<select id="selCountry" style="min-width:120px"><option value="">国家:全部</option></select>
|
||||
<select id="selStatus" style="min-width:100px">
|
||||
<option value="">状态:全部</option>
|
||||
<option value="待开始">待开始</option>
|
||||
<option value="进行中">进行中</option>
|
||||
<option value="已完成">已完成</option>
|
||||
<option value="已暂停">已暂停</option>
|
||||
</select>
|
||||
<input type="text" id="txtKeyword" placeholder="搜索 产品编码 / 产品名称" style="width:200px">
|
||||
<button class="btn btn-primary" onclick="renderBoard()">查询</button>
|
||||
<button class="btn btn-outline" onclick="resetFilter()">重置</button>
|
||||
<div style="flex:1"></div>
|
||||
<button class="btn btn-outline" onclick="location.reload()">🔄 刷新</button>
|
||||
</div>
|
||||
<div class="board-wrap">
|
||||
<table class="board-table" id="boardTable">
|
||||
<thead id="boardHead"></thead>
|
||||
<tbody id="boardBody"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="legend">
|
||||
<span><span class="dot blue"></span>有排产量</span>
|
||||
<span><span class="dot yellow"></span>今天</span>
|
||||
<span id="legendTotal"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script>
|
||||
var boardData=[];
|
||||
var dateList=[];
|
||||
|
||||
function toast(msg,tp){var el=document.getElementById('toast');el.textContent=msg;el.className='toast '+tp;clearTimeout(el._timer);el._timer=setTimeout(function(){el.className='toast'},3000)}
|
||||
function api(url,method,data,cb){
|
||||
var opts={method:method||'GET',headers:{'Content-Type':'application/json'}};
|
||||
if(data)opts.body=JSON.stringify(data);
|
||||
fetch(url,opts).then(function(r){return r.json()}).then(function(res){
|
||||
if(res&&res.success===false){toast(res.message||'操作失败','error');return}
|
||||
cb&&cb(res);
|
||||
}).catch(function(e){toast('请求失败:'+e.message,'error')});
|
||||
}
|
||||
function getApiUrl(){return '../../api/deliver/'}
|
||||
|
||||
// 生成本月的所有日期(yyyy-MM-dd,1号到月末)
|
||||
function buildMonthDates(){
|
||||
var arr=[];
|
||||
var now=new Date();
|
||||
var y=now.getFullYear(),m=now.getMonth();
|
||||
var first=new Date(y,m,1);
|
||||
var last=new Date(y,m+1,0); // 下月0号 = 本月最后一天
|
||||
var s=first;
|
||||
while(s<=last){
|
||||
var yy=s.getFullYear(),mm=('0'+(s.getMonth()+1)).slice(-2),dd=('0'+s.getDate()).slice(-2);
|
||||
arr.push(yy+'-'+mm+'-'+dd);
|
||||
s=new Date(s.getTime()+86400000);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
function fmtDate(d){
|
||||
if(!d)return '';
|
||||
var dt=new Date(d);
|
||||
if(isNaN(dt.getTime()))return d;
|
||||
return dt.getFullYear()+'-'+('0'+(dt.getMonth()+1)).slice(-2)+'-'+('0'+dt.getDate()).slice(-2);
|
||||
}
|
||||
function isWeekend(dateStr){
|
||||
var d=new Date(dateStr);
|
||||
var w=d.getDay();
|
||||
return w===0||w===6;
|
||||
}
|
||||
function todayStr(){return fmtDate(new Date())}
|
||||
|
||||
// 从数据提取筛选选项
|
||||
function fillFilters(){
|
||||
var f={},pt={},rg={},ct={};
|
||||
boardData.forEach(function(row){
|
||||
if(row.Factory){f[row.Factory]=1}
|
||||
if(row.ProductType){pt[row.ProductType]=1}
|
||||
if(row.Region){rg[row.Region]=1}
|
||||
if(row.Country){ct[row.Country]=1}
|
||||
});
|
||||
function fill(id,map,label){
|
||||
var el=document.getElementById(id);
|
||||
var cur=el.value;
|
||||
var h='<option value="">'+label+':全部</option>';
|
||||
Object.keys(map).sort().forEach(function(k){h+='<option value="'+k+'">'+k+'</option>'});
|
||||
el.innerHTML=h;
|
||||
el.value=cur;
|
||||
}
|
||||
fill('selFactory',f,'工厂');
|
||||
fill('selProductType',pt,'产品类型');
|
||||
fill('selRegion',rg,'区域');
|
||||
fill('selCountry',ct,'国家');
|
||||
}
|
||||
|
||||
// 渲染看板
|
||||
function renderBoard(){
|
||||
var kw=(document.getElementById('txtKeyword').value||'').trim().toLowerCase();
|
||||
var f=document.getElementById('selFactory').value;
|
||||
var pt=document.getElementById('selProductType').value;
|
||||
var rg=document.getElementById('selRegion').value;
|
||||
var ct=document.getElementById('selCountry').value;
|
||||
var st=document.getElementById('selStatus').value;
|
||||
|
||||
var rows=boardData.filter(function(row){
|
||||
if(f&&row.Factory!==f)return false;
|
||||
if(pt&&row.ProductType!==pt)return false;
|
||||
if(rg&&row.Region!==rg)return false;
|
||||
if(ct&&row.Country!==ct)return false;
|
||||
if(st&&row.Status!==st)return false;
|
||||
if(kw){
|
||||
var code=(row.ProductCode||'').toLowerCase();
|
||||
var name=(row.ProductName||'').toLowerCase();
|
||||
if(code.indexOf(kw)<0&&name.indexOf(kw)<0)return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// 按产品类型分组排序
|
||||
var typeOrder={};
|
||||
var types=[];
|
||||
rows.forEach(function(row){
|
||||
var t=row.ProductType||'(未分类)';
|
||||
if(!(t in typeOrder)){typeOrder[t]=[];types.push(t)}
|
||||
typeOrder[t].push(row);
|
||||
});
|
||||
types.sort();
|
||||
|
||||
var today=todayStr();
|
||||
|
||||
// 表头:工厂 / 产品类型 / 区域 / 国家 / 产品编码BOM / 产品名称 / 总产量 / 日期列
|
||||
var headHtml='<tr>';
|
||||
headHtml+='<th class="col-fix" style="min-width:90px">工厂</th>';
|
||||
headHtml+='<th class="col-fix-info" style="left:90px;min-width:100px">产品类型</th>';
|
||||
headHtml+='<th class="col-fix-info" style="left:190px;min-width:100px">区域</th>';
|
||||
headHtml+='<th class="col-fix-info" style="left:290px;min-width:100px">国家</th>';
|
||||
headHtml+='<th class="col-fix-info" style="left:390px;min-width:120px">产品编码 / BOM</th>';
|
||||
headHtml+='<th class="col-fix-info" style="left:510px;min-width:130px">产品名称</th>';
|
||||
headHtml+='<th>总产量</th>';
|
||||
dateList.forEach(function(d){
|
||||
var cls='cell-date';
|
||||
if(isWeekend(d))cls+=' weekend';
|
||||
if(d===today)cls+=' today';
|
||||
var label=d.slice(5);
|
||||
headHtml+='<th class="'+cls+'">'+label+'</th>';
|
||||
});
|
||||
headHtml+='</tr>';
|
||||
document.getElementById('boardHead').innerHTML=headHtml;
|
||||
|
||||
// 表体
|
||||
var bodyHtml='';
|
||||
var totalRowCount=0;
|
||||
if(rows.length===0){
|
||||
bodyHtml='<tr><td colspan="'+(7+dateList.length)+'" style="text-align:center;padding:36px;color:#bbb">暂无数据</td></tr>';
|
||||
}
|
||||
|
||||
// 每组:先列明细行,最后加一行"产品类型合计"
|
||||
types.forEach(function(t){
|
||||
var group=typeOrder[t];
|
||||
// 明细行
|
||||
group.forEach(function(row){
|
||||
var stCls=row.Status==='进行中'?'badge-success':(row.Status==='待开始'?'badge-warning':(row.Status==='已完成'?'badge-info':'badge-muted'));
|
||||
var dailyMap={};
|
||||
(row.Daily||[]).forEach(function(d){dailyMap[d.PlanDate]=Number(d.DailyOutput)||0});
|
||||
bodyHtml+='<tr>';
|
||||
bodyHtml+='<td class="col-fix">'+row.Factory+'</td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:90px">'+row.ProductType+'</td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:190px">'+row.Region+'</td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:290px">'+row.Country+'</td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:390px"><div style="font-weight:600">'+row.ProductCode+'</div><div style="font-size:11px;color:#94a3b8">'+row.BOMVersion+'</div></td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:510px">'+row.ProductName+'</td>';
|
||||
bodyHtml+='<td style="font-weight:600">'+(row.TotalOutput||0)+'</td>';
|
||||
dateList.forEach(function(d){
|
||||
var cls='cell-date';
|
||||
if(isWeekend(d))cls+=' weekend';
|
||||
if(d===today)cls+=' today';
|
||||
var q=dailyMap[d];
|
||||
if(q>0)cls+=' has';
|
||||
bodyHtml+='<td class="'+cls+'"><span class="qty">'+(q>0?q:'')+'</span></td>';
|
||||
});
|
||||
bodyHtml+='</tr>';
|
||||
totalRowCount++;
|
||||
});
|
||||
|
||||
// 合计行(该产品类型下所有排程按日汇总 + 总产量合计)
|
||||
var sumDaily={},sumTotal=0;
|
||||
group.forEach(function(row){
|
||||
(row.Daily||[]).forEach(function(d){
|
||||
var dd=d.PlanDate, v=Number(d.DailyOutput)||0;
|
||||
sumDaily[dd]=(sumDaily[dd]||0)+v;
|
||||
sumTotal+=v;
|
||||
});
|
||||
});
|
||||
bodyHtml+='<tr class="sum-row" style="background:#eef4ff;font-weight:600">';
|
||||
bodyHtml+='<td class="col-fix" style="background:#eef4ff"></td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:90px;background:#eef4ff">'+t+' 合计</td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:190px;background:#eef4ff"></td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:290px;background:#eef4ff"></td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:390px;background:#eef4ff"></td>';
|
||||
bodyHtml+='<td class="col-fix-info" style="left:510px;background:#eef4ff"></td>';
|
||||
bodyHtml+='<td style="background:#eef4ff;font-weight:700">'+sumTotal+'</td>';
|
||||
dateList.forEach(function(d){
|
||||
var cls='cell-date';
|
||||
if(isWeekend(d))cls+=' weekend';
|
||||
if(d===today)cls+=' today';
|
||||
var q=sumDaily[d]||0;
|
||||
if(q>0)cls+=' has';
|
||||
bodyHtml+='<td class="'+cls+'" style="background:#eef4ff"><span class="qty">'+(q>0?q:'')+'</span></td>';
|
||||
});
|
||||
bodyHtml+='</tr>';
|
||||
});
|
||||
|
||||
document.getElementById('boardBody').innerHTML=bodyHtml;
|
||||
document.getElementById('legendTotal').textContent='共 '+totalRowCount+' 条排程,'+types.length+' 个产品类型';
|
||||
}
|
||||
|
||||
function resetFilter(){
|
||||
document.getElementById('txtKeyword').value='';
|
||||
document.getElementById('selFactory').value='';
|
||||
document.getElementById('selProductType').value='';
|
||||
document.getElementById('selRegion').value='';
|
||||
document.getElementById('selCountry').value='';
|
||||
document.getElementById('selStatus').value='';
|
||||
renderBoard();
|
||||
}
|
||||
|
||||
// 加载看板数据
|
||||
function loadBoard(){
|
||||
api(getApiUrl()+'GetScheduleBoard','GET',null,function(res){
|
||||
boardData=res.data||[];
|
||||
dateList=buildMonthDates(); // 本月所有日期
|
||||
fillFilters();
|
||||
renderBoard();
|
||||
});
|
||||
}
|
||||
|
||||
loadBoard();
|
||||
</script>
|
||||
<!-- 公共侧边栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+856
@@ -0,0 +1,856 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>MES扫码物料追溯看板 - Gaussian</title>
|
||||
<!-- 公共侧边栏组件 -->
|
||||
<link rel="stylesheet" href="../common/nav.css">
|
||||
<style>
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
body { font-family: 'Segoe UI','Microsoft YaHei',sans-serif; background: #f0f2f5; color: #333; }
|
||||
|
||||
/* ===== 顶部导航栏 ===== */
|
||||
.top-bar {
|
||||
position: fixed; top: 0; left: 0; right: 0; height: 48px;
|
||||
background: linear-gradient(90deg, #001529 0%, #003a70 100%);
|
||||
display: flex; align-items: center; padding: 0 24px; z-index: 100;
|
||||
}
|
||||
.top-bar .logo { color: #fff; font-size: 16px; font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
|
||||
.top-bar .top-links { display: flex; gap: 4px; height: 100%; margin-left: 40px; }
|
||||
.top-bar .top-links a {
|
||||
color: rgba(255,255,255,0.75); text-decoration: none; padding: 0 20px;
|
||||
display: flex; align-items: center; font-size: 14px; border-radius: 4px 4px 0 0;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.top-bar .top-links a:hover, .top-bar .top-links a.active { color: #fff; background: rgba(255,255,255,0.15); }
|
||||
.top-bar .user-info { margin-left: auto; font-size: 13px; color: rgba(255,255,255,0.85); }
|
||||
|
||||
/* ===== 页面主体 ===== */
|
||||
.page-body { padding-top: 48px; }
|
||||
|
||||
.header {
|
||||
background: #fff; padding: 16px 24px; display: flex; justify-content: space-between;
|
||||
align-items: center; box-shadow: 0 1px 4px rgba(0,0,0,0.05); margin-bottom: 16px;
|
||||
}
|
||||
.header h1 { font-size: 20px; font-weight: 600; color: #333; }
|
||||
.header-right { display: flex; align-items: center; gap: 16px; }
|
||||
.header-right span { font-size: 13px; color: #999; }
|
||||
.btn-refresh {
|
||||
padding: 6px 16px; background: #1890ff; color: #fff; border: none;
|
||||
border-radius: 4px; font-size: 13px; cursor: pointer; transition: background 0.2s;
|
||||
}
|
||||
.btn-refresh:hover { background: #40a9ff; }
|
||||
|
||||
.container { padding: 0 24px 24px; }
|
||||
|
||||
/* ===== Tab栏 ===== */
|
||||
.tabs {
|
||||
display: flex; gap: 4px; background: #fff; padding: 0 24px;
|
||||
border-radius: 8px 8px 0 0; box-shadow: 0 1px 4px rgba(0,0,0,0.05);
|
||||
}
|
||||
.tab {
|
||||
padding: 12px 24px; cursor: pointer; font-size: 14px; color: #666;
|
||||
border-bottom: 2px solid transparent; transition: all 0.2s; white-space: nowrap;
|
||||
}
|
||||
.tab:hover { color: #1890ff; }
|
||||
.tab.active { color: #1890ff; border-bottom-color: #1890ff; font-weight: 500; }
|
||||
.tab .badge {
|
||||
display: inline-block; background: #f0f0f0; color: #666; font-size: 12px;
|
||||
padding: 1px 8px; border-radius: 10px; margin-left: 4px;
|
||||
}
|
||||
.tab.active .badge { background: #e6f7ff; color: #1890ff; }
|
||||
|
||||
/* ===== 全部机型对比视图 ===== */
|
||||
.compare-view { padding-top: 16px; }
|
||||
.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(440px, 1fr)); gap: 16px; }
|
||||
.machine-card {
|
||||
background: #fff; border-radius: 8px; overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: box-shadow 0.3s;
|
||||
}
|
||||
.machine-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
|
||||
.machine-card-header {
|
||||
padding: 12px 20px; color: #fff; font-size: 16px; font-weight: 600;
|
||||
display: flex; justify-content: space-between; align-items: center;
|
||||
}
|
||||
.machine-card-header.gss { background: linear-gradient(135deg, #1890ff, #0050b3); }
|
||||
.machine-card-header.gs50 { background: linear-gradient(135deg, #52c41a, #389e0d); }
|
||||
.machine-card-header.gs40 { background: linear-gradient(135deg, #fa8c16, #d4380d); }
|
||||
.machine-card-header.gssw { background: linear-gradient(135deg, #f5222d, #a8071a); }
|
||||
.machine-card-header .product-count { font-size: 13px; font-weight: 400; opacity: 0.9; }
|
||||
.machine-card-body { padding: 20px; }
|
||||
.coverage-ring { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; }
|
||||
.ring-svg { width: 80px; height: 80px; flex-shrink: 0; }
|
||||
.ring-info { flex: 1; }
|
||||
.ring-info .rate { font-size: 28px; font-weight: 700; line-height: 1.2; }
|
||||
.ring-info .label { font-size: 12px; color: #999; margin-bottom: 2px; }
|
||||
.ring-info .detail { font-size: 13px; color: #666; }
|
||||
.status-row { display: flex; gap: 12px; margin-bottom: 16px; }
|
||||
.status-item {
|
||||
flex: 1; text-align: center; padding: 8px; border-radius: 6px; background: #fafafa;
|
||||
}
|
||||
.status-item .num { font-size: 20px; font-weight: 700; line-height: 1.4; }
|
||||
.status-item .text { font-size: 12px; color: #999; }
|
||||
.status-item.completed .num { color: #52c41a; }
|
||||
.status-item.exception .num { color: #f5222d; }
|
||||
.status-item.pending .num { color: #bfbfbf; }
|
||||
.process-bars { display: flex; flex-direction: column; gap: 6px; }
|
||||
.process-bar-item { font-size: 12px; }
|
||||
.process-bar-label { display: flex; justify-content: space-between; margin-bottom: 2px; }
|
||||
.process-bar-label .name { color: #666; }
|
||||
.process-bar-label .pct { font-weight: 600; }
|
||||
.process-bar-track { height: 6px; background: #f0f0f0; border-radius: 3px; overflow: hidden; }
|
||||
.process-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s; }
|
||||
.process-bar-fill.high { background: #52c41a; }
|
||||
.process-bar-fill.mid { background: #1890ff; }
|
||||
.process-bar-fill.zero { background: #d9d9d9; }
|
||||
.machine-card-footer { padding: 8px 20px; border-top: 1px solid #f0f0f0; text-align: right; }
|
||||
.machine-card-footer a { color: #1890ff; cursor: pointer; font-size: 13px; text-decoration: none; }
|
||||
.machine-card-footer a:hover { text-decoration: underline; }
|
||||
|
||||
/* ===== 单机型深度视图 ===== */
|
||||
.detail-view { padding-top: 16px; }
|
||||
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 16px; }
|
||||
.kpi-card {
|
||||
background: #fff; border-radius: 8px; padding: 20px; text-align: center;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
||||
}
|
||||
.kpi-card .value { font-size: 32px; font-weight: 700; line-height: 1.2; }
|
||||
.kpi-card .label { font-size: 13px; color: #999; margin-top: 4px; }
|
||||
.kpi-card .sub { font-size: 11px; color: #bbb; margin-top: 2px; }
|
||||
.kpi-card.blue .value { color: #1890ff; }
|
||||
.kpi-card.green .value { color: #52c41a; }
|
||||
.kpi-card.red .value { color: #f5222d; }
|
||||
.kpi-card.gray .value { color: #bfbfbf; }
|
||||
.kpi-card.orange .value { color: #fa8c16; }
|
||||
.kpi-card.purple .value { color: #722ed1; }
|
||||
|
||||
/* 图表区 */
|
||||
.chart-row { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; margin-bottom: 16px; }
|
||||
.chart-card {
|
||||
background: #fff; border-radius: 8px; padding: 20px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
||||
}
|
||||
.chart-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: #333; }
|
||||
|
||||
/* 环形图 */
|
||||
.donut-container { display: flex; align-items: center; justify-content: center; gap: 20px; }
|
||||
.donut-svg { width: 160px; height: 160px; }
|
||||
.donut-legend { font-size: 13px; }
|
||||
.donut-legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
|
||||
.donut-legend-item .dot { width: 10px; height: 10px; border-radius: 50%; }
|
||||
.donut-legend-item .pct { font-weight: 600; margin-left: auto; }
|
||||
|
||||
/* 工序条形图 */
|
||||
.process-bars-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
|
||||
|
||||
/* 产品明细表 */
|
||||
.product-table-wrapper {
|
||||
background: #fff; border-radius: 8px; padding: 20px;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
||||
}
|
||||
.product-table-wrapper h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
|
||||
.product-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
.product-table th { text-align: left; padding: 10px 12px; background: #fafafa; color: #666; font-weight: 500; border-bottom: 2px solid #e8e8e8; white-space: nowrap; }
|
||||
.product-table td { padding: 10px 12px; border-bottom: 1px solid #f5f5f5; }
|
||||
.product-table tr:hover { background: #fafafa; }
|
||||
.progress-bar { display: inline-block; width: 120px; height: 14px; background: #f0f0f0; border-radius: 7px; overflow: hidden; vertical-align: middle; margin-right: 8px; border: 1px solid #e8e8e8; }
|
||||
.progress-bar-fill { height: 100%; border-radius: 6px; transition: width 0.3s; }
|
||||
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
|
||||
.status-badge.normal { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
|
||||
.status-badge.abnormal { background: #fff1f0; color: #f5222d; border: 1px solid #ffa39e; }
|
||||
.status-badge.notstart { background: #fafafa; color: #bfbfbf; border: 1px solid #d9d9d9; }
|
||||
.btn-detail { color: #1890ff; cursor: pointer; font-size: 13px; }
|
||||
.btn-detail:hover { text-decoration: underline; }
|
||||
|
||||
/* 搜索栏 */
|
||||
.search-bar { display: flex; gap: 12px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
|
||||
.search-bar input, .search-bar select { padding: 6px 12px; border: 1px solid #d9d9d9; border-radius: 4px; font-size: 13px; outline: none; }
|
||||
.search-bar input:focus, .search-bar select:focus { border-color: #1890ff; }
|
||||
.btn-search { padding: 6px 16px; background: #1890ff; color: #fff; border: none; border-radius: 4px; font-size: 13px; cursor: pointer; }
|
||||
.btn-search:hover { background: #40a9ff; }
|
||||
|
||||
/* 分页 */
|
||||
.pagination { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
|
||||
.pagination button { padding: 4px 10px; border: 1px solid #d9d9d9; background: #fff; border-radius: 4px; font-size: 12px; cursor: pointer; color: #555; }
|
||||
.pagination button:hover:not(:disabled) { border-color: #1890ff; color: #1890ff; }
|
||||
.pagination button.active { background: #1890ff; color: #fff; border-color: #1890ff; }
|
||||
.pagination button:disabled { opacity: 0.5; cursor: default; }
|
||||
.pagination span { font-size: 12px; color: #999; margin: 0 4px; }
|
||||
|
||||
/* 弹窗 */
|
||||
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; justify-content: center; align-items: center; }
|
||||
.modal-overlay.show { display: flex; }
|
||||
.modal { background: #fff; border-radius: 8px; width: 800px; max-height: 80vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
|
||||
.modal-header { padding: 16px 20px; border-bottom: 1px solid #e8e8e8; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: #fff; z-index: 1; }
|
||||
.modal-header h3 { font-size: 16px; font-weight: 600; }
|
||||
.modal-close { font-size: 22px; color: #999; cursor: pointer; line-height: 1; }
|
||||
.modal-close:hover { color: #333; }
|
||||
.modal-body { padding: 20px; }
|
||||
.trace-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
||||
.trace-table th { text-align: left; padding: 8px 12px; background: #fafafa; color: #666; font-weight: 500; border-bottom: 1px solid #e8e8e8; white-space: nowrap; }
|
||||
.trace-table td { padding: 8px 12px; border-bottom: 1px solid #f5f5f5; }
|
||||
.trace-table .scanned { color: #52c41a; }
|
||||
.trace-table .not-scanned { color: #bfbfbf; }
|
||||
|
||||
/* 折线图 */
|
||||
.trend-card {
|
||||
background: #fafafa; border: 1px solid #f0f0f0; border-radius: 8px;
|
||||
padding: 16px; margin-bottom: 20px;
|
||||
}
|
||||
.trend-card h4 {
|
||||
font-size: 14px; font-weight: 600; color: #333;
|
||||
margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
|
||||
}
|
||||
.trend-card h4::before { content: ''; width: 4px; height: 14px; background: #1890ff; border-radius: 2px; }
|
||||
.trend-chart { position: relative; width: 100%; height: 220px; }
|
||||
.trend-tooltip {
|
||||
position: absolute; background: rgba(0,0,0,0.75); color: #fff; padding: 6px 10px;
|
||||
border-radius: 4px; font-size: 12px; pointer-events: none; display: none;
|
||||
white-space: nowrap; z-index: 10;
|
||||
}
|
||||
.trend-tooltip.show { display: block; }
|
||||
.chart-legend { display: flex; gap: 20px; margin-top: 8px; font-size: 12px; color: #666; }
|
||||
.chart-legend-item { display: flex; align-items: center; gap: 6px; }
|
||||
.chart-legend-item .legend-dot { width: 14px; height: 3px; border-radius: 2px; }
|
||||
|
||||
/* 加载中 */
|
||||
.loading-overlay {
|
||||
display: none; position: fixed; inset: 0; background: rgba(255,255,255,0.6);
|
||||
z-index: 999; justify-content: center; align-items: center;
|
||||
}
|
||||
.loading-overlay.show { display: flex; }
|
||||
.loading-spinner {
|
||||
width: 40px; height: 40px; border: 3px solid #e8e8e8;
|
||||
border-top-color: #1890ff; border-radius: 50%; animation: spin 0.8s linear infinite;
|
||||
}
|
||||
@keyframes spin { to { transform: rotate(360deg); } }
|
||||
|
||||
/* Toast */
|
||||
.toast {
|
||||
position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
|
||||
padding: 10px 24px; border-radius: 4px; font-size: 14px; z-index: 2000;
|
||||
opacity: 0; transition: opacity 0.3s; pointer-events: none;
|
||||
}
|
||||
.toast.show { opacity: 1; }
|
||||
.toast.error { background: #fff1f0; color: #f5222d; border: 1px solid #ffa39e; }
|
||||
|
||||
/* 空状态 */
|
||||
.empty-state { text-align: center; padding: 60px 20px; color: #bbb; font-size: 14px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- 侧边栏 -->
|
||||
<div id="sidebar"></div>
|
||||
|
||||
<div class="page-body">
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<div class="header">
|
||||
<h1>MES 扫码物料追溯看板</h1>
|
||||
<div class="header-right">
|
||||
<span id="curTime"></span>
|
||||
<button class="btn-refresh" onclick="refreshData()">刷新数据</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 机型Tab栏 -->
|
||||
<div class="tabs" id="tabBar"></div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<!-- 全部机型对比视图 -->
|
||||
<div id="compareView" class="compare-view">
|
||||
<div class="machine-grid" id="machineGrid"></div>
|
||||
</div>
|
||||
|
||||
<!-- 单机型深度视图 -->
|
||||
<div id="detailView" class="detail-view" style="display:none">
|
||||
<div class="kpi-row" id="kpiRow"></div>
|
||||
|
||||
<div class="chart-row">
|
||||
<div class="chart-card">
|
||||
<h3>产品扫码状态分布</h3>
|
||||
<div class="donut-container" id="donutContainer"></div>
|
||||
</div>
|
||||
<div class="chart-card">
|
||||
<h3>各工序扫码数量</h3>
|
||||
<div class="process-bars-detail" id="detailProcessBars"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 近一周扫码率趋势 -->
|
||||
<div class="chart-card" style="margin-bottom:16px">
|
||||
<h3>近一周每日扫码率</h3>
|
||||
<div class="trend-chart" id="machineTrendChart"></div>
|
||||
<div class="chart-legend">
|
||||
<div class="chart-legend-item"><span class="legend-dot" style="background:#1890ff"></span>每日扫码率(实扫/应扫)</div>
|
||||
<div class="chart-legend-item"><span class="legend-dot" style="background:#52c41a"></span>基准线 100%</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="product-table-wrapper">
|
||||
<h3>产品扫码明细</h3>
|
||||
<div class="search-bar">
|
||||
<input type="text" placeholder="搜索车号 / SN..." id="txtSearch">
|
||||
<select id="selStatus">
|
||||
<option value="">全部状态</option>
|
||||
<option value="normal">正常完成</option>
|
||||
<option value="abnormal">漏扫异常</option>
|
||||
<option value="notstart">未扫码</option>
|
||||
</select>
|
||||
<select id="selLine">
|
||||
<option value="">全部产线</option>
|
||||
</select>
|
||||
<button class="btn-search" onclick="filterProducts()">查询</button>
|
||||
</div>
|
||||
<table class="product-table" id="productTable"></table>
|
||||
<div class="pagination" id="pagination"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- /container -->
|
||||
|
||||
</div><!-- /page-body -->
|
||||
|
||||
<!-- 产品扫码详情弹窗 -->
|
||||
<div class="modal-overlay" id="modalOverlay">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<h3 id="modalTitle">扫码追溯详情</h3>
|
||||
<span class="modal-close" onclick="closeModal()">×</span>
|
||||
</div>
|
||||
<div class="modal-body" id="modalBody"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 加载中 -->
|
||||
<div class="loading-overlay" id="loading">
|
||||
<div class="loading-spinner"></div>
|
||||
</div>
|
||||
|
||||
<!-- Toast -->
|
||||
<div class="toast" id="toast"></div>
|
||||
|
||||
<script>
|
||||
/* ===== 全局变量 ===== */
|
||||
var dashboardData = null; // 全部机型汇总数据
|
||||
var machineDetail = null; // 当前机型详情数据
|
||||
var currentMachine = null; // 当前选中的机型key
|
||||
var filteredProducts = [];
|
||||
var currentPage = 1;
|
||||
var pageSize = 10;
|
||||
|
||||
/* ===== 工具函数 ===== */
|
||||
function showLoading() { document.getElementById('loading').classList.add('show'); }
|
||||
function hideLoading() { document.getElementById('loading').classList.remove('show'); }
|
||||
function toast(msg) {
|
||||
var el = document.getElementById('toast');
|
||||
el.textContent = msg;
|
||||
el.classList.add('show', 'error');
|
||||
setTimeout(function() { el.classList.remove('show'); }, 3000);
|
||||
}
|
||||
function barClass(barPct) {
|
||||
if (barPct > 0) return 'mid';
|
||||
return 'zero';
|
||||
}
|
||||
function barColor(scanned) {
|
||||
return scanned > 0 ? '#1890ff' : '#d9d9d9';
|
||||
}
|
||||
function statusBadge(status) {
|
||||
var map = { normal: '正常完成', abnormal: '漏扫异常', notstart: '未扫码' };
|
||||
return '<span class="status-badge ' + status + '">' + (map[status] || status) + '</span>';
|
||||
}
|
||||
function machineClass(fType) {
|
||||
var key = (fType || '').toLowerCase();
|
||||
if (key.indexOf('gssw') >= 0) return 'gssw';
|
||||
if (key.indexOf('gss') >= 0) return 'gss';
|
||||
if (key.indexOf('gs50') >= 0) return 'gs50';
|
||||
if (key.indexOf('gs40') >= 0) return 'gs40';
|
||||
return 'gss';
|
||||
}
|
||||
function machineColor(fType) {
|
||||
var colors = { gss: '#1890ff', gs50: '#52c41a', gs40: '#fa8c16', gssw: '#f5222d' };
|
||||
return colors[machineClass(fType)] || '#1890ff';
|
||||
}
|
||||
|
||||
/* ===== API 调用 ===== */
|
||||
function apiGet(url, callback) {
|
||||
showLoading();
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.onload = function() {
|
||||
hideLoading();
|
||||
try {
|
||||
var r = JSON.parse(xhr.responseText);
|
||||
if (r.success) { callback(r.data); }
|
||||
else { toast(r.message || '获取数据失败'); }
|
||||
} catch(e) { toast('数据解析异常'); }
|
||||
};
|
||||
xhr.onerror = function() { hideLoading(); toast('网络请求失败'); };
|
||||
xhr.send();
|
||||
}
|
||||
|
||||
function loadDashboardData(callback) {
|
||||
apiGet('../../api/Mes/GetDashboardData', function(data) {
|
||||
dashboardData = data;
|
||||
renderTabs();
|
||||
if (callback) callback();
|
||||
else renderCompareView();
|
||||
});
|
||||
}
|
||||
|
||||
/* 默认打开 GSS 机型详情视图 */
|
||||
function openDefaultMachine() {
|
||||
if (!dashboardData || !dashboardData.machines || dashboardData.machines.length === 0) {
|
||||
renderCompareView();
|
||||
return;
|
||||
}
|
||||
// 优先找 GSS(精确匹配),找不到则回退第一个机型
|
||||
var defaultType = null;
|
||||
for (var i = 0; i < dashboardData.machines.length; i++) {
|
||||
if (dashboardData.machines[i].fType === 'GSS') {
|
||||
defaultType = 'GSS';
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!defaultType) defaultType = dashboardData.machines[0].fType;
|
||||
showDetailView(defaultType);
|
||||
}
|
||||
|
||||
function loadMachineDetail(fType) {
|
||||
apiGet('../../api/Mes/GetMachineDetail?fType=' + encodeURIComponent(fType), function(data) {
|
||||
machineDetail = data;
|
||||
renderDetailView(fType);
|
||||
});
|
||||
}
|
||||
|
||||
function loadProductDetail(fInterID) {
|
||||
apiGet('../../api/Mes/GetProductDetail?fInterID=' + encodeURIComponent(fInterID), function(data) {
|
||||
showProductDetailModal(data);
|
||||
});
|
||||
}
|
||||
|
||||
/* ===== 渲染Tab栏 ===== */
|
||||
function renderTabs() {
|
||||
if (!dashboardData || !dashboardData.machines) return;
|
||||
var html = '<div class="tab active" onclick="showCompareView()">全部机型 <span class="badge">' + dashboardData.totalCount + '</span></div>';
|
||||
dashboardData.machines.forEach(function(m) {
|
||||
html += '<div class="tab" onclick="showDetailView(\'' + m.fType + '\')">' + m.fType + ' <span class="badge">' + m.count + '</span></div>';
|
||||
});
|
||||
document.getElementById('tabBar').innerHTML = html;
|
||||
}
|
||||
|
||||
/* ===== 渲染全部机型对比 ===== */
|
||||
function renderCompareView() {
|
||||
if (!dashboardData || !dashboardData.machines || dashboardData.machines.length === 0) {
|
||||
document.getElementById('machineGrid').innerHTML = '<div class="empty-state">暂无扫码数据</div>';
|
||||
return;
|
||||
}
|
||||
var grid = document.getElementById('machineGrid');
|
||||
var html = '';
|
||||
dashboardData.machines.forEach(function(m) {
|
||||
var cls = machineClass(m.fType);
|
||||
var color = machineColor(m.fType);
|
||||
var circ = 2 * Math.PI * 32;
|
||||
var dashLen = (m.coverage / 100) * circ;
|
||||
html += '<div class="machine-card">'
|
||||
+ '<div class="machine-card-header ' + cls + '">'
|
||||
+ '<span>' + m.fType + '</span>'
|
||||
+ '<span class="product-count">' + m.count + ' 台</span>'
|
||||
+ '</div>'
|
||||
+ '<div class="machine-card-body">'
|
||||
+ '<div class="coverage-ring">'
|
||||
+ '<svg class="ring-svg" viewBox="0 0 80 80">'
|
||||
+ '<circle cx="40" cy="40" r="32" fill="none" stroke="#f0f0f0" stroke-width="8"/>'
|
||||
+ '<circle cx="40" cy="40" r="32" fill="none" stroke="' + color + '" stroke-width="8" stroke-dasharray="' + dashLen.toFixed(1) + ' ' + circ.toFixed(1) + '" stroke-linecap="round" transform="rotate(-90 40 40)"/>'
|
||||
+ '<text x="40" y="44" text-anchor="middle" font-size="16" font-weight="700" fill="' + color + '">' + m.coverage + '%</text>'
|
||||
+ '</svg>'
|
||||
+ '<div class="ring-info">'
|
||||
+ '<div class="rate" style="color:' + color + '">' + m.coverage + '%</div>'
|
||||
+ '<div class="label">整体扫码覆盖率</div>'
|
||||
+ '<div class="detail">正常完成 ' + m.status.normal + ' / 总数 ' + m.count + '</div>'
|
||||
+ '</div>'
|
||||
+ '</div>'
|
||||
+ '<div class="status-row">'
|
||||
+ '<div class="status-item completed"><div class="num">' + m.status.normal + '</div><div class="text">正常完成</div></div>'
|
||||
+ '<div class="status-item exception"><div class="num">' + m.status.abnormal + '</div><div class="text">漏扫异常</div></div>'
|
||||
+ '<div class="status-item pending"><div class="num">' + m.status.notstart + '</div><div class="text">未扫码</div></div>'
|
||||
+ '</div>'
|
||||
+ '<div class="process-bars">';
|
||||
if (m.processes && m.processes.length > 0) {
|
||||
m.processes.forEach(function(p) {
|
||||
html += '<div class="process-bar-item">'
|
||||
+ '<div class="process-bar-label"><span class="name">' + p.name + '</span><span class="pct" style="color:' + barColor(p.scanned) + '">扫码: ' + p.scanned + '</span></div>'
|
||||
+ '<div class="process-bar-track"><div class="process-bar-fill ' + barClass(p.barPct) + '" style="width:' + p.barPct + '%"></div></div>'
|
||||
+ '</div>';
|
||||
});
|
||||
} else {
|
||||
html += '<div style="color:#bbb;font-size:12px;padding:8px 0">暂无工序扫码数据</div>';
|
||||
}
|
||||
html += '</div></div>'
|
||||
+ '<div class="machine-card-footer"><a onclick="showDetailView(\'' + m.fType + '\')">查看详情 ></a></div>'
|
||||
+ '</div>';
|
||||
});
|
||||
grid.innerHTML = html;
|
||||
}
|
||||
|
||||
/* ===== 渲染单机型深度视图 ===== */
|
||||
function renderDetailView(fType) {
|
||||
var d = machineDetail;
|
||||
if (!d) return;
|
||||
currentMachine = fType;
|
||||
var color = machineColor(fType);
|
||||
|
||||
// KPI
|
||||
var pctC = d.count > 0 ? (d.status.normal / d.count * 100).toFixed(1) : 0;
|
||||
var pctA = d.count > 0 ? (d.status.abnormal / d.count * 100).toFixed(1) : 0;
|
||||
var pctN = d.count > 0 ? (d.status.notstart / d.count * 100).toFixed(1) : 0;
|
||||
document.getElementById('kpiRow').innerHTML = ''
|
||||
+ '<div class="kpi-card blue"><div class="value">' + d.count + '</div><div class="label">产品总数</div><div class="sub">' + fType + ' 机型</div></div>'
|
||||
+ '<div class="kpi-card green"><div class="value">' + d.status.normal + '</div><div class="label">正常完成</div><div class="sub">' + pctC + '%</div></div>'
|
||||
+ '<div class="kpi-card red"><div class="value">' + d.status.abnormal + '</div><div class="label">漏扫异常</div><div class="sub">' + pctA + '%</div></div>'
|
||||
+ '<div class="kpi-card gray"><div class="value">' + d.status.notstart + '</div><div class="label">未扫码</div><div class="sub">' + pctN + '%</div></div>'
|
||||
+ '<div class="kpi-card orange"><div class="value">' + d.totalRealityQty + '</div><div class="label">实扫总数</div><div class="sub">应扫 ' + d.totalNeedQty + '</div></div>'
|
||||
+ '<div class="kpi-card purple"><div class="value">' + d.coverage + '%</div><div class="label">整体覆盖率</div><div class="sub">正常完成/总数</div></div>';
|
||||
|
||||
// 环形图
|
||||
var total = d.count;
|
||||
var s1 = d.status.normal, s2 = d.status.abnormal, s3 = d.status.notstart;
|
||||
var circ = 2 * Math.PI * 60;
|
||||
var d1 = total > 0 ? (s1 / total) * circ : 0;
|
||||
var d2 = total > 0 ? (s2 / total) * circ : 0;
|
||||
var donutHtml = '<svg class="donut-svg" viewBox="0 0 160 160">'
|
||||
+ '<circle cx="80" cy="80" r="60" fill="none" stroke="#f0f0f0" stroke-width="20"/>'
|
||||
+ '<circle cx="80" cy="80" r="60" fill="none" stroke="#52c41a" stroke-width="20" stroke-dasharray="' + d1.toFixed(1) + ' ' + circ.toFixed(1) + '" transform="rotate(-90 80 80)"/>'
|
||||
+ '<circle cx="80" cy="80" r="60" fill="none" stroke="#f5222d" stroke-width="20" stroke-dasharray="' + d2.toFixed(1) + ' ' + circ.toFixed(1) + '" stroke-dashoffset="-' + d1.toFixed(1) + '" transform="rotate(-90 80 80)"/>'
|
||||
+ '<text x="80" y="76" text-anchor="middle" font-size="28" font-weight="700" fill="#333">' + total + '</text>'
|
||||
+ '<text x="80" y="96" text-anchor="middle" font-size="12" fill="#999">总产量</text>'
|
||||
+ '</svg>'
|
||||
+ '<div class="donut-legend">'
|
||||
+ '<div class="donut-legend-item"><span class="dot" style="background:#52c41a"></span>正常完成 <span class="pct">' + s1 + (total > 0 ? ' (' + (s1/total*100).toFixed(1) + '%)' : '') + '</span></div>'
|
||||
+ '<div class="donut-legend-item"><span class="dot" style="background:#f5222d"></span>漏扫异常 <span class="pct">' + s2 + (total > 0 ? ' (' + (s2/total*100).toFixed(1) + '%)' : '') + '</span></div>'
|
||||
+ '<div class="donut-legend-item"><span class="dot" style="background:#f0f0f0;border:1px solid #d9d9d9"></span>未扫码 <span class="pct">' + s3 + (total > 0 ? ' (' + (s3/total*100).toFixed(1) + '%)' : '') + '</span></div>'
|
||||
+ '</div>';
|
||||
document.getElementById('donutContainer').innerHTML = donutHtml;
|
||||
|
||||
// 工序扫码数量
|
||||
var procEl = document.getElementById('detailProcessBars');
|
||||
if (d.processes && d.processes.length > 0) {
|
||||
var procHtml = '';
|
||||
d.processes.forEach(function(p) {
|
||||
procHtml += '<div class="process-bar-item">'
|
||||
+ '<div class="process-bar-label"><span class="name">' + p.name + '</span><span class="pct" style="color:' + barColor(p.scanned) + '">扫码: ' + p.scanned + '</span></div>'
|
||||
+ '<div class="process-bar-track"><div class="process-bar-fill ' + barClass(p.barPct) + '" style="width:' + p.barPct + '%"></div></div>'
|
||||
+ '</div>';
|
||||
});
|
||||
procEl.innerHTML = procHtml;
|
||||
} else {
|
||||
procEl.innerHTML = '<div class="empty-state" style="padding:20px">暂无工序扫码数据</div>';
|
||||
}
|
||||
|
||||
// 近一周每日扫码量折线图
|
||||
renderTrendChart('machineTrendChart', d.trend || []);
|
||||
|
||||
// 初始化产线筛选
|
||||
var lines = [];
|
||||
if (d.products) {
|
||||
d.products.forEach(function(p) {
|
||||
if (p.line && lines.indexOf(p.line) < 0) lines.push(p.line);
|
||||
});
|
||||
}
|
||||
lines.sort();
|
||||
var selLine = document.getElementById('selLine');
|
||||
selLine.innerHTML = '<option value="">全部产线</option>';
|
||||
lines.forEach(function(l) { selLine.innerHTML += '<option value="' + l + '">' + l + '</option>'; });
|
||||
|
||||
// 产品明细
|
||||
filteredProducts = (d.products || []).slice();
|
||||
currentPage = 1;
|
||||
renderProductTable();
|
||||
}
|
||||
|
||||
/* ===== 产品明细表 ===== */
|
||||
function renderProductTable() {
|
||||
var el = document.getElementById('productTable');
|
||||
var start = (currentPage - 1) * pageSize;
|
||||
var pageData = filteredProducts.slice(start, start + pageSize);
|
||||
if (pageData.length === 0) {
|
||||
el.innerHTML = '<thead><tr><th>车号</th><th>SN</th><th>机型</th><th>应扫</th><th>实扫</th><th>进度</th><th>状态</th><th>缺失工序</th><th>记录时间</th><th>操作</th></tr></thead><tbody><tr><td colspan="10" style="text-align:center;color:#bbb;padding:24px">暂无数据</td></tr></tbody>';
|
||||
document.getElementById('pagination').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
var html = '<thead><tr><th>车号</th><th>SN</th><th>机型</th><th>应扫</th><th>实扫</th><th>进度</th><th>状态</th><th>缺失工序</th><th>记录时间</th><th>操作</th></tr></thead><tbody>';
|
||||
pageData.forEach(function(p) {
|
||||
var pct = p.expected > 0 ? (p.actual / p.expected * 100).toFixed(1) : 0;
|
||||
var pctNum = parseFloat(pct);
|
||||
var barBg = pctNum >= 100 ? '#52c41a' : pctNum > 0 ? '#1890ff' : '#bfbfbf';
|
||||
html += '<tr>'
|
||||
+ '<td>' + p.carNo + '</td>'
|
||||
+ '<td>' + p.sn + '</td>'
|
||||
+ '<td>' + p.fType + '</td>'
|
||||
+ '<td>' + p.expected + '</td>'
|
||||
+ '<td>' + p.actual + '</td>'
|
||||
+ '<td><span class="progress-bar"><span class="progress-bar-fill" style="width:' + Math.min(pct, 100) + '%;background:' + barBg + '"></span></span>' + pct + '%</td>'
|
||||
+ '<td>' + statusBadge(p.status) + '</td>'
|
||||
+ '<td>' + (p.missingProcs || '--') + '</td>'
|
||||
+ '<td>' + p.fDate + '</td>'
|
||||
+ '<td><span class="btn-detail" onclick="loadProductDetail(\'' + p.fInterID + '\')">详情</span></td>'
|
||||
+ '</tr>';
|
||||
});
|
||||
html += '</tbody>';
|
||||
el.innerHTML = html;
|
||||
renderPagination();
|
||||
}
|
||||
|
||||
function renderPagination() {
|
||||
var total = filteredProducts.length;
|
||||
var totalPages = Math.ceil(total / pageSize);
|
||||
var el = document.getElementById('pagination');
|
||||
if (totalPages <= 1) { el.innerHTML = '<span>共 ' + total + ' 条</span>'; return; }
|
||||
var html = '<span>共 ' + total + ' 条</span>';
|
||||
html += '<button onclick="goPage(1)" ' + (currentPage === 1 ? 'disabled' : '') + '>首页</button>';
|
||||
html += '<button onclick="goPage(' + (currentPage - 1) + ')" ' + (currentPage === 1 ? 'disabled' : '') + '>上一页</button>';
|
||||
for (var i = 1; i <= totalPages; i++) {
|
||||
if (i === 1 || i === totalPages || Math.abs(i - currentPage) <= 2) {
|
||||
html += '<button onclick="goPage(' + i + ')" class="' + (i === currentPage ? 'active' : '') + '">' + i + '</button>';
|
||||
} else if (Math.abs(i - currentPage) === 3) {
|
||||
html += '<span>...</span>';
|
||||
}
|
||||
}
|
||||
html += '<button onclick="goPage(' + (currentPage + 1) + ')" ' + (currentPage === totalPages ? 'disabled' : '') + '>下一页</button>';
|
||||
html += '<button onclick="goPage(' + totalPages + ')" ' + (currentPage === totalPages ? 'disabled' : '') + '>末页</button>';
|
||||
el.innerHTML = html;
|
||||
}
|
||||
|
||||
function goPage(p) { currentPage = p; renderProductTable(); }
|
||||
|
||||
function filterProducts() {
|
||||
if (!machineDetail || !machineDetail.products) return;
|
||||
var kw = document.getElementById('txtSearch').value.trim().toLowerCase();
|
||||
var st = document.getElementById('selStatus').value;
|
||||
var line = document.getElementById('selLine').value;
|
||||
filteredProducts = machineDetail.products.filter(function(p) {
|
||||
var matchKw = !kw || (p.carNo || '').toLowerCase().indexOf(kw) >= 0 || (p.sn || '').toLowerCase().indexOf(kw) >= 0;
|
||||
var matchSt = !st || p.status === st;
|
||||
var matchLine = !line || p.line === line;
|
||||
return matchKw && matchSt && matchLine;
|
||||
});
|
||||
currentPage = 1;
|
||||
renderProductTable();
|
||||
}
|
||||
|
||||
/* ===== 产品扫码详情弹窗 ===== */
|
||||
function showProductDetailModal(data) {
|
||||
var html = '<div style="margin-bottom:16px;display:flex;gap:24px;font-size:13px;flex-wrap:wrap;">'
|
||||
+ '<div><span style="color:#999">车号:</span><b>' + data.carNo + '</b></div>'
|
||||
+ '<div><span style="color:#999">SN:</span><b>' + data.sn + '</b></div>'
|
||||
+ '<div><span style="color:#999">机型:</span><b>' + data.fType + '</b></div>'
|
||||
+ '<div><span style="color:#999">状态:</span>' + statusBadge(data.status) + '</div>'
|
||||
+ '<div><span style="color:#999">应扫总数:</span><b>' + data.expected + '</b></div>'
|
||||
+ '<div><span style="color:#999">实扫总数:</span><b>' + data.actual + '</b></div>'
|
||||
+ '<div><span style="color:#999">记录时间:</span>' + data.fDate + '</div>'
|
||||
+ '</div>';
|
||||
|
||||
if (data.processes && data.processes.length > 0) {
|
||||
html += '<table class="trace-table"><thead><tr>'
|
||||
+ '<th>序号</th><th>工序编号</th><th>工序名称</th><th>扫码数量</th><th>扫码状态</th>'
|
||||
+ '</tr></thead><tbody>';
|
||||
data.processes.forEach(function(p, idx) {
|
||||
html += '<tr>'
|
||||
+ '<td>' + (idx + 1) + '</td>'
|
||||
+ '<td>' + p.code + '</td>'
|
||||
+ '<td>' + p.name + '</td>'
|
||||
+ '<td class="' + (p.scanned ? 'scanned' : 'not-scanned') + '">' + p.qty + '</td>'
|
||||
+ '<td>' + (p.scanned ? '<span class="status-badge normal">已扫码</span>' : '<span class="status-badge notstart">未扫码</span>') + '</td>'
|
||||
+ '</tr>';
|
||||
});
|
||||
html += '</tbody></table>';
|
||||
} else {
|
||||
html += '<div class="empty-state">暂无工序扫码记录</div>';
|
||||
}
|
||||
|
||||
document.getElementById('modalTitle').textContent = '扫码追溯详情 - ' + data.carNo;
|
||||
document.getElementById('modalBody').innerHTML = html;
|
||||
document.getElementById('modalOverlay').classList.add('show');
|
||||
}
|
||||
|
||||
function closeModal() { document.getElementById('modalOverlay').classList.remove('show'); }
|
||||
|
||||
/* ===== 近一周扫码率折线图(SVG,百分比) ===== */
|
||||
function renderTrendChart(containerId, trend) {
|
||||
var el = document.getElementById(containerId);
|
||||
if (!el || !trend || trend.length === 0) {
|
||||
if (el) el.innerHTML = '<div class="empty-state" style="padding:30px">暂无近一周扫码数据</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
var W = el.clientWidth || 700;
|
||||
var H = 220;
|
||||
var padL = 44, padR = 16, padT = 16, padB = 36;
|
||||
var plotW = W - padL - padR;
|
||||
var plotH = H - padT - padB;
|
||||
|
||||
// 取每个点的扫码率(%)
|
||||
var getVal = function(t) { return t.ratio || 0; };
|
||||
|
||||
// Y轴范围:0 ~ 上限(至少100,向上取整到50的倍数)
|
||||
var maxVal = 100;
|
||||
trend.forEach(function(t) { var v = getVal(t); if (v > maxVal) maxVal = v; });
|
||||
maxVal = Math.ceil(maxVal / 50) * 50;
|
||||
|
||||
var n = trend.length;
|
||||
var stepX = n > 1 ? plotW / (n - 1) : 0;
|
||||
var yFor = function(v) { return padT + plotH - (v / maxVal) * plotH; };
|
||||
var xFor = function(i) { return padL + i * stepX; };
|
||||
|
||||
var html = '<svg width="' + W + '" height="' + H + '" style="display:block">';
|
||||
|
||||
// 网格线 + Y轴刻度(5等分)
|
||||
var yTicks = [0, 0.25, 0.5, 0.75, 1];
|
||||
yTicks.forEach(function(r) {
|
||||
var y = yFor(maxVal * r);
|
||||
html += '<line x1="' + padL + '" y1="' + y + '" x2="' + (W - padR) + '" y2="' + y + '" stroke="#f0f0f0" stroke-width="1"/>';
|
||||
html += '<text x="' + (padL - 6) + '" y="' + (y + 4) + '" text-anchor="end" font-size="11" fill="#999">' + Math.round(maxVal * r) + '%</text>';
|
||||
});
|
||||
|
||||
// 基准线 100%
|
||||
if (maxVal >= 100) {
|
||||
var y100 = yFor(100);
|
||||
html += '<line x1="' + padL + '" y1="' + y100 + '" x2="' + (W - padR) + '" y2="' + y100 + '" stroke="#52c41a" stroke-width="1" stroke-dasharray="4,4"/>';
|
||||
}
|
||||
|
||||
// X轴标签
|
||||
trend.forEach(function(t, i) {
|
||||
var x = xFor(i);
|
||||
html += '<text x="' + x + '" y="' + (H - padB + 16) + '" text-anchor="middle" font-size="11" fill="#666">' + t.label + '</text>';
|
||||
});
|
||||
|
||||
// 折线路径
|
||||
var linePath = '', areaPath = 'M ' + padL + ' ' + yFor(0);
|
||||
trend.forEach(function(t, i) {
|
||||
var x = xFor(i), y = yFor(getVal(t));
|
||||
linePath += (i === 0 ? 'M ' : 'L ') + x + ' ' + y + ' ';
|
||||
areaPath += ' L ' + x + ' ' + y;
|
||||
});
|
||||
areaPath += ' L ' + xFor(n - 1) + ' ' + yFor(0) + ' Z';
|
||||
|
||||
html += '<path d="' + areaPath + '" fill="rgba(24,144,255,0.10)" stroke="none"/>';
|
||||
html += '<path d="' + linePath + '" fill="none" stroke="#1890ff" stroke-width="2.5" stroke-linejoin="round" stroke-linecap="round"/>';
|
||||
|
||||
// 数据点 + tooltip
|
||||
trend.forEach(function(t, i) {
|
||||
var x = xFor(i), y = yFor(getVal(t));
|
||||
html += '<circle cx="' + x + '" cy="' + y + '" r="4" fill="#fff" stroke="#1890ff" stroke-width="2" style="cursor:pointer" data-label="' + t.label + '" data-ratio="' + getVal(t) + '" data-need="' + (t.needQty || 0) + '" data-reality="' + (t.realityQty || 0) + '"/>';
|
||||
});
|
||||
|
||||
html += '</svg>';
|
||||
html += '<div class="trend-tooltip" id="trendTooltip"></div>';
|
||||
|
||||
el.innerHTML = html;
|
||||
|
||||
// tooltip 交互
|
||||
var tooltip = document.getElementById('trendTooltip');
|
||||
el.querySelectorAll('circle').forEach(function(c) {
|
||||
c.addEventListener('mousemove', function(e) {
|
||||
tooltip.innerHTML = '<b>' + c.getAttribute('data-label') + '</b><br>'
|
||||
+ '实扫 ' + c.getAttribute('data-reality') + ' / 应扫 ' + c.getAttribute('data-need') + '<br>'
|
||||
+ '扫码率 ' + c.getAttribute('data-ratio') + '%';
|
||||
tooltip.style.left = (c.getAttribute('cx') - 50) + 'px';
|
||||
tooltip.style.top = (c.getAttribute('cy') - 34) + 'px';
|
||||
tooltip.classList.add('show');
|
||||
});
|
||||
c.addEventListener('mouseleave', function() { tooltip.classList.remove('show'); });
|
||||
});
|
||||
}
|
||||
|
||||
/* ===== 视图切换 ===== */
|
||||
function showCompareView() {
|
||||
document.querySelectorAll('.tab').forEach(function(t) { t.classList.remove('active'); });
|
||||
var firstTab = document.querySelector('.tab');
|
||||
if (firstTab) firstTab.classList.add('active');
|
||||
document.getElementById('compareView').style.display = '';
|
||||
document.getElementById('detailView').style.display = 'none';
|
||||
currentMachine = null;
|
||||
renderCompareView();
|
||||
}
|
||||
|
||||
function showDetailView(fType) {
|
||||
document.querySelectorAll('.tab').forEach(function(t) { t.classList.remove('active'); });
|
||||
var tabs = document.querySelectorAll('.tab');
|
||||
if (dashboardData) {
|
||||
for (var i = 0; i < dashboardData.machines.length; i++) {
|
||||
if (dashboardData.machines[i].fType === fType && tabs[i + 1]) {
|
||||
tabs[i + 1].classList.add('active');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
document.getElementById('compareView').style.display = 'none';
|
||||
document.getElementById('detailView').style.display = '';
|
||||
loadMachineDetail(fType);
|
||||
}
|
||||
|
||||
function refreshData() {
|
||||
if (currentMachine) {
|
||||
loadMachineDetail(currentMachine);
|
||||
} else {
|
||||
loadDashboardData(function() { renderCompareView(); });
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== 实时时间 ===== */
|
||||
function updateTime() {
|
||||
var now = new Date();
|
||||
var pad = function(n) { return n < 10 ? '0' + n : n; };
|
||||
document.getElementById('curTime').textContent =
|
||||
now.getFullYear() + '-' + pad(now.getMonth() + 1) + '-' + pad(now.getDate()) + ' '
|
||||
+ pad(now.getHours()) + ':' + pad(now.getMinutes()) + ':' + pad(now.getSeconds());
|
||||
}
|
||||
|
||||
/* ===== 页面访问控制:Produce02;导航栏由公共组件提供 ===== */
|
||||
(function() {
|
||||
var userData = sessionStorage.getItem('gx_user');
|
||||
if (!userData) { window.location.href = '../../login.html'; return; }
|
||||
try {
|
||||
var user = JSON.parse(userData);
|
||||
var roles = user.roleNumbers || [];
|
||||
if (roles.indexOf('Produce02') < 0) {
|
||||
alert('当前用户无权限访问MES看板');
|
||||
sessionStorage.removeItem('gx_user');
|
||||
window.location.href = '../../login.html';
|
||||
return;
|
||||
}
|
||||
} catch(e) {
|
||||
alert('登录信息异常,请重新登录');
|
||||
window.location.href = '../../login.html';
|
||||
return;
|
||||
}
|
||||
|
||||
// 初始化
|
||||
updateTime();
|
||||
setInterval(updateTime, 1000);
|
||||
loadDashboardData(openDefaultMachine);
|
||||
startAutoRefresh();
|
||||
})();
|
||||
|
||||
/* ===== 定时自动刷新 ===== */
|
||||
function startAutoRefresh() {
|
||||
apiGet('../../api/Mes/GetConfig', function(config) {
|
||||
var seconds = (config && config.autoRefreshSeconds) ? config.autoRefreshSeconds : 600;
|
||||
if (seconds <= 0) {
|
||||
console.log('自动刷新已关闭');
|
||||
return;
|
||||
}
|
||||
console.log('看板每 ' + seconds + ' 秒自动刷新一次');
|
||||
setInterval(function() {
|
||||
refreshData();
|
||||
}, seconds * 1000);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<!-- 公共侧边栏组件(菜单维护点:View/common/nav.js) -->
|
||||
<script src="../common/nav.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
/* ============================================
|
||||
* GX-WMS 通用列表(Grid)组件样式
|
||||
* 与 grid.js 配套使用
|
||||
* ============================================ */
|
||||
|
||||
.gx-grid { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); overflow-x: auto; max-height: calc(100vh - 220px); overflow-y: auto; }
|
||||
.gx-grid table { width: 100%; border-collapse: collapse; min-width: 2400px; table-layout: fixed; }
|
||||
.gx-grid thead { background: #f7f9fc; }
|
||||
.gx-grid thead th { position: sticky; top: 0; background: #f7f9fc; z-index: 5; text-align: left; padding: 9px 8px; font-size: 12px; color: #606266; font-weight: 600; border-bottom: 2px solid #ebeef5; white-space: nowrap; border-right: 1px solid #ebeef5; position: relative; user-select: none; }
|
||||
.gx-grid thead th .gx-resizer { position: absolute; right: 0; top: 0; height: 100%; width: 6px; cursor: col-resize; user-select: none; }
|
||||
.gx-grid thead th .gx-resizer:hover { background: #409eff; }
|
||||
.gx-grid thead th .gx-resizer.active { background: #409eff; }
|
||||
.gx-grid tbody td { padding: 8px; font-size: 12px; color: #303133; border-bottom: 1px solid #f0f2f5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid #f5f7fa; }
|
||||
.gx-grid tbody tr:hover { background: #f5f7fa; }
|
||||
.gx-grid tbody tr:nth-child(even) { background: #fafbfc; }
|
||||
.gx-grid tbody tr:nth-child(even):hover { background: #f5f7fa; }
|
||||
|
||||
/* 风险标签 */
|
||||
.gx-grid .tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
|
||||
.gx-grid .tag.broken { background: #fef0f0; color: #f56c6c; }
|
||||
.gx-grid .tag.warn { background: #fdf6ec; color: #e6a23c; }
|
||||
.gx-grid .tag.safe { background: #f0f9eb; color: #67c23a; }
|
||||
.gx-grid .tag.empty { background: #f4f4f5; color: #909399; }
|
||||
|
||||
/* 数字 */
|
||||
.gx-grid .num { font-family: 'Consolas','Monaco',monospace; }
|
||||
.gx-grid .num.zero { color: #c0c4cc; }
|
||||
.gx-grid .num.neg { color: #f56c6c; font-weight: 600; }
|
||||
|
||||
/* 占位符 */
|
||||
.gx-grid .muted { color: #909399; }
|
||||
Executable
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* ============================================
|
||||
* GX-WMS 通用列表(Grid)组件
|
||||
*
|
||||
* 功能:
|
||||
* 1. 表头固定(上下滚动时不消失)
|
||||
* 2. 列宽可拖动(拖动表头右边调整,列与列之间互不影响)
|
||||
* 3. 行 hover 高亮
|
||||
* 4. 风险标签自动着色(断线/预警/安全)
|
||||
* 5. 数字自动格式化(0 灰色、负数红色)
|
||||
* 6. 横向滚动自然
|
||||
* 7. 自动重新绑定(数据刷新后)
|
||||
*
|
||||
* 用法:
|
||||
* 1. 引入 CSS:<link rel="stylesheet" href="../common/grid.css">
|
||||
* 2. 引入 JS:<script src="../common/grid.js"></script>
|
||||
* 3. HTML 结构:
|
||||
* <div id="myGrid" class="gx-grid">
|
||||
* <table>
|
||||
* <thead><tr><th style="width:80px">列名</th>...</tr></thead>
|
||||
* <tbody id="myTbody"></tbody>
|
||||
* </table>
|
||||
* </div>
|
||||
* 4. JS 渲染后调用:Grid.bind('myGrid');
|
||||
* 5. 工具函数:
|
||||
* Grid.riskTag('断线') => <span class="tag broken">断线</span>
|
||||
* Grid.num(120) => <span class="num">120</span>
|
||||
* Grid.num(0) => <span class="num zero">0</span>
|
||||
* Grid.num(-5) => <span class="num neg">-5</span>
|
||||
* Grid.muted('未填写') => <span class="muted">未填写</span>
|
||||
* ============================================
|
||||
*/
|
||||
|
||||
const Grid = (function() {
|
||||
/**
|
||||
* 绑定列宽拖动 + 重新绑定的工具
|
||||
* @param {string} containerId - 容器元素的 id(含 class="gx-grid")
|
||||
*/
|
||||
function bind(containerId) {
|
||||
const wrap = document.getElementById(containerId);
|
||||
if (!wrap) return;
|
||||
const table = wrap.querySelector('table');
|
||||
if (!table) return;
|
||||
|
||||
// 确保有 <colgroup>,按列设置宽度(改 col 宽度,浏览器自动应用到整列,无需遍历 td,性能好)
|
||||
let colgroup = table.querySelector('colgroup');
|
||||
if (!colgroup) {
|
||||
colgroup = document.createElement('colgroup');
|
||||
table.insertBefore(colgroup, table.firstChild);
|
||||
}
|
||||
const theadRow = table.querySelector('thead tr');
|
||||
const colCount = theadRow ? theadRow.children.length : 0;
|
||||
const cols = [];
|
||||
for (let i = 0; i < colCount; i++) {
|
||||
let col = colgroup.children[i];
|
||||
if (!col) {
|
||||
col = document.createElement('col');
|
||||
colgroup.appendChild(col);
|
||||
}
|
||||
cols.push(col);
|
||||
}
|
||||
|
||||
const ths = wrap.querySelectorAll('thead th');
|
||||
ths.forEach((th, idx) => {
|
||||
if (th.querySelector('.gx-resizer')) return;
|
||||
// 用 th 当前宽度初始化 col 宽度(保持原列宽不被 colgroup 覆盖)
|
||||
if (cols[idx]) {
|
||||
const w = th.style.width || th.getBoundingClientRect().width + 'px';
|
||||
cols[idx].style.width = w;
|
||||
}
|
||||
const r = document.createElement('div');
|
||||
r.className = 'gx-resizer';
|
||||
th.appendChild(r);
|
||||
|
||||
r.addEventListener('mousedown', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const startX = e.pageX;
|
||||
const startW = th.getBoundingClientRect().width;
|
||||
let raf = null;
|
||||
let pendingW = startW;
|
||||
r.classList.add('active');
|
||||
|
||||
const onMove = function(ev) {
|
||||
const dx = ev.pageX - startX;
|
||||
pendingW = Math.max(8, startW + dx); // 最小 8px,允许一直收缩到很小
|
||||
if (raf) return; // 已有待处理的帧,跳过(该帧会用最新 pendingW)
|
||||
raf = requestAnimationFrame(function() {
|
||||
raf = null;
|
||||
if (cols[idx]) cols[idx].style.width = pendingW + 'px';
|
||||
th.style.width = pendingW + 'px'; // 同步 th,保证表头与列内容对齐
|
||||
});
|
||||
};
|
||||
const onUp = function() {
|
||||
if (raf) { cancelAnimationFrame(raf); raf = null; }
|
||||
// 最终确保应用一次
|
||||
if (cols[idx]) cols[idx].style.width = pendingW + 'px';
|
||||
th.style.width = pendingW + 'px';
|
||||
r.classList.remove('active');
|
||||
document.removeEventListener('mousemove', onMove);
|
||||
document.removeEventListener('mouseup', onUp);
|
||||
};
|
||||
document.addEventListener('mousemove', onMove);
|
||||
document.addEventListener('mouseup', onUp);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 风险标签
|
||||
*/
|
||||
function riskTag(risk) {
|
||||
if (!risk) return '<span class="tag empty">未判定</span>';
|
||||
const cls = ({'断线':'broken','预警':'warn','安全':'safe'})[risk] || 'empty';
|
||||
return '<span class="tag ' + cls + '">' + risk + '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字格式化
|
||||
*/
|
||||
function num(v) {
|
||||
if (v === null || v === undefined || v === '' || v === '-') return '<span class="muted">-</span>';
|
||||
const n = Number(v);
|
||||
if (isNaN(n)) return v;
|
||||
if (n === 0) return '<span class="num zero">0</span>';
|
||||
if (n < 0) return '<span class="num neg">' + n + '</span>';
|
||||
return '<span class="num">' + n + '</span>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 占位符
|
||||
*/
|
||||
function muted(v, placeholder) {
|
||||
if (!v) return '<span class="muted">' + (placeholder || '-') + '</span>';
|
||||
return v;
|
||||
}
|
||||
|
||||
return { bind: bind, riskTag: riskTag, num: num, muted: muted };
|
||||
})();
|
||||
Executable
+246
@@ -0,0 +1,246 @@
|
||||
/* GX-WMS 左侧侧边栏导航样式 */
|
||||
:root { --sidebar-width: 240px; --sidebar-collapsed: 60px; }
|
||||
|
||||
body.with-sidebar { padding-left: var(--sidebar-width); transition: padding-left .25s ease; }
|
||||
body.sidebar-collapsed.with-sidebar { padding-left: var(--sidebar-collapsed); }
|
||||
|
||||
#sidebar {
|
||||
position: fixed;
|
||||
top: 0; left: 0; bottom: 0;
|
||||
width: var(--sidebar-width);
|
||||
background: #1e293b;
|
||||
color: #cbd5e1;
|
||||
overflow-y: auto;
|
||||
box-shadow: 2px 0 8px rgba(0,0,0,.08);
|
||||
z-index: 1000;
|
||||
font-family: 'Microsoft YaHei','PingFang SC',sans-serif;
|
||||
transition: width .25s ease;
|
||||
}
|
||||
body.sidebar-collapsed #sidebar { width: var(--sidebar-collapsed); }
|
||||
|
||||
#sidebar::-webkit-scrollbar { width: 6px; }
|
||||
#sidebar::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
|
||||
#sidebar::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
/* 收缩按钮 */
|
||||
.sidebar-toggle {
|
||||
position: absolute;
|
||||
top: 16px; right: 10px;
|
||||
width: 26px; height: 26px;
|
||||
border: none; border-radius: 4px;
|
||||
background: transparent;
|
||||
color: #94a3b8;
|
||||
font-size: 15px;
|
||||
cursor: pointer;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
transition: all .15s;
|
||||
}
|
||||
.sidebar-toggle:hover { background: #334155; color: #fff; }
|
||||
body.sidebar-collapsed .sidebar-toggle { right: 17px; }
|
||||
|
||||
/* 用户信息区 */
|
||||
.sidebar-user {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 16px 14px;
|
||||
border-bottom: 1px solid #334155;
|
||||
background: #0f172a;
|
||||
}
|
||||
.sidebar-user .avatar {
|
||||
width: 38px; height: 38px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg,#3b82f6,#1d4ed8);
|
||||
color: #fff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.sidebar-user .user-text { flex: 1; min-width: 0; }
|
||||
.sidebar-user .user-name { font-size: 14px; color: #e2e8f0; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.sidebar-user .user-action { font-size: 12px; margin-top: 2px; }
|
||||
.sidebar-user .user-action a { color: #94a3b8; text-decoration: none; }
|
||||
.sidebar-user .user-action a:hover { color: #60a5fa; }
|
||||
|
||||
/* 菜单容器 */
|
||||
.sidebar-menu { padding: 8px 0; }
|
||||
|
||||
/* 分组标题(可折叠) */
|
||||
.menu-group-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 11px 16px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
color: #cbd5e1;
|
||||
user-select: none;
|
||||
transition: background .15s;
|
||||
}
|
||||
.menu-group-title:hover { background: #334155; color: #fff; }
|
||||
.menu-group-title .menu-icon {
|
||||
width: 22px;
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
text-align: center;
|
||||
}
|
||||
.menu-group-title .menu-label { flex: 1; margin-left: 10px; }
|
||||
.menu-group-title .menu-arrow {
|
||||
font-size: 11px;
|
||||
color: #64748b;
|
||||
transition: transform .2s;
|
||||
}
|
||||
.menu-arrow.rotate { transform: rotate(-180deg); color: #94a3b8; }
|
||||
.menu-group.expanded > .menu-group-title {
|
||||
background: #334155;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* 子菜单容器 */
|
||||
.menu-children {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height .25s ease;
|
||||
background: #0f172a;
|
||||
}
|
||||
.menu-group.expanded > .menu-children {
|
||||
max-height: 1200px;
|
||||
}
|
||||
|
||||
/* 子菜单项 */
|
||||
.menu-child {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 9px 16px 9px 44px;
|
||||
color: #94a3b8;
|
||||
text-decoration: none;
|
||||
font-size: 13px;
|
||||
transition: all .15s;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
.menu-child:hover { background: #1e293b; color: #e2e8f0; }
|
||||
.menu-child.active {
|
||||
background: #1e3a8a;
|
||||
color: #fff;
|
||||
border-left-color: #3b82f6;
|
||||
font-weight: 500;
|
||||
}
|
||||
.menu-child-dot {
|
||||
width: 14px;
|
||||
color: #475569;
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.menu-child.active .menu-child-dot { color: #60a5fa; }
|
||||
|
||||
/* ===== 子分组(多级菜单,支持任意层级) ===== */
|
||||
.menu-subgroup-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px 16px 10px 22px;
|
||||
color: #94a3b8;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
transition: all .15s;
|
||||
}
|
||||
.menu-subgroup-title:hover { background: #334155; color: #fff; }
|
||||
.menu-subgroup-title .menu-icon { width: 20px; font-size: 14px; text-align: center; }
|
||||
.menu-subgroup-title .menu-label { flex: 1; margin-left: 8px; }
|
||||
.menu-subgroup-title .menu-arrow { font-size: 10px; color: #64748b; margin-right: 10px; transition: transform .2s; }
|
||||
.menu-subgroup-children {
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height .25s ease;
|
||||
}
|
||||
.menu-subgroup.expanded > .menu-subgroup-children { max-height: 1000px; }
|
||||
|
||||
/* 多级缩进:按层级加深 */
|
||||
.menu-child[data-depth="2"] { padding-left: 58px; }
|
||||
.menu-child[data-depth="3"] { padding-left: 72px; }
|
||||
.menu-child[data-depth="4"] { padding-left: 86px; }
|
||||
.menu-subgroup-title[data-depth="2"] { padding-left: 34px; }
|
||||
.menu-subgroup-title[data-depth="3"] { padding-left: 48px; }
|
||||
.menu-subgroup-title[data-depth="4"] { padding-left: 62px; }
|
||||
|
||||
/* 单项菜单(无子项) */
|
||||
.menu-single {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 11px 16px;
|
||||
color: #cbd5e1;
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
transition: background .15s;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
.menu-single:hover { background: #334155; color: #fff; }
|
||||
.menu-single.active {
|
||||
background: #1e3a8a;
|
||||
color: #fff;
|
||||
border-left-color: #3b82f6;
|
||||
font-weight: 500;
|
||||
}
|
||||
.menu-single .menu-icon {
|
||||
width: 22px;
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
text-align: center;
|
||||
}
|
||||
.menu-single .menu-label { margin-left: 10px; }
|
||||
|
||||
/* ===== 折叠状态(只显示图标) ===== */
|
||||
body.sidebar-collapsed .sidebar-user { justify-content: center; padding: 16px 0; }
|
||||
body.sidebar-collapsed .sidebar-user .avatar { width: 34px; height: 34px; font-size: 14px; }
|
||||
body.sidebar-collapsed .sidebar-user .user-text { display: none; }
|
||||
|
||||
body.sidebar-collapsed .menu-group-title { justify-content: center; padding: 13px 0; }
|
||||
body.sidebar-collapsed .menu-group-title .menu-label { display: none; }
|
||||
body.sidebar-collapsed .menu-group-title .menu-arrow { display: none; }
|
||||
body.sidebar-collapsed .menu-group-title .menu-icon { width: auto; }
|
||||
|
||||
body.sidebar-collapsed .menu-children { display: none; }
|
||||
|
||||
body.sidebar-collapsed .menu-single { justify-content: center; padding: 13px 0; }
|
||||
body.sidebar-collapsed .menu-single .menu-label { display: none; }
|
||||
body.sidebar-collapsed .menu-single .menu-icon { width: auto; }
|
||||
|
||||
/* 折叠时菜单项 hover 提示 */
|
||||
body.sidebar-collapsed .menu-group-title { position: relative; }
|
||||
body.sidebar-collapsed .menu-group-title:hover::after {
|
||||
content: attr(data-title);
|
||||
position: absolute;
|
||||
left: calc(var(--sidebar-collapsed) + 8px);
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
padding: 6px 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
z-index: 1001;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,.3);
|
||||
pointer-events: none;
|
||||
}
|
||||
body.sidebar-collapsed .menu-single { position: relative; }
|
||||
body.sidebar-collapsed .menu-single:hover::after {
|
||||
content: attr(data-title);
|
||||
position: absolute;
|
||||
left: calc(var(--sidebar-collapsed) + 8px);
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: #0f172a;
|
||||
color: #e2e8f0;
|
||||
padding: 6px 12px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
z-index: 1001;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,.3);
|
||||
pointer-events: none;
|
||||
}
|
||||
Executable
+335
@@ -0,0 +1,335 @@
|
||||
/**
|
||||
* ============================================
|
||||
* GX-WMS 左侧侧边栏导航组件
|
||||
* 用法:
|
||||
* 1. 页面 <head> 引入 nav.css:<link rel="stylesheet" href=".../common/nav.css">
|
||||
* 2. <body> 顶部加一个容器:<div id="sidebar"></div>
|
||||
* 3. 主内容区域包裹在 <div class="main-content"> 中
|
||||
* 4. 页面底部引入本JS,自动初始化
|
||||
*
|
||||
* 维护点:仅修改本文件的 MENU_GROUPS 配置
|
||||
* ============================================
|
||||
*/
|
||||
|
||||
// ---------- 应用根路径自动探测 ----------
|
||||
// 支持 IIS 子目录部署(如 /WebApi,名称可变)和 VS 调试(网站根目录)两种场景。
|
||||
// 原理:根据本脚本自身 URL(<应用根>/View/common/nav.js)反推出应用根前缀。
|
||||
// - 部署在子目录时自动得到 '/WebApi' 之类前缀
|
||||
// - VS 调试 / 根目录部署时为空字符串,不影响原行为
|
||||
var APP_BASE = '';
|
||||
(function () {
|
||||
try {
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
for (var i = scripts.length - 1; i >= 0; i--) {
|
||||
var src = scripts[i].getAttribute('src') || '';
|
||||
if (src.indexOf('nav.js') >= 0) {
|
||||
var a = document.createElement('a');
|
||||
a.href = src;
|
||||
var p = a.pathname.replace(/\\/g, '/');
|
||||
var idx = p.indexOf('/View/common/nav.js');
|
||||
if (idx >= 0) APP_BASE = p.substring(0, idx);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (e) { APP_BASE = ''; }
|
||||
window.APP_BASE = APP_BASE;
|
||||
})();
|
||||
|
||||
// ---------- 菜单配置(唯一维护点) ----------
|
||||
// 顶级项:{ title, icon, role, children? } 有 children = 分组
|
||||
// 子项:{ title, href, role }
|
||||
// href 使用绝对路径(以 / 开头),渲染时会自动加上应用根前缀 APP_BASE
|
||||
var MENU_GROUPS = [
|
||||
{ title: '首页', icon: '🏠', href: '/home.html', hideOnHome: true },
|
||||
{
|
||||
title: '生产管理', icon: '🏭', role: 'Purchase01',
|
||||
children: [
|
||||
{ title: 'BOM主数据', href: '/View/Delivery/bom_master.html', icon: '🧩', role: 'Purchase01' },
|
||||
{ title: '生产排程计划', href: '/View/Delivery/schedule.html', icon: '📅', role: 'Purchase01' },
|
||||
{ title: '生产排程看板', href: '/View/Delivery/schedule_board.html', icon: '📊', role: 'Purchase01' },
|
||||
{ title: '线边仓库存', href: '/View/Delivery/production_delivery.html', icon: '🏬', role: 'Purchase01' },
|
||||
{ title: 'MES追溯看板', href: '/View/MES/mes_dashboard.html', icon: '🔍', role: 'Produce02' }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '采购管理', icon: '📋', role: ['YF01', 'Purchase01'],
|
||||
children: [
|
||||
{
|
||||
title: '采购申请管理', icon: '📦', role: ['YF01', 'Purchase01'],
|
||||
children: [
|
||||
{ title: '采购申请管理', href: '/procurement.html', icon: '📋', role: 'Purchase01' },
|
||||
{ title: '研发采购全链路看板', href: '/procurement_board_list.html', icon: '📈', role: ['YF01', 'Purchase01'] },
|
||||
{ title: '研发订单考核时效看板', href: '/procurement_audit_leadtime.html', icon: '⏱️', role: ['YF01', 'Purchase01'] }
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '采购物料交付', icon: '🚚', role: 'Purchase01',
|
||||
children: [
|
||||
{ title: '采购物料交付', href: '/View/Delivery/material_delivery.html', icon: '🚚', role: 'Purchase01' },
|
||||
{ title: '采购物料交付计划看板', href: '/View/Delivery/delivery_dashboard.html', icon: '📊', role: 'Purchase01' }
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'CRM', icon: '📊', role: 'CRM01',
|
||||
children: [
|
||||
{ title: '金蝶-CRM产品同步', href: '/index.html', icon: '🔄', role: 'CRM01' },
|
||||
{ title: '金蝶-CRM销售订单新变更单同步', href: '/crm_sale_order_sync.html', icon: '📄', role: 'CRM01' }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// ============================================
|
||||
// 通用逻辑,一般无需修改
|
||||
// ============================================
|
||||
|
||||
function getLoginUser() {
|
||||
try {
|
||||
var raw = sessionStorage.getItem('gx_user');
|
||||
if (!raw) return null;
|
||||
return JSON.parse(raw);
|
||||
} catch (e) { return null; }
|
||||
}
|
||||
|
||||
function hasRole(role) {
|
||||
if (!role) return true;
|
||||
// 支持 role 为数组:任一角色命中即通过(一个功能可分给多个角色)
|
||||
if (Array.isArray(role)) {
|
||||
for (var i = 0; i < role.length; i++) {
|
||||
if (hasRole(role[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var user = getLoginUser();
|
||||
if (!user) return false;
|
||||
var rn = user.roleNumbers;
|
||||
if (Array.isArray(rn)) {
|
||||
if (rn.indexOf(role) >= 0) return true;
|
||||
for (var i = 0; i < rn.length; i++) {
|
||||
if (String(rn[i]).toUpperCase() === String(role).toUpperCase()) return true;
|
||||
}
|
||||
}
|
||||
var rs = user.roles;
|
||||
if (Array.isArray(rs)) {
|
||||
for (var j = 0; j < rs.length; j++) {
|
||||
var item = rs[j] || {};
|
||||
if (String(item.roleNumber || '').toUpperCase() === String(role).toUpperCase()) return true;
|
||||
if (String(item.roleName || '').toUpperCase() === String(role).toUpperCase()) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function isActive(href) {
|
||||
try {
|
||||
var u = new URL(APP_BASE + href, window.location.origin);
|
||||
return window.location.pathname.replace(/\\/g, '/').indexOf(u.pathname) >= 0;
|
||||
} catch (e) { return false; }
|
||||
}
|
||||
|
||||
function getLoginPath() {
|
||||
// 用 APP_BASE(自动探测的应用根前缀)拼接登录页地址:
|
||||
// - VS 调试/根目录部署:APP_BASE 为空,返回 '/login.html'
|
||||
// - 子目录部署(如 /WebApi):返回 '/WebApi/login.html'
|
||||
return APP_BASE + '/login.html';
|
||||
}
|
||||
|
||||
function logout() {
|
||||
sessionStorage.removeItem('gx_user');
|
||||
window.location.href = getLoginPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归判断菜单项(含子孙)是否有激活项
|
||||
*/
|
||||
function isItemActive(item) {
|
||||
if (item.href && isActive(item.href)) return true;
|
||||
if (item.children) {
|
||||
for (var i = 0; i < item.children.length; i++) {
|
||||
if (isItemActive(item.children[i])) return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归判断菜单项是否有可见(有权限)的子孙
|
||||
*/
|
||||
function hasVisibleItem(item) {
|
||||
if (!hasRole(item.role)) return false;
|
||||
if (!item.children || !item.children.length) return true;
|
||||
for (var i = 0; i < item.children.length; i++) {
|
||||
if (hasVisibleItem(item.children[i])) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归渲染子菜单项(支持任意层级)
|
||||
* items: 菜单配置数组;depth: 当前层级(从1开始)
|
||||
*/
|
||||
function renderSubItems(items, depth) {
|
||||
var html = '';
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var it = items[i];
|
||||
if (!hasVisibleItem(it)) continue;
|
||||
if (it.children && it.children.length) {
|
||||
// 子分组(可继续递归)
|
||||
var subActive = isItemActive(it) ? ' expanded' : '';
|
||||
var subRotate = isItemActive(it) ? ' rotate' : '';
|
||||
html += '<div class="menu-subgroup' + subActive + '" data-depth="' + depth + '">'
|
||||
+ ' <div class="menu-subgroup-title" onclick="toggleSubGroup(this)" data-title="' + it.title + '">'
|
||||
+ ' <span class="menu-icon">' + (it.icon || '') + '</span>'
|
||||
+ ' <span class="menu-label">' + it.title + '</span>'
|
||||
+ ' <span class="menu-arrow' + subRotate + '">▾</span>'
|
||||
+ ' </div>'
|
||||
+ ' <div class="menu-subgroup-children">'
|
||||
+ renderSubItems(it.children, depth + 1)
|
||||
+ ' </div>'
|
||||
+ '</div>';
|
||||
} else {
|
||||
// 叶子项
|
||||
var activeCls = isActive(it.href) ? ' active' : '';
|
||||
html += '<a class="menu-child" data-depth="' + depth + '" href="' + APP_BASE + it.href + '" data-title="' + it.title + '">'
|
||||
+ ' <span class="menu-child-dot">•</span>'
|
||||
+ ' <span class="menu-label">' + it.title + '</span>'
|
||||
+ '</a>';
|
||||
}
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换子分组展开/收起
|
||||
*/
|
||||
function toggleSubGroup(titleEl) {
|
||||
var sub = titleEl.parentNode;
|
||||
if (!sub) return;
|
||||
sub.classList.toggle('expanded');
|
||||
var arrow = titleEl.querySelector('.menu-arrow');
|
||||
if (arrow) arrow.classList.toggle('rotate');
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染侧边栏
|
||||
*/
|
||||
function renderSidebar() {
|
||||
var user = getLoginUser();
|
||||
if (!user) {
|
||||
if (window.location.href.indexOf('login.html') < 0) {
|
||||
window.location.href = getLoginPath();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var html = '';
|
||||
// 收缩按钮
|
||||
html += '<button class="sidebar-toggle" title="收起/展开菜单" onclick="toggleSidebar()">☰</button>';
|
||||
// 用户信息区
|
||||
var name = user.userName || user.userId || user.name || '用户';
|
||||
html += '<div class="sidebar-user">'
|
||||
+ '<div class="avatar">' + (name || '?').charAt(0) + '</div>'
|
||||
+ '<div class="user-text">'
|
||||
+ ' <div class="user-name">' + name + '</div>'
|
||||
+ ' <div class="user-action"><a href="javascript:void(0)" onclick="logout()">退出登录</a></div>'
|
||||
+ '</div>'
|
||||
+ '</div>';
|
||||
|
||||
// 找出当前页面所在分组(用于默认展开)
|
||||
var activeGroupIdx = -1;
|
||||
var activeChildIdx = -1;
|
||||
|
||||
// 渲染菜单
|
||||
html += '<div class="sidebar-menu">';
|
||||
for (var i = 0; i < MENU_GROUPS.length; i++) {
|
||||
var g = MENU_GROUPS[i];
|
||||
|
||||
if (g.children && g.children.length) {
|
||||
// 分组自身有角色限制时先过滤(未配置 role 则不限制)
|
||||
if (g.role && !hasRole(g.role)) continue;
|
||||
// 递归检查组内是否有激活项(任意层级)
|
||||
var hasActiveChild = isItemActive(g);
|
||||
// 组内没有任何有权限的可见项则跳过
|
||||
if (!hasVisibleItem(g)) continue;
|
||||
if (hasActiveChild && activeGroupIdx < 0) activeGroupIdx = i;
|
||||
|
||||
var expanded = hasActiveChild ? ' expanded' : '';
|
||||
var rotate = hasActiveChild ? ' rotate' : '';
|
||||
html += '<div class="menu-group' + expanded + '" data-group="' + i + '">'
|
||||
+ ' <div class="menu-group-title" data-title="' + g.title + '" onclick="toggleGroup(' + i + ')">'
|
||||
+ ' <span class="menu-icon">' + (g.icon || '') + '</span>'
|
||||
+ ' <span class="menu-label">' + g.title + '</span>'
|
||||
+ ' <span class="menu-arrow' + rotate + '">▾</span>'
|
||||
+ ' </div>'
|
||||
+ ' <div class="menu-children">'
|
||||
+ renderSubItems(g.children, 1)
|
||||
+ ' </div>'
|
||||
+ '</div>';
|
||||
} else {
|
||||
// 单项菜单:按 g.role 判断(分组由子项权限决定,不看 g.role)
|
||||
if (!hasRole(g.role)) continue;
|
||||
// 在首页本身不显示"首页"入口
|
||||
if (g.href === '/home.html' && isActive(g.href)) continue;
|
||||
var activeSingle = isActive(g.href) ? ' active' : '';
|
||||
if (activeSingle) activeGroupIdx = i;
|
||||
html += '<a class="menu-single' + activeSingle + '" href="' + APP_BASE + g.href + '" data-title="' + g.title + '">'
|
||||
+ ' <span class="menu-icon">' + (g.icon || '') + '</span>'
|
||||
+ ' <span class="menu-label">' + g.title + '</span>'
|
||||
+ '</a>';
|
||||
}
|
||||
}
|
||||
html += '</div>';
|
||||
|
||||
var el = document.getElementById('sidebar');
|
||||
if (el) el.innerHTML = html;
|
||||
|
||||
// 主体内容左边距
|
||||
document.body.classList.add('with-sidebar');
|
||||
|
||||
// 恢复折叠状态
|
||||
if (localStorage.getItem('gx_sidebar_collapsed') === '1') {
|
||||
document.body.classList.add('sidebar-collapsed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换侧边栏折叠/展开
|
||||
*/
|
||||
function toggleSidebar() {
|
||||
document.body.classList.toggle('sidebar-collapsed');
|
||||
var collapsed = document.body.classList.contains('sidebar-collapsed');
|
||||
if (collapsed) localStorage.setItem('gx_sidebar_collapsed', '1');
|
||||
else localStorage.removeItem('gx_sidebar_collapsed');
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换分组展开/折叠
|
||||
*/
|
||||
function toggleGroup(idx) {
|
||||
// 折叠状态下点击分组:先展开侧边栏,再展开该分组
|
||||
if (document.body.classList.contains('sidebar-collapsed')) {
|
||||
toggleSidebar();
|
||||
// 展开侧边栏后延迟让 CSS 过渡完成,再展开分组
|
||||
var el = document.querySelector('.menu-group[data-group="' + idx + '"]');
|
||||
if (el) el.classList.add('expanded');
|
||||
return;
|
||||
}
|
||||
var el = document.querySelector('.menu-group[data-group="' + idx + '"]');
|
||||
if (!el) return;
|
||||
el.classList.toggle('expanded');
|
||||
var arrow = el.querySelector('.menu-arrow');
|
||||
if (arrow) arrow.classList.toggle('rotate');
|
||||
}
|
||||
|
||||
function initNav() {
|
||||
renderSidebar();
|
||||
}
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener('DOMContentLoaded', function () { initNav(); });
|
||||
} else {
|
||||
window.onload = function () { initNav(); };
|
||||
}
|
||||
Reference in new issue
Block a user