编辑页面

修改后将从当前时间重新计算过期时间
💡 新增说明:
• 批次号自动生成,格式:年月日+序号
• 新增后默认状态为"已完成"
• 产值将自动汇总到月度统计报表
`; break; case 'workshop': modalTitle.textContent = '新增车间'; content = `
`; break; case 'production': modalTitle.textContent = '新增生产单'; content = `
`; break; case 'wage': modalTitle.textContent = '新增工资记录'; content = `
`; break; case 'energyPrice': modalTitle.textContent = '编辑能源单价参数'; content = `
`; break; case 'stdWorkHours': modalTitle.textContent = '编辑标准工时参数'; content = `
`; break; case 'user': modalTitle.textContent = '新增用户'; content = `
`; break; case 'backup': modalTitle.textContent = '创建数据备份'; content = `
`; break; case 'energy': modalTitle.textContent = '新增能耗记录'; content = `
💡 提示:用量的计算公式:用量 = 期末读数 - 期初读数
金额的计算公式:金额 = 用量 × 单价
`; break; case 'deviceLog': modalTitle.textContent = '新增设备运行日志'; content = `
💡 提示:OEE计算公式:
• 工作时间 = 关机时间 - 开机时间
• 负荷时间 = 工作时间 - 计划停机时间
• 开动时间 = 负荷时间 - 设备初始化时间 - 故障时间
• OEE = 时间开动率 × 性能开动率 × 合格品率
`; break; case 'cost': modalTitle.textContent = '新增成本记录'; content = `
💡 成本计算公式:
• 产品总成本 = 直接材料 + 直接人工 + 能耗成本 + 制造费用
• 产品单位成本 = 产品总成本 ÷ 产品产量
• 成本差异额 = 实际单位成本 - 标准单位成本
• 成本差异率 = 成本差异额 ÷ 标准单位成本 × 100%
`; break; case 'person': modalTitle.textContent = '新增人员档案'; content = `
💡 人员档案说明:
• 工号自动生成,也可手动输入
• 人员信息与工资系统关联
• 离职后状态变更为"离职",不影响历史工资记录
`; break; case 'product': modalTitle.textContent = '新增产品档案'; content = `
💡 产品档案说明:
• 产品ID自动生成,也可手动输入
• 产品信息与生产、成本系统关联
• 含税单价自动根据税率计算
`; break; case 'process': modalTitle.textContent = '新增工序档案'; content = `
💡 工序档案说明:
• 工序ID自动生成,也可手动输入
• 工序与产品关联,影响生产效率计算
• 工序顺序决定生产流程
`; break; case 'equipment': modalTitle.textContent = '新增设备档案'; content = `
💡 设备档案说明:
• 设备ID自动生成
• 设备信息用于OEE计算
• 状态变更自动记录到设备日志
`; break; case 'energyType': modalTitle.textContent = '新增能源类型'; content = `
💡 能源类型说明:
• 能源ID自动生成
• 能源类型用于能耗成本计算
• 税率影响含税单价计算
`; break; case 'importProduction': modalTitle.textContent = '📥 批量导入生产数据'; content = `
💡 导入说明:
• 请先下载导入模板,按模板格式填写数据
• 支持 .xlsx/.xls/.csv 格式文件
• 单次导入最多支持 1000 条数据
`; break; case 'importEnergy': modalTitle.textContent = '📥 批量导入能耗数据'; content = `
💡 导入说明:
• 请先下载导入模板,按模板格式填写数据
• 能耗数据包含:期初读数、期末读数、用量、单价等
• 系统将自动计算金额
`; break; case 'importWage': modalTitle.textContent = '📥 批量导入工资数据'; content = `
💡 导入说明:
• 请先下载导入模板,按模板格式填写数据
• 必须包含:工号、姓名、计件数量、计件单价等
• 计件工资将自动计算
`; break; case 'importCost': modalTitle.textContent = '📥 批量导入成本数据'; content = `
💡 导入说明:
• 请先下载导入模板,按模板格式填写数据
• 必须包含:产品名称、直接材料、直接人工、能耗成本等
• 成本计算公式:总成本 = 直接材料 + 直接人工 + 能耗成本 + 制造费用
`; break; case 'importDevice': modalTitle.textContent = '📥 批量导入设备运行数据'; content = `
💡 导入说明:
• 请先下载导入模板,按模板格式填写数据
• 必须包含:设备名称、车间、工作时间、故障时间等
• 系统将自动计算OEE各项指标
`; break; case 'exportShipment': modalTitle.textContent = '📥 导出成品发货趋势及生产计划'; content = `
💡 导出说明:
• 预计导出 4 条产品记录
• 文件名将包含导出时间戳,格式:成品发货趋势及生产计划_年月.xlsx
`; break; case 'exportEnergy': modalTitle.textContent = '📥 导出能源消耗报表'; content = `
💡 导出说明:
• 预计导出 12 条数据记录
• 文件名将包含导出时间戳
`; break; case 'exportCost': modalTitle.textContent = '📥 导出成本分析报表'; content = `
💡 导出说明:
• 预计导出 8 条数据记录
• 包含直接材料、直接人工、能耗成本等成本项
`; break; case 'exportOEE': modalTitle.textContent = '📥 导出设备OEE分析报表'; content = `
💡 导出说明:
• 预计导出 15 条数据记录
• 包含时间开动率、性能开动率、合格品率等指标
`; break; case 'exportViz': modalTitle.textContent = '📥 导出统计可视化报表'; content = `
💡 导出说明:
• 预计导出 50 条数据记录
• 包含生产、能源、成本、设备等多维度统计数据
`; break; case 'exportWageReport': modalTitle.textContent = '📥 导出工资报表'; content = `
💡 导出说明:
• 预计导出 149 条工资记录
• 包含计件工资、计时工资、奖金及扣款明细
• 文件名将包含导出时间戳,格式:工资报表_年月.xlsx
`; break; case 'exportLog': modalTitle.textContent = '📥 导出系统日志'; content = `
⚠️ 注意事项:
• 日志数据仅用于系统审计和问题追踪
• 预计导出 128 条日志记录
`; break; case 'schedule': modalTitle.textContent = '新增生产调度单'; content = `
💡 调度单说明:
• 调度单号自动生成,格式:SC+年月日+序号
• 新增后默认状态为"待排产"
• 排产后状态更新为"已排产"
`; break; } content += '
'; modalBody.innerHTML = content; modal.classList.add('show'); } function closeModal() { document.getElementById('modal').classList.remove('show'); } function saveData() { const type = currentModalType; const modal = document.getElementById('modal'); modal.classList.remove('show'); // 根据类型处理数据 switch(type) { case 'workshop': addWorkshopRow(); break; case 'production': addProductionRow(); break; case 'productionLedger': addProductionLedgerRow(); break; case 'wage': addWageRow(); break; case 'energy': addEnergyRow(); break; case 'schedule': addScheduleRow(); break; case 'exportProduction': showToast('📥 生产台账导出中,请稍候...'); setTimeout(() => showToast('✅ 导出成功!文件已保存'), 2000); break; case 'exportYearlySales': showToast('📥 品种历年销售统计导出中,请稍候...'); setTimeout(() => showToast('✅ 导出成功!文件已保存'), 2000); break; case 'exportEnergy': showToast('📥 能源消耗报表导出中...'); break; case 'exportCost': showToast('📥 成本分析报表导出中...'); break; case 'exportOEE': showToast('📥 设备OEE分析报表导出中...'); break; case 'exportViz': showToast('📥 统计可视化报表导出中...'); break; case 'exportWageReport': showToast('📥 工资报表导出中,请稍候...'); setTimeout(() => showToast('✅ 工资报表导出成功!'), 2000); break; case 'exportShipment': showToast('📥 成品发货趋势报表导出中,请稍候...'); setTimeout(() => showToast('✅ 导出成功!文件已保存'), 2000); break; case 'exportLog': showToast('📥 系统日志导出中...'); break; default: break; } showToast('✅ 操作成功!'); } // 新增车间数据 function addWorkshopRow() { const table = document.querySelector('#workshop-tab .data-table tbody'); const nameInput = document.querySelector('#modalBody input[placeholder="请输入车间名称"]'); const leaderInput = document.querySelector('#modalBody input[placeholder="请输入负责人"]'); const name = nameInput?.value || '新车间'; const id = 'WS' + String(Math.floor(Math.random() * 900) + 100); const row = `${id}${name}${leaderInput?.value || '待定'}生技部● 启用${new Date().toISOString().slice(0,10)}`; table.insertAdjacentHTML('beforeend', row); } // 新增生产单数据 function addProductionRow() { const table = document.querySelector('#production-tab .data-table tbody'); const productSelect = document.querySelector('#modalBody select:nth-of-type(1)'); const qtyInput = document.querySelector('#modalBody input[type="number"]'); const id = 'PS' + new Date().getFullYear() + String(Math.floor(Math.random() * 9000) + 1000); const row = `${id}${productSelect?.value || '新产品'}${qtyInput?.value || '0'}待定待定${new Date().toISOString().slice(0,10)}-待计算`; table.insertAdjacentHTML('beforeend', row); } // 新增生产台账记录 function addProductionLedgerRow() { const table = document.querySelector('#production-tab .data-table tbody'); const batchNo = document.getElementById('ledgerBatchNo')?.value || new Date().getTime().toString().slice(-6); const product = document.getElementById('ledgerProduct')?.value || ''; const qty = document.getElementById('ledgerQty')?.value || '0'; const convertedQty = document.getElementById('ledgerConvertedQty')?.value || qty; const workshop = document.getElementById('ledgerWorkshop')?.value || ''; const team = document.getElementById('ledgerTeam')?.value || ''; const startTime = document.getElementById('ledgerStartTime')?.value || ''; const endTime = document.getElementById('ledgerEndTime')?.value || ''; const outputValue = document.getElementById('ledgerOutputValue')?.value || '0'; const formatDate = (datetime) => { if (!datetime) return '-'; return datetime.replace('T', ' '); }; const row = ` ${batchNo} ${product} ${parseInt(qty).toLocaleString()} ${parseInt(convertedQty).toLocaleString()}盒 ${workshop} ${team} ${formatDate(startTime)} ${formatDate(endTime)} ${parseInt(outputValue).toLocaleString()} `; table.insertAdjacentHTML('beforeend', row); } // 新增工资记录 function addWageRow() { const table = document.querySelector('#wageEntry-tab .data-table tbody'); const nameInput = document.querySelector('#modalBody input[placeholder="请输入姓名"]'); const qtyInput = document.querySelector('#modalBody input[type="number"]'); const id = 'W' + String(Math.floor(Math.random() * 9000) + 1000); const qty = qtyInput?.value || '0'; const row = `${id}${nameInput?.value || '新员工'}待定待定${qty}待计算● 已录入`; table.insertAdjacentHTML('beforeend', row); } // 新增能耗记录 function addEnergyRow() { const table = document.querySelector('#energyEntry-tab .data-table tbody'); const row = `待定待定---待定-`; table.insertAdjacentHTML('beforeend', row); } // 新增调度单记录 function addScheduleRow() { const table = document.querySelector('#schedule-tab .data-table tbody'); const productSelect = document.querySelector('#scheduleProduct'); const qtyInput = document.querySelector('#scheduleQty'); const startInput = document.querySelector('#scheduleStartDate'); const endInput = document.querySelector('#scheduleEndDate'); const id = 'SC' + new Date().getFullYear() + String(Math.floor(Math.random() * 90000) + 10000); const qty = qtyInput?.value || '0'; const start = startInput?.value || new Date().toISOString().slice(0,10); const end = endInput?.value || new Date().toISOString().slice(0,10); const row = `${id}${productSelect?.value || '待定'}${qty}0
0%${start}${end}● 待排产`; table.insertAdjacentHTML('beforeend', row); } // 下载导入模板 function downloadTemplate(type) { const templates = { production: '生产数据导入模板:批次号,产品名称,生产数量,生产车间,生产班组,开工时间,完工时间', energy: '能耗数据导入模板:车间,能源类型,期初读数,期末读数,单价', wage: '工资数据导入模板:工号,姓名,车间,班组,计件数量,计件单价', cost: '成本数据导入模板:产品名称,直接材料,直接人工,能耗成本,制造费用,产量', device: '设备运行数据导入模板:设备名称,车间,工作时间,故障时间,合格品数' }; const content = templates[type] || '模板内容'; showToast('📥 ' + content.substring(0, 10) + '...模板下载功能开发中'); } function showToast(message) { const toast = document.getElementById('toast'); toast.textContent = message; toast.classList.add('show'); setTimeout(() => toast.classList.remove('show'), 3000); } // 加载车间数据 function loadWorkshopData() { const tbody = document.getElementById('workshopTableBody'); const data = [ {id: 'WS001', name: '前处理车间', leader: '待定', dept: '生技部', status: '启用', date: '2024-01-01'}, {id: 'WS002', name: '一车间', leader: '待定', dept: '生技部', status: '启用', date: '2024-01-01'}, {id: 'WS003', name: '二车间', leader: '待定', dept: '生技部', status: '启用', date: '2024-01-01'}, {id: 'WS004', name: '三车间', leader: '待定', dept: '生技部', status: '启用', date: '2024-01-01'}, {id: 'WS005', name: '公用工程', leader: '待定', dept: '生技部', status: '启用', date: '2024-01-01'} ]; tbody.innerHTML = data.map(item => ` ${item.id} ${item.name} ${item.leader} ${item.dept} ● ${item.status} ${item.date} `).join(''); } function editItem(type, id) { currentModalType = type; const modal = document.getElementById('modal'); const modalTitle = document.getElementById('modalTitle'); const modalBody = document.getElementById('modalBody'); let content = ''; switch(type) { case 'editWorkshop': modalTitle.textContent = '📝 编辑车间信息'; content = `
车间详情
编号:${id || 'WS001'}

基本信息

统计信息

5
设备数量
3
生产线数量
25
员工人数

备注说明

`; break; case 'editTeam': modalTitle.textContent = '📝 编辑班组信息'; content = `
班组详情
编号:${id || 'TM001'}

基本信息

班组配置

`; break; case 'editProduct': modalTitle.textContent = '📝 编辑产品信息'; content = `
产品详情
编号:${id || 'PD001'}

基本信息

生产信息

`; break; case 'editProcess': modalTitle.textContent = '📝 编辑工序信息'; content = `
工序详情
编号:${id || 'PR001'}

基本信息

工艺参数

`; break; case 'editEquipment': modalTitle.textContent = '📝 编辑设备信息'; content = `
设备详情
编号:${id || 'EQ001'}

基本信息

技术参数

`; break; case 'editEnergyType': modalTitle.textContent = '📝 编辑能源类型'; content = `
能源类型详情
编号:${id || 'EN001'}

基本信息

(吨)

统计信息

3%
占比
125
使用次数
¥3,280
本月费用
`; break; case 'editProduction': modalTitle.textContent = '📝 编辑生产单'; content = `
生产单详情
单号:${id || '260501'}

基本信息

产值信息

`; break; case 'editWage': modalTitle.textContent = '📝 编辑工资记录'; content = `
工资记录详情
工号:${id || 'P001'}

员工信息

工资构成

`; break; case 'editEnergy': modalTitle.textContent = '📝 编辑能源消耗记录'; content = `
能源消耗详情
记录:${id || 'REC001'}

基本信息

`; break; case 'editDevice': modalTitle.textContent = '📝 编辑设备运行记录'; content = `
设备运行详情
编号:${id || 'DR001'}

设备信息

OEE指标

85%
时间开动率
95%
性能开动率
99%
合格品率
80%
OEE
`; break; case 'editCost': modalTitle.textContent = '📝 编辑成本记录'; content = `
成本分析详情
月份:${id || '2026-05'}

成本构成

`; break; case 'editUser': modalTitle.textContent = '📝 编辑用户信息'; content = `
用户详情
工号:${id || 'U001'}

基本信息

`; break; case 'editStdWorkHours': modalTitle.textContent = '📝 编辑标准工时'; content = `
标准工时详情
编号:${id || 'WH001'}

基本信息

`; break; case 'editPerson': modalTitle.textContent = '📝 编辑人员信息'; content = `
人员详情
工号:${id || 'P001'}

基本信息

`; break; case 'editSchedule': modalTitle.textContent = '📝 编辑生产调度'; content = `
生产调度详情
单号:${id || 'SCH001'}

调度信息

`; break; case 'viewDeviceDetail': modalTitle.textContent = '🔧 设备运行详情'; content = `
设备运行详情
编号:${id || 'DR001'}

基本信息

运行时间分析

OEE三大指标

89.4%
时间开动率
85.0%
性能开动率
99.0%
合格品率
75.2%
OEE综合

生产统计

维护信息

备注说明

`; break; default: showAddModal(type); return; } modalBody.innerHTML = content; modal.classList.add('show'); } // 图表初始化 let chartsInitialized = false; function initCharts() { if (chartsInitialized) return; chartsInitialized = true; // 产值趋势图 new Chart(document.getElementById('productionTrendChart'), { type: 'line', data: { labels: ['1月', '2月', '3月', '4月', '5月'], datasets: [{ label: '产值(万元)', data: [12480, 12450, 13000, 12600, 13000], borderColor: '#667eea', backgroundColor: 'rgba(102, 126, 234, 0.1)', fill: true, tension: 0.4 }] }, options: { responsive: true, plugins: { legend: { display: false } } } }); // 车间产值饼图 new Chart(document.getElementById('workshopPieChart'), { type: 'doughnut', data: { labels: ['前处理', '一车间', '二车间', '三车间'], datasets: [{ data: [19.3, 25.2, 22.4, 33.1], backgroundColor: ['#667eea', '#764ba2', '#f093fb', '#4facfe'] }] }, options: { responsive: true } }); // 计件工资统计图 new Chart(document.getElementById('wageWorkshopChart'), { type: 'bar', data: { labels: ['前处理', '一车间', '二车间', '三车间', '公用工程'], datasets: [{ label: '工资总额(元)', data: [159860, 256789, 256520, 325632, 200012], backgroundColor: '#667eea' }] }, options: { responsive: true } }); // 能耗饼图 new Chart(document.getElementById('energyPieChart'), { type: 'pie', data: { labels: ['水', '电', '蒸汽', '天然气'], datasets: [{ data: [0.01, 87.8, 11.5, 0.7], backgroundColor: ['#4facfe', '#f093fb', '#667eea', '#764ba2'] }] }, options: { responsive: true } }); // 能耗趋势 new Chart(document.getElementById('energyTrendChart'), { type: 'line', data: { labels: ['1月', '2月', '3月', '4月', '5月'], datasets: [{ label: '能耗费用(元)', data: [445012, 0, 0, 0, 0], borderColor: '#667eea', backgroundColor: 'rgba(102, 126, 234, 0.1)', fill: true }] }, options: { responsive: true } }); // OEE趋势 new Chart(document.getElementById('oeeTrendChart'), { type: 'line', data: { labels: ['1月', '2月', '3月'], datasets: [{ label: 'OEE', data: [82.8, 80.7, 85.3], borderColor: '#667eea', fill: false }] }, options: { responsive: true } }); // M07统计可视化图表初始化 // 产值与成本趋势 if (document.getElementById('costTrendChart')) { new Chart(document.getElementById('costTrendChart'), { type: 'bar', data: { labels: ['1月', '2月', '3月', '4月', '5月'], datasets: [{ label: '产值(万元)', data: [12480, 12450, 13000, 12600, 13000], backgroundColor: '#667eea' }, { label: '成本(万元)', data: [13120, 13050, 13650, 13280, 13520], backgroundColor: '#f093fb' }] }, options: { responsive: true, plugins: { legend: { position: 'top' }, tooltip: { callbacks: { label: (ctx) => ctx.dataset.label + ': ' + ctx.raw.toLocaleString() + '万元' } } }, scales: { y: { beginAtZero: false } } } }); } // 工资与产量关联 if (document.getElementById('wageOutputChart')) { new Chart(document.getElementById('wageOutputChart'), { type: 'line', data: { labels: ['1月', '2月', '3月', '4月', '5月'], datasets: [{ label: '产量(吨)', data: [850, 840, 870, 860, 865], borderColor: '#667eea', backgroundColor: 'rgba(102, 126, 234, 0.1)', fill: true, yAxisID: 'y' }, { label: '工资总额(万元)', data: [119.88, 118.56, 122.05, 119.85, 121.00], borderColor: '#f093fb', backgroundColor: 'rgba(240, 147, 251, 0.1)', fill: true, yAxisID: 'y1' }] }, options: { responsive: true, plugins: { legend: { position: 'top' } }, scales: { y: { type: 'linear', position: 'left', title: { display: true, text: '产量(吨)' } }, y1: { type: 'linear', position: 'right', title: { display: true, text: '工资(万元)' }, grid: { drawOnChartArea: false } } } } }); } // 能耗效率分析 if (document.getElementById('energyEfficiencyChart')) { new Chart(document.getElementById('energyEfficiencyChart'), { type: 'bar', data: { labels: ['前处理', '一车间', '二车间', '三车间'], datasets: [{ label: '万元产值能耗(元)', data: [118, 125, 132, 121], backgroundColor: ['#667eea', '#764ba2', '#f093fb', '#4facfe'] }] }, options: { responsive: true, plugins: { legend: { display: false } }, scales: { y: { beginAtZero: true, title: { display: true, text: '元/万元产值' } } } } }); } // 设备OEE趋势 if (document.getElementById('deviceOeeChart')) { new Chart(document.getElementById('deviceOeeChart'), { type: 'line', data: { labels: ['1月', '2月', '3月', '4月', '5月'], datasets: [{ label: '时间开动率', data: [95.2, 93.9, 96.0, 94.5, 95.5], borderColor: '#667eea', fill: false }, { label: '性能开动率', data: [88.8, 87.6, 90.7, 89.2, 90.5], borderColor: '#f093fb', fill: false }, { label: '合格品率', data: [98, 98, 98, 98, 98], borderColor: '#4facfe', fill: false }, { label: 'OEE综合', data: [82.8, 80.7, 85.3, 83.5, 84.2], borderColor: '#43e97b', borderWidth: 3, fill: false }] }, options: { responsive: true, plugins: { legend: { position: 'top' } }, scales: { y: { min: 70, max: 100, title: { display: true, text: '百分比(%)' } } } } }); } // 产值月度趋势图 if (document.getElementById('outputTrendChart')) { new Chart(document.getElementById('outputTrendChart'), { type: 'line', data: { labels: ['1月', '2月', '3月', '4月', '5月'], datasets: [{ label: '产值(万元)', data: [12480, 12450, 13000, 12600, 13000], borderColor: '#667eea', backgroundColor: 'rgba(102, 126, 234, 0.1)', fill: true, tension: 0.4 }] }, options: { responsive: true, plugins: { legend: { display: false } }, scales: { y: { beginAtZero: false, title: { display: true, text: '产值(万元)' } } } } }); } // 各车间产值占比 if (document.getElementById('outputWorkshopChart')) { new Chart(document.getElementById('outputWorkshopChart'), { type: 'doughnut', data: { labels: ['前处理车间', '一车间', '二车间', '三车间'], datasets: [{ data: [2380, 3200, 2800, 4100], backgroundColor: ['#667eea', '#764ba2', '#f093fb', '#4facfe'] }] }, options: { responsive: true, plugins: { legend: { position: 'right' }, tooltip: { callbacks: { label: (ctx) => ctx.label + ': ' + ctx.raw.toLocaleString() + '万元' } } } } }); } // 成本构成分析图 if (document.getElementById('costBreakdownChart')) { new Chart(document.getElementById('costBreakdownChart'), { type: 'pie', data: { labels: ['直接材料', '直接人工', '能耗成本', '制造费用'], datasets: [{ data: [13, 14, 13.18, 0], backgroundColor: ['#667eea', '#f093fb', '#4facfe', '#43e97b'] }] }, options: { responsive: true, plugins: { legend: { position: 'right' }, tooltip: { callbacks: { label: (ctx) => ctx.label + ': ' + ctx.raw + '万元' } } } } }); } } // M07刷新图表 function refreshVizCharts() { const year = document.getElementById('vizYear')?.value || '2026'; const month = document.getElementById('vizMonth')?.value || 'all'; const workshop = document.getElementById('vizWorkshop')?.value || ''; showToast('📊 已刷新 ' + year + '年数据'); chartsInitialized = false; initCharts(); } // M07导出数据 function exportVizData() { showToast('📥 正在导出综合分析报表...'); } // 页面加载时初始化 document.addEventListener('DOMContentLoaded', function() { loadWorkshopData(); initCharts(); });
取消
访问码: 5w9cf8xq