产量对标FTo

This commit is contained in:
朱菊兰 2024-06-12 13:27:09 +08:00
parent 40c7aaa323
commit 5f98f4a361
3 changed files with 508 additions and 0 deletions

View File

@ -0,0 +1,180 @@
<template>
<div>
<!-- 图例 -->
<div class="legend">
<span class="item" v-for="item in legendList" :key="item.id">
<span
v-if="item.type === 1"
class="block"
:style="{ backgroundColor: item.color }"
></span>
<span
v-if="item.type === 2"
class="line"
:style="{ backgroundColor: item.color }"
>
<span
class="line-block"
:style="{ backgroundColor: item.color }"
></span>
</span>
{{ item.name }}</span
>
</div>
<div id="main" :style="{ width: '100%', height: chartHeight + 'px' }"></div>
</div>
</template>
<script>
import * as echarts from "echarts";
import { debounce } from "@/utils/debounce";
export default {
name: "bmLineBar",
data() {
return {
myChart: "",
option: {
color: [],
// color: ["#8EF0AB", "#63BDFF", "#288AFF"],
grid: {
left: 100,
right: 10,
bottom: 30,
top: 30,
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
crossStyle: {
color: "rgba(237,237,237,0.5)",
},
},
formatter: function (params) {
var res = `<span style='color:rgba(0,0,0,0.8)'>${params[0].name}</span>`;
for (var i = 0, l = params.length; i < l; i++) {
res +=
"<br/>" +
`<span style='display:inline-block;margin-right:4px;border-radius:10px;width:10px;height:10px;background-color:${params[i].color}'></span>` +
`<span style='display:inline-block;width:150px;color:rgba(0,0,0,0.8);font-size:14px;'>${params[i].seriesName}</span>` +
`<span style='color:rgba(0,0,0,0.48);font-size:14px;'>${params[i].value}</span>`;
}
return res;
},
},
xAxis: {
type: "category",
data: [],
axisTick: {
show: false,
},
axisPointer: {
type: "shadow",
},
},
yAxis: {
type: "value",
},
series: [],
},
};
},
props: {
chartHeight: {
type: Number,
default: 300,
},
legendList: {
type: Array,
default: () => [],
},
chartMsg: {
type: Object,
default: () => {},
},
},
watch: {
chartHeight: {
handler(newVal) {
this.chartHeight = newVal;
},
},
isOpen(val) {
this.canvasReset();
},
chartMsg: {
handler(newVal) {
this.getMes();
},
deep: true,
},
},
computed: {
isOpen() {
return this.$store.getters.sidebar.opened;
},
},
mounted() {
this.canvasReset();
window.addEventListener("resize", this.canvasReset);
},
beforeDestroy() {
if (this.chart) {
this.myChart.dispose();
}
},
destroyed() {
window.removeEventListener("resize", this.canvasReset);
},
methods: {
canvasReset() {
debounce(() => {
this.getMes();
}, 500)();
},
getMes() {
if (this.myChart) {
this.myChart.dispose();
this.myChart = "";
}
var chartDom = document.getElementById("main");
this.myChart = echarts.init(chartDom);
this.option.color = this.chartMsg.color;
this.option.xAxis.data = this.chartMsg.xData;
this.option.series = this.chartMsg.series;
this.myChart.setOption(this.option);
},
},
};
</script>
<style lang="scss" scoped>
.legend {
text-align: right;
.item {
display: inline-block;
margin-right: 10px;
font-size: 14px;
color: #8c8c8c;
.block {
width: 10px;
height: 10px;
display: inline-block;
margin-right: 4px;
}
.line {
width: 10px;
height: 10px;
border-radius: 5px;
display: inline-block;
margin-right: 4px;
position: relative;
.line-block {
position: absolute;
width: 20px;
height: 2px;
left: -5px;
top: 4px;
}
}
}
}
</style>

View File

@ -0,0 +1,136 @@
<template>
<el-form :model="form" :inline="true" ref="bmSearchBarForm" class="blueTip">
<el-form-item label="时间维度" prop="type">
<el-select
size="small"
v-model="form.type"
placeholder="请选择"
style="width: 100px"
>
<el-option
v-for="item in typeList"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item v-show="form.type === 1" label="时间" prop="dayTime">
<el-date-picker
size="small"
clearable
v-model="form.dayTime"
type="date"
placeholder="选择日期"
style="width: 150px"
>
</el-date-picker>
</el-form-item>
<el-form-item v-show="form.type === 2" label="时间" prop="weekTime">
<el-date-picker
v-model="form.weekTime"
type="week"
format="yyyy 第 WW 周"
placeholder="选择周"
style="width: 150px"
>
</el-date-picker>
</el-form-item>
<el-form-item v-show="form.type === 3" label="时间" prop="monthTime">
<el-date-picker
v-model="form.monthTime"
type="month"
placeholder="选择月份"
style="width: 150px"
>
</el-date-picker>
</el-form-item>
<el-form-item v-show="form.type === 4" label="时间" prop="yearTime">
<el-date-picker
v-model="form.yearTime"
type="year"
placeholder="选择年份"
style="width: 150px"
>
</el-date-picker>
</el-form-item>
<el-form-item label="工厂" prop="factory">
<el-select
size="small"
multiple
v-model="form.factory"
placeholder="请选择"
style="width: 250px"
>
<el-option
v-for="item in factoryList"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="getDataList"
>查询</el-button
>
<el-divider direction="vertical"></el-divider>
<el-button type="primary" size="small" plain @click="handleExport"
>导出</el-button
>
</el-form-item>
</el-form>
</template>
<script>
export default {
name: "bmSearchBar",
data() {
return {
form: {
type: 1,
dayTime: "",
weekTime: "",
monthTime: "",
yearTime: "",
factory: "",
},
typeList: [
{ id: 1, name: "日" },
{ id: 2, name: "周" },
{ id: 3, name: "月" },
{ id: 4, name: "年" },
],
factoryList: [
{ id: 1, name: "瑞昌" },
{ id: 2, name: "邯郸" },
],
};
},
methods: {
getDataList() {
console.log(this.form);
this.$emit("getSearch", this.form);
},
handleExport() {
this.$emit("handleExport");
},
},
};
</script>
<style lang="scss" scoped>
.el-divider--vertical {
height: 24px;
}
.blueTip::before {
display: inline-block;
content: "";
width: 4px;
height: 18px;
background: #0b58ff;
border-radius: 1px;
margin-right: 8px;
margin-top: 8px;
}
</style>

View File

@ -0,0 +1,192 @@
<!-- 产量对标FTO -->
<template>
<div>
<div class="containerTop">
<bmSearchBar @getSearch="getSearch" @handleExport="handleExport" />
<bm-line-bar
:chartHeight="chartHeight"
:legendList="legendList"
:chartMsg="chartMsg"
/>
</div>
<div class="containerBottom">
<div class="smallTitle">产量对标FTO</div>
<base-table
:table-props="tableProps"
:page="listQuery.current"
:limit="listQuery.size"
:table-data="tableData"
:max-height="tableH"
/>
</div>
</div>
</template>
<script>
import bmSearchBar from "../components/bmSearchBar.vue";
import BmLineBar from "../components/bmLineBar.vue";
const tableProps = [
{
prop: "factory",
label: "工厂名称",
// filter: (val) => factoryList[val],
minWidth: 200,
showOverflowtooltip: true,
},
{
prop: "name",
label: "科目",
minWidth: 120,
showOverflowtooltip: true,
},
{
prop: "unit",
label: "单位",
minWidth: 80,
showOverflowtooltip: true,
},
{
prop: "time1",
label: "时间1",
minWidth: 150,
showOverflowtooltip: true,
},
{
prop: "time2",
label: "时间2",
minWidth: 150,
showOverflowtooltip: true,
},
{
prop: "mubiao",
label: "目标值",
minWidth: 150,
showOverflowtooltip: true,
},
];
export default {
name: "FtoOutputBM",
data() {
return {
tableProps,
listQuery: {
current: 1,
size: 1000,
},
tableData: [
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
{ factory: "工厂1" },
],
chartHeight: this.tableHeight(137) / 2 - 111,
tableH: this.tableHeight(137) / 2 - 70,
legendList: [
{ id: 1, name: "2024年4月目标值", type: 2, color: "#FFCE6A" },
{ id: 2, name: "2023年4月", type: 1, color: "#8EF0AB" },
{ id: 3, name: "2024年4月", type: 1, color: "#288AFF" },
],
chartMsg: {
color: ["#FFCE6A", "#8EF0AB", "#288AFF"],
xData: ["成都", "邯郸", "瑞昌"],
series: [
{
name: "2024年4月目标值",
data: [70000, 80000, 90000],
type: "line",
symbol: "circle",
symbolSize: 6,
},
{
name: "2023年4月",
data: [12000, 20000, 150000],
type: "bar",
barWidth: 20,
},
{
name: "2024年4月",
data: [60000, 70000, 80000],
type: "bar",
barWidth: 20,
},
],
},
};
},
components: {
bmSearchBar,
BmLineBar,
},
created() {
this.tableH = this.tableHeight(137) / 2 - 70;
this.chartHeight = this.tableHeight(137) / 2 - 111;
window.addEventListener("resize", this._setTableHeight);
},
destroyed() {
window.removeEventListener("resize", this._setTableHeight);
},
methods: {
_setTableHeight() {
this.tableH = this.tableHeight(137) / 2 - 70;
this.chartHeight = this.tableHeight(137) / 2 - 111;
},
getSearch(val) {
console.log(val);
console.log("=========================");
},
handleExport() {
console.log("导出");
},
},
};
</script>
<style lang="scss" scoped>
.containerTop,
.containerBottom {
height: calc((100vh - 137px) / 2);
background-color: #fff;
border-radius: 8px;
padding: 16px;
}
.containerBottom {
margin-top: 8px;
.smallTitle {
font-size: 16px;
color: #000;
margin-bottom: 15px;
}
.smallTitle::before {
display: inline-block;
width: 4px;
height: 16px;
background: #0b58ff;
content: "";
margin-right: 8px;
vertical-align: -3px;
}
}
</style>