yudao-init/src/views/copilot/factoryData/components/ChipOee.vue

279 lines
8.4 KiB
Vue
Raw Normal View History

2024-05-29 17:05:55 +08:00
<!--
* @Author: zhp
* @Date: 2024-05-29 14:48:06
2024-05-30 16:00:18 +08:00
* @LastEditTime: 2024-05-30 10:54:00
2024-05-29 17:05:55 +08:00
* @LastEditors: zhp
* @Description:
-->
<template>
<BarChartBase
:legend="legend"
:series="series"
:xAxis="xAxis"
in="chipOEE"
class="chip-oee"
/>
</template>
<script>
2024-05-30 16:00:18 +08:00
import BarChartBase from "./BarChartChipOEE.vue";
2024-05-29 17:05:55 +08:00
export default {
name: "ChipOEE",
components: { BarChartBase },
props: {
period: {
type: Number,
default:1,
},
than: {
type: String,
default: "同比",
},
2024-05-30 16:00:18 +08:00
companyId: {
type: Number,
default: 0
},
2024-05-29 17:05:55 +08:00
data: {
type: Object,
default:{}
}
},
data() {
// 城市数组的顺序必须是固定的
2024-05-30 16:00:18 +08:00
const cities = ["fto投入", "芯片产量", "标准组件产量"];
2024-05-29 17:05:55 +08:00
return {
2024-05-30 16:00:18 +08:00
// xAxis: cities,
2024-05-29 17:05:55 +08:00
};
},
computed: {
2024-05-30 16:00:18 +08:00
xAxis() {
console.log(' this.companyId', this.companyId);
return this.companyId === 0 ? ["fto投入", "芯片产量", "标准组件产量"] : ["fto投入", "芯片产量", "标准组件产量", 'BIPV产量'];
},
2024-05-29 17:05:55 +08:00
legend() {
let items = [];
var day1 = new Date();
day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000);
var yesterday = (day1.getMonth() + 1) + "月" + day1.getDate()
//今天的时间
// var day2 = new Date();
// day2.setTime(day2.getTime());
// var s2 = (day2.getMonth() + 1) + "月" + day2.getDate() + '日';
const today = new Date().getDate();
// let yesterday = new Date().getDate() -1;
const month = new Date().getMonth() + 1;
const lastMonth = new Date().getMonth() + 1 === 12 ? 1 : new Date().getMonth() + 1 - 1;
const year = new Date().getFullYear();
if (this.period === 1 && this.than === '同比') {
items = [
{ label: `去年${month}${today}`, color: "#12f7f1" },
{ label: `${month}${today}`, color: "#58adfa" },
];
} else if (this.period ===1 && this.than === '环比') {
items = [
{ label: `${yesterday}`, color: "#12f7f1" },
{ label: `${month}${today}`, color: "#58adfa" },
];
} else if (this.period === 2 && this.than === '同比') {
items = [
{ label: `去年本周`, color: "#12f7f1" },
{ label: `本周`, color: "#58adfa" },
];
} else if (this.period === 2 && this.than === '环比') {
items = [
{ label: `上周`, color: "#12f7f1" },
{ label: `本周`, color: "#58adfa" },
];
} else if (this.period === 3 && this.than === '同比') {
items = [
{ label: `去年${month}`, color: "#12f7f1" },
{ label: `${month}`, color: "#58adfa" },
{ label: `${month}月目标`, color: "#58adfa" },
// { label: `${month}月目标`, value: valueTuple[2] },
];
} else if (this.period === 3 && this.than === '环比') {
items = [
{ label: `${lastMonth}`, color: "#12f7f1" },
{ label: `${month}`, color: "#58adfa" },
{ label: `${month}月目标`, color: "#58adfa" },
// { label: `${month}月目标`, value: valueTuple[2] },
];
} else {
items = [
{ label: `${year - 1}`, color: "#12f7f1" },
{ label: `${year}`, color: "#58adfa" },
2024-05-30 16:00:18 +08:00
{ label: `${year}年目标`, color: "#58adfa" },
2024-05-29 17:05:55 +08:00
// { label: `${year}年目标`, value: valueTuple[2] },
];
}
return items
// switch (this.period) {
// case "日":
// return [{ label: "昨日", color: "#12f7f1" }];
// case "周":
// return [{ label: "本周", color: "#12f7f1" }];
// case "月": {
// const year = new Date().getFullYear();
// const month = new Date().getMonth() + 1;
// return [
// { label: `${year - 1}年${month}月`, color: "#12f7f1" },
// { label: `${year}年${month}月`, color: "#58adfa" },
// ];
// }
// case "年": {
// const year = new Date().getFullYear();
// return [
// { label: `${year - 1}年`, color: "#12f7f1" },
// { label: `${year}年`, color: "#58adfa" },
// ];
// }
// default:
// return [
// { label: `${year - 1}年`, color: "#12f7f1" },
// { label: `${year}年`, color: "#58adfa" },
// ];
// }
},
// chipOeeRate() {
// return this.$store.getters.copilot.efficiency.chipOeeRate
// },
series() {
// console.log('aaaaaaaa', this.$store.getters.copilot.efficiency.chipOee);
2024-05-30 16:00:18 +08:00
// const chipOeeRate = this.data
2024-05-29 17:05:55 +08:00
// console.log('chipOee', chipOeeRate)
2024-05-30 16:00:18 +08:00
let dataList = []
dataList[0] = this.data.preDataDetail
dataList[1] = this.data.currentDataDetail
dataList[2] = this.data.targetDataDetail
2024-05-29 17:05:55 +08:00
console.log(dataList)
return getTemplate(this.period, dataList,this.than);
},
},
methods: {},
};
function getTemplate(period, dataList, than) {
// console.log('dataList',dataList);
let items = [];
var day1 = new Date();
day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000);
var yesterday = (day1.getMonth() + 1) + "月" + day1.getDate()
//今天的时间
// var day2 = new Date();
// day2.setTime(day2.getTime());
// var s2 = (day2.getMonth() + 1) + "月" + day2.getDate() + '日';
const today = new Date().getDate();
// let yesterday = new Date().getDate() -1;
const month = new Date().getMonth() + 1;
const lastMonth = new Date().getMonth() + 1 === 12 ? 1 : new Date().getMonth() + 1 - 1;
const year = new Date().getFullYear();
if (period === 1 && than === '同比') {
items = [
{
name: `去年${month}${today}`,
data: dataList ? dataList[0] : [],
},
{
name: `${month}${today}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period ===1 && than === '环比') {
items = [
{
name: `${yesterday}`,
data: dataList ? dataList[0] : [],
},
{
name: `${month}${today}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === 2 && than === '同比') {
items = [
{
name: `去年本周`,
data: dataList ? dataList[0] : [],
},
{
name: `本周`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === 2&& than === '环比') {
items = [
{
name: `上周`,
data: dataList ? dataList[0] : [],
},
{
name: `本周`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === 3 && than === '同比') {
items = [
{
name: `去年${month}`,
data: dataList ? dataList[0] : [],
},
{
name: `${month}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
{
name: `${month}目标`,
data: dataList ? dataList[2] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === 3 && than === '环比') {
items = [
{
name: `${lastMonth}`,
data: dataList ? dataList[0] : [],
},
{
name: `${month}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
{
name: `${month}目标`,
data: dataList ? dataList[2] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else {
items = [
{
name: `${year - 1}`,
data: dataList ? dataList[0] : [],
},
{
name: `${year}`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
{
name: `${year}目标`,
data: dataList ? dataList[2] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
}
return items
}
</script>
<style scoped lang="scss">
</style>