项目初始化
This commit is contained in:
209
ruoyi-ui/src/views/kpi/spaceAnalysis/index.vue
Normal file
209
ruoyi-ui/src/views/kpi/spaceAnalysis/index.vue
Normal file
@@ -0,0 +1,209 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">-->
|
||||
<!-- <!– 仓库 –>-->
|
||||
<!-- <el-form-item label="仓库" prop="warehouseId">-->
|
||||
<!-- <el-select v-model="queryParams.warehouseId" placeholder="请选择仓库" clearable>-->
|
||||
<!-- <el-option-->
|
||||
<!-- v-for="dict in warehouseOptions"-->
|
||||
<!-- :key="dict.warehouseId"-->
|
||||
<!-- :label="dict.warehouseName"-->
|
||||
<!-- :value="dict.warehouseId"-->
|
||||
<!-- />-->
|
||||
<!-- </el-select>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- <el-form-item>-->
|
||||
<!-- <!– 【搜索】按钮 –>-->
|
||||
<!-- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
|
||||
<!-- <!– 【重置】按钮 –>-->
|
||||
<!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
|
||||
<!-- </el-form-item>-->
|
||||
<!-- </el-form>-->
|
||||
|
||||
<!-- 柱状图容器 -->
|
||||
<div class="chart-container" style="height: 700px">
|
||||
<div ref="spaceChart" style="width: 100%; height: 100%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import * as echarts from '@/plugins/echarts.min.js'
|
||||
import { getSpaceAnalysisList } from "@/api/kpi/spaceAnalysis"
|
||||
import {listWarehouse} from "@/api/bas/warehouse";
|
||||
export default {
|
||||
name: "spaceAnalysis",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 仓库选项
|
||||
warehouseOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
warehouseId: null // 默认选择仓库1
|
||||
},
|
||||
// 图表实例
|
||||
chart: null,
|
||||
// 图表数据(模拟数据)
|
||||
chartData:[],
|
||||
queryWarehouseParam:{
|
||||
pageNum: 1,
|
||||
pageSize: 99,
|
||||
typeData:[1,2]
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
created() {
|
||||
this.getWarehouseList();
|
||||
this.handleQuery();
|
||||
}
|
||||
,
|
||||
mounted() {
|
||||
this.initChart();
|
||||
}
|
||||
,
|
||||
beforeDestroy() {
|
||||
if (this.chart) {
|
||||
this.chart.dispose();
|
||||
this.chart = null;
|
||||
}
|
||||
}
|
||||
,
|
||||
methods: {
|
||||
/** 查询仓库列表 */
|
||||
getWarehouseList() {
|
||||
|
||||
listWarehouse(this.queryWarehouseParam).then(response => {
|
||||
this.warehouseOptions = response.rows;
|
||||
});
|
||||
// this.warehouseOptions = [{warehouseId: "01", warehouseName: "仓库1"}, {warehouseId: "02", warehouseName: "仓库2"}];
|
||||
}
|
||||
,
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
getSpaceAnalysisList(this.queryParams).then(response => {
|
||||
if (response.code === 200) {
|
||||
this.chartData = response.data;
|
||||
this.updateChart();
|
||||
} else {
|
||||
this.$message.error(response.msg);
|
||||
}
|
||||
}).catch(error => {
|
||||
// 提示:获取数据失败
|
||||
console.error('获取数据失败:', error);
|
||||
this.$message.error('获取数据失败');
|
||||
});
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.queryParams.warehouseId = "01"; // 重置时仍选择仓库1
|
||||
this.handleQuery();
|
||||
}
|
||||
,
|
||||
/** 初始化图表 */
|
||||
initChart() {
|
||||
this.chart = echarts.init(this.$refs.spaceChart);
|
||||
this.updateChart();
|
||||
}
|
||||
,
|
||||
/** 状态码转换为国际化文本 */
|
||||
getStatusText(statusCode) {
|
||||
const statusMap = {
|
||||
'1': '空闲',
|
||||
'2': '占用',
|
||||
'3': '入库分配',
|
||||
'4': '出库分配',
|
||||
'5': '入库待检',
|
||||
'6': '出库待检'
|
||||
};
|
||||
return statusMap[statusCode] || statusCode;
|
||||
},
|
||||
/** 更新图表数据 */
|
||||
updateChart() {
|
||||
console.log('chartData:', this.chartData);
|
||||
if (!this.chartData || !this.chartData.data || this.chartData.data.length === 0) {
|
||||
// 提示:无效的图表数据
|
||||
console.warn('无效的图表数据');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取数据中所有的巷道字段
|
||||
const firstItem = this.chartData.data[0];
|
||||
// 巷道
|
||||
const roadwayFields = Object.keys(firstItem).filter(key => key.startsWith('巷道'));
|
||||
|
||||
// 准备系列配置
|
||||
const series = roadwayFields.map(roadway => ({
|
||||
name: roadway,
|
||||
type: 'bar',
|
||||
data: this.chartData.data.map(item => item[roadway]),
|
||||
barWidth: '30%',
|
||||
itemStyle: {
|
||||
// 巷道1-4
|
||||
color: roadway === '巷道1' ? '#1890ff' :
|
||||
roadway === '巷道2' ? '#52c41a' :
|
||||
roadway === '巷道3' ? '#1890ff' :
|
||||
roadway === '巷道4' ? '#52c41a' : '#1890ff'
|
||||
},
|
||||
label: {
|
||||
show: true,
|
||||
position: 'top'
|
||||
}
|
||||
}));
|
||||
// 提示:生成的系列配置
|
||||
console.log('系列配置:', series);
|
||||
|
||||
const option = {
|
||||
title: {
|
||||
// 货位状态分析
|
||||
text: '货位状态分析',
|
||||
left: 'center'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
top: "5%",
|
||||
textStyle: {
|
||||
fontSize: 15,
|
||||
color: "#292c2c"
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: this.chartData.data.map(item => this.getStatusText(item.status)),
|
||||
axisLabel: {
|
||||
interval: 0,
|
||||
rotate: 0
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
// 数量
|
||||
name: '数量'
|
||||
},
|
||||
series: series
|
||||
};
|
||||
this.chart.setOption(option);
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.chart-container {
|
||||
margin-top: 20px;
|
||||
padding: 20px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user