产量和效率
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
<!--
|
||||
filename: DoubleRingChart.vue
|
||||
author: liubin
|
||||
date: 2024-04-17 11:01:55
|
||||
description:
|
||||
* @Author: zhp
|
||||
* @Date: 2024-05-20 13:32:59
|
||||
* @LastEditTime: 2024-05-29 09:31:49
|
||||
* @LastEditors: zhp
|
||||
* @Description:
|
||||
-->
|
||||
|
||||
<template>
|
||||
@@ -45,6 +46,10 @@ export default {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
than: {
|
||||
type: String,
|
||||
default: "同比",
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -89,27 +94,83 @@ export default {
|
||||
},
|
||||
|
||||
options() {
|
||||
const today = new Date().getDate();
|
||||
const year = new Date().getFullYear();
|
||||
const month = new Date().getMonth() + 1;
|
||||
const vt = this.valueTuple;
|
||||
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 === '日' && this.than === '同比') {
|
||||
items = [
|
||||
{ label: `${month}月${today}日累计`,},
|
||||
{ label: `去年${month}月${today}日累计` },
|
||||
];
|
||||
} else if (this.period === '日' && this.than === '环比') {
|
||||
items = [
|
||||
{ label: `${month}月${today}日累计`},
|
||||
{ label: `${yesterday}日累计`},
|
||||
];
|
||||
} else if (this.period === '周' && this.than === '同比') {
|
||||
items = [
|
||||
{ label: `本周累计`,},
|
||||
{ label: `去年本周累计`},
|
||||
];
|
||||
} else if (this.period === '周' && this.than === '环比') {
|
||||
items = [
|
||||
{ label: `本周累计`,},
|
||||
{ label: `上周累计`,},
|
||||
];
|
||||
} else if (this.period === '月' && this.than === '同比') {
|
||||
items = [
|
||||
{ label: `${month}月累计`,},
|
||||
{ label: `去年${month}月累计`, },
|
||||
{ label: `${month}月目标`,},
|
||||
];
|
||||
} else if (this.period === '月' && this.than === '环比') {
|
||||
items = [
|
||||
{ label: `${month}月累计`, },
|
||||
{ label: `${lastMonth}月累计`,},
|
||||
{ label: `${month}月目标`, },
|
||||
];
|
||||
} else {
|
||||
items = [
|
||||
{ label: `${year}年累计`, },
|
||||
{ label: `${year - 1}年累计` },
|
||||
{ label: `${year}年目标` },
|
||||
];
|
||||
}
|
||||
let titleValue =
|
||||
vt[0] != null && vt[2] != null && vt[2] !== 0
|
||||
? `${vt[1] / vt[2]}%`
|
||||
: "0%",
|
||||
subtitle =
|
||||
this.period == "月" ? `${month}月累计产出` : `${year}年累计产出`;
|
||||
|
||||
this.period == "日" ? `${month}月${today}日累计` : this.period == "周" ? `本周` : this.period == "月" ? `${month}月累计产出` : `${year}年累计产出`;
|
||||
console.log(this.valueTuple[0], this.valueTuple[1], this.valueTuple[2],)
|
||||
console.log(items)
|
||||
return getOptions({
|
||||
titleValue,
|
||||
subtitle,
|
||||
currentName: items[0].label,
|
||||
preName: items[1].label,
|
||||
previousSum: this.valueTuple[0],
|
||||
currentSum: this.valueTuple[1],
|
||||
targetSum: this.valueTuple[2],
|
||||
targetSum: this.valueTuple[2] ? this.valueTuple[2] :0 ,
|
||||
});
|
||||
},
|
||||
|
||||
legendItems() {
|
||||
return calculateItems(this.period, this.valueTuple);
|
||||
return calculateItems(this.period, this.valueTuple,this.than);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
@@ -142,39 +203,68 @@ export default {
|
||||
},
|
||||
};
|
||||
|
||||
function calculateItems(period, valueTuple) {
|
||||
function calculateItems(period, valueTuple,than) {
|
||||
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();
|
||||
switch (period) {
|
||||
case "日":
|
||||
items = [
|
||||
{ label: `${month}月${today}日累计`, value: valueTuple[1] },
|
||||
{ label: `去年${month}月${today}日累计`, value: valueTuple[0] },
|
||||
];
|
||||
break;
|
||||
case "周":
|
||||
items = [
|
||||
{ label: `本周累计`, value: valueTuple[1] },
|
||||
{ label: `去年本周累计`, value: valueTuple[0] },
|
||||
];
|
||||
break;
|
||||
case "月":
|
||||
items = [
|
||||
{ label: `${month}月累计`, value: valueTuple[1] },
|
||||
{ label: `去年${month}月累计`, value: valueTuple[0] },
|
||||
{ label: `${month}月目标`, value: valueTuple[2] },
|
||||
];
|
||||
break;
|
||||
case "年":
|
||||
items = [
|
||||
{ label: `${year}年累计`, value: valueTuple[1] },
|
||||
{ label: `${year - 1}年累计`, value: valueTuple[0] },
|
||||
{ label: `${year}年目标`, value: valueTuple[2] },
|
||||
];
|
||||
break;
|
||||
if (period === '日' && than === '同比') {
|
||||
items = [
|
||||
{ label: `${month}月${today}日累计`, value: valueTuple[1] },
|
||||
{ label: `去年${month}月${today}日累计`, value: valueTuple[0] },
|
||||
];
|
||||
} else if (period === '日' && than === '环比') {
|
||||
items = [
|
||||
{ label: `${month}月${today}日累计`, value: valueTuple[1] },
|
||||
{ label: `${yesterday}日累计`, value: valueTuple[0] },
|
||||
];
|
||||
} else if (period === '周' && than === '同比') {
|
||||
items = [
|
||||
{ label: `本周累计`, value: valueTuple[1] },
|
||||
{ label: `去年本周累计`, value: valueTuple[0] },
|
||||
];
|
||||
} else if (period === '周' && than === '环比') {
|
||||
items = [
|
||||
{ label: `本周累计`, value: valueTuple[1] },
|
||||
{ label: `上周累计`, value: valueTuple[0] },
|
||||
];
|
||||
} else if (period === '月' && than === '同比') {
|
||||
items = [
|
||||
{ label: `${month}月累计`, value: valueTuple[1] },
|
||||
{ label: `去年${month}月累计`, value: valueTuple[0] },
|
||||
{ label: `${month}月目标`, value: valueTuple[2] },
|
||||
];
|
||||
} else if (period === '月' && than === '环比') {
|
||||
items = [
|
||||
{ label: `${month}月累计`, value: valueTuple[1] },
|
||||
{ label: `${lastMonth}月累计`, value: valueTuple[0] },
|
||||
{ label: `${month}月目标`, value: valueTuple[2] },
|
||||
];
|
||||
} else {
|
||||
items = [
|
||||
{ label: `${year}年累计`, value: valueTuple[1] },
|
||||
{ label: `${year - 1}年累计`, value: valueTuple[0] },
|
||||
{ label: `${year}年目标`, value: valueTuple[2] },
|
||||
];
|
||||
}
|
||||
// switch (period) {
|
||||
// case "年":
|
||||
// items = [
|
||||
// { label: `${year}年累计`, value: valueTuple[1] },
|
||||
// { label: `${year - 1}年累计`, value: valueTuple[0] },
|
||||
// { label: `${year}年目标`, value: valueTuple[2] },
|
||||
// ];
|
||||
// break;
|
||||
// }
|
||||
return items;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -7,22 +7,12 @@
|
||||
|
||||
<template>
|
||||
<div class="double-ring-wrapper">
|
||||
<template v-if="period == '月' || period == '年'">
|
||||
<copilot-select
|
||||
@update:active="handleActiveUpdate"
|
||||
:options="cityOptions"
|
||||
/>
|
||||
<template>
|
||||
<copilot-select @update:active="handleActiveUpdate" :options="cityOptions" />
|
||||
<div class="flex-1 stretch">
|
||||
<DoubleRingChartVue
|
||||
:data-source="dataSource"
|
||||
:period="period"
|
||||
:factoryId="factoryId"
|
||||
/>
|
||||
<DoubleRingChartVue :data-source="dataSource" :period="period" :than="than" :factoryId="factoryId" />
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<CityData :data-source="dataSource" :period="period" />
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -43,6 +33,10 @@ export default {
|
||||
type: String,
|
||||
default: "日",
|
||||
},
|
||||
than: {
|
||||
type: String,
|
||||
default: "同比",
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
<!--
|
||||
* @Author: zhp
|
||||
* @Date: 2024-05-24 15:15:00
|
||||
* @LastEditTime: 2024-05-28 08:42:36
|
||||
* @LastEditors: zhp
|
||||
* @Description:
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="double-ring-wrapper">
|
||||
<template >
|
||||
<copilot-select
|
||||
@update:active="handleActiveUpdate"
|
||||
:options="cityOptions"
|
||||
/>
|
||||
<div class="flex-1 stretch">
|
||||
<DoubleRingChartVue
|
||||
:data-source="dataSource"
|
||||
:than="than"
|
||||
:period="period"
|
||||
:factoryId="factoryId"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<!-- <template v-else>
|
||||
<CityData :data-source="dataSource" :period="period" />
|
||||
</template> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CopilotSelect from "@/views/copilot/components/select.vue";
|
||||
import DoubleRingChartVue from "./DoubleRingChart.vue";
|
||||
import CityData from "../city/CityData.vue";
|
||||
|
||||
export default {
|
||||
name: "DoubleRingWrapper",
|
||||
components: { CopilotSelect, DoubleRingChartVue, CityData },
|
||||
props: {
|
||||
dataSource: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
period: {
|
||||
type: String,
|
||||
default: "日",
|
||||
},
|
||||
than: {
|
||||
type: String,
|
||||
default: "同比",
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
factoryId: 4, // 默认成都
|
||||
cityOptions: [
|
||||
"成都",
|
||||
"邯郸",
|
||||
"株洲",
|
||||
"佳木斯",
|
||||
"凯盛光伏",
|
||||
"蚌埠兴科",
|
||||
],
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
handleActiveUpdate(index) {
|
||||
this.factoryId = index;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.double-ring-wrapper {
|
||||
height: 100%;
|
||||
padding: 12px 24px;
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.stretch {
|
||||
align-self: stretch;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user