baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)

This commit is contained in:
Gaussian committed 2026-11-06 18:38:38 +08:00
commit c2b0e7be0d
6522 files changed
+3530643

No files matched your search

+322
View File
@@ -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>