实验室运维app端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.0 KiB

1 year ago
<template>
<view class="eacharts-box">
<!-- eacharts 图表 -->
<view class="echarts" >
1 year ago
<l-echart ref="chartRef" :key="Math.random()"></l-echart>
</view>
</view>
</template>
<script>
import * as echarts from "echarts";
import lEchart from "@/uni_modules/lime-echart/components/lime-echart/";
export default {
components: { lEchart },
props: {
type: {
type: String,
default: "",
},
},
data() {
return {
form: {
searchTime: "",
startTime: "",
endTime: "",
},
calendarShow: false,
mode: "range",
upkeepStatInfo: {},
pieInfo: {},//饼图数据
1 year ago
};
},
mounted() {
this.upkeepStat()
1 year ago
},
methods: {
// 维修统计
upkeepStat() {
let query_ = {
startTime: this.form.startTime,
endTime: this.form.endTime,
}
this.$u.api.upkeepStat(query_).then(res => {
if (res.code == 200) {
this.upkeepStatInfo = JSON.parse(JSON.stringify(res.data))
this.maintenanceInit();
}
})
},
// 维修统计柱状图
1 year ago
maintenanceInit() {
let opts = {
tooltip: {},
legend: {
//图例组件
data: ["总计", "已完成", "未完成"],
itemWidth: 15,
itemHeight: 10,
1 year ago
},
xAxis: {
data: this.upkeepStatInfo.xData,
1 year ago
},
grid: {
top: "25%",
1 year ago
left: "10%",
right: "5%",
bottom: "15%",
},
yAxis: {},
series: [
{
name: "总计",
type: "bar",
data: this.upkeepStatInfo.total,
barWidth: 25, // 设置柱子宽度
1 year ago
barGap: "0", // 设置不同系列之间的间隔为0
itemStyle: {
1 year ago
color: "#2148D1",
1 year ago
},
},
{
name: "已完成",
type: "bar",
data: this.upkeepStatInfo.completed,
barWidth: 25, // 设置柱子宽度
1 year ago
barGap: "0", // 设置不同系列之间的间隔为0
itemStyle: {
1 year ago
color: "#5E8CFF",
1 year ago
},
},
{
name: "未完成",
type: "bar",
data: this.upkeepStatInfo.unCompleted,
barWidth: 25, // 设置柱子宽度
1 year ago
barGap: "0", // 设置不同系列之间的间隔为0
itemStyle: {
1 year ago
color: "#B0CCFF",
1 year ago
},
},
],
};
this.$refs.chartRef.init((config) => {
const { canvas } = config;
const chart = echarts.init(canvas, null, config);
chart.setOption(opts);
// 需要把 chart 返回
return chart;
});
},
},
};
</script>
<style lang="scss" scoped>
.eacharts-box {
background: #fff;
margin: 0 32rpx 32rpx;
1 year ago
border-radius: 20rpx;
overflow: hidden;
height: 368rpx;
1 year ago
.echarts {
width: calc(100% - 64rpx);
height: 328rpx;
margin:30rpx auto 20rpx;
overflow: hidden;
1 year ago
}
}
</style>