Files
GX.O3.WMS/WebApi/procurement_dashboard_level4.html

164 lines
11 KiB
HTML
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>物料明细 - Gaussian</title>
<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 20px;display:flex;align-items:center;height:52px;box-shadow:0 2px 8px rgba(0,0,0,.15);position:sticky;top:0;z-index:100;gap:12px}
.top-bar .back{color:rgba(255,255,255,.85);text-decoration:none;font-size:14px;padding:4px 10px;border-radius:4px}
.top-bar .back:hover{background:rgba(255,255,255,.15)}
.top-bar .title{font-size:15px;font-weight:600;flex:1}
.user-info{margin-left:auto;font-size:12px;opacity:.85}
.main{max-width:1500px;margin:0 auto;padding:12px 16px}
.card{background:#fff;border-radius:8px;box-shadow:0 1px 4px rgba(0,0,0,.08);overflow:visible}
.card-header{padding:10px 16px;border-bottom:1px solid #f0f0f0;display:flex;justify-content:space-between;align-items:center}
.card-header h3{font-size:14px;color:#333;font-weight:600}
.table-wrap{overflow:auto;max-height:calc(100vh-160px)}
table{min-width:100%;border-collapse:collapse;font-size:12px}
thead th{background:#f8f9fa;color:#555;font-weight:600;padding:6px 8px;text-align:left;border:1px solid #999;border-bottom:2px solid #999;white-space:nowrap;position:sticky;top:0;z-index:2;position:relative;user-select:none}
thead th .resizer{position:absolute;right:0;top:0;bottom:0;width:5px;cursor:col-resize;z-index:3}
thead th .resizer:hover{background:#1a73e8}
tbody td{padding:5px 8px;border:1px solid #ddd;color:#333}
tbody tr:hover{background:#f0f6ff}
.empty td{text-align:center;padding:36px;color:#bbb}
.loading-overlay{display:none;position:fixed;inset:0;background:rgba(255,255,255,.7);z-index:999;justify-content:center;align-items:center}
.loading-overlay.show{display:flex}
.toast{position:fixed;top:12px;left:50%;transform:translateX(-50%);padding:10px 20px;border-radius:8px;font-size:13px;z-index:1000;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}
.pagination{display:flex;justify-content:space-between;align-items:center;padding:8px 12px;border-top:1px solid #f0f0f0;font-size:12px;color:#999}
.pagination .btns{display:flex;gap:2px}
.pagination .btns button,.pagination .size-btn{min-width:32px;height:26px;border:1px solid #e0e0e0;border-radius:3px;background:#fff;color:#666;cursor:pointer;font-size:11px;padding:0 6px}
.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:6px}
</style>
</head>
<body>
<div class="loading-overlay" id="loading"><div class="loading-spinner"></div></div>
<div class="toast" id="toast"></div>
<div class="top-bar">
<a class="back" href="javascript:history.back()">← 返回</a>
<span class="title" id="pageTitle">物料明细</span>
<span class="user-info" id="userInfo"></span>
</div>
<div class="main">
<div class="card">
<div class="card-header"><h3 id="subTitle">物料明细列表</h3></div>
<div class="table-wrap">
<table>
<thead><tr>
<th>流程编号<span class="resizer"></span></th><th>单据编号<span class="resizer"></span></th><th>行号<span class="resizer"></span></th><th>物料编码<span class="resizer"></span></th><th>物料名称<span class="resizer"></span></th><th>数量<span class="resizer"></span></th>
<th>第一轮报价<span class="resizer"></span></th><th>第二轮报价<span class="resizer"></span></th><th>供应商<span class="resizer"></span></th>
<th>研发采购负责人<span class="resizer"></span></th><th>要求交付日期<span class="resizer"></span></th><th>审批日期<span class="resizer"></span></th><th>天数<span class="resizer"></span></th>
</tr></thead>
<tbody id="dataBody"><tr class="empty"><td colspan="13">加载中...</td></tr></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>
<script>
var params={};location.search.substr(1).split('&').forEach(function(s){var kv=s.split('=');if(kv[0])params[decodeURIComponent(kv[0])]=decodeURIComponent(kv[1]||'')});
var month=params.month||'',ywzt=params.ywzt||'',yfxm=params.yfxm||'',rangeType=params.rangeType||'';
var ywztMap={'0':'--','1':'采购订单-转单追踪','2':'供应链-待供应商报价','3':'供应链-待ED审批','4':'供应链-ED驳回,重新议价','5':'供应链-ED已审批','6':'研发-采购申请驳回','7':'研发-采购申请撤回','8':'研发-采购申请取消','9':'研发-量产复用件'};
var pageSizeOptions=[20,50,100,200],pageSize=20,currentPage=1,allData=[];
document.getElementById('subTitle').textContent='研发项目:'+yfxm+' | '+(ywztMap[ywzt]||'')+' | '+rangeType;
function escapeHtml(s){if(!s)return'';var d=document.createElement('div');d.appendChild(document.createTextNode(String(s)));return d.innerHTML}
function loading(b){document.getElementById('loading').classList.toggle('show',b)}
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'},3500)}
function logout(){sessionStorage.removeItem('gx_user');window.location.href='login.html'}
function loadData(){
loading(true);
var xhr=new XMLHttpRequest();
xhr.open('GET','api/Procurement/GetProcurementDashboardLevel4?month='+encodeURIComponent(month)+'&yfxm='+encodeURIComponent(yfxm)+'&ywzt='+ywzt+'&rangeType='+encodeURIComponent(rangeType),true);
xhr.onload=function(){
loading(false);
try{
var r=JSON.parse(xhr.responseText);
if(r.success)renderList(r.data);
else toast(r.message||'查询失败','error')
}catch(e){toast('数据解析异常','error')}
};
xhr.onerror=function(){loading(false);toast('网络请求失败','error')};
xhr.send();
}
function setPageSize(size){pageSize=size;currentPage=1;renderPage()}
function renderPagination(){
var total=allData.length,tp=Math.ceil(total/pageSize)||1;
var pc=document.getElementById('pagination');
if(total<=pageSize&&total<=20){pc.style.display='none';return}
pc.style.display='flex';
document.getElementById('totalCnt').textContent=total;
var sb=document.getElementById('sizeBtns');
sb.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 '+(currentPage<=1?'disabled':'')+' onclick="loadPage(1)">首页</button><button '+(currentPage<=1?'disabled':'')+' onclick="loadPage('+(currentPage-1)+')">‹</button>';
for(var i=Math.max(1,currentPage-2);i<=Math.min(tp,currentPage+2);i++)h+='<button class="'+(i===currentPage?'active':'')+'" onclick="loadPage('+i+')">'+i+'</button>';
h+='<button '+(currentPage>=tp?'disabled':'')+' onclick="loadPage('+(currentPage+1)+')">›</button><button '+(currentPage>=tp?'disabled':'')+' onclick="loadPage('+tp+')">末页</button>';
pb.innerHTML=h;
}
function loadPage(page){currentPage=page;renderPage()}
function renderPage(){
var tb=document.getElementById('dataBody');
if(!allData.length){tb.innerHTML='<tr class="empty"><td colspan="13">暂无数据</td></tr>';return}
var start=(currentPage-1)*pageSize,end=Math.min(start+pageSize,allData.length);
var h='';
for(var i=start;i<end;i++){
var item=allData[i];
h+='<tr><td>'+escapeHtml(item.lcbh)+'</td><td>'+escapeHtml(item.djbh)+'</td><td>'+escapeHtml(item.xh)+'</td><td>'+escapeHtml(item.wlbmCode)+'</td><td>'+escapeHtml(item.wlmc)+'</td><td>'+escapeHtml(item.sqsl)+'</td><td>'+escapeHtml(item.onebj)+'</td><td>'+escapeHtml(item.twobj)+'</td><td>'+escapeHtml(item.gys)+'</td><td>'+escapeHtml(item.yfcgfzr)+'</td><td>'+escapeHtml(item.dhrq)+'</td><td>'+escapeHtml(item.pmDate)+'</td><td>'+escapeHtml(item.dayDiff)+'</td></tr>';
}
tb.innerHTML=h;
renderPagination();
}
function renderList(data){
allData=data||[];
renderPage();
}
(function(){
var userData=sessionStorage.getItem('gx_user');
if(!userData){window.location.href='login.html';return}
try{
var u=JSON.parse(userData);
document.getElementById('userInfo').innerHTML=(u.userName||u.userId)+' | <a href="javascript:void(0)" onclick="logout()" style="color:rgba(255,255,255,.75);text-decoration:none;margin-left:8px;font-size:12px;">退出</a>';
}catch(e){window.location.href='login.html'}
})();
// 列宽拖动
(function(){
var t=null,sx=0,sw=0,si=0,st=null;
document.addEventListener('mousedown',function(e){
var r=e.target.closest('.resizer');if(!r)return;
var th=r.parentElement;if(!th||th.tagName!='TH')return;
t=th;sx=e.clientX;sw=th.offsetWidth;st=th.closest('table');si=Array.prototype.indexOf.call(th.parentNode.children,th);
if(st)st._origW=st.offsetWidth;
document.body.style.cursor='col-resize';e.preventDefault()
});
document.addEventListener('mousemove',function(e){
if(!t)return;var d=e.clientX-sx;var w=Math.max(40,sw+d);
t.style.width=w+'px';t.style.minWidth=w+'px';t.style.maxWidth='none';
if(st){st.style.width=(st._origW+d)+'px';st.querySelectorAll('tbody tr').forEach(function(tr){var td=tr.children[si];if(td)td.style.width=w+'px'})}
});
document.addEventListener('mouseup',function(){if(t){t=null;st=null;document.body.style.cursor=''}});
})();
loadData();
</script>
</body>
</html>