fix(dashboard): 控制台剖析图表支持仓房与品种智能双向联动及空状态优雅提示
这个提交包含在:
@@ -18,6 +18,18 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
|
||||
this.getInitData();
|
||||
},
|
||||
methods: {
|
||||
// 仓库切换智能联动其品种并刷新折线图
|
||||
granaryChange(gid) {
|
||||
let cur = this.granaryList.find(function (item) { return item.id === gid; });
|
||||
if (cur && cur.type) {
|
||||
this.search.type = cur.type;
|
||||
}
|
||||
this.getParamsLineCharts();
|
||||
},
|
||||
// 品种切换自动刷新折线图
|
||||
typeChange(type) {
|
||||
this.getParamsLineCharts();
|
||||
},
|
||||
// 获取初始化数据
|
||||
getInitData() {
|
||||
let loading = this.$loading({
|
||||
@@ -37,9 +49,15 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
|
||||
this.granaryList = res.data.granaryList;
|
||||
this.typeList = res.data.typeList;
|
||||
this.search.year = res.data.year;
|
||||
if (res.data.defaultType) {
|
||||
this.search.type = res.data.defaultType;
|
||||
}
|
||||
|
||||
if (this.granaryList.length) {
|
||||
this.search.gid = this.granaryList[0]['id'];
|
||||
if (this.granaryList[0]['type']) {
|
||||
this.search.type = this.granaryList[0]['type'];
|
||||
}
|
||||
}
|
||||
|
||||
this.lineCharts = res.data.lineCharts;
|
||||
@@ -80,34 +98,47 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
|
||||
},
|
||||
// 折线图
|
||||
paramsLineCharts() {
|
||||
let series = this.lineCharts;
|
||||
let series = this.lineCharts || {};
|
||||
let lineChart = Echarts.init(document.getElementById('main-chart'));
|
||||
let legendData = [];
|
||||
let hasData = false;
|
||||
|
||||
if (series.seriesData && series.seriesData.length) {
|
||||
// 数据处理
|
||||
for (item of series.seriesData) {
|
||||
for (let i = 0; i < series.seriesData.length; i++) {
|
||||
let item = series.seriesData[i];
|
||||
item.type = 'line';
|
||||
item.areaStyle = {
|
||||
focus: 'series'
|
||||
};
|
||||
|
||||
legendData.push(item.name);
|
||||
if (item.data && item.data.length && item.data.some(function (v) { return v !== null && v !== undefined && v !== ''; })) {
|
||||
hasData = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('aaasd');
|
||||
series.seriesData = [{
|
||||
name: '暂无检测数据',
|
||||
type: 'line',
|
||||
areaStyle: {
|
||||
focus: 'series'
|
||||
},
|
||||
data: []
|
||||
}];
|
||||
}
|
||||
|
||||
let curGid = this.search.gid;
|
||||
let curGranary = this.granaryList.find(function (g) { return g.id === curGid; });
|
||||
let granaryName = curGranary ? curGranary.name : '所选仓库';
|
||||
let typeName = this.typeList && this.typeList[this.search.type] ? this.typeList[this.search.type].name : this.search.type;
|
||||
let yearText = this.search.year || '';
|
||||
|
||||
let option = {
|
||||
title: {
|
||||
title: !hasData ? {
|
||||
text: '暂无检测数据',
|
||||
subtext: (yearText ? yearText + '年 ' : '') + granaryName + ' 暂无【' + typeName + '】检测报告,可切换年份或对应品种查看',
|
||||
left: 'center',
|
||||
top: 'middle',
|
||||
textStyle: {
|
||||
color: '#909399',
|
||||
fontSize: 16,
|
||||
fontWeight: 'normal'
|
||||
},
|
||||
subtextStyle: {
|
||||
color: '#c0c4cc',
|
||||
fontSize: 13
|
||||
}
|
||||
} : {
|
||||
text: ''
|
||||
},
|
||||
tooltip: {
|
||||
@@ -120,7 +151,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
data: legendData
|
||||
data: hasData ? legendData : []
|
||||
},
|
||||
toolbox: {
|
||||
feature: {
|
||||
@@ -137,7 +168,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
|
||||
{
|
||||
type: 'category',
|
||||
boundaryGap: false,
|
||||
data: series.list
|
||||
data: hasData ? (series.list || []) : []
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
@@ -145,7 +176,7 @@ define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echart
|
||||
type: 'value'
|
||||
}
|
||||
],
|
||||
series: series.seriesData
|
||||
series: hasData ? series.seriesData : []
|
||||
};
|
||||
|
||||
lineChart.setOption(option, true);
|
||||
|
||||
在新工单中引用
屏蔽一个用户