| | |
| | | <div class="home-page"> |
| | | <div class="top-bar"> |
| | | <div class="user-box"> |
| | | <!-- <img :src="userStore.avatar" |
| | | <img :src="userStore.avatar" |
| | | class="avatar" |
| | | alt="" /> --> |
| | | alt="" /> |
| | | <div> |
| | | <div class="hello">{{ userStore.roleName || "系统管理员" }},你好</div> |
| | | <div class="sub">登录时间:{{ userStore.currentLoginTime }}</div> |
| | |
| | | type="primary" |
| | | plain |
| | | @click="refreshDashboardData">刷新数据</el-button> |
| | | <el-button size="small" |
| | | <!-- <el-button size="small" |
| | | plain |
| | | @click="configDialogVisible = true">首页配置</el-button> |
| | | @click="configDialogVisible = true">首页配置</el-button> --> |
| | | </div> |
| | | </div> |
| | | <div class="content-grid"> |
| | |
| | | </el-button> |
| | | </div> |
| | | </section> |
| | | <section class="section-card"> |
| | | <!-- <section class="section-card"> |
| | | <div class="section-title">重点待办</div> |
| | | <div class="todo-row" |
| | | v-for="todo in todos" |
| | |
| | | :type="todo.type">{{ todo.level }}</el-tag> |
| | | <span>{{ todo.title }}</span> |
| | | </div> |
| | | </section> |
| | | </section> --> |
| | | <section class="section-card"> |
| | | <div class="section-title">经营关注</div> |
| | | <div class="focus-row" |
| | |
| | | </section> |
| | | <section class="section-card flex-fill-card"> |
| | | <div class="section-title-row"> |
| | | <div class="section-title">今日待处理</div> |
| | | <el-radio-group v-model="pendingFilter" |
| | | size="small"> |
| | | <el-radio-button label="all">全部</el-radio-button> |
| | | <el-radio-button label="mine">我的</el-radio-button> |
| | | <el-radio-button label="high">高优先</el-radio-button> |
| | | <div class="section-title">区域销售金额分析</div> |
| | | <el-radio-group v-model="chartProductType2" |
| | | size="small" |
| | | @change="fetchSalesAmountChartData"> |
| | | <el-radio-button label="板材">板材</el-radio-button> |
| | | <el-radio-button label="砌块">砌块</el-radio-button> |
| | | </el-radio-group> |
| | | </div> |
| | | <div class="task-row" |
| | | v-for="task in filteredPendingTasks" |
| | | :key="task.id"> |
| | | <div class="task-left"> |
| | | <el-tag size="small" |
| | | :type="task.type">{{ task.level }}</el-tag> |
| | | <span class="task-title">{{ task.title }}</span> |
| | | </div> |
| | | <el-button link |
| | | type="primary" |
| | | @click="goTo(task.path)">去处理</el-button> |
| | | </div> |
| | | <el-empty v-if="filteredPendingTasks.length === 0" |
| | | description="暂无待处理事项" |
| | | :image-size="80" /> |
| | | <Echarts :chartStyle="chartStyle" |
| | | :grid="grid" |
| | | :tooltip="barTooltip" |
| | | :xAxis="salesAmountXAxis" |
| | | :yAxis="salesAmountYAxis" |
| | | :series="salesAmountSeries" |
| | | style="height: 90%" /> |
| | | </section> |
| | | </div> |
| | | <div class="right-col"> |
| | | <section class="section-card" |
| | | <!-- <section class="section-card" |
| | | v-if="isSectionVisible('trendCards')"> |
| | | <div class="section-title">最近7天关键指标趋势</div> |
| | | <div class="trend-cards"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </section> |
| | | </section> --> |
| | | <section class="section-card" |
| | | v-if="isSectionVisible('planTrend')"> |
| | | <div class="section-title-row"> |
| | |
| | | v-if="isSectionVisible('qualityChart') || isSectionVisible('costChart')"> |
| | | <section class="section-card" |
| | | v-if="isSectionVisible('qualityChart')"> |
| | | <div class="section-title-row"> |
| | | <div class="section-title">质检异常分布</div> |
| | | <el-radio-group v-model="chartRangeQuality" |
| | | size="small" |
| | | @change="loadQualityData"> |
| | | <el-radio-button :label="1">周</el-radio-button> |
| | | <el-radio-button :label="2">月</el-radio-button> |
| | | <el-radio-button :label="3">季度</el-radio-button> |
| | | </el-radio-group> |
| | | </div> |
| | | <div class="section-title">今年能耗用量趋势</div> |
| | | <Echarts :chartStyle="chartStyle" |
| | | :grid="grid" |
| | | :tooltip="barTooltip" |
| | | :xAxis="qualityXAxis" |
| | | :xAxis="energyConsumptionXAxis" |
| | | :yAxis="valueYAxis" |
| | | :series="qualitySeries" |
| | | :series="energyConsumptionSeries" |
| | | style="height: 260px" /> |
| | | </section> |
| | | <section class="section-card" |
| | | v-if="isSectionVisible('costChart')"> |
| | | <div class="section-title">能耗与成本结构</div> |
| | | <div class="section-title">今年能耗类型占比</div> |
| | | <Echarts :chartStyle="chartStyle" |
| | | :legend="costLegend" |
| | | :tooltip="pieTooltip" |
| | | :series="costSeries" |
| | | :series="energyTypeSeries" |
| | | style="height: 260px" /> |
| | | </section> |
| | | </div> |
| | | <section class="section-card" |
| | | <!-- <section class="section-card" |
| | | v-if="isSectionVisible('warningCenter')"> |
| | | <div class="section-title">异常预警中心</div> |
| | | <div class="warning-row" |
| | |
| | | <el-empty v-if="warningList.length === 0" |
| | | description="暂无异常预警" |
| | | :image-size="80" /> |
| | | </section> |
| | | </section> --> |
| | | <section class="section-card mini-table-wrap" |
| | | v-if="isSectionVisible('planTable')"> |
| | | <div class="section-title">生产计划执行明细</div> |
| | | <el-table :data="planTable" |
| | | <div class="section-title">最近报工</div> |
| | | <el-table :data="reportingTable" |
| | | size="small" |
| | | stripe> |
| | | <el-table-column prop="planNo" |
| | | label="计划单号" |
| | | stripe |
| | | :loading="reportingTableLoading"> |
| | | <el-table-column prop="productNo" |
| | | label="报工编号" |
| | | min-width="150" /> |
| | | <el-table-column prop="product" |
| | | label="产品" |
| | | min-width="120" /> |
| | | <el-table-column prop="qty" |
| | | label="计划量" |
| | | min-width="90" /> |
| | | <el-table-column prop="issued" |
| | | label="已下发" |
| | | min-width="90" /> |
| | | <el-table-column prop="status" |
| | | label="状态" |
| | | <el-table-column prop="schedule" |
| | | label="班组" |
| | | min-width="80"> |
| | | <template #default="{ row }"> |
| | | <el-tag :type="row.schedule === '白班' ? 'primary' : 'warning'">{{ row.schedule || '-' }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="postName" |
| | | label="创建人" |
| | | min-width="100" /> |
| | | <el-table-column label="操作" |
| | | <el-table-column prop="createTime" |
| | | label="报工时间" |
| | | min-width="150"> |
| | | <template #default="{ row }"> |
| | | {{ row.createTime ? dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') : '' }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="productName" |
| | | label="产品" |
| | | min-width="120"> |
| | | <template #default="{ row }"> |
| | | <el-button link |
| | | type="primary" |
| | | @click="goTo(routePathMap.plan)">查看</el-button> |
| | | <el-button v-if="row.status !== '已完成'" |
| | | link |
| | | type="success" |
| | | @click="goTo(routePathMap.dispatch)"> |
| | | 下发 |
| | | </el-button> |
| | | <el-tag :type="row.productName === '砌块' ? 'primary' : 'warning'">{{ row.productName || '-' }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="totalQuantity" |
| | | label="生产数量" |
| | | min-width="100"> |
| | | <template #default="{ row }"> |
| | | <span style="color:rgba(18, 148, 212, 0.8);">{{ row.totalQuantity || '-' }}</span> 方 |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="quantity" |
| | | label="合格数量" |
| | | min-width="100"> |
| | | <template #default="{ row }"> |
| | | <span style="color:rgba(0, 228, 99, 0.8);">{{ row.quantity || '-' }}</span> 方 |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | |
| | | processDataProductionStatistics, |
| | | qualityInspectionStatistics, |
| | | nonComplianceWarning, |
| | | getManageStatistics, |
| | | } from "@/api/viewIndex.js"; |
| | | import { energyConsumptionDetailStatistics } from "@/api/energyManagement/energyType"; |
| | | import { getSalesAmountAnalysis } from "@/api/reportAnalysis/salesStatistics"; |
| | | import { productionReportListPage } from "@/api/productionManagement/productionReporting.js"; |
| | | import dayjs from "dayjs"; |
| | | |
| | | const router = useRouter(); |
| | | const userStore = useUserStore(); |
| | |
| | | { name: "已完成订单数", value: "-" }, |
| | | { name: "未完成订单数", value: "-" }, |
| | | { name: "部分完成订单数", value: "-" }, |
| | | { name: "质检总数", value: "-" }, |
| | | { name: "过程检总数", value: "-" }, |
| | | { name: "来料检总数", value: "-" }, |
| | | // { name: "过程检总数", value: "-" }, |
| | | ]); |
| | | |
| | | const pendingTasks = reactive([]); |
| | |
| | | }, |
| | | ]); |
| | | |
| | | const planTable = reactive([]); |
| | | // 能耗类型占比数据 |
| | | const energyTypeSeries = reactive([ |
| | | { |
| | | type: "pie", |
| | | radius: ["40%", "70%"], |
| | | center: ["50%", "50%"], |
| | | avoidLabelOverlap: false, |
| | | itemStyle: { |
| | | borderRadius: 10, |
| | | borderColor: "#fff", |
| | | borderWidth: 2, |
| | | }, |
| | | label: { |
| | | show: true, |
| | | formatter: "{b}: {d}%", |
| | | }, |
| | | data: [ |
| | | { value: 0, name: "水", itemStyle: { color: "#409EFF" } }, |
| | | { value: 0, name: "电", itemStyle: { color: "#E6A23C" } }, |
| | | { value: 0, name: "气", itemStyle: { color: "#F56C6C" } }, |
| | | ], |
| | | }, |
| | | ]); |
| | | |
| | | // 能耗用量趋势图表 |
| | | const energyConsumptionXAxis = reactive({ |
| | | type: "category", |
| | | data: [], |
| | | axisLabel: { |
| | | rotate: 45, |
| | | }, |
| | | }); |
| | | |
| | | const energyConsumptionSeries = reactive([ |
| | | { |
| | | name: "用水量", |
| | | type: "bar", |
| | | data: [], |
| | | itemStyle: { color: "#409EFF" }, |
| | | }, |
| | | { |
| | | name: "用电量", |
| | | type: "bar", |
| | | data: [], |
| | | itemStyle: { color: "#E6A23C" }, |
| | | }, |
| | | { |
| | | name: "用气量", |
| | | type: "bar", |
| | | data: [], |
| | | itemStyle: { color: "#67C23A" }, |
| | | }, |
| | | ]); |
| | | |
| | | // 销售金额图表 |
| | | const chartProductType2 = ref("砌块"); |
| | | const salesAmountChartData = ref({ |
| | | dates: [], |
| | | customerTrends: [], |
| | | }); |
| | | |
| | | const salesAmountXAxis = reactive({ |
| | | type: "value", |
| | | axisLabel: { |
| | | interval: "auto", |
| | | formatter: value => { |
| | | // 格式化金额,显示为更易读的形式 |
| | | if (value >= 10000) { |
| | | return (value / 10000).toFixed(0) + "万"; |
| | | } |
| | | return value; |
| | | }, |
| | | }, |
| | | axisTick: { |
| | | interval: "auto", |
| | | }, |
| | | }); |
| | | |
| | | const salesAmountYAxis = reactive({ |
| | | type: "category", |
| | | data: [], |
| | | axisLabel: { |
| | | rotate: 0, |
| | | }, |
| | | }); |
| | | |
| | | const salesAmountSeries = reactive([]); |
| | | |
| | | // 获取销售金额分析图表数据 |
| | | const fetchSalesAmountChartData = async () => { |
| | | try { |
| | | const response = await getSalesAmountAnalysis({ |
| | | type: chartProductType2.value, |
| | | days: "年", // 默认年 |
| | | }); |
| | | if (response?.data) { |
| | | salesAmountChartData.value = response.data; |
| | | updateSalesAmountChart(); |
| | | } |
| | | } catch (error) { |
| | | console.error("获取销售金额分析图表数据失败:", error); |
| | | // 使用模拟数据 |
| | | salesAmountChartData.value = { |
| | | dates: [ |
| | | "2026-01-01", |
| | | "2025-01-01", |
| | | "2024-01-01", |
| | | "2023-01-01", |
| | | "2022-01-01", |
| | | ], |
| | | customerTrends: [ |
| | | { 内蒙古: 100, 银川: 200, 自提: 300, 其他: 150, 全部: 750 }, |
| | | { 内蒙古: 80, 银川: 180, 自提: 280, 其他: 130, 全部: 670 }, |
| | | { 内蒙古: 90, 银川: 190, 自提: 290, 其他: 140, 全部: 710 }, |
| | | { 内蒙古: 70, 银川: 170, 自提: 270, 其他: 120, 全部: 630 }, |
| | | { 内蒙古: 110, 银川: 210, 自提: 310, 其他: 160, 全部: 790 }, |
| | | ], |
| | | }; |
| | | updateSalesAmountChart(); |
| | | } |
| | | }; |
| | | |
| | | // 更新销售金额图表 |
| | | const updateSalesAmountChart = () => { |
| | | const { customerTrends = [] } = salesAmountChartData.value; |
| | | |
| | | // 计算每个销售区域的总销售额(过滤掉"全部") |
| | | const areaTotalMap = new Map(); |
| | | customerTrends.forEach(item => { |
| | | Object.keys(item).forEach(key => { |
| | | // 过滤掉"全部"销售区域 |
| | | if (key !== "全部") { |
| | | const value = item[key] || 0; |
| | | if (areaTotalMap.has(key)) { |
| | | areaTotalMap.set(key, areaTotalMap.get(key) + value); |
| | | } else { |
| | | areaTotalMap.set(key, value); |
| | | } |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | // 转换为数组 |
| | | const salesAreas = Array.from(areaTotalMap.keys()); |
| | | |
| | | const colors = [ |
| | | "#00A4ED", |
| | | "#34D8F7", |
| | | "#4A8BFF", |
| | | "#8A6BFF", |
| | | "#C8C447", |
| | | "#FF6B6B", |
| | | ]; |
| | | |
| | | // 更新Y轴数据(现在是销售区域) |
| | | salesAmountYAxis.data = salesAreas; |
| | | |
| | | // 更新系列数据(每个销售区域的总销售额) |
| | | salesAmountSeries.splice(0, salesAmountSeries.length); |
| | | salesAmountSeries.push({ |
| | | name: "销售金额", |
| | | data: salesAreas.map(area => areaTotalMap.get(area)), |
| | | type: "bar", |
| | | itemStyle: { color: "#00A4ED" }, |
| | | }); |
| | | }; |
| | | |
| | | // 模拟能耗数据 |
| | | const energyData = reactive({ |
| | | water: 120, |
| | | electricity: 350, |
| | | gas: 80, |
| | | }); |
| | | |
| | | // 更新能耗类型占比图表和能耗用量趋势图表 |
| | | const updateEnergyTypeChart = () => { |
| | | // 构建参数:今年的年初到年末以及天数 |
| | | const currentYear = new Date().getFullYear(); |
| | | const params = { |
| | | startDate: `${currentYear}-01-01`, |
| | | endDate: `${currentYear}-12-31`, |
| | | days: 365, |
| | | state: "年", |
| | | }; |
| | | |
| | | // 调用接口获取数据 |
| | | energyConsumptionDetailStatistics(params) |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | const data = res.data; |
| | | // 处理能耗类型占比数据 |
| | | const energyTypeData = data.energyCostDtos || []; |
| | | |
| | | // 计算各能耗类型的总消耗量 |
| | | let total = 0; |
| | | const typeMap = { |
| | | 水: 0, |
| | | 电: 0, |
| | | 气: 0, |
| | | }; |
| | | |
| | | // 准备能耗用量趋势图表数据 |
| | | const dates = []; |
| | | const waterConsumptionData = []; |
| | | const electricityConsumptionData = []; |
| | | const gasConsumptionData = []; |
| | | |
| | | energyTypeData.forEach(item => { |
| | | // 收集日期和各能耗类型数据 |
| | | if (item.meterReadingDate) { |
| | | dates.push(item.meterReadingDate); |
| | | waterConsumptionData.push(item.waterConsumption || 0); |
| | | electricityConsumptionData.push(item.electricityConsumption || 0); |
| | | gasConsumptionData.push(item.gasConsumption || 0); |
| | | } |
| | | |
| | | // 计算总消耗量 |
| | | if (item.waterConsumption) |
| | | typeMap.水 += Number(item.waterConsumption); |
| | | if (item.electricityConsumption) |
| | | typeMap.电 += Number(item.electricityConsumption); |
| | | if (item.gasConsumption) typeMap.气 += Number(item.gasConsumption); |
| | | }); |
| | | |
| | | total = typeMap.水 + typeMap.电 + typeMap.气; |
| | | |
| | | // 更新能耗类型占比图表数据 |
| | | energyTypeSeries[0].data = [ |
| | | { |
| | | value: total > 0 ? ((typeMap.水 / total) * 100).toFixed(2) : 0, |
| | | name: "水", |
| | | itemStyle: { color: "#409EFF" }, |
| | | }, |
| | | { |
| | | value: total > 0 ? ((typeMap.电 / total) * 100).toFixed(2) : 0, |
| | | name: "电", |
| | | itemStyle: { color: "#E6A23C" }, |
| | | }, |
| | | { |
| | | value: total > 0 ? ((typeMap.气 / total) * 100).toFixed(2) : 0, |
| | | name: "气", |
| | | itemStyle: { color: "#F56C6C" }, |
| | | }, |
| | | ]; |
| | | |
| | | // 更新能耗用量趋势图表数据 |
| | | energyConsumptionXAxis.data = dates; |
| | | energyConsumptionSeries[0].data = waterConsumptionData; |
| | | energyConsumptionSeries[1].data = electricityConsumptionData; |
| | | energyConsumptionSeries[2].data = gasConsumptionData; |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | console.error("获取能耗数据异常:", err); |
| | | }); |
| | | }; |
| | | |
| | | // 报工表格数据 |
| | | const reportingTable = ref([]); |
| | | const reportingTableLoading = ref(false); |
| | | |
| | | // 获取最近报工数据 |
| | | const fetchReportingData = () => { |
| | | reportingTableLoading.value = true; |
| | | productionReportListPage({ |
| | | current: 1, |
| | | size: 5, // 只显示最近5条 |
| | | }) |
| | | .then(res => { |
| | | if (res.code === 200) { |
| | | console.log(res.data.records || []); |
| | | reportingTable.value = res.data.records || []; |
| | | } else { |
| | | reportingTable.value = []; |
| | | } |
| | | }) |
| | | .catch(error => { |
| | | console.error("获取报工数据失败:", error); |
| | | reportingTable.value = []; |
| | | }) |
| | | .finally(() => { |
| | | reportingTableLoading.value = false; |
| | | }); |
| | | }; |
| | | const recentTrendCards = reactive([ |
| | | { |
| | | key: "planIssued", |
| | |
| | | }; |
| | | |
| | | const loadHomeTodos = async () => { |
| | | try { |
| | | const res = await homeTodos(); |
| | | const list = Array.isArray(res?.data) ? res.data : []; |
| | | const mapped = list.slice(0, 4).map((item, idx) => { |
| | | const text = |
| | | item?.approveReason || item?.approveTypeName || `待处理事项 ${idx + 1}`; |
| | | const levelType = idx === 0 ? "danger" : idx <= 2 ? "warning" : "success"; |
| | | const level = idx === 0 ? "高" : idx <= 2 ? "中" : "低"; |
| | | return { level, title: text, type: levelType }; |
| | | }); |
| | | updateArray(todos, mapped); |
| | | const pendingMapped = list.slice(0, 4).map((item, idx) => { |
| | | const title = |
| | | item?.approveReason || item?.approveTypeName || `待处理事项 ${idx + 1}`; |
| | | const path = inferTodoPath(item); |
| | | return { |
| | | id: item?.id || `${idx}-${title}`, |
| | | title, |
| | | level: idx === 0 ? "高" : idx <= 2 ? "中" : "低", |
| | | type: idx === 0 ? "danger" : idx <= 2 ? "warning" : "success", |
| | | path, |
| | | ownerId: item?.approveUserId || item?.userId || "", |
| | | ownerName: item?.approveUserName || item?.userName || "", |
| | | }; |
| | | }); |
| | | updateArray(pendingTasks, pendingMapped); |
| | | } catch (error) { |
| | | console.error("homeTodos接口获取失败:", error); |
| | | } |
| | | // try { |
| | | // const res = await homeTodos(); |
| | | // const list = Array.isArray(res?.data) ? res.data : []; |
| | | // const mapped = list.slice(0, 4).map((item, idx) => { |
| | | // const text = |
| | | // item?.approveReason || item?.approveTypeName || `待处理事项 ${idx + 1}`; |
| | | // const levelType = idx === 0 ? "danger" : idx <= 2 ? "warning" : "success"; |
| | | // const level = idx === 0 ? "高" : idx <= 2 ? "中" : "低"; |
| | | // return { level, title: text, type: levelType }; |
| | | // }); |
| | | // updateArray(todos, mapped); |
| | | // const pendingMapped = list.slice(0, 4).map((item, idx) => { |
| | | // const title = |
| | | // item?.approveReason || item?.approveTypeName || `待处理事项 ${idx + 1}`; |
| | | // const path = inferTodoPath(item); |
| | | // return { |
| | | // id: item?.id || `${idx}-${title}`, |
| | | // title, |
| | | // level: idx === 0 ? "高" : idx <= 2 ? "中" : "低", |
| | | // type: idx === 0 ? "danger" : idx <= 2 ? "warning" : "success", |
| | | // path, |
| | | // ownerId: item?.approveUserId || item?.userId || "", |
| | | // ownerName: item?.approveUserName || item?.userName || "", |
| | | // }; |
| | | // }); |
| | | // updateArray(pendingTasks, pendingMapped); |
| | | // } catch (error) { |
| | | // console.error("homeTodos接口获取失败:", error); |
| | | // } |
| | | }; |
| | | |
| | | const loadOrderAndProgress = async () => { |
| | | try { |
| | | const [orderRes, progressRes] = await Promise.allSettled([ |
| | | orderCount(), |
| | | getProgressStatistics(), |
| | | ]); |
| | | |
| | | if (orderRes.status === "fulfilled") { |
| | | const items = Array.isArray(orderRes.value?.data) |
| | | ? orderRes.value.data |
| | | : []; |
| | | const byName = Object.fromEntries( |
| | | items.map(i => [String(i?.name || "").replace(/\s/g, ""), i?.value]) |
| | | ); |
| | | businessFocus[0].value = `${ |
| | | pickFirstNumber(byName, ["生产订单数", "生产订单总数", "总订单数"]) || 0 |
| | | } 单`; |
| | | businessFocus[1].value = `${ |
| | | pickFirstNumber(byName, ["已完成订单数"]) || 0 |
| | | } 单`; |
| | | businessFocus[2].value = `${ |
| | | pickFirstNumber(byName, ["待生产订单数", "未完成订单数"]) || 0 |
| | | } 单`; |
| | | businessFocus[3].value = `${ |
| | | pickFirstNumber(byName, ["部分完成订单数"]) || 0 |
| | | } 单`; |
| | | } |
| | | |
| | | if (progressRes.status === "fulfilled") { |
| | | const p = progressRes.value?.data || {}; |
| | | const detail = Array.isArray(p.completedOrderDetails) |
| | | ? p.completedOrderDetails |
| | | : []; |
| | | const rows = detail.slice(0, 6).map((item, index) => { |
| | | const qty = pickFirstNumber(item, ["quantity", "planQuantity"]); |
| | | const done = pickFirstNumber(item, [ |
| | | "completeQuantity", |
| | | "completedQuantity", |
| | | ]); |
| | | return { |
| | | planNo: item.npsNo || item.productionPlanNo || `NO-${index + 1}`, |
| | | product: item.productCategory || item.productName || "-", |
| | | qty, |
| | | issued: done, |
| | | status: |
| | | qty > 0 && done >= qty ? "已完成" : done > 0 ? "执行中" : "待下发", |
| | | }; |
| | | }); |
| | | updateArray(planTable, rows); |
| | | setTrendCard( |
| | | "planIssued", |
| | | detail |
| | | .slice(-7) |
| | | .map(i => |
| | | pickFirstNumber(i, [ |
| | | "completeQuantity", |
| | | "completedQuantity", |
| | | "issueNum", |
| | | ]) |
| | | ) |
| | | ); |
| | | } |
| | | } catch (error) { |
| | | console.error("orderCount/getProgressStatistics接口获取失败:", error); |
| | | } |
| | | // try { |
| | | // const [orderRes, progressRes] = await Promise.allSettled([ |
| | | // orderCount(), |
| | | // getProgressStatistics(), |
| | | // ]); |
| | | // if (orderRes.status === "fulfilled") { |
| | | // const items = Array.isArray(orderRes.value?.data) |
| | | // ? orderRes.value.data |
| | | // : []; |
| | | // const byName = Object.fromEntries( |
| | | // items.map(i => [String(i?.name || "").replace(/\s/g, ""), i?.value]) |
| | | // ); |
| | | // businessFocus[0].value = `${ |
| | | // pickFirstNumber(byName, ["生产订单数", "生产订单总数", "总订单数"]) || 0 |
| | | // } 单`; |
| | | // businessFocus[1].value = `${ |
| | | // pickFirstNumber(byName, ["已完成订单数"]) || 0 |
| | | // } 单`; |
| | | // businessFocus[2].value = `${ |
| | | // pickFirstNumber(byName, ["待生产订单数", "未完成订单数"]) || 0 |
| | | // } 单`; |
| | | // businessFocus[3].value = `${ |
| | | // pickFirstNumber(byName, ["部分完成订单数"]) || 0 |
| | | // } 单`; |
| | | // } |
| | | // if (progressRes.status === "fulfilled") { |
| | | // const p = progressRes.value?.data || {}; |
| | | // const detail = Array.isArray(p.completedOrderDetails) |
| | | // ? p.completedOrderDetails |
| | | // : []; |
| | | // const rows = detail.slice(0, 6).map((item, index) => { |
| | | // const qty = pickFirstNumber(item, ["quantity", "planQuantity"]); |
| | | // const done = pickFirstNumber(item, [ |
| | | // "completeQuantity", |
| | | // "completedQuantity", |
| | | // ]); |
| | | // return { |
| | | // planNo: item.npsNo || item.productionPlanNo || `NO-${index + 1}`, |
| | | // product: item.productCategory || item.productName || "-", |
| | | // qty, |
| | | // issued: done, |
| | | // status: |
| | | // qty > 0 && done >= qty ? "已完成" : done > 0 ? "执行中" : "待下发", |
| | | // }; |
| | | // }); |
| | | // updateArray(planTable, rows); |
| | | // setTrendCard( |
| | | // "planIssued", |
| | | // detail |
| | | // .slice(-7) |
| | | // .map(i => |
| | | // pickFirstNumber(i, [ |
| | | // "completeQuantity", |
| | | // "completedQuantity", |
| | | // "issueNum", |
| | | // ]) |
| | | // ) |
| | | // ); |
| | | // } |
| | | // } catch (error) { |
| | | // console.error("orderCount/getProgressStatistics接口获取失败:", error); |
| | | // } |
| | | }; |
| | | |
| | | const inferTodoPath = todo => { |
| | |
| | | }; |
| | | |
| | | const loadPlanTrend = async () => { |
| | | try { |
| | | const res = await processDataProductionStatistics({ |
| | | type: chartRangePlan.value, |
| | | }); |
| | | const list = Array.isArray(res?.data) ? res.data : []; |
| | | planXAxis[0].data = list.map( |
| | | (i, index) => i.processName || `工序${index + 1}` |
| | | ); |
| | | planSeries[0].data = list.map(i => |
| | | pickFirstNumber(i, ["totalInput", "input", "planNum"]) |
| | | ); |
| | | planSeries[1].data = list.map(i => |
| | | pickFirstNumber(i, ["totalOutput", "output", "issueNum"]) |
| | | ); |
| | | planSeries[2].data = list.map(i => |
| | | pickFirstNumber(i, ["totalScrap", "scrap", "completeNum"]) |
| | | ); |
| | | } catch (error) { |
| | | console.error("processDataProductionStatistics接口获取失败:", error); |
| | | } |
| | | // try { |
| | | // const res = await processDataProductionStatistics({ |
| | | // type: chartRangePlan.value, |
| | | // }); |
| | | // const list = Array.isArray(res?.data) ? res.data : []; |
| | | // planXAxis[0].data = list.map( |
| | | // (i, index) => i.processName || `工序${index + 1}` |
| | | // ); |
| | | // planSeries[0].data = list.map(i => |
| | | // pickFirstNumber(i, ["totalInput", "input", "planNum"]) |
| | | // ); |
| | | // planSeries[1].data = list.map(i => |
| | | // pickFirstNumber(i, ["totalOutput", "output", "issueNum"]) |
| | | // ); |
| | | // planSeries[2].data = list.map(i => |
| | | // pickFirstNumber(i, ["totalScrap", "scrap", "completeNum"]) |
| | | // ); |
| | | // } catch (error) { |
| | | // console.error("processDataProductionStatistics接口获取失败:", error); |
| | | // } |
| | | }; |
| | | |
| | | const loadQualityData = async () => { |
| | | try { |
| | | const res = await qualityInspectionStatistics({ |
| | | type: chartRangeQuality.value, |
| | | }); |
| | | const data = res?.data || {}; |
| | | const items = Array.isArray(data.item) ? data.item : []; |
| | | if (items.length > 0) { |
| | | qualityXAxis[0].data = items.map(i => i.date || i.name || "-"); |
| | | qualitySeries[0].data = items.map(i => |
| | | pickFirstNumber(i, [ |
| | | "supplierNum", |
| | | "processNum", |
| | | "factoryNum", |
| | | "totalNum", |
| | | ]) |
| | | ); |
| | | setTrendCard( |
| | | "qualityRaw", |
| | | items.map(i => pickFirstNumber(i, ["supplierNum"])) |
| | | ); |
| | | setTrendCard( |
| | | "qualityProcess", |
| | | items.map(i => pickFirstNumber(i, ["processNum"])) |
| | | ); |
| | | setTrendCard( |
| | | "qualityFactory", |
| | | items.map(i => pickFirstNumber(i, ["factoryNum"])) |
| | | ); |
| | | } else { |
| | | qualityXAxis[0].data = ["来料检", "过程检", "成品检"]; |
| | | qualitySeries[0].data = [ |
| | | pickFirstNumber(data, ["supplierNum"]), |
| | | pickFirstNumber(data, ["processNum"]), |
| | | pickFirstNumber(data, ["factoryNum"]), |
| | | ]; |
| | | setTrendCard("qualityRaw", [pickFirstNumber(data, ["supplierNum"])]); |
| | | setTrendCard("qualityProcess", [pickFirstNumber(data, ["processNum"])]); |
| | | setTrendCard("qualityFactory", [pickFirstNumber(data, ["factoryNum"])]); |
| | | } |
| | | businessFocus[4].value = `${pickFirstNumber(data, [ |
| | | "supplierNum", |
| | | "totalNum", |
| | | ])} 条`; |
| | | businessFocus[5].value = `${pickFirstNumber(data, ["processNum"])} 条`; |
| | | } catch (error) { |
| | | console.error("qualityInspectionStatistics接口获取失败:", error); |
| | | } |
| | | // try { |
| | | // const res = await qualityInspectionStatistics({ |
| | | // type: chartRangeQuality.value, |
| | | // }); |
| | | // const data = res?.data || {}; |
| | | // const items = Array.isArray(data.item) ? data.item : []; |
| | | // if (items.length > 0) { |
| | | // qualityXAxis[0].data = items.map(i => i.date || i.name || "-"); |
| | | // qualitySeries[0].data = items.map(i => |
| | | // pickFirstNumber(i, [ |
| | | // "supplierNum", |
| | | // "processNum", |
| | | // "factoryNum", |
| | | // "totalNum", |
| | | // ]) |
| | | // ); |
| | | // setTrendCard( |
| | | // "qualityRaw", |
| | | // items.map(i => pickFirstNumber(i, ["supplierNum"])) |
| | | // ); |
| | | // setTrendCard( |
| | | // "qualityProcess", |
| | | // items.map(i => pickFirstNumber(i, ["processNum"])) |
| | | // ); |
| | | // setTrendCard( |
| | | // "qualityFactory", |
| | | // items.map(i => pickFirstNumber(i, ["factoryNum"])) |
| | | // ); |
| | | // } else { |
| | | // qualityXAxis[0].data = ["来料检", "过程检", "成品检"]; |
| | | // qualitySeries[0].data = [ |
| | | // pickFirstNumber(data, ["supplierNum"]), |
| | | // pickFirstNumber(data, ["processNum"]), |
| | | // pickFirstNumber(data, ["factoryNum"]), |
| | | // ]; |
| | | // setTrendCard("qualityRaw", [pickFirstNumber(data, ["supplierNum"])]); |
| | | // setTrendCard("qualityProcess", [pickFirstNumber(data, ["processNum"])]); |
| | | // setTrendCard("qualityFactory", [pickFirstNumber(data, ["factoryNum"])]); |
| | | // } |
| | | // businessFocus[4].value = `${pickFirstNumber(data, [ |
| | | // "supplierNum", |
| | | // "totalNum", |
| | | // ])} 条`; |
| | | // businessFocus[5].value = `${pickFirstNumber(data, ["processNum"])} 条`; |
| | | // } catch (error) { |
| | | // console.error("qualityInspectionStatistics接口获取失败:", error); |
| | | // } |
| | | }; |
| | | |
| | | const loadWarningCenter = async () => { |
| | | try { |
| | | const res = await nonComplianceWarning(); |
| | | const list = Array.isArray(res?.data) ? res.data : []; |
| | | const mapped = list.slice(0, 6).map((item, idx) => { |
| | | const levelNum = toNumber(item.level ?? item.warningLevel ?? 2); |
| | | const levelType = |
| | | levelNum >= 3 ? "danger" : levelNum === 2 ? "warning" : "info"; |
| | | const levelText = levelNum >= 3 ? "高" : levelNum === 2 ? "中" : "低"; |
| | | const title = |
| | | item.name || item.title || item.paramName || `异常预警 ${idx + 1}`; |
| | | const text = `${title}${item.processName || ""}${ |
| | | item.orderNo || "" |
| | | }`.toLowerCase(); |
| | | const path = text.includes("质检") |
| | | ? routePathMap.processInspection |
| | | : text.includes("订单") |
| | | ? routePathMap.order |
| | | : routePathMap.processInspection || |
| | | routePathMap.order || |
| | | routePathMap.plan; |
| | | return { |
| | | id: item.id || `${idx}-${title}`, |
| | | levelType, |
| | | levelText, |
| | | title, |
| | | path, |
| | | }; |
| | | }); |
| | | updateArray(warningList, mapped); |
| | | } catch (error) { |
| | | console.error("nonComplianceWarning接口获取失败:", error); |
| | | updateArray(warningList, []); |
| | | } |
| | | // try { |
| | | // const res = await nonComplianceWarning(); |
| | | // const list = Array.isArray(res?.data) ? res.data : []; |
| | | // const mapped = list.slice(0, 6).map((item, idx) => { |
| | | // const levelNum = toNumber(item.level ?? item.warningLevel ?? 2); |
| | | // const levelType = |
| | | // levelNum >= 3 ? "danger" : levelNum === 2 ? "warning" : "info"; |
| | | // const levelText = levelNum >= 3 ? "高" : levelNum === 2 ? "中" : "低"; |
| | | // const title = |
| | | // item.name || item.title || item.paramName || `异常预警 ${idx + 1}`; |
| | | // const text = `${title}${item.processName || ""}${ |
| | | // item.orderNo || "" |
| | | // }`.toLowerCase(); |
| | | // const path = text.includes("质检") |
| | | // ? routePathMap.processInspection |
| | | // : text.includes("订单") |
| | | // ? routePathMap.order |
| | | // : routePathMap.processInspection || |
| | | // routePathMap.order || |
| | | // routePathMap.plan; |
| | | // return { |
| | | // id: item.id || `${idx}-${title}`, |
| | | // levelType, |
| | | // levelText, |
| | | // title, |
| | | // path, |
| | | // }; |
| | | // }); |
| | | // updateArray(warningList, mapped); |
| | | // } catch (error) { |
| | | // console.error("nonComplianceWarning接口获取失败:", error); |
| | | // updateArray(warningList, []); |
| | | // } |
| | | }; |
| | | |
| | | const initSectionConfig = () => { |
| | |
| | | }; |
| | | |
| | | const loadCostComposition = async () => { |
| | | // try { |
| | | // const res = await expenseCompositionAnalysis({ type: 1 }); |
| | | // const list = Array.isArray(res?.data) ? res.data : []; |
| | | // const mapped = list.map(i => ({ |
| | | // name: i.name || "未命名", |
| | | // value: pickFirstNumber(i, ["value", "amount", "cost"]), |
| | | // })); |
| | | // costSeries[0].data = mapped; |
| | | // } catch (error) { |
| | | // console.error("expenseCompositionAnalysis接口获取失败:", error); |
| | | // } |
| | | }; |
| | | const loadManageStatistics = async () => { |
| | | try { |
| | | const res = await expenseCompositionAnalysis({ type: 1 }); |
| | | const list = Array.isArray(res?.data) ? res.data : []; |
| | | const mapped = list.map(i => ({ |
| | | name: i.name || "未命名", |
| | | value: pickFirstNumber(i, ["value", "amount", "cost"]), |
| | | })); |
| | | costSeries[0].data = mapped; |
| | | const res = await getManageStatistics(); |
| | | const data = res?.data || {}; |
| | | businessFocus[0].value = `${pickFirstNumber(data, ["total"])} 条`; |
| | | businessFocus[1].value = `${pickFirstNumber(data, ["completed"])} 条`; |
| | | businessFocus[2].value = `${pickFirstNumber(data, ["uncompleted"])} 条`; |
| | | businessFocus[3].value = `${pickFirstNumber(data, [ |
| | | "partialCompleted", |
| | | ])} 条`; |
| | | businessFocus[4].value = `${pickFirstNumber(data, [ |
| | | "materialInspection", |
| | | ])} 条`; |
| | | // businessFocus[5].value = `${pickFirstNumber(data, [""])} 条`; |
| | | } catch (error) { |
| | | console.error("expenseCompositionAnalysis接口获取失败:", error); |
| | | console.error("manageStatistics接口获取失败:", error); |
| | | } |
| | | }; |
| | | |
| | | const refreshDashboardData = () => { |
| | | loadHomeTodos(); |
| | | loadOrderAndProgress(); |
| | | loadPlanTrend(); |
| | | loadQualityData(); |
| | | loadCostComposition(); |
| | | loadWarningCenter(); |
| | | // loadHomeTodos(); |
| | | // loadOrderAndProgress(); |
| | | // loadPlanTrend(); |
| | | // loadQualityData(); |
| | | // loadCostComposition(); |
| | | // loadWarningCenter(); |
| | | loadManageStatistics(); |
| | | updateEnergyTypeChart(); |
| | | fetchSalesAmountChartData(); |
| | | fetchReportingData(); |
| | | lastUpdatedAt.value = new Date().toLocaleString(); |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | // initSectionConfig(); |
| | | // refreshDashboardData(); |
| | | refreshDashboardData(); |
| | | }); |
| | | </script> |
| | | |