|  |  | 
 |  |  |             :shortcuts="dateShortcuts" | 
 |  |  |           /> | 
 |  |  |         </el-form-item> | 
 |  |  |         <el-form-item label="煤种"> | 
 |  |  |         <!-- <el-form-item label="煤种"> | 
 |  |  |           <el-input v-model="searchParams.coalType" placeholder="请输入煤种" clearable /> | 
 |  |  |         </el-form-item> | 
 |  |  |         <el-form-item label="排产状态"> | 
 |  |  | 
 |  |  |             <el-option label="排产中" value="processing" /> | 
 |  |  |             <el-option label="已完成" value="completed" /> | 
 |  |  |           </el-select> | 
 |  |  |         </el-form-item> | 
 |  |  |         </el-form-item> --> | 
 |  |  |         <el-form-item> | 
 |  |  |           <el-button type="primary" @click="handleSearch" :loading="loading">查询</el-button> | 
 |  |  |           <el-button @click="handleReset">重置</el-button> | 
 |  |  |           <el-button type="success" @click="handleRandomScheduling">随机排产</el-button> | 
 |  |  |           <!-- <el-button type="success" @click="handleRandomScheduling">随机排产</el-button> --> | 
 |  |  |         </el-form-item> | 
 |  |  |       </el-form> | 
 |  |  |     </el-card> | 
 |  |  | 
 |  |  |         </div> | 
 |  |  |         <div class="card-content"> | 
 |  |  |           <div class="card-title">总排产量</div> | 
 |  |  |           <div class="card-value">{{ totalScheduledQuantity.toFixed(2) }} 吨</div> | 
 |  |  |           <div class="card-value">{{ statisticsData.totalOutput.toFixed(2) }} 吨</div> | 
 |  |  |         </div> | 
 |  |  |       </div> | 
 |  |  |        | 
 |  |  | 
 |  |  |         </div> | 
 |  |  |         <div class="card-content"> | 
 |  |  |           <div class="card-title">已完成排产</div> | 
 |  |  |           <div class="card-value">{{ completedScheduledQuantity.toFixed(2) }} 吨</div> | 
 |  |  |           <div class="card-value">{{ statisticsData.completedScheduling }} 吨</div> | 
 |  |  |         </div> | 
 |  |  |       </div> | 
 |  |  |        | 
 |  |  | 
 |  |  |         </div> | 
 |  |  |         <div class="card-content"> | 
 |  |  |           <div class="card-title">待排产</div> | 
 |  |  |           <div class="card-value">{{ pendingScheduledQuantity.toFixed(2) }} 吨</div> | 
 |  |  |           <div class="card-value">{{ statisticsData.pendingScheduling }} 吨</div> | 
 |  |  |         </div> | 
 |  |  |       </div> | 
 |  |  |        | 
 |  |  | 
 |  |  |         </div> | 
 |  |  |         <div class="card-content"> | 
 |  |  |           <div class="card-title">库存预警</div> | 
 |  |  |           <div class="card-value">{{ stockWarningCount }} 项</div> | 
 |  |  |           <div class="card-value">{{ statisticsData.inventoryWarning }} 项</div> | 
 |  |  |         </div> | 
 |  |  |       </div> | 
 |  |  |     </div> | 
 |  |  | 
 |  |  |         </div> | 
 |  |  |       </template> | 
 |  |  |       <el-table v-loading="loading" :data="stockMaterials" style="width: 100%"> | 
 |  |  |         <el-table-column prop="id" label="序号" width="80" type="index" /> | 
 |  |  |         <el-table-column prop="coalType" label="煤种" width="120" /> | 
 |  |  |         <el-table-column prop="origin" label="产地" width="120" /> | 
 |  |  |         <el-table-column prop="calorificValue" label="热值" width="120" /> | 
 |  |  |         <el-table-column prop="currentStock" label="当前库存(吨)" width="150" align="right"> | 
 |  |  |         <el-table-column prop="id" label="序号" width="80" type="index" align="center" /> | 
 |  |  |         <el-table-column prop="type" label="煤料类型"> | 
 |  |  |           <template #default="scope"> | 
 |  |  |             <span :class="{ 'stock-warning': scope.row.currentStock < scope.row.minStock }"> | 
 |  |  |               {{ scope.row.currentStock.toFixed(2) }} | 
 |  |  |             </span> | 
 |  |  |             <span>{{ scope.row.type === 1 ? '成品' : scope.row.type === 2 ? '原料' : '-' }}</span> | 
 |  |  |           </template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column prop="minStock" label="最低库存(吨)" width="150" align="right"> | 
 |  |  |           <template #default="scope">{{ scope.row.minStock.toFixed(2) }}</template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column prop="unit" label="单位" width="80" /> | 
 |  |  |         <el-table-column prop="coalId" label="煤种" /> | 
 |  |  |         <el-table-column prop="inventoryQuantity" label="当前库存"></el-table-column> | 
 |  |  |         <el-table-column prop="pendingReplenishment" label="待补库"></el-table-column> | 
 |  |  |         <el-table-column prop="unit" label="单位" /> | 
 |  |  |         <el-table-column prop="updateTime" label="更新时间" width="180" /> | 
 |  |  |       </el-table> | 
 |  |  |     </el-card> | 
 |  |  | 
 |  |  |         </div> | 
 |  |  |       </template> | 
 |  |  |       <el-table v-loading="loading" :data="schedulingResults" style="width: 100%"> | 
 |  |  |         <el-table-column prop="code" label="排产编码" width="180" /> | 
 |  |  |         <el-table-column prop="productionLine" label="生产线" width="120" /> | 
 |  |  |         <el-table-column prop="coalType" label="煤种" width="120" /> | 
 |  |  |         <el-table-column prop="quantity" label="排产数量(吨)" width="150" align="right"> | 
 |  |  |           <template #default="scope">{{ scope.row.quantity.toFixed(2) }}</template> | 
 |  |  |         <el-table-column prop="id" label="序号" width="60" type="index"/> | 
 |  |  |         <el-table-column prop="schedulingNum" label="排产数量" width="100"> | 
 |  |  |           <template #default="scope">{{ scope.row.schedulingNum ? scope.row.schedulingNum.toFixed(2) : '0.00' }}</template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column prop="scheduleTime" label="排产时间" width="180" /> | 
 |  |  |         <el-table-column prop="successNum" label="入库数量" width="100"> | 
 |  |  |           <template #default="scope">{{ scope.row.successNum ? scope.row.successNum.toFixed(2) : '0.00' }}</template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column prop="type" label="煤料类型" width="100"> | 
 |  |  |           <template #default="scope"> | 
 |  |  |             <span>{{ scope.row.type === 1 ? '成品' : scope.row.type === 2 ? '原料' : '-' }}</span> | 
 |  |  |           </template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column prop="status" label="状态" width="100"> | 
 |  |  |           <template #default="scope"> | 
 |  |  |             <el-tag | 
 |  |  |               :type="scope.row.status === 'completed' ? 'success' : scope.row.status === 'processing' ? 'warning' : 'info'" | 
 |  |  |               :type="scope.row.status === 3 ? 'success' : scope.row.status === 2 ? 'warning' : 'info'" | 
 |  |  |               size="small" | 
 |  |  |             > | 
 |  |  |               {{ scope.row.status === 'completed' ? '已完成' : scope.row.status === 'processing' ? '排产中' : '待排产' }} | 
 |  |  |               {{ scope.row.status === 3 ? '已报工' : scope.row.status === 2 ? '生产中' : '待生产' }} | 
 |  |  |             </el-tag> | 
 |  |  |           </template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column prop="remark" label="备注" width="200" /> | 
 |  |  |         <el-table-column prop="process" label="工序" width="120" /> | 
 |  |  |         <el-table-column prop="unit" label="单位" width="80" /> | 
 |  |  |         <el-table-column prop="workHours" label="工时定额" width="100"> | 
 |  |  |           <template #default="scope">{{ scope.row.workHours ? scope.row.workHours.toFixed(2) : '0.00' }}</template> | 
 |  |  |         </el-table-column> | 
 |  |  |         <el-table-column prop="schedulingDate" label="排产日期" width="180" /> | 
 |  |  |         <el-table-column prop="schedulingUserName" label="排产人" width="120" /> | 
 |  |  |         <el-table-column prop="createTime" label="创建时间" width="180" /> | 
 |  |  |         <el-table-column prop="updateTime" label="更新时间" width="180" /> | 
 |  |  |       </el-table> | 
 |  |  |     </el-card> | 
 |  |  |   </div> | 
 |  |  | 
 |  |  | <script setup> | 
 |  |  | import { ref, onMounted } from 'vue' | 
 |  |  | import { ElMessage } from 'element-plus' | 
 |  |  | import { getProductionSchedulingInventoryList, getProductionSchedulingStatistics, getProductionSchedulingStatisticsList } from '@/api/productionScheduling' | 
 |  |  |  | 
 |  |  | // 搜索参数 | 
 |  |  | const searchParams = ref({ | 
 |  |  | 
 |  |  |   } | 
 |  |  | ] | 
 |  |  |  | 
 |  |  | // 统计数据 | 
 |  |  | const totalScheduledQuantity = ref(0) | 
 |  |  | const completedScheduledQuantity = ref(0) | 
 |  |  | const pendingScheduledQuantity = ref(0) | 
 |  |  | const stockWarningCount = ref(0) | 
 |  |  |  | 
 |  |  | // 库存原料数据 | 
 |  |  | const stockMaterials = ref([ | 
 |  |  |   { id: 1, coalType: '烟煤', origin: '山西', calorificValue: '5300大卡', currentStock: 1200.5, minStock: 500, unit: '吨', updateTime: '2023-05-07 09:30:15' }, | 
 |  |  |   { id: 2, coalType: '无烟煤', origin: '内蒙古', calorificValue: '5800大卡', currentStock: 800.2, minStock: 400, unit: '吨', updateTime: '2023-05-07 10:15:30' }, | 
 |  |  |   { id: 3, coalType: '褐煤', origin: '新疆', calorificValue: '4200大卡', currentStock: 350.8, minStock: 400, unit: '吨', updateTime: '2023-05-07 11:05:45' }, | 
 |  |  |   { id: 4, coalType: '贫煤', origin: '陕西', calorificValue: '5100大卡', currentStock: 900.0, minStock: 300, unit: '吨', updateTime: '2023-05-07 13:20:00' }, | 
 |  |  |   { id: 5, coalType: '瘦煤', origin: '贵州', calorificValue: '5400大卡', currentStock: 650.5, minStock: 350, unit: '吨', updateTime: '2023-05-07 14:45:15' } | 
 |  |  | ]) | 
 |  |  | const stockMaterials = ref([]) | 
 |  |  |  | 
 |  |  | // 排产结果数据 | 
 |  |  | const schedulingResults = ref([ | 
 |  |  |   { code: 'PS20230507001', productionLine: '生产线1', coalType: '烟煤', quantity: 200.5, scheduleTime: '2023-05-07 09:30:15', status: 'completed', remark: '按计划完成' }, | 
 |  |  |   { code: 'PS20230507002', productionLine: '生产线2', coalType: '无烟煤', quantity: 150.2, scheduleTime: '2023-05-07 10:15:30', status: 'processing', remark: '正在进行中' }, | 
 |  |  |   { code: 'PS20230507003', productionLine: '生产线3', coalType: '贫煤', quantity: 180.0, scheduleTime: '2023-05-07 11:05:45', status: 'pending', remark: '等待排产' } | 
 |  |  | ]) | 
 |  |  | const schedulingResults = ref([]) | 
 |  |  |  | 
 |  |  | // 加载状态 | 
 |  |  | const loading = ref(false) | 
 |  |  |  | 
 |  |  | // 计算统计数据 | 
 |  |  | const calculateStats = () => { | 
 |  |  |   // 计算总排产量 | 
 |  |  |   totalScheduledQuantity.value = schedulingResults.value.reduce((sum, item) => sum + item.quantity, 0) | 
 |  |  |    | 
 |  |  |   // 计算已完成排产 | 
 |  |  |   completedScheduledQuantity.value = schedulingResults.value | 
 |  |  |     .filter(item => item.status === 'completed') | 
 |  |  |     .reduce((sum, item) => sum + item.quantity, 0) | 
 |  |  |    | 
 |  |  |   // 计算待排产 | 
 |  |  |   pendingScheduledQuantity.value = schedulingResults.value | 
 |  |  |     .filter(item => item.status === 'pending') | 
 |  |  |     .reduce((sum, item) => sum + item.quantity, 0) | 
 |  |  |    | 
 |  |  |   // 计算库存预警数量 | 
 |  |  |   stockWarningCount.value = stockMaterials.value.filter(item => item.currentStock < item.minStock).length | 
 |  |  | } | 
 |  |  | // 统计数据 | 
 |  |  | const statisticsData = ref({ | 
 |  |  |   totalOutput: 0, | 
 |  |  |   completedScheduling: 0, | 
 |  |  |   pendingScheduling: 0, | 
 |  |  |   inventoryWarning: 0 | 
 |  |  | }) | 
 |  |  |  | 
 |  |  | // 生成排产编码 | 
 |  |  | const generateSchedulingCode = () => { | 
 |  |  | 
 |  |  |     // 更新库存数量 | 
 |  |  |     randomMaterial.currentStock -= quantity | 
 |  |  |      | 
 |  |  |     // 更新统计数据 | 
 |  |  |     calculateStats() | 
 |  |  |      | 
 |  |  |     ElMessage.success('随机排产成功') | 
 |  |  |   } catch (error) { | 
 |  |  |     console.error('随机排产失败:', error) | 
 |  |  | 
 |  |  |   } | 
 |  |  | } | 
 |  |  |  | 
 |  |  | // 查询数据 | 
 |  |  | const handleSearch = async () => { | 
 |  |  | // 获取库存原料列表 | 
 |  |  | const getStockMaterials = async () => { | 
 |  |  |   try { | 
 |  |  |     loading.value = true | 
 |  |  |      | 
 |  |  |     // 模拟API请求延迟 | 
 |  |  |     await new Promise(resolve => setTimeout(resolve, 800)) | 
 |  |  |     // 构建请求参数 | 
 |  |  |     const params = { | 
 |  |  |       dto: { | 
 |  |  |         entryDateStart: searchParams.value.dateRange && searchParams.value.dateRange[0] ?  | 
 |  |  |           searchParams.value.dateRange[0].toISOString().split('T')[0] : '', | 
 |  |  |         entryDateEnd: searchParams.value.dateRange && searchParams.value.dateRange[1] ?  | 
 |  |  |           searchParams.value.dateRange[1].toISOString().split('T')[0] : '' | 
 |  |  |       } | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     // 这里可以根据搜索条件过滤数据 | 
 |  |  |     // 实际应用中应该调用API获取数据 | 
 |  |  |     // 调用接口获取数据 | 
 |  |  |     const response = await getProductionSchedulingInventoryList(params) | 
 |  |  |      | 
 |  |  |     ElMessage.success('查询成功') | 
 |  |  |     if (response.code === 200 && response.data) { | 
 |  |  |       // 处理返回的数据,将接口字段映射到表格需要的字段 | 
 |  |  |       stockMaterials.value = response.data | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |   } catch (error) { | 
 |  |  |     console.error('查询失败:', error) | 
 |  |  |     ElMessage.error('查询失败,请稍后重试') | 
 |  |  |     console.error('获取库存原料失败:', error) | 
 |  |  |   } finally { | 
 |  |  |     loading.value = false | 
 |  |  |   } | 
 |  |  | } | 
 |  |  |  | 
 |  |  | // 获取统计数据 | 
 |  |  | const getProductionStatistics = async () => { | 
 |  |  |   try { | 
 |  |  |     // 构建请求参数 | 
 |  |  |     const params = { | 
 |  |  |       dto: { | 
 |  |  |         entryDateStart: searchParams.value.dateRange && searchParams.value.dateRange[0] ?  | 
 |  |  |           searchParams.value.dateRange[0].toISOString().split('T')[0] : '', | 
 |  |  |         entryDateEnd: searchParams.value.dateRange && searchParams.value.dateRange[1] ?  | 
 |  |  |           searchParams.value.dateRange[1].toISOString().split('T')[0] : '' | 
 |  |  |       } | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     // 调用接口获取数据 | 
 |  |  |     const response = await getProductionSchedulingStatistics(params) | 
 |  |  |      | 
 |  |  |     if (response.code === 200 && response.data) { | 
 |  |  |       statisticsData.value = response.data | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |   } catch (error) { | 
 |  |  |     console.error('获取统计数据失败:', error) | 
 |  |  |   } | 
 |  |  | } | 
 |  |  |  | 
 |  |  | // 获取排产结果列表 | 
 |  |  | const getSchedulingResults = async () => { | 
 |  |  |   try { | 
 |  |  |     // 构建请求参数 | 
 |  |  |     const params = { | 
 |  |  |       dto: { | 
 |  |  |         entryDateStart: searchParams.value.dateRange && searchParams.value.dateRange[0] ?  | 
 |  |  |           searchParams.value.dateRange[0].toISOString().split('T')[0] : '', | 
 |  |  |         entryDateEnd: searchParams.value.dateRange && searchParams.value.dateRange[1] ?  | 
 |  |  |           searchParams.value.dateRange[1].toISOString().split('T')[0] : '' | 
 |  |  |       } | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |     // 调用接口获取数据 | 
 |  |  |     const response = await getProductionSchedulingStatisticsList(params) | 
 |  |  |      | 
 |  |  |     if (response.code === 200 && response.data) { | 
 |  |  |       schedulingResults.value = response.data | 
 |  |  |     } | 
 |  |  |      | 
 |  |  |   } catch (error) { | 
 |  |  |     console.error('获取排产结果失败:', error) | 
 |  |  |   } | 
 |  |  | } | 
 |  |  |  | 
 |  |  | // 查询数据 | 
 |  |  | const handleSearch = async () => { | 
 |  |  |   await getStockMaterials() | 
 |  |  |   getProductionStatistics() | 
 |  |  |   getSchedulingResults() | 
 |  |  | } | 
 |  |  |  | 
 |  |  | // 重置搜索参数 | 
 |  |  | 
 |  |  |     coalType: '', | 
 |  |  |     status: '' | 
 |  |  |   } | 
 |  |  |    | 
 |  |  |   // 重置后重新查询 | 
 |  |  |   handleSearch() | 
 |  |  | } | 
 |  |  |  | 
 |  |  | 
 |  |  |   const start = new Date() | 
 |  |  |   start.setTime(start.getTime() - 3600 * 1000 * 24 * 7) | 
 |  |  |   searchParams.value.dateRange = [start, end] | 
 |  |  |    | 
 |  |  |   // 计算统计数据 | 
 |  |  |   calculateStats() | 
 |  |  |    | 
 |  |  |   // 初始加载数据 | 
 |  |  |   handleSearch() |