358 lines
9.4 KiB
Vue
358 lines
9.4 KiB
Vue
<template>
|
|
<div>
|
|
<div class="containerTop">
|
|
<bmSearchBar @getSearch="getSearch" @handleExport="handleExport" />
|
|
</div>
|
|
<div class="containerBottom">
|
|
<div class="smallTitle">FTO/基片投入</div>
|
|
<bm-line-bar
|
|
:chartHeight="chartHeight"
|
|
:legendList="legendList"
|
|
:chartMsg="chartMsg"
|
|
:chartId="chartId"
|
|
:chartNum="chartNum"
|
|
/>
|
|
<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";
|
|
import {
|
|
fTOReportByDateRangePage,
|
|
fTOReportByDateRangeExport,
|
|
} from "@/api/report/benchmarking.js";
|
|
import moment from "moment";
|
|
export default {
|
|
name: "FtoOutputBM",
|
|
data() {
|
|
return {
|
|
factoryList: [
|
|
{ id: 0, name: "瑞昌" },
|
|
{ id: 1, name: "邯郸" },
|
|
],
|
|
tableProps: [],
|
|
tableProps1: [
|
|
{
|
|
prop: "factory",
|
|
label: "工厂名称",
|
|
filter: (val) => this.factoryList[val].name,
|
|
minWidth: 150,
|
|
showOverflowtooltip: true,
|
|
},
|
|
{
|
|
prop: "item",
|
|
label: "科目",
|
|
minWidth: 120,
|
|
showOverflowtooltip: true,
|
|
},
|
|
{
|
|
prop: "unit",
|
|
label: "单位",
|
|
minWidth: 80,
|
|
showOverflowtooltip: true,
|
|
},
|
|
],
|
|
listQuery: {
|
|
current: 1,
|
|
size: 100,
|
|
},
|
|
tableData: [],
|
|
chartHeight: this.tableHeight(269) / 2,
|
|
tableH: this.tableHeight(269) / 2,
|
|
legendList: [
|
|
{ id: 1, name: "", type: 2, color: "#FFCE6A" },
|
|
{ id: 2, name: "", type: 1, color: "#8EF0AB" },
|
|
{ id: 3, name: "", type: 1, color: "#288AFF" },
|
|
],
|
|
chartMsg: {
|
|
color: ["#FFCE6A", "#8EF0AB", "#288AFF"],
|
|
xData: [],
|
|
yName: "单位/片",
|
|
series: [
|
|
{
|
|
name: "1",
|
|
data: [],
|
|
type: "line",
|
|
symbol: "circle",
|
|
symbolSize: 6,
|
|
label: {
|
|
show: true,
|
|
color: "#FFAE17",
|
|
},
|
|
},
|
|
{
|
|
name: "2",
|
|
data: [],
|
|
type: "bar",
|
|
barWidth: 20,
|
|
label: {
|
|
show: true,
|
|
// position: [-5, -16],
|
|
// position: [-5, -16],
|
|
position: [-10, -16],
|
|
// position: [-17, -16],
|
|
color: "#68C483",
|
|
},
|
|
},
|
|
{
|
|
name: "3",
|
|
data: [],
|
|
type: "bar",
|
|
barWidth: 20,
|
|
label: {
|
|
show: true,
|
|
position: [0, -16],
|
|
color: "#288AFF",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
chartId: "ftoOutputBMChart",
|
|
chartNum: 1,
|
|
};
|
|
},
|
|
components: {
|
|
bmSearchBar,
|
|
BmLineBar,
|
|
},
|
|
computed: {
|
|
isOpen() {
|
|
return this.$store.getters.sidebar.opened;
|
|
},
|
|
},
|
|
watch: {
|
|
// 监听左侧菜单栏是否展开
|
|
isOpen(val) {
|
|
if (this.$route.name === "FtoOutputBM") {
|
|
this.chartNum++;
|
|
}
|
|
},
|
|
},
|
|
created() {
|
|
this.tableH = this.tableHeight(269) / 2;
|
|
this.chartHeight = this.tableHeight(269) / 2;
|
|
window.addEventListener("resize", this._setTableHeight);
|
|
},
|
|
mounted() {
|
|
this.tableProp = this.tableProp1;
|
|
this.listQuery.date = 2;
|
|
this.listQuery.queryTime = moment().format("yyyy-MM-DD");
|
|
this.listQuery.factorys = [];
|
|
this.getList();
|
|
},
|
|
destroyed() {
|
|
window.removeEventListener("resize", this._setTableHeight);
|
|
},
|
|
activated() {
|
|
// 图重新加载,为了防止窗口变化后尺寸图显示不佳,数据不更新
|
|
if (this.$route.name === "FtoOutputBM") {
|
|
this.chartNum++;
|
|
}
|
|
},
|
|
methods: {
|
|
_setTableHeight() {
|
|
this.tableH = this.tableHeight(269) / 2;
|
|
this.chartHeight = this.tableHeight(269) / 2;
|
|
if (this.$route.name === "FtoOutputBM") {
|
|
this.chartNum++;
|
|
}
|
|
},
|
|
getSearch(val) {
|
|
this.listQuery.date = val.type;
|
|
this.listQuery.queryTime = val.startDate;
|
|
this.listQuery.factorys = val.factory;
|
|
this.getList();
|
|
},
|
|
getList() {
|
|
this.tableProps = [];
|
|
fTOReportByDateRangePage({ ...this.listQuery }).then((res) => {
|
|
if (res.data && res.data.length > 0) {
|
|
// 设置表头
|
|
let msg = res.data[0];
|
|
let arr = [
|
|
{
|
|
prop: "lastone",
|
|
label: msg.lastone.reportTime,
|
|
filter: (val) => (val || val === 0 ? val : "-"),
|
|
minWidth: 150,
|
|
},
|
|
{
|
|
prop: "currentone",
|
|
label: msg.currentone.reportTime,
|
|
filter: (val) => (val || val === 0 ? val : "-"),
|
|
minWidth: 150,
|
|
},
|
|
{
|
|
prop: "targetone",
|
|
label: msg.targetone.reportTime,
|
|
filter: (val) => (val || val === 0 ? val : "-"),
|
|
minWidth: 150,
|
|
},
|
|
];
|
|
this.tableProps = this.tableProps1.concat(arr);
|
|
// 整理表格数据
|
|
let tableArr = [];
|
|
res.data.forEach((item) => {
|
|
let obj = {};
|
|
obj.factory = item.factory;
|
|
obj.item = "FTO投入";
|
|
obj.unit = "片";
|
|
obj.lastone = item.lastone.total;
|
|
obj.currentone = item.currentone.total;
|
|
obj.targetone = item.targetone.total;
|
|
tableArr.push(obj);
|
|
});
|
|
this.tableData = tableArr;
|
|
// 设置图例
|
|
this.legendList[0].name = msg.targetone.reportTime;
|
|
this.legendList[1].name = msg.lastone.reportTime;
|
|
this.legendList[2].name = msg.currentone.reportTime;
|
|
this.chartMsg.series[0].name = msg.targetone.reportTime;
|
|
this.chartMsg.series[1].name = msg.lastone.reportTime;
|
|
this.chartMsg.series[2].name = msg.currentone.reportTime;
|
|
// 设置偏移量
|
|
switch (this.listQuery.type) {
|
|
case 0:
|
|
this.chartMsg.series[1].label.position = [-5, -16];
|
|
break;
|
|
case 1:
|
|
this.chartMsg.series[1].label.position = [-5, -16];
|
|
break;
|
|
case 2:
|
|
this.chartMsg.series[1].label.position = [-10, -16];
|
|
break;
|
|
default:
|
|
this.chartMsg.series[1].label.position = [-17, -16];
|
|
}
|
|
// 设置chartMsg的series的数据
|
|
this.setChartMsg(res.data);
|
|
} else {
|
|
// 重置
|
|
this.resetMsg();
|
|
}
|
|
});
|
|
},
|
|
setChartMsg(val) {
|
|
let xData = [];
|
|
let lineData = [];
|
|
let barData1 = [];
|
|
let barData2 = [];
|
|
for (let i = 0; i < val.length; i++) {
|
|
this.factoryList.map((item) => {
|
|
if (item.id === val[i].factory) {
|
|
xData.push(item.name);
|
|
}
|
|
});
|
|
lineData.push(val[i].targetone.total || 0);
|
|
barData1.push(val[i].lastone.total || 0);
|
|
barData2.push(val[i].currentone.total || 0);
|
|
}
|
|
this.chartMsg.xData = xData;
|
|
this.chartMsg.series[0].data = lineData;
|
|
this.chartMsg.series[1].data = barData1;
|
|
this.chartMsg.series[2].data = barData2;
|
|
this.chartMsg.xData = xData;
|
|
},
|
|
resetMsg() {
|
|
this.tableProps = this.tableProps1;
|
|
this.tableData = [];
|
|
this.chartMsg = {
|
|
color: ["#FFCE6A", "#8EF0AB", "#288AFF"],
|
|
xData: [],
|
|
yName: "单位/片",
|
|
series: [
|
|
{
|
|
name: "1",
|
|
data: [],
|
|
type: "line",
|
|
symbol: "circle",
|
|
symbolSize: 6,
|
|
label: {
|
|
show: true,
|
|
color: "#FFAE17",
|
|
},
|
|
},
|
|
{
|
|
name: "2",
|
|
data: [],
|
|
type: "bar",
|
|
barWidth: 20,
|
|
label: {
|
|
show: true,
|
|
// position: [-5, -16],
|
|
// position: [-5, -16],
|
|
position: [-10, -16],
|
|
// position: [-17, -16],
|
|
color: "#68C483",
|
|
},
|
|
},
|
|
{
|
|
name: "3",
|
|
data: [],
|
|
type: "bar",
|
|
barWidth: 20,
|
|
label: {
|
|
show: true,
|
|
position: [0, -16],
|
|
color: "#288AFF",
|
|
},
|
|
},
|
|
],
|
|
};
|
|
},
|
|
handleExport(val) {
|
|
this.listQuery.type = val.type;
|
|
this.listQuery.startDate = val.startDate;
|
|
this.listQuery.factory = val.factory;
|
|
let fileName = "产量对标FTO.xls";
|
|
fTOReportByDateRangeExport({ ...this.listQuery })
|
|
.then((response) => {
|
|
this.$download.excel(response, fileName);
|
|
this.$message.success("导出成功");
|
|
})
|
|
.catch(() => {});
|
|
},
|
|
},
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.containerTop {
|
|
height: 64px;
|
|
}
|
|
.containerTop,
|
|
.containerBottom {
|
|
position: relative;
|
|
background-color: #fff;
|
|
border-radius: 8px;
|
|
padding: 16px;
|
|
}
|
|
.containerBottom {
|
|
height: calc(100vh - 201px);
|
|
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>
|