149 lines
8.5 KiB
Plaintext
Executable File
149 lines
8.5 KiB
Plaintext
Executable File
<!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>
|
||
<!-- 公共侧边栏组件 -->
|
||
<link rel="stylesheet" href="View/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 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}
|
||
.top-bar .logo{font-size:17px;font-weight:600;margin-right:24px}
|
||
.top-links a{color:rgba(255,255,255,.75);text-decoration:none;padding:0 16px;height:100%;display:flex;align-items:center;font-size:13px;border-radius:4px 4px 0 0;transition:.2s}
|
||
.top-links a:hover,.top-links a.active{color:#fff;background:rgba(255,255,255,.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-180px)}
|
||
table{min-width:100%;border-collapse:collapse;font-size:12px}
|
||
thead th{background:#f8f9fa;color:#555;font-weight:600;padding:8px 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:7px 8px;border:1px solid #ddd;color:#333;text-align:center}
|
||
tbody tr:hover{background:#f0f6ff}
|
||
tbody td.month-cell{text-align:left;font-weight:600;color:#1a73e8}
|
||
tbody tr.total-row td{background:#f0f6ff;font-weight:700;color:#1a73e8}
|
||
.count-link{color:#1a73e8;cursor:pointer;text-decoration:underline;font-weight:600}
|
||
.count-link:hover{color:#1557b0}
|
||
.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 id="sidebar"></div>
|
||
|
||
<div class="main-content">
|
||
<div class="main">
|
||
<div class="card">
|
||
<div class="card-header"><h3>采购看板 - 按月业务状态汇总</h3></div>
|
||
<div class="table-wrap">
|
||
<table>
|
||
<thead><tr id="headerRow"></tr></thead>
|
||
<tbody id="dataBody"><tr class="empty"><td colspan="2">加载中...</td></tr></tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
var ywztMap={'0':'--','1':'采购订单-转单追踪','2':'供应链-待供应商报价','3':'供应链-待ED审批','4':'供应链-ED驳回,重新议价','5':'供应链-ED已审批','6':'研发-采购申请驳回','7':'研发-采购申请撤回','8':'研发-采购申请取消','9':'研发-量产复用件'};
|
||
|
||
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 loadData(){
|
||
loading(true);
|
||
var xhr=new XMLHttpRequest();
|
||
xhr.open('GET','api/Procurement/GetProcurementDashboard',true);
|
||
xhr.onload=function(){
|
||
loading(false);
|
||
try{
|
||
var r=JSON.parse(xhr.responseText);
|
||
if(r.success)renderTable(r.data,r.ywzts,r.ywztMap);
|
||
else toast(r.message||'查询失败','error')
|
||
}catch(e){toast('数据异常','error')}
|
||
};
|
||
xhr.onerror=function(){loading(false);toast('网络请求失败','error')};
|
||
xhr.send();
|
||
}
|
||
|
||
function renderTable(data,ywzts,_ywztMap){
|
||
var header=document.getElementById('headerRow');
|
||
var tbody=document.getElementById('dataBody');
|
||
if(!data||!data.length){header.innerHTML='<th>月份</th>';tbody.innerHTML='<tr class="empty"><td colspan="2">暂无数据</td></tr>';return}
|
||
|
||
// 表头
|
||
var hh='<th style="min-width:100px">月份<span class="resizer"></span></th>';
|
||
ywzts.forEach(function(y){hh+='<th style="min-width:110px">'+(ywztMap[y]||y)+'<span class="resizer"></span></th>'});
|
||
hh+='<th style="min-width:80px">合计<span class="resizer"></span></th>';
|
||
header.innerHTML=hh;
|
||
|
||
// 数据行
|
||
var h='';
|
||
data.forEach(function(row,idx){
|
||
var isTotal=(idx===data.length-1);
|
||
var trCls=isTotal?' class="total-row"':'';
|
||
h+='<tr'+trCls+'>';
|
||
h+='<td class="month-cell">'+escapeHtml(row.month)+'</td>';
|
||
var rowTotal=0;
|
||
ywzts.forEach(function(y){
|
||
var cnt=parseInt(row[y])||0;
|
||
rowTotal+=cnt;
|
||
if(cnt>0&&!isTotal)
|
||
h+='<td><span class="count-link" onclick="openDetail(\''+escapeHtml(row.month)+'\',\''+y+'\')">'+cnt+'</span></td>';
|
||
else
|
||
h+='<td>'+(cnt||'')+'</td>';
|
||
});
|
||
h+='<td>'+(isTotal?rowTotal:'')+'</td>';
|
||
h+='</tr>';
|
||
});
|
||
tbody.innerHTML=h;
|
||
}
|
||
|
||
function openDetail(month,ywzt){
|
||
// 暂时跳转到看板详情(后续开发二级列表)
|
||
window.location.href='procurement_dashboard_detail.html?month='+encodeURIComponent(month)+'&ywzt='+encodeURIComponent(ywzt);
|
||
}
|
||
|
||
// ===== 登录校验和导航栏由公共组件提供 =====
|
||
|
||
// 列宽拖动
|
||
(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>
|
||
</div><!-- /main-content -->
|
||
<!-- 公共侧边栏组件(菜单维护点:View/common/nav.js) -->
|
||
<script src="View/common/nav.js"></script>
|
||
</body>
|
||
</html>
|