348 lines
14 KiB
Plaintext
348 lines
14 KiB
Plaintext
@model WalkingTec.Mvvm.Core.BaseVM
|
|
@using System.Text.Json
|
|
|
|
<div id="app">
|
|
<div id="fullscreen-container" style="padding: 20px; background-color: #f2f3f5; min-height: 100vh; position: relative;">
|
|
<!-- 全屏按钮 -->
|
|
<div style="position: absolute; top: 20px; right: 20px; z-index: 100;">
|
|
<a-button type="primary" shape="circle" @@click="toggleFullscreen">
|
|
<template #icon>
|
|
<icon-fullscreen-exit v-if="isFullscreen"></icon-fullscreen-exit>
|
|
<icon-fullscreen v-else></icon-fullscreen>
|
|
</template>
|
|
</a-button>
|
|
</div>
|
|
|
|
<a-grid :cols="24" :col-gap="16" :row-gap="16">
|
|
<!-- 一周内出入库任务统计柱状图 -->
|
|
<a-grid-item :span="24">
|
|
<a-card title="一周内出入库任务统计" :bordered="false" :style="{ borderRadius: '8px' }">
|
|
<div id="taskHistoryChart" style="width: 100%; height: 350px;"></div>
|
|
</a-card>
|
|
</a-grid-item>
|
|
|
|
<!-- 库内库位统计南丁格尔图 -->
|
|
<a-grid-item :span="12">
|
|
<a-card title="库内库位统计" :bordered="false" :style="{ borderRadius: '8px' }">
|
|
<div id="locationChart" style="width: 100%; height: 350px;"></div>
|
|
</a-card>
|
|
</a-grid-item>
|
|
|
|
<!-- 当前任务统计仪表盘 -->
|
|
<a-grid-item :span="12">
|
|
<a-card title="未完成任务统计" :bordered="false" :style="{ borderRadius: '8px' }">
|
|
<div id="currentTaskChart" style="width: 100%; height: 350px;"></div>
|
|
</a-card>
|
|
</a-grid-item>
|
|
<!-- Heatmap Display -->
|
|
<a-grid-item :span="24">
|
|
<a-card title="库位占用分布 (Heatmap)" :bordered="false" :style="{ borderRadius: '8px' }">
|
|
<!-- 状态图例 -->
|
|
<div style="margin-bottom: 16px; display: flex; justify-content: center; gap: 20px;">
|
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
<div style="width: 16px; height: 16px; background-color: #EBEEF5; border: 1px solid #DCDFE6; border-radius: 2px;"></div>
|
|
<span style="font-size: 13px;">空仓位</span>
|
|
</div>
|
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
<div style="width: 16px; height: 16px; background-color: #1890FF; border-radius: 2px;"></div>
|
|
<span style="font-size: 13px;">有货</span>
|
|
</div>
|
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
<div style="width: 16px; height: 16px; background-color: #FAAD14; border-radius: 2px;"></div>
|
|
<span style="font-size: 13px;">满货</span>
|
|
</div>
|
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
<div style="width: 16px; height: 16px; background-color: #F5222D; border-radius: 2px;"></div>
|
|
<span style="font-size: 13px;">任务锁</span>
|
|
</div>
|
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
<div style="width: 16px; height: 16px; background-color: #52C41A; border-radius: 2px;"></div>
|
|
<span style="font-size: 13px;">空容器</span>
|
|
</div>
|
|
</div>
|
|
<a-grid :cols="24" :col-gap="16" :row-gap="16">
|
|
<a-grid-item v-for="(item, index) in heatmaps" :key="index" :span="12">
|
|
<div :id="'heatmap-' + index" style="width: 100%; height: 320px;"></div>
|
|
</a-grid-item>
|
|
</a-grid>
|
|
</a-card>
|
|
</a-grid-item>
|
|
</a-grid>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="/front/vue.global.js"></script>
|
|
<script src="/front/arco-vue.js"></script>
|
|
<script src="/front/arco-vue-icon.js"></script>
|
|
<link rel="stylesheet" href="/front/arco.min.css" />
|
|
<script src="/jquery.min.js"></script>
|
|
<script src="/jquery.cookie.js"></script>
|
|
<script src="/echarts/json-fns.js"></script>
|
|
<script src="/echarts/echarts.min.js"></script>
|
|
<script src="/echarts/chalk.js"></script>
|
|
<script src="/echarts/essos.js"></script>
|
|
<script src="/echarts/macarons.js"></script>
|
|
<script src="/echarts/roma.js"></script>
|
|
<script src="/echarts/vintage.js"></script>
|
|
<script src="/echarts/walden.js"></script>
|
|
<script src="/echarts/westeros.js"></script>
|
|
<script src="/echarts/wonderland.js"></script>
|
|
|
|
<script>
|
|
const { createApp, ref, onMounted, onUnmounted, nextTick } = Vue;
|
|
|
|
const App = {
|
|
setup() {
|
|
let charts = [];
|
|
const isFullscreen = ref(false);
|
|
const heatmaps = ref([]);
|
|
|
|
const toggleFullscreen = () => {
|
|
const container = document.getElementById('fullscreen-container');
|
|
if (!document.fullscreenElement) {
|
|
container.requestFullscreen().catch(err => {
|
|
console.error(`Error attempting to enable full-screen mode: ${err.message}`);
|
|
});
|
|
} else {
|
|
document.exitFullscreen();
|
|
}
|
|
};
|
|
|
|
const handleFullscreenChange = () => {
|
|
isFullscreen.value = !!document.fullscreenElement;
|
|
// Resize charts after transition
|
|
setTimeout(() => {
|
|
charts.forEach(chart => chart && chart.resize());
|
|
}, 300);
|
|
};
|
|
|
|
onMounted(() => {
|
|
nextTick(() => {
|
|
initCharts();
|
|
// Ensure charts are correctly sized after layout
|
|
setTimeout(() => {
|
|
charts.forEach(chart => chart && chart.resize());
|
|
}, 200);
|
|
});
|
|
|
|
window.addEventListener('resize', () => {
|
|
charts.forEach(chart => chart && chart.resize());
|
|
});
|
|
|
|
document.addEventListener('fullscreenchange', handleFullscreenChange);
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
document.removeEventListener('fullscreenchange', handleFullscreenChange);
|
|
});
|
|
|
|
const initCharts = () => {
|
|
charts.push(initTaskHistoryChart());
|
|
charts.push(initLocationChart());
|
|
charts.push(initCurrentTaskChart());
|
|
initHeatmaps();
|
|
};
|
|
|
|
function initTaskHistoryChart() {
|
|
const chart = echarts.init(document.getElementById('taskHistoryChart'));
|
|
chart.showLoading();
|
|
$.ajax({
|
|
url: '/api/IData/GetTaskHistoryChart',
|
|
type: 'GET',
|
|
success: (res) => {
|
|
chart.hideLoading();
|
|
const data = res.Data || res;
|
|
if (!data) return;
|
|
try {
|
|
const dataset = JSON.parse(data.dataset);
|
|
if (dataset && dataset.source && dataset.source.length > 1) {
|
|
const headers = dataset.source[0];
|
|
const inIndex = headers.indexOf('入库任务');
|
|
const outIndex = headers.indexOf('出库任务');
|
|
const moveIndex = headers.indexOf('移库任务');
|
|
const categories = dataset.source.slice(1).map(row => row[0]);
|
|
const inData = dataset.source.slice(1).map(row => inIndex >= 0 ? parseInt(row[inIndex]) || 0 : 0);
|
|
const outData = dataset.source.slice(1).map(row => outIndex >= 0 ? parseInt(row[outIndex]) || 0 : 0);
|
|
const moveData = dataset.source.slice(1).map(row => moveIndex >= 0 ? parseInt(row[moveIndex]) || 0 : 0);
|
|
|
|
chart.setOption({
|
|
tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
|
|
legend: { data: ['入库任务', '出库任务', '移库任务'] },
|
|
grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true },
|
|
xAxis: { type: 'category', data: categories },
|
|
yAxis: { type: 'value', minInterval: 1 },
|
|
series: [
|
|
{ name: '入库任务', type: 'bar', label: { show: true, position: 'top' }, data: inData },
|
|
{ name: '出库任务', type: 'bar', label: { show: true, position: 'top' }, data: outData },
|
|
{ name: '移库任务', type: 'bar', label: { show: true, position: 'top' }, data: moveData }
|
|
]
|
|
});
|
|
}
|
|
} catch (e) { console.error('Data parse error:', e); }
|
|
},
|
|
error: () => {
|
|
chart.hideLoading();
|
|
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取任务历史数据失败');
|
|
}
|
|
});
|
|
return chart;
|
|
}
|
|
|
|
function initLocationChart() {
|
|
const chart = echarts.init(document.getElementById('locationChart'));
|
|
chart.showLoading();
|
|
$.ajax({
|
|
url: '/api/IData/GetLocationChart',
|
|
type: 'GET',
|
|
success: (res) => {
|
|
chart.hideLoading();
|
|
const chartData = res.Data || res;
|
|
if (!chartData) return;
|
|
try {
|
|
const dataset = JSON.parse(chartData.dataset);
|
|
if (dataset && dataset.source && dataset.source.length > 1) {
|
|
const data = dataset.source.slice(1).map(row => ({ name: row[0], value: row[1] }));
|
|
chart.setOption({
|
|
tooltip: { trigger: 'item', formatter: '{a} <br/>{b}: {c} ({d}%)' },
|
|
legend: { orient: 'vertical', left: 'left' },
|
|
series: [{
|
|
name: '库位状态', type: 'pie', radius: ['30%', '70%'], roseType: 'area',
|
|
itemStyle: { borderRadius: 8 }, data: data
|
|
}]
|
|
});
|
|
}
|
|
} catch (e) { console.error('Data parse error:', e); }
|
|
},
|
|
error: () => {
|
|
chart.hideLoading();
|
|
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取库位统计数据失败');
|
|
}
|
|
});
|
|
return chart;
|
|
}
|
|
|
|
function initCurrentTaskChart() {
|
|
const chart = echarts.init(document.getElementById('currentTaskChart'));
|
|
chart.showLoading();
|
|
$.ajax({
|
|
url: '/api/IData/GetCurrentTaskChart',
|
|
type: 'GET',
|
|
success: (res) => {
|
|
chart.hideLoading();
|
|
const chartData = res.Data || res;
|
|
if (!chartData) return;
|
|
try {
|
|
const dataset = JSON.parse(chartData.dataset);
|
|
if (dataset && dataset.source && dataset.source.length > 1) {
|
|
const data = dataset.source.slice(1).map(row => ({ name: row[0], value: parseInt(row[1]) || 0 }));
|
|
const maxValue = Math.max(...data.map(item => item.value), 10);
|
|
const gaugeWidth = 100 / (data.length || 1);
|
|
const series = data.map((item, index) => ({
|
|
name: item.name, type: 'gauge', center: [(index + 0.5) * gaugeWidth + '%', '55%'],
|
|
radius: '70%', min: 0, max: maxValue, detail: { valueAnimation: true, formatter: '{value}', fontSize: 16 },
|
|
title: { offsetCenter: [0, '80%'], fontSize: 12 }, data: [{ value: item.value, name: item.name }]
|
|
}));
|
|
chart.setOption({ tooltip: { formatter: '{a} <br/>{b} : {c}' }, series: series });
|
|
}
|
|
} catch (e) { console.error('Data parse error:', e); }
|
|
},
|
|
error: () => {
|
|
chart.hideLoading();
|
|
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取当前任务统计数据失败');
|
|
}
|
|
});
|
|
return chart;
|
|
}
|
|
|
|
function initHeatmaps() {
|
|
$.ajax({
|
|
url: '/api/IData/GetLocationHeatmap',
|
|
type: 'GET',
|
|
success: (res) => {
|
|
const data = res.Data || res;
|
|
if (!data || !Array.isArray(data)) return;
|
|
heatmaps.value = data;
|
|
|
|
nextTick(() => {
|
|
data.forEach((hm, index) => {
|
|
const chartDom = document.getElementById('heatmap-' + index);
|
|
if (!chartDom) return;
|
|
const chart = echarts.init(chartDom);
|
|
|
|
// Prepare heatmap data: [x, y, value, status, color, locationCode, containerCode]
|
|
const points = hm.points || hm.Points || [];
|
|
const scatterData = points.map(p => {
|
|
return [
|
|
(p.line ?? p.Line) - 1,
|
|
(p.layer ?? p.Layer) - 1,
|
|
1,
|
|
p.status ?? p.Status,
|
|
p.color ?? p.Color,
|
|
p.locationCode ?? p.LocationCode,
|
|
p.containerCode ?? p.ContainerCode
|
|
];
|
|
});
|
|
|
|
const option = {
|
|
title: { text: hm.title || hm.Title, left: 'center', textStyle: { fontSize: 14 } },
|
|
tooltip: {
|
|
position: 'top',
|
|
formatter: function (params) {
|
|
return `库位: ${params.data[5]}<br/>状态: ${params.data[3]}<br/>容器: ${params.data[6] || '无'}`;
|
|
}
|
|
},
|
|
grid: { height: '65%', top: '15%', bottom: '20%', left: '8%', right: '8%' },
|
|
xAxis: {
|
|
type: 'category',
|
|
data: Array.from({length: hm.maxLine || hm.MaxLine}, (_, i) => i + 1),
|
|
splitArea: { show: true },
|
|
name: '列'
|
|
},
|
|
yAxis: {
|
|
type: 'category',
|
|
data: Array.from({length: hm.maxLayer || hm.MaxLayer}, (_, i) => i + 1),
|
|
splitArea: { show: true },
|
|
name: '层'
|
|
},
|
|
series: [{
|
|
name: hm.title || hm.Title,
|
|
type: 'heatmap',
|
|
data: scatterData,
|
|
label: { show: false },
|
|
itemStyle: {
|
|
color: function(params) {
|
|
return params.data[4];
|
|
},
|
|
borderWidth: 1,
|
|
borderColor: '#fff'
|
|
},
|
|
emphasis: {
|
|
itemStyle: { shadowBlur: 10, shadowColor: 'rgba(0, 0, 0, 0.5)' }
|
|
}
|
|
}]
|
|
};
|
|
chart.setOption(option);
|
|
charts.push(chart);
|
|
});
|
|
});
|
|
},
|
|
error: () => {
|
|
if (window.ArcoVue && window.ArcoVue.Message) window.ArcoVue.Message.error('获取库位热力图数据失败');
|
|
}
|
|
});
|
|
}
|
|
|
|
return {
|
|
isFullscreen,
|
|
toggleFullscreen,
|
|
heatmaps
|
|
};
|
|
}
|
|
};
|
|
|
|
const app = createApp(App);
|
|
app.use(window.ArcoVue);
|
|
app.use(window.ArcoVueIcon);
|
|
app.mount('#app');
|
|
</script>
|