yudao-init/src/views/copilot/efficiency/components/TransformRate.vue

279 lines
8.4 KiB
Vue
Raw Normal View History

2024-05-08 16:38:05 +08:00
<!--
2024-04-29 13:26:38 +08:00
filename: TransformRate.vue
author: liubin
date: 2024-04-29 08:50:34
description: 转化效率
-->
2024-04-29 16:06:59 +08:00
<template>
<BarChartBase
:legend="legend"
:series="series"
:xAxis="xAxis"
in="chipOEE"
class="chip-oee"
/>
</template>
2024-04-29 13:26:38 +08:00
<script>
2024-05-29 17:05:55 +08:00
import BarChartBase from "@/views/copilot/efficiency/components/sub/bar/BarChartChipTrans.vue";
2024-04-29 13:26:38 +08:00
export default {
2024-04-29 16:06:59 +08:00
name: "TransformRate",
components: { BarChartBase },
props: {
period: {
type: String,
default: "日",
2024-04-29 13:26:38 +08:00
},
2024-05-29 17:05:55 +08:00
than: {
type: String,
default: '同比',
},
transformRate: {
type: Object,
default: {}
}
2024-04-29 16:06:59 +08:00
},
data() {
// 城市数组的顺序必须是固定的
2024-06-03 08:23:40 +08:00
const cities = ["瑞昌", "邯郸",
// "株洲", "佳木斯", "成都", "凯盛", "蚌埠"
];
2024-04-29 16:06:59 +08:00
return {
xAxis: cities,
};
},
computed: {
legend() {
2024-05-29 17:05:55 +08:00
let items = [];
var day1 = new Date();
2024-06-14 10:18:20 +08:00
var day2 = new Date();
day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000)
day2.setTime(day2.getTime() - 48 * 60 * 60 * 1000)
2024-05-29 17:05:55 +08:00
var yesterday = (day1.getMonth() + 1) + "月" + day1.getDate()
2024-06-14 10:18:20 +08:00
var dayBeYes = (day2.getMonth() + 1) + "月" + day2.getDate()
2024-05-29 17:05:55 +08:00
//今天的时间
// 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 === '日' && this.than === '同比') {
items = [
2024-06-14 10:18:20 +08:00
{ label: `${year - 1}${yesterday}`, color: "#12f7f1" },
{ label: `${yesterday}`, color: "#58adfa" },
2024-05-29 17:05:55 +08:00
];
} else if (this.period === '日' && this.than === '环比') {
items = [
2024-06-14 10:18:20 +08:00
{ label: `${dayBeYes}`, color: "#12f7f1" },
{ label: `${yesterday}`, color: "#58adfa" },
2024-05-29 17:05:55 +08:00
];
} else if (this.period === '周' && this.than === '同比') {
items = [
2024-06-07 11:13:59 +08:00
{ label: `${year-1}年本周`, color: "#12f7f1" },
2024-05-29 17:05:55 +08:00
{ label: `本周`, color: "#58adfa" },
];
} else if (this.period === '周' && this.than === '环比') {
items = [
{ label: `上周`, color: "#12f7f1" },
{ label: `本周`, color: "#58adfa" },
];
} else if (this.period === '月' && this.than === '同比') {
items = [
2024-06-07 11:13:59 +08:00
{ label: `${year-1}${month}`, color: "#12f7f1" },
2024-05-29 17:05:55 +08:00
{ label: `${month}`, color: "#58adfa" },
{ label: `${month}月目标`, color: "#58adfa" },
// { label: `${month}月目标`, value: valueTuple[2] },
];
} else if (this.period === '月' && 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-06-14 10:18:20 +08:00
{ label: `${year}年目标`, color: "#58adfa" },
2024-05-29 17:05:55 +08:00
// { label: `${year}年目标`, value: valueTuple[2] },
];
2024-04-29 16:06:59 +08:00
}
2024-05-29 17:05:55 +08:00
return items
2024-04-29 16:06:59 +08:00
},
2024-05-29 17:05:55 +08:00
// transformRate() {
// return this.$store.getters.copilot.efficiency.transformRate
// },
2024-04-29 16:06:59 +08:00
series() {
2024-05-29 17:05:55 +08:00
// console.log('aaaaaaaa', this.$store.getters.copilot.efficiency.chipOee);
const transformRate = this.transformRate
// console.log('chipOee', chipOeeRate)
2024-04-29 16:06:59 +08:00
let dataList = null;
switch (this.period) {
case "日":
2024-05-29 17:05:55 +08:00
dataList = [];
dataList[0] = transformRate.previous;
dataList[1] = transformRate.current;
2024-04-29 16:06:59 +08:00
case "周":
2024-05-29 17:05:55 +08:00
dataList = [];
dataList[0] = transformRate.previous;
dataList[1] = transformRate.current;
2024-04-29 16:06:59 +08:00
default:
dataList = [];
2024-05-29 17:05:55 +08:00
dataList[0] = transformRate.previous;
dataList[1] = transformRate.current
dataList[2] = transformRate.target
2024-04-29 16:06:59 +08:00
}
2024-05-29 17:05:55 +08:00
console.log('transformRate', dataList)
return getTemplate(this.period, dataList, this.than);
2024-04-29 16:06:59 +08:00
},
2024-05-29 17:05:55 +08:00
// series() {
// const { transformRate } = this.$store.getters.copilot.efficiency;
// let dataList = null;
// switch (this.period) {
// case "日":
// case "周":
// dataList = transformRate?.current;
// break;
// default:
// dataList = [];
// dataList[0] = transformRate?.previous;
// dataList[1] = transformRate?.current;
// }
// return getTemplate(this.period, dataList);
// },
2024-04-29 16:06:59 +08:00
},
methods: {},
};
2024-05-29 17:05:55 +08:00
function getTemplate(period, dataList,than) {
// console.log('dataList',dataList);
let items = [];
var day1 = new Date();
2024-06-14 10:18:20 +08:00
var day2 = new Date();
day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000)
day2.setTime(day2.getTime() - 48 * 60 * 60 * 1000)
2024-05-29 17:05:55 +08:00
var yesterday = (day1.getMonth() + 1) + "月" + day1.getDate()
2024-06-14 10:18:20 +08:00
var dayBeYes = (day2.getMonth() + 1) + "月" + day2.getDate()
2024-05-29 17:05:55 +08:00
//今天的时间
// 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;
2024-04-29 16:06:59 +08:00
const month = new Date().getMonth() + 1;
2024-05-29 17:05:55 +08:00
const lastMonth = new Date().getMonth() + 1 === 12 ? 1 : new Date().getMonth() + 1 - 1;
const year = new Date().getFullYear();
if (period === '日' && than === '同比') {
items = [
{
2024-06-14 10:18:20 +08:00
name: `${year - 1}${yesterday}`,
2024-05-29 17:05:55 +08:00
data: dataList ? dataList[0] : [],
},
{
2024-06-14 10:18:20 +08:00
name: `${yesterday}`,
2024-05-29 17:05:55 +08:00
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === '日' && than === '环比') {
items = [
{
2024-06-14 10:18:20 +08:00
name: `${dayBeYes}`,
2024-05-29 17:05:55 +08:00
data: dataList ? dataList[0] : [],
},
{
2024-06-14 10:18:20 +08:00
name: `${yesterday}`,
2024-05-29 17:05:55 +08:00
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === '周' && than === '同比') {
items = [
{
2024-06-07 11:13:59 +08:00
name: `${year-1}年本周`,
2024-05-29 17:05:55 +08:00
data: dataList ? dataList[0] : [],
},
{
name: `本周`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === '周' && than === '环比') {
items = [
{
name: `上周`,
data: dataList ? dataList[0] : [],
},
{
name: `本周`,
data: dataList ? dataList[1] : [],
// : Array.from({ length: 7 }, () => Math.floor(Math.random() * 1000)),
},
];
} else if (period === '月' && than === '同比') {
items = [
{
2024-06-07 11:13:59 +08:00
name: `${year-1}${month}`,
2024-05-29 17:05:55 +08:00
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 === '月' && 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
2024-04-29 13:26:38 +08:00
}
</script>
2024-04-29 16:06:59 +08:00
<style scoped lang="scss"></style>