yudao-init/src/views/report/productionYield.vue
‘937886381’ 3e025020ab 修改bug
2024-07-05 14:06:15 +08:00

873 lines
28 KiB
Vue

<template>
<div>
<!-- <div class="search"> -->
<ButtonNav style="padding: 0;" :menus="['邯郸', '瑞昌']" :button-mode="true" @change="currentMenu = $event">
</ButtonNav>
<!-- </div> -->
<div class="search">
<el-form :model="listQuery" :inline="true" ref="dataForm" class="blueTip">
<el-form-item label="时间维度" prop="type">
<el-select size="small" clearable v-model="listQuery.type" placeholder="请选择" @change="handleChange">
<el-option v-for="item in timeList" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item v-show="listQuery.type === 0 || listQuery.type === ''" label="时间范围" prop="reportTime">
<el-date-picker size="small" clearable v-model="listQuery.reportTime" type="datetimerange" range-separator="至"
start-placeholder="开始日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" @change="changeDayTime"
end-placeholder="结束日期">
</el-date-picker>
</el-form-item>
<el-form-item v-show="listQuery.type === 1" label="时间范围" prop="reportTime">
<el-date-picker size="small" clearable v-model="listQuery.start" type="week" format="yyyy 第 WW 周"
placeholder="选择周" style="width: 180px" @change="onValueChange" :picker-options="{'firstDayOfWeek': 1}">
</el-date-picker>
<el-date-picker size="small" clearable v-model="listQuery.end" type="week" format="yyyy 第 WW 周"
placeholder="选择周" style="width: 180px" @change="onValueChange" :picker-options="{'firstDayOfWeek': 1}">
</el-date-picker>
<!-- <span v-if="listQuery.start && listQuery.end" style="margin-left: 10px">
{{ date1 }} 至 {{ date2 }},共 {{ weekNum }} 周
</span> -->
</el-form-item>
<el-form-item v-show="listQuery.type === 2" label="时间范围" prop="reportTime">
<el-date-picker size="small" clearable v-model="listQuery.reportTime" type="monthrange"
value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始月份" end-placeholder="结束月份"
@change="changeTime">
</el-date-picker>
</el-form-item>
<el-form-item v-show="listQuery.type === 3" label="时间范围" prop="reportTime">
<el-date-picker size="small" clearable v-model="listQuery.start" value-format="yyyy-MM-dd" type="year"
placeholder="开始时间">
</el-date-picker>
~
<el-date-picker size="small" clearable v-model="listQuery.end" value-format="yyyy-MM-dd" type="year"
placeholder="结束时间" @change="getYear">
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" size="small" @click="getDataList">查询</el-button>
<el-button type="primary" size="small" plain @click="handleExport">导出</el-button>
</el-form-item>
</el-form>
</div>
<div class="containerTop">
<el-row v-if="listQuery.type === 2">
<el-col :span="16">
<div class="blueTip">
产量及良率对比
</div>
<bm-line-bar :chartHeight="chartHeight" :legendList="legendList" :chartMsg="chartMsg" :chartId="chartId"
:chartNum="chartNum" />
</el-col>
<el-col :span="8">
<div class="blueTip">
{{ title }}
</div>
<produce-line-bar-year-target :chartHeight="chartHeight" :legendList="legendListTarget"
:chartMsg="chartMsgYearTarget" :chartId=" 'yearData'" :chartNum="chartNum" />
</el-col>
</el-row>
<el-row v-else>
<!-- <el-col :span="24"> -->
<div class="blueTip">
产量及良率对比
</div>
<bm-line-bar :chartHeight="chartHeight" :legendList="legendList" :chartMsg="chartMsg" :chartId="chartId"
:chartNum="chartNum" />
<!-- </el-col> -->
<!-- <el-col :span="8">
<div class="blueTip">
{{ title }}
</div>
<produce-line-bar-year-target :chartHeight="chartHeight" :legendList="legendList"
:chartMsg="chartMsgYearTarget" :chartId=" 'yearData'" :chartNum="chartNum" />
</el-col> -->
</el-row>
<base-table :key="showTable" :table-props="tableProps" :page="listQuery.current"
:limit="listQuery.size" :table-data="tableData" :max-height="tableH" />
</div>
<!-- <div class="containerBottom">
</div> -->
</div>
</template>
<script>
import { getProductionYieldSituationMWData, exportProductionYieldSituationMWData } from '@/api/report';
import bmSearchBar from "./components/bmSearchBar";
import BmLineBar from "./components/produceLineBar.vue";
import produceLineBarYearTarget from "./components/produceLineYieldBarTarget.vue";
import ButtonNav from '@/components/ButtonNav'
import moment from 'moment'
export default {
name: "ChipYieldBM",
data() {
return {
otherProps: [],
start: undefined,
end: undefined,
currentMenu:'邯郸',
title: '',
showTable:false,
listQuery: {
pageNo: 1,
pageSize: 999,
// size: 10,
// current: 1,
factory: null,
start: undefined,
end: undefined,
// total: 0,
type: 2,
startDate: undefined,
endDate: undefined,
reportTime: []
},
timeList: [
{
value: 0,
label: '日'
},
{
value: 1,
label: '周'
},
{
value: 2,
label: '月'
},
{
value: 3,
label: '年'
}
],
tableData: [],
chartHeight: this.tableHeight(137) / 2 - 111,
tableH: this.tableHeight(137) / 2 - 70,
legendList: [
{id: 2, name: "FTO投入", type: 1, color: "#8EF0AB" },
{ id: 3, name: "芯片产量", type: 1, color: "#288AFF" },
{ id: 4, name: "标准组件产量", type: 1, color: "#64BDFF" },
{
id: 1, name: "综合良率", type: 2, color: "#FFCE6A"
},
],
legendListTarget: [
{
id: 2, name: "FTO投入", type: 1, color: "#8EF0AB"
},
{ id: 3, name: "芯片产量", type: 1, color: "#288AFF" },
{
id: 4, name: "标准组件产量", type: 1, color: "#64BDFF"
},
{
id: 1, name: "综合良率", type: 1, color: "#7164FF"
},
],
chartMsgYearTarget: {
color: ["#8EF0AB", "#288AFF", '#64BDFF', "#7164FF",],
xData: [],
// yName: "单位/%",
yAxis: [
{
type: "value",
name: "单位/片",
splitNumber: 4,
// min: function (value) {//取最小值向下取整为最小刻度
// return Math.floor(value.min)
// },
// max: function (value) {//取最大值向上取整为最大刻度
// return Math.ceil(value.max)
// },
alignTicks: true,
nameTextStyle: {
fontSize: 12,
align: "right",
},
axisLabel: {},
},
{
type: 'value',
// inverse: true,
alignTicks: true,
// min: 0,
// max: 100,
// scale: true,
// interval: 25,//间隔
splitNumber: 4,
name: "单位/%",
nameTextStyle: {
fontSize: 12,
align: "right",
},
axisLabel: {},
}
],
series: [
{
name: "",
// yAxisIndex: 0,
data: [],
type: "bar",
barWidth: 20,
label: {
show: true,
position: [-18, -16],
color: "#68C483",
formatter: function (params) {
return params.value
},
},
},
{
name: '',
// type: 'bar',
data: [],
type: "bar",
barWidth: 20,
label: {
show: true,
position: [-18, -16],
color: "#68C483",
formatter: function (params) {
return params.value
},
},
yAxisIndex: 1
}
],
},
chartMsg: {
color: ["#8EF0AB", "#288AFF", '#64BDFF', "#FFCE6A",],
xData: [],
// yName: "单位/%",
yAxis: [
{
type: "value",
name: "单位/片",
// min: function (value) {//取最小值向下取整为最小刻度
// return Math.floor(value.min)
// },
// max: function (value) {//取最大值向上取整为最大刻度
// return Math.ceil(value.max)
// },
alignTicks:true,
// splitNumber: 4,
// scale: true,
nameTextStyle: {
fontSize: 12,
align: "right",
},
axisLabel: {},
},
{
type: 'value',
// inverse: true,
name: "单位/%",
alignTicks: true,
// min: 0,
// max:100,
// scale: true,
// interval: 25,//间隔
splitNumber: 4,
nameTextStyle: {
fontSize: 12,
align: "right",
},
axisLabel: {},
}
],
series: [
{
name: "",
// yAxisIndex: 0,
data: [],
type: "bar",
barWidth: 20,
yAxisIndex: 0,
label: {
show: true,
position: [-18, -16],
color: "#68C483",
formatter: function (params) {
return params.value
},
},
},
{
name: "",
// yAxisIndex: 0,
data: [],
yAxisIndex: 0,
type: "bar",
barWidth: 20,
label: {
show: true,
position: [0, -16],
color: "#288AFF",
formatter: function (params) {
return params.value
},
},
},
{
name: "",
// yAxisIndex: 0,
data: [],
type: "bar",
yAxisIndex: 0,
barWidth: 20,
label: {
show: true,
position: [0, -16],
color: "#64BDFF",
formatter: function (params) {
return params.value
},
},
},
{
name: "",
data: [],
type: "line",
// barWidth: 20,
symbol: "circle",
symbolSize: 6,
yAxisIndex: 1,
label: {
show: true,
color: "#FFAE17",
formatter: function (params) {
return params.value.toFixed(2)
},
},
},
],
},
chartId: "chipYieldBMChart",
chartNum: 1,
};
},
components: {
bmSearchBar,
BmLineBar,
produceLineBarYearTarget,
ButtonNav
},
computed: {
tableProps() {
return [
{
prop: "item",
label: "科目",
// filter: (val) => factoryList[val],
minWidth: 200,
showOverflowtooltip: true,
},
{
prop: "unit",
label: "单位",
minWidth: 120,
showOverflowtooltip: true,
},
...this.otherProps
]
},
weekNum() {
return Math.round((this.end - this.start) / (24 * 60 * 60 * 1000 * 7)) + 1
},
isOpen() {
return this.$store.getters.sidebar.opened;
},
type() {
return this.listQuery.type
}
},
watch: {
// 监听左侧菜单栏是否展开
type(val) {
},
currentMenu() {
this.getDataList()
},
isOpen(val) {
if (this.$route.name === "productionYield") {
this.chartNum++;
}
},
},
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);
},
activated() {
// 图重新加载,为了防止窗口变化后尺寸图显示不佳,数据不更新
if (this.$route.name === "productionYield") {
this.chartNum++;
}
},
mounted() {
// this.getOverView()
const today = new Date()
const sevenDaysAgo = new Date(today.getTime() - (7 * 24 * 60 * 60 * 1000))
this.listQuery.startDate = moment(sevenDaysAgo).format('yyyy-MM-DD')
this.listQuery.endDate = moment(today).format('yyyy-MM-DD')
this.listQuery.reportTime = [this.listQuery.startDate, this.listQuery.endDate]
this.getDataList()
},
methods: {
handleChange() {
this.listQuery.reportTime = []
this.listQuery.end = null
this.listQuery.start = null
this.listQuery.endTime = null
this.listQuery.beginTime = null
},
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
let spanOneArr = [], concatOne = 0;
// let spanTwoArr = [], concatTwo = 0;
this.tableData.map((item, index) => {
// console.log(inde);
if (index === 0) {
spanOneArr.push(1);
} else {
//第一列需合并相同内容的判断条件
if (item.factory === this.tableData[index - 1].factory) {
spanOneArr[concatOne] += 1;
spanOneArr.push(0);
} else {
spanOneArr.push(1);
concatOne = index;
};
}
});
if (columnIndex === 0) {
const _row = spanOneArr[rowIndex];
const _col = _row > 0 ? 1 : 0;
return {
rowspan: _row,
colspan: _col
}
}
},
getYear(e) {
if (this.listQuery.end - this.listQuery.start > 10 * 365 * 24 * 60 * 60 * 1000) {
this.$message({
message: '年份起止时间不能超过十年',
type: 'warning'
});
this.listQuery.reportTime = []
this.listQuery.start = undefined
this.listQuery.end = undefined
// console.log();
} else {
this.listQuery.startDate = this.listQuery.start
this.listQuery.endDate = this.listQuery.end
}
if (!this.listQuery.start && !this.listQuery.end) {
this.listQuery.startDate = undefined
this.listQuery.endDate = undefined
}
// console.log(e);
},
onValueChange(picker, k) { // 选中近k周后触发的操作
// console.log(this.listQuery.reportTime[0], this.listQuery.reportTime[1])
if (this.listQuery.start && this.listQuery.end) {
console.log(this.listQuery.reportTime)
this.date1 = moment(this.listQuery.start.getTime() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
this.date2 = moment(this.listQuery.end.getTime() + 5 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD HH:mm:ss')
const numDays = (new Date(this.date2).getTime() - new Date(this.date1).getTime()) / (24 * 3600 * 1000);
if (numDays > 168) {
console.log(numDays)
this.$message({
message: '周范围不能超过24周',
type: 'warning'
});
} else {
this.listQuery.startDate = moment(this.listQuery.start.getTime() - 24 * 60 * 60 * 1000).format('YYYY-MM-DD')
this.listQuery.endDate = moment(this.listQuery.end.getTime() + 5 * 24 * 60 * 60 * 1000).format('YYYY-MM-DD')
}
}
if (!this.listQuery.start && !this.listQuery.end) {
this.listQuery.startDate = undefined
this.listQuery.endDate = undefined
}
},
changeDayTime() {
if (this.listQuery.reportTime) {
// this.createStartDate = moment(new Date(this.listQuery.reportTime[0]), 'yyyy-MM-dd hh:mm:ss');
// this.createEndDate = moment(new Date(this.listQuery.reportTime[1]), 'yyyy-MM-dd hh:mm:ss');
console.log(this.listQuery.reportTime[1])
const numDays = (this.listQuery.reportTime[1] - this.listQuery.reportTime[0]) / (24 * 3600 * 1000);
if (numDays > 30) {
this.$message({
message: '时间范围不能超过30天',
type: 'warning'
});
this.listQuery.reportTime = [];
} else {
this.listQuery.startDate = this.listQuery.reportTime[0]
this.listQuery.endDate = this.listQuery.reportTime[1]
}
} else {
this.listQuery.startDate = undefined
this.listQuery.endDate = undefined
}
},
changeTime(value) {
if (this.listQuery.reportTime) {
const numDays = this.listQuery.reportTime[1] - this.listQuery.reportTime[0];
if (numDays > 2 * 365 * 24 * 60 * 60 * 1000) {
this.$message({
message: '时间范围不能超过24个月',
type: 'warning'
});
this.listQuery.reportTime = [];
} else {
this.listQuery.startDate = this.listQuery.reportTime[0]
this.listQuery.endDate = this.listQuery.reportTime[1]
}
} else {
this.listQuery.startDate = undefined
this.listQuery.endDate = undefined
}
},
async getDataList() {
this.otherProps = []
this.chartMsg.xData = []
this.chartMsg.series[0].data = []
this.chartMsg.series[1].data = []
this.chartMsg.series[2].data = []
this.chartMsg.series[3].data = []
this.chartMsgYearTarget.xData = []
this.chartMsgYearTarget.series[0].data = []
this.chartMsgYearTarget.series[1].data = []
if (this.listQuery.type == null) {
return this.$message('请选择时间维度')
}
if (!this.listQuery.startDate && !this.listQuery.endDate) {
return this.$message('请选择起止时间')
}
let arr = []
this.currentMenu === '邯郸' ? arr.push(1) : arr.push(0)
this.listQuery.factory = arr
const res = await getProductionYieldSituationMWData(this.listQuery)
let dataArr = [{
factory: null,
item: 'FTO投入',
unit: '片'
},
{
factory: null,
item: '芯片产量',
unit: '片'
},
{
factory: null,
item: '标准组件产量',
unit: '片'
},
{
factory: null,
item: '综合良率',
unit: '%'
},]
if (this.listQuery.type == 2) {
res.data.list.forEach((ele, index) => {
let i = index + 1
this.chartMsg.xData.push(ele.titleValue)
this.otherProps.push({
label: ele.titleValue,
filter: (val) => (val || val === 0 ? val : "-"),
prop: 'value' + i
})
})
this.chartMsgYearTarget.xData.push('FTO投入', '芯片产量', '标准组件产量', '综合良率')
res.data.list.slice(res.data.list.length - 1, res.data.list.length).forEach((ele) => {
this.title = ele.titleValue
ele.productYieldDataVOList.forEach((item) => {
// this.chartMsgYearTarget.series[0].name = 'FTO投入目标值',
// this.chartMsgYearTarget.series[1].name = '芯片产量目标值',
// this.chartMsgYearTarget.series[2].name = '标准组件产量目标值',
// this.chartMsgYearTarget.series[3].name = '综合良率目标值',
this.chartMsgYearTarget.series[0].data = [
{
value: item.ftoInput,
label: {
color: '#8EF0AB'
},
itemStyle: {
color: '#8EF0AB'
}
},
{
value: item.chipYield,
label: {
color: '#288AFF'
},
itemStyle: {
color: '#288AFF'
}
},
{
value: item.componentYield,
label: {
color: '#64BDFF'
},
itemStyle: {
color: '#64BDFF'
}
},
{
value: null,
label: {
color: '#FFCE6A'
},
itemStyle: {
color: '#FFCE6A'
}
}]
this.chartMsgYearTarget.series[1].data = [
{
value: null,
label: {
color: '#8EF0AB'
},
itemStyle: {
color: '#8EF0AB'
}
},
{
value: null,
label: {
color: '#288AFF'
},
itemStyle: {
color: '#288AFF'
}
},
{
value: null,
label: {
color: '#64BDFF'
},
itemStyle: {
color: '#64BDFF'
}
},
{
value: item.ftoInput,
label: {
color: '#FFCE6A'
},
itemStyle: {
color: '#FFCE6A'
}
}]
// dataArr[0]['' + m + ''] = item.ftoInput
// dataArr[0].factory = item.factory == 1 ? '邯郸' : '瑞昌'
// dataArr[1].factory = item.factory == 1 ? '邯郸' : '瑞昌'
// dataArr[2].factory = item.factory == 1 ? '邯郸' : '瑞昌'
// dataArr[3].factory = item.factory == 1 ? '邯郸' : '瑞昌'
// dataArr[1]['' + m + ''] = item.chipYield
// dataArr[2]['' + m + ''] = item.componentYield
// dataArr[3]['' + m + ''] = item.comprehensiveYieldRate
})
})
console.log(this.otherProps)
res.data.list.forEach((ele, index) => {
let i = index + 1
let m = 'value' + i
ele.productYieldDataVOList.forEach((item) => {
dataArr[0]['' + m + ''] = item.ftoInput
dataArr[1]['' + m + ''] = item.chipYield
dataArr[2]['' + m + ''] = item.componentYield
dataArr[3]['' + m + ''] = item.comprehensiveYieldRate
})
})
for (let i in dataArr[0]) {
this.chartMsg.series[0].name = dataArr[0]['item']
if (i.search('value') === 0) {
this.chartMsg.series[0].data.push({
name: dataArr[0]['item'],
value: dataArr[0][i] === 0 ? null : dataArr[0][i]
})
}
}
for (let i in dataArr[1]) {
this.chartMsg.series[1].name = dataArr[1]['item']
if (i.search('value') === 0) {
this.chartMsg.series[1].data.push({
name: dataArr[1]['item'],
value: dataArr[1][i] === 0 ? null : dataArr[1][i]
})
}
}
for (let i in dataArr[2]) {
this.chartMsg.series[2].name = dataArr[2]['item']
if (i.search('value') === 0) {
this.chartMsg.series[2].data.push({
name: dataArr[2]['item'],
value: dataArr[2][i] === 0 ? null : dataArr[2][i]
})
}
}
for (let i in dataArr[3]) {
this.chartMsg.series[3].name = dataArr[3]['item']
if (i.search('value') === 0) {
this.chartMsg.series[3].data.push({
name: dataArr[3]['item'],
value: dataArr[3][i] === 0 ? null : dataArr[3][i]
})
}
}
} else {
res.data.list.forEach((ele, index) => {
let i = index + 1
this.chartMsg.xData.push(ele.titleValue)
this.otherProps.push({
label: ele.titleValue,
prop: 'value' + i
})
})
console.log(this.otherProps)
res.data.list.forEach((ele, index) => {
let i = index + 1
let m = 'value' + i
ele.productYieldDataVOList.forEach((item) => {
dataArr[0]['' + m + ''] = item.ftoInput
dataArr[0].factory = item.factory == 1 ? '邯郸' : '瑞昌'
dataArr[1].factory = item.factory == 1 ? '邯郸' : '瑞昌'
dataArr[2].factory = item.factory == 1 ? '邯郸' : '瑞昌'
dataArr[3].factory = item.factory == 1 ? '邯郸' : '瑞昌'
dataArr[1]['' + m + ''] = item.chipYield
dataArr[2]['' + m + ''] = item.componentYield
dataArr[3]['' + m + ''] = item.comprehensiveYieldRate
})
})
for (let i in dataArr[0]) {
this.chartMsg.series[0].name = dataArr[0]['item']
if (i.search('value') === 0) {
this.chartMsg.series[0].data.push({
name: dataArr[0]['item'],
value: dataArr[0][i] === 0 ? null : dataArr[0][i]
})
}
}
for (let i in dataArr[1]) {
this.chartMsg.series[1].name = dataArr[1]['item']
if (i.search('value') === 0) {
this.chartMsg.series[1].data.push({
name: dataArr[1]['item'],
value: dataArr[1][i] === 0 ? null : dataArr[1][i]
})
}
}
for (let i in dataArr[2]) {
this.chartMsg.series[2].name = dataArr[2]['item']
if (i.search('value') === 0) {
this.chartMsg.series[2].data.push({
name: dataArr[2]['item'],
value: dataArr[2][i] === 0 ? null : dataArr[2][i]
})
}
}
for (let i in dataArr[3]) {
this.chartMsg.series[3].name = dataArr[3]['item']
if (i.search('value') === 0) {
this.chartMsg.series[3].data.push({
name: dataArr[3]['item'],
value: dataArr[3][i] === 0 ? null : dataArr[3][i]
})
}
}
}
console.log(dataArr)
this.tableData = res.data.length != 0 ? dataArr : []
this.showTable = !this.showTable
// this.tableProps.push()
},
_setTableHeight() {
this.tableH = this.tableHeight(137) / 2 - 70;
this.chartHeight = this.tableHeight(137) / 2 - 111;
if (this.$route.name === "productionYield") {
this.chartNum++;
}
},
getSearch(val) {
console.log(val);
console.log("=========================");
},
handleExport() {
// this.listQuery.type = val.type;
// this.listQuery.startDate = val.startDate;
// this.listQuery.factory = val.factory;
let fileName = "产品良率.xls";
exportProductionYieldSituationMWData(this.listQuery)
.then((response) => {
this.$download.excel(response, fileName);
this.$message.success("导出成功");
})
.catch(() => { });
},
},
};
</script>
<style lang="scss" scoped>
.search {
// height: calc((100px));
background-color: #fff;
border-radius: 8px;
padding: 16px 16px 0 16px;
margin:8px 0 8px 0px;
}
.containerTop {
height: calc((100vh - 170px));
background-color: #fff;
border-radius: 8px;
padding: 16px;
}
.blueTip::before {
display: inline-block;
content: '';
width: 4px;
height: 18px;
background: #0B58FF;
border-radius: 1px;
margin-right: 8PX;
margin-top: 8px;
}
.containerTop {
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>