Files
GX.O3.WMS/WebApi/.svn/pristine/00/00532ca29018edf72d4eef756e8af0a2091d8f1c.svn-base

212 lines
13 KiB
Plaintext
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}
.table-wrap{overflow:auto;max-height:calc(100vh-190px)}
.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;transition:all.15s;padding:0 6px}
.pagination .btns button:hover,.pagination .size-btn:hover{border-color:#1a73e8;color:#1a73e8}
.pagination .btns button.active{background:#1a73e8;color:#fff;border-color:#1a73e8}
.pagination .size-btn.active{background:#1a73e8;color:#fff;border-color:#1a73e8}
.pagination .size-group{display:inline-flex;gap:2px;margin-left:6px}
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;white-space:nowrap;position:sticky;top:0;z-index:3;position:relative;user-select:none}
thead th .resizer{position:absolute;right:0;top:0;bottom:0;width:5px;cursor:col-resize;z-index:4}
thead th .resizer:hover{background:#1a73e8}
thead th.sub-header{background:#eef2f7;border-top:0;font-weight:400;color:#666}
tbody td{padding:5px 8px;border:1px solid #ddd;color:#333;text-align:center}
tbody td.left{text-align:left}
tbody tr:hover{background:#f0f6ff}
tbody tr.total-row td{background:#f0f6ff;font-weight:700;color:#1a73e8}
.yfxm-link{color:#1a73e8;cursor:pointer;font-weight:600}
.yfxm-link:hover{color:#1557b0;text-decoration:underline}
.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}
.loading-spinner{width:34px;height:34px;border:3px solid #e0e0e0;border-top-color:#1a73e8;border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
.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}
</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="procurement_dashboard.html">← 返回看板</a>
<span class="title" id="pageTitle">采购看板明细</span>
<span class="user-info" id="userInfo"></span>
</div>
<div class="main">
<div class="card">
<div class="table-wrap">
<table>
<thead id="headerArea"></thead>
<tbody id="dataBody"><tr class="empty"><td colspan="3">加载中...</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||'';
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('pageTitle').textContent='采购看板明细 - '+month+' '+(ywztMap[ywzt]||'');
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/GetProcurementDashboardDetail?month='+encodeURIComponent(month)+'&ywzt='+encodeURIComponent(ywzt),true);
xhr.onload=function(){
loading(false);
try{
var r=JSON.parse(xhr.responseText);
if(r.success)renderTable(r.data,r.cncgfzrList);
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 renderTable(data,cncgfzrList){
var ha=document.getElementById('headerArea');
var tb=document.getElementById('dataBody');
allData=data||[];
if(!allData.length){ha.innerHTML='';tb.innerHTML='<tr class="empty"><td colspan="3">暂无数据</td></tr>';return}
// 第一行表头:基础列,cncgfzr列留空
var h1='<tr>';
h1+='<th style="min-width:160px">研发项目<span class="resizer"></span></th>';
h1+='<th style="min-width:100px">采购申请条数<span class="resizer"></span></th>';
h1+='<th style="min-width:100px">(第二轮)已有价格<span class="resizer"></span></th>';
h1+='<th style="min-width:120px">(第二轮)无价格<span class="resizer"></span></th>';
cncgfzrList.forEach(function(){h1+='<th style="min-width:90px"><span class="resizer"></span></th>'});
h1+='</tr>';
// 第二行表头:未分配采购策略 + 各策略采购负责人
var h2='<tr>';
h2+='<th class="sub-header"></th>';
h2+='<th class="sub-header"></th>';
h2+='<th class="sub-header"></th>';
h2+='<th class="sub-header">未分配采购策略</th>';
cncgfzrList.forEach(function(cg){h2+='<th class="sub-header">'+escapeHtml(cg)+'</th>'});
h2+='</tr>';
ha.innerHTML=h1+h2;
renderPage(cncgfzrList);
}
function renderPage(cncgfzrList){
var tb=document.getElementById('dataBody');
if(!cncgfzrList)cncgfzrList=[]; // keep from initial render
var cols=3+cncgfzrList.length;
var start=(currentPage-1)*pageSize,end=Math.min(start+pageSize,allData.length);
var h='';
for(var i=start;i<end;i++){
var row=allData[i];
var isTotal=(i===allData.length-1);
var trCls=isTotal?' class="total-row"' : '';
h+='<tr'+trCls+'>';
h+='<td class="left">';
if(!isTotal) h+='<span class="yfxm-link" onclick="openThird(\''+escapeHtml(row.yfxmmc).replace(/\'/g,"\\'")+'\')">'+escapeHtml(row.yfxmmc)+'</span>';
else h+=escapeHtml(row.yfxmmc);
h+='</td>';
h+='<td>'+(row.total||0)+'</td>';
h+='<td>'+(row.hasPrice||0)+'</td>';
h+='<td>'+(row.noPrice||0)+'</td>';
cncgfzrList.forEach(function(cg){
h+='<td>'+(row['_cg_'+cg]||0)+'</td>';
});
h+='</tr>';
}
tb.innerHTML=h;
renderPagination();
}
function openThird(yfxmmc){
window.location.href='procurement_dashboard_detail_items.html?month='+encodeURIComponent(month)+'&ywzt='+encodeURIComponent(ywzt)+'&yfxm='+encodeURIComponent(yfxmmc);
}
(function(){
var userData=sessionStorage.getItem('gx_user');
if(!userData||!month){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>