Compare commits

..

No commits in common. "5444ff92f7810aa9b913017019f274f3d8543a91" and "b45818e2a409dd37180c7d91c64f2888893227bc" have entirely different histories.

3 changed files with 137 additions and 87 deletions

View File

@ -70,7 +70,7 @@ const LOCATIONS = [
// 2 // 2
// { x: 61, y: 53, tx: 39, ty: 68, path: 'factoryData/ksIndex' }, // { x: 61, y: 53, tx: 39, ty: 68, path: 'factoryData/ksIndex' },
// 西 // 西
{ x: 60, y: 58, tx: 68, ty: 50,lx:61,ly:61.5,ltx:69.5,lty:51.2, path: 'factoryData/factory-data' }, { x: 60, y: 58, tx: 68, ty: 52,lx:61,ly:61.5,ltx:69.5,lty:52, path: 'factoryData/factory-data' },
// //
// { x: 56, y: 60, tx: 60, ty: 95, path: 'factoryData/zzIndex' }, // { x: 56, y: 60, tx: 60, ty: 95, path: 'factoryData/zzIndex' },
// //

View File

@ -1,7 +1,7 @@
<!-- <!--
* @Author: zhp * @Author: zhp
* @Date: 2024-04-15 10:49:13 * @Date: 2024-04-15 10:49:13
* @LastEditTime: 2024-07-17 08:55:15 * @LastEditTime: 2024-07-10 09:58:59
* @LastEditors: zhp * @LastEditors: zhp
* @Description: * @Description:
--> -->
@ -17,15 +17,15 @@
</el-form-item> </el-form-item>
<el-form-item v-show="listQuery.type === 0 || listQuery.type === ''" label="时间范围" prop="reportTime"> <el-form-item v-show="listQuery.type === 0 || listQuery.type === ''" label="时间范围" prop="reportTime">
<el-date-picker size="small" clearable v-model="listQuery.reportTime" type="daterange" range-separator="" <el-date-picker size="small" clearable v-model="listQuery.reportTime" type="daterange" range-separator=""
start-placeholder="开始日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" @change="changeDayTime" end-placeholder="结束日期" :picker-options="{ firstDayOfWeek: 1 }"> start-placeholder="开始日期" value-format="yyyy-MM-dd" format="yyyy-MM-dd" @change="changeDayTime" end-placeholder="结束日期" :picker-options="{ }">
</el-date-picker> </el-date-picker>
</el-form-item> </el-form-item>
<el-form-item v-show="listQuery.type === 1" label="时间范围" prop="reportTime"> <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-MM-dd" placeholder="选择周" :picker-options="{ firstDayOfWeek: 1 }" <el-date-picker size="small" clearable v-model="listQuery.start" type="week" format="yyyy 第 WW 周" placeholder="选择周"
style="width: 180px" @change="onValueChange"> style="width: 180px" @change="onValueChange">
</el-date-picker> </el-date-picker>
<el-date-picker size="small" clearable v-model="listQuery.end" type="week" format="yyyy-MM-dd" placeholder="选择周" :picker-options="{ firstDayOfWeek: 1 }" <el-date-picker size="small" clearable v-model="listQuery.end" type="week" format="yyyy 第 WW 周" placeholder="选择周"
style="width: 180px" @change="onValueChange"> style="width: 180px" @change="onValueChange">
</el-date-picker> </el-date-picker>
<!-- <span v-if="listQuery.start && listQuery.end" style="margin-left: 10px"> <!-- <span v-if="listQuery.start && listQuery.end" style="margin-left: 10px">
@ -115,7 +115,7 @@ import moment from 'moment'
import ButtonNav from '@/components/ButtonNav' import ButtonNav from '@/components/ButtonNav'
import basicPage from '@/mixins/basic-page' import basicPage from '@/mixins/basic-page'
import AddOrUpdate from './add-or-updata' import AddOrUpdate from './add-or-updata'
import { factoryList, factoryArray, factoryListabbr } from "@/utils/constants"; import { factoryList, factoryArray } from "@/utils/constants";
export default { export default {
components: { lineChart, ButtonNav, AddOrUpdate }, components: { lineChart, ButtonNav, AddOrUpdate },
@ -124,7 +124,7 @@ export default {
return { return {
factoryList, factoryList,
factoryArray, factoryArray,
factoryListabbr, // factoryArray1,
listQuery: { listQuery: {
pageSize: 20, pageSize: 20,
pageNo: 1, pageNo: 1,
@ -253,7 +253,7 @@ export default {
// }, // },
created() { created() {
const today = new Date() const today = new Date()
const sevenDaysAgo = new Date(today.getTime() - (6 * 24 * 60 * 60 * 1000)) const sevenDaysAgo = new Date(today.getTime() - (7 * 24 * 60 * 60 * 1000))
this.listQuery.startDate = moment(sevenDaysAgo).format('yyyy-MM-DD') this.listQuery.startDate = moment(sevenDaysAgo).format('yyyy-MM-DD')
this.listQuery.endDate = moment(today).format('yyyy-MM-DD') this.listQuery.endDate = moment(today).format('yyyy-MM-DD')
this.listQuery.reportTime = [this.listQuery.startDate, this.listQuery.endDate] this.listQuery.reportTime = [this.listQuery.startDate, this.listQuery.endDate]
@ -385,72 +385,115 @@ export default {
this.seriesList = [] this.seriesList = []
// x // x
xAxisData = Object.keys(data) xAxisData = Object.keys(data)
let arr = []
if (this.listQuery.factory.length === 0) {
arr = this.factoryArray
} else {
this.listQuery.factory.forEach((ele, index) => {
// series let i = this.factoryArray.findIndex((item) => item.id == ele)
// ['chipYield', 'componentYield', 'bipvProductOutput'] if (i != -1) {
const typeArray = (this.listQuery.glass.length === 0 || this.listQuery.glass.length === 3) ? [0, 1, 2] : this.listQuery.glass arr.push({
// this.factoryListabbr id: this.factoryArray[i].id,
const factoryNameArray = (this.listQuery.factory.length === 0 || this.listQuery.factory.length === this.factoryListabbr.length) ? [0, 1] : this.listQuery.factory name: this.factoryArray[i].name
const seriesArray = [] })
typeArray.forEach((type, typeIndex) => {
factoryNameArray.forEach((fac, facIndex) => {
const series = {
data: Array(xAxisData.length).fill(0),
type: 'bar',
stack: String(fac),
barWidth: 16,
itemStyle: {
color: this.colorList[type]
},
name: this.factoryListabbr[fac] + '-' + type
} }
seriesArray.push(series)
}) })
})
// seriesdata
const seriesDataArray = []
Object.values(data).forEach((item) => {
let seriesData = []
// item[0].datestr
typeArray.forEach(t => {
const zidr = ['chipYield', 'componentYield', 'bipvProductOutput'][t]
item.forEach(it => {
seriesData.push(it[zidr])
})
})
seriesDataArray.push(seriesData)
})
for (let y = 0; y < seriesArray.length; y ++) {
const days = []
seriesDataArray.forEach(a => {
days.push(a[y])
})
//
seriesArray[y].data = days
} }
// // y
const validSeriesArray = [] arr.forEach((fac,index) => {
factoryNameArray.forEach(f => { console.log('fac',fac);
const s = { let i = 0
name: '显示工厂', let position = fac.id == 1 ? [1, -16,] : [-8, -16,]
data: Array(xAxisData.length).fill(0), while ( i < 3) {
type: 'bar', //
stack: String(f), const index1 = ['chipYield', 'componentYield', 'bipvProductOutput'][i]
barWidth: 16, // let oneChart = {}
label: { xAxisData.forEach((x, index) => {
show: true, if (this.listQuery.glass.length === 0 || this.listQuery.glass.length === 3) {
position: 'top', let series = {
// position: f > 0 ? [2, -16] : [-10, -16], name: ['玻璃芯片', '标准组件', 'BIPV'][i] + '-' + fac.id,
formatter(params) { type: 'bar',
return factoryListabbr[f] stack: String(fac.id),
data: Array(xAxisData.length).fill(0),
barWidth: 16,
itemStyle: {
color: this.colorList[i]
},
label: {
show: i === 2 ? true : false,
position: 'top',
// fontSize:10,
position: position,
formatter(params) {
return fac.name.substring(0, 2)
}
}
}
dataList.forEach(item => {
if (fac.id === item.factory && item.datestr === x) {
series.data[index] = item[index1]
}
})
this.seriesList.push(series)
} else {
this.listQuery.glass.forEach(gl => {
if (gl === i) {
let series = {
name: ['玻璃芯片', '标准组件', 'BIPV'][i] + '-' + fac.id,
type: 'bar',
stack: String(fac.id),
data: Array(xAxisData.length).fill(0),
barWidth: 16,
itemStyle: {
color: this.colorList[i]
},
label: {
show: true,
position: 'top',
position: position,
formatter(params) {
if (params.value === 0) {
return ''
} else {
// return ['', ''][params.seriesName.split('-')[1]]
return fac.name.substring(0, 2)
}
}
}
}
dataList.forEach(item => {
if (fac.id === item.factory && item.datestr === x) {
series.data[index] = item[index1]
}
})
this.seriesList.push(series)
}
})
} }
} // let series = {
// name: ['', '', 'BIPV'][i] + '-' + fac.id,
// type: 'bar',
// stack: String(fac.id),
// data: Array(xAxisData.length).fill(0),
// barWidth: 16,
// itemStyle: {
// color: this.colorList[i]
// }
// }
// dataList.forEach(item => {
// if (fac.id === item.factory && item.datestr === x) {
// series.data[index] = item[index1]
// }
// })
// this.seriesList.push(series)
})
i ++
} }
validSeriesArray.push(s)
}) })
this.seriesList = [...seriesArray, ...validSeriesArray] console.log('你好', this.seriesList)
this.$refs.lineChart.initChart(xAxisData, this.seriesList, factoryNameArray) this.$refs.lineChart.initChart(xAxisData, this.seriesList,arr)
}, },
buttonClick(val) { buttonClick(val) {
this.listQuery.reportTime = val.reportTime ? val.reportTime : undefined; this.listQuery.reportTime = val.reportTime ? val.reportTime : undefined;

View File

@ -1,8 +1,8 @@
<!-- <!--
* @Author: zwq * @Author: zwq
* @Date: 2022-01-21 14:43:06 * @Date: 2022-01-21 14:43:06
* @LastEditors: DY * @LastEditors: zhp
* @LastEditTime: 2024-07-16 18:41:27 * @LastEditTime: 2024-07-04 09:37:49
* @Description: * @Description:
--> -->
<template> <template>
@ -73,7 +73,7 @@ export default {
this.chart = null this.chart = null
}, },
methods: { methods: {
initChart(xAxis, seriesList, facs) { initChart(xAxis, seriesList,arr) {
if (xAxis.length === 0) { if (xAxis.length === 0) {
this.chart.clear() this.chart.clear()
} }
@ -93,9 +93,9 @@ export default {
itemHeight: 10, itemHeight: 10,
itemGap: 40, itemGap: 40,
formatter(name) { formatter(name) {
return ['玻璃芯片', '标准组件', 'BIPV'][name.split('-')[1]] return name.split('-')[0]
}, },
data: ['瑞昌-0', '瑞昌-1', '瑞昌-2'] data: ['玻璃芯片-0', '标准组件-0', 'BIPV-0']
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@ -103,41 +103,48 @@ export default {
type: 'shadow', type: 'shadow',
color: "rgba(237,237,237,0.5)" color: "rgba(237,237,237,0.5)"
}, },
formatter(params) { formatter: function (params) {
// console.log(params)
let str = '' let str = ''
facs.forEach(ele => { arr.forEach(ele => {
str += `<div style="width: 60px; text-align: right">${ factoryListabbr[ele] }</div>` str += `<div style="width: 60px; text-align: right">${ele.name.substring(0, 2) }</div>`
}) })
console.log(str);
let result = ` let result = `
<div style="width: 270px; display: flex"> <div style="width: 270px; display: flex">
<div style="width: 150px">${params[0].name}</div> <div style="width: 150px">${params[0].name}</div>
${ str } ${str}
</div>` </div>`
const analyzeArray = params.filter(p => p.seriesName !== '显示工厂').map(item => { const newArray = params.map(p => {
const obj = { console.log(factoryListabbr[p.seriesName.split('-')[1]], p.seriesName.split('-')[0])
glass: ['玻璃芯片', '标准组件', 'BIPV'][item.seriesName.split('-')[1]], // return {
factoryName: item.seriesName.split('-')[0], // glass: p.seriesName.split('-')[0], //
value: item.value, factoryName: arr[p.seriesName.split('-')[1]], //
name: item.name, value: p.value,
marker: item.marker, name: p.name,
color: item.color marker: p.marker,
color: p.color
} }
return obj
}) })
const analyzeList = Object.groupBy(analyzeArray, (member) => member.glass) const analyzeList = Object.groupBy(newArray, (member) => member.glass)
for (let g in analyzeList) { for (let g in analyzeList) {
// date => // date =>
let oneData = `<div style="width: 270px; display: flex"> let oneData = `<div style="width: 270px; display: flex">
<div style="width: 150px; display: flex; align-items: center"> <div style="width: 150px; display: flex; align-items: center">
<div style="background-color: ${analyzeList[g][0].color}; width: 10px; height: 10px; margin-right: 5px"></div> <div style="background-color: ${analyzeList[g][0].color}; width: 10px; height: 10px; margin-right: 5px"></div>
<div>${g}</div></div>` <div>${g}</div></div>`
for (let fac of arr) {
let goodNum = 0 let goodNum = 0
for (let ana of analyzeList[g]) { for (let ana of analyzeList[g]) {
goodNum = ana.value if (ana.factoryName === fac && ana.value !== 0) {
goodNum = ana.value
}
}
oneData += `<div style="width: 60px; text-align: right">${goodNum}</div>` oneData += `<div style="width: 60px; text-align: right">${goodNum}</div>`
} }
result = result + oneData + '</div>' result = result + oneData + '</div>'
} }
// console.log('result', result);
return result return result
} }
}, },