326 lines
15 KiB
Plaintext
Executable File
326 lines
15 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>生产计划排程看板</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>
|