更新产量驾驶舱 #10

Merged
g7hoo merged 8 commits from projects/mescc/lb into projects/mescc/develop 2024-04-28 13:21:02 +08:00
3 changed files with 86 additions and 30 deletions
Showing only changes of commit 622a8b4a31 - Show all commits

View File

@ -12,9 +12,7 @@
<div class="double-ring-chart__legend"> <div class="double-ring-chart__legend">
<div v-for="item in legendItems" :key="item.label" class="legend-item"> <div v-for="item in legendItems" :key="item.label" class="legend-item">
<span class="legend-item__label">{{ item.label }}</span> <span class="legend-item__label">{{ item.label }}</span>
<span class="legend-item__value">{{ <span class="legend-item__value">{{ item.value | numberFilter }}</span>
item.value.toLocaleString()
}}</span>
</div> </div>
</div> </div>
</div> </div>
@ -33,6 +31,10 @@ export default {
type: Number, type: Number,
default: 24, default: 24,
}, },
factoryId: {
type: Number,
required: true,
},
period: { period: {
type: String, type: String,
default: "日", default: "日",
@ -45,26 +47,69 @@ export default {
data() { data() {
return {}; return {};
}, },
computed: { filters: {
legendItems() { numberFilter(val) {
return calculateItems(this.period); if (!isNaN(val)) {
return (+val).toLocaleString();
}
return 0;
}, },
},
computed: {
dataSourceField() {
switch (this.dataSource) {
case "标准组件产出":
return "stdOutput";
case "芯片产出":
return "chipOutput";
case "BIPV产出":
return "bipvOutput";
}
},
valueTuple() {
// [previousValue, currentValue, sumValue?]
const getter = this.$store.getters.copilot.yield[this.dataSourceField];
if (this.period === "日" || this.period === "周") {
return [
getter.previous[this.factoryId],
getter.current[this.factoryId],
];
}
return [
getter.previous[this.factoryId],
getter.current[this.factoryId],
getter.target[this.factoryId],
];
},
options() { options() {
// TODO: const year = new Date().getFullYear();
let titleValue = "10%", const month = new Date().getMonth() + 1;
subtitle = "测试子标题", const vt = this.valueTuple;
previousSum = 10, let titleValue =
currentSum = 0, vt[0] != null && vt[2] != null && vt[2] !== 0
targetSum = 100; ? `${vt[1] / vt[2]}%`
: "0%",
subtitle =
this.period == "月" ? `${month}月累计产出` : `${year}年累计产出`;
return getOptions({ return getOptions({
titleValue, titleValue,
subtitle, subtitle,
previousSum, previousSum: this.valueTuple[0],
currentSum, currentSum: this.valueTuple[1],
targetSum, targetSum: this.valueTuple[2],
}); });
}, },
legendItems() {
return calculateItems(this.period, this.valueTuple);
},
},
watch: {
legendItems() {
this.initOptions(this.options);
},
}, },
mounted() { mounted() {
this.initOptions(this.options); this.initOptions(this.options);
@ -77,7 +122,7 @@ export default {
}, },
}; };
function calculateItems(period) { function calculateItems(period, valueTuple) {
let items = []; let items = [];
const today = new Date().getDate(); const today = new Date().getDate();
const month = new Date().getMonth() + 1; const month = new Date().getMonth() + 1;
@ -85,28 +130,28 @@ function calculateItems(period) {
switch (period) { switch (period) {
case "日": case "日":
items = [ items = [
{ label: `${month}${today}日累计`, value: 24 }, { label: `${month}${today}日累计`, value: valueTuple[1] },
{ label: `去年${month}${today}日累计`, value: 33 }, { label: `去年${month}${today}日累计`, value: valueTuple[0] },
]; ];
break; break;
case "周": case "周":
items = [ items = [
{ label: `本周累计`, value: 32 }, { label: `本周累计`, value: valueTuple[1] },
{ label: `去年本周累计`, value: 12 }, { label: `去年本周累计`, value: valueTuple[0] },
]; ];
break; break;
case "月": case "月":
items = [ items = [
{ label: `${month}月累计`, value: 24 }, { label: `${month}月累计`, value: valueTuple[1] },
{ label: `去年${month}月累计`, value: 33 }, { label: `去年${month}月累计`, value: valueTuple[0] },
{ label: `${month}月目标`, value: 12334 }, { label: `${month}月目标`, value: valueTuple[2] },
]; ];
break; break;
case "年": case "年":
items = [ items = [
{ label: `${year - 1}年累计`, value: 23234 }, { label: `${year}年累计`, value: valueTuple[1] },
{ label: `${year}年累计`, value: 4324 }, { label: `${year - 1}年累计`, value: valueTuple[0] },
{ label: `${year}年目标`, value: 12334 }, { label: `${year}年目标`, value: valueTuple[2] },
]; ];
break; break;
} }

View File

@ -13,7 +13,11 @@
:options="cityOptions" :options="cityOptions"
/> />
<div class="flex-1 stretch"> <div class="flex-1 stretch">
<DoubleRingChartVue :data-source="dataSource" :period="period" /> <DoubleRingChartVue
:data-source="dataSource"
:period="period"
:factoryId="factoryId"
/>
</div> </div>
</template> </template>
<template v-else> <template v-else>
@ -42,6 +46,7 @@ export default {
}, },
data() { data() {
return { return {
factoryId: 4, //
cityOptions: [ cityOptions: [
"成都", "成都",
"邯郸", "邯郸",
@ -55,7 +60,7 @@ export default {
}, },
methods: { methods: {
handleActiveUpdate(index) { handleActiveUpdate(index) {
console.log("handleActiveUpdate--->", index); this.factoryId = index;
}, },
}, },
}; };

View File

@ -81,11 +81,12 @@ export default ({
value: value:
targetSum > currentSum targetSum > currentSum
? targetSum - currentSum ? targetSum - currentSum
: targetSum == currentSum : targetSum == 0
? currentSum == 0 ? currentSum == 0
? 1 ? 1
: 0 : 0
: 0, : 0,
name: "未达成累计", name: "未达成累计",
itemStyle: { color: "transparent" }, itemStyle: { color: "transparent" },
label: { show: false }, label: { show: false },
@ -128,7 +129,12 @@ export default ({
}, },
}, },
{ {
value: targetSum > previousSum ? targetSum - previousSum : 0, value:
targetSum > previousSum
? targetSum - previousSum
: previousSum == 0
? 1
: 0,
name: "-", name: "-",
itemStyle: { color: "transparent" }, itemStyle: { color: "transparent" },
label: { show: false }, label: { show: false },