'+ '

支持CSV格式,首行为列名。必填列:编码、名称。可选:规格、单位、成本价、零售价、条码。

'+ '
'+ '
'+ ''+ '
'+ '
'+ '', async function(){ var csv=document.getElementById('imp_csv').value.trim(); if(!csv){T('请粘贴CSV数据或选择文件','e');return} var lines=csv.split('\n').filter(function(l){return l.trim()}); if(lines.length<2){T('至少需要表头+1行数据','e');return} var headers=lines[0].split(',').map(function(h){return h.trim()}); var rows=[]; for(var i=1;i'; }; reader.readAsText(file,'UTF-8'); } async async function toggleGoodsStatus(id,newStatus){ try{await api('/goods/status',{method:'PUT',body:{id:id}});T(newStatus?'商品已启用':'商品已停用');renderGoods()}catch(e){T(e.message,'e')} } async function toggleCustStatus(id){ try{await api('/customers/status',{method:'PUT',body:{id:id}});T('状态已切换');renderCust()}catch(e){T(e.message,'e')} } function showGoodsEdit(id){ var g=$cache.goods.find(function(x){return x.id==id});if(!g){T('商品不存在','e');return} M('编辑商品 — '+g.code, '
'+ '
'+ '
'+ '
'+ '
', async function(){ var body={id:id,name:document.getElementById('ge_name').value,code:document.getElementById('ge_code').value, retail_price:parseFloat(document.getElementById('ge_retail').value), cost_price:parseFloat(document.getElementById('ge_cost').value), specs:document.getElementById('ge_specs').value}; try{await api('/goods',{method:'PUT',body:body});T('商品更新成功');renderGoods()}catch(e){T(e.message,'e')} })} async function showCustEdit(id){ var c=$cache.customers.find(function(x){return x.id==id});if(!c){T('客户不存在','e');return} M('编辑客户 — '+c.name, '
'+ '
'+ '
'+ '
'+ '
'+ '
', async function(){ var body={id:id,name:document.getElementById('ce_name').value,contact:document.getElementById('ce_contact').value, phone:document.getElementById('ce_phone').value,address:document.getElementById('ce_addr').value, settlement_type:document.getElementById('ce_settle').value,credit_limit:parseFloat(document.getElementById('ce_limit').value)}; try{await api('/customers',{method:'PUT',body:body});T('客户更新成功');renderCust()}catch(e){T(e.message,'e')} })} function showSuppEdit(id){ var s=$cache.suppliers.find(function(x){return x.id==id});if(!s){T('供应商不存在','e');return} M('编辑供应商 — '+s.name, '
'+ '
'+ '
'+ '
', async function(){ var body={id:id,name:document.getElementById('se_name').value,contact:document.getElementById('se_contact').value, phone:document.getElementById('se_phone').value,address:document.getElementById('se_addr').value}; try{await api('/suppliers',{method:'PUT',body:body});T('供应商更新成功');renderSupp()}catch(e){T(e.message,'e')} })} >