Files
luos/resources/assets/js/home/TaskMetrics/VueCharts.vue

126 lines
2.6 KiB
Vue
Raw Normal View History

2021-07-30 20:18:11 +00:00
<template>
2021-08-12 19:05:50 +00:00
<div id="v-pm-charts" ref="v-pm-charts" class="v-pm-charts vp-inline-block">
2021-09-27 22:05:05 +00:00
<vue-chart-lv-zero v-if="level === 0" @updateDataLevel="updateDataLevel" />
2021-08-12 19:05:50 +00:00
<vue-chart-lv-one
2021-08-16 18:54:43 +00:00
:key="key1"
2021-09-25 00:01:50 +00:00
v-if="level === 1"
:data="levels"
2021-08-12 19:05:50 +00:00
@updateDataLevel="updateDataLevel"
/>
<vue-chart-lv-two
2021-08-26 20:33:59 +00:00
:key="key2"
2021-09-25 00:01:50 +00:00
v-if="level === 2"
:data="levels"
2021-08-17 18:46:57 +00:00
@updateDataLevel="updateDataLevel"
/>
<vue-chart-lv-three
2021-08-26 20:33:59 +00:00
:key="key3"
v-if="level === 3"
:data="levels"
2021-09-27 22:05:05 +00:00
@updateDataLevel="updateDataLevel"
2021-08-12 19:05:50 +00:00
/>
2021-07-30 20:18:11 +00:00
</div>
</template>
<script>
2021-08-04 16:25:56 +00:00
import VueChartLvZero from "./VueChartLvZero.vue";
2021-07-30 20:18:11 +00:00
import VueChartLvOne from "./VueChartLvOne.vue";
2021-08-12 19:05:50 +00:00
import VueChartLvTwo from "./VueChartLvTwo.vue";
2021-08-17 18:46:57 +00:00
import VueChartLvThree from "./VueChartLvThree.vue";
2021-09-14 13:54:19 +00:00
import _ from "lodash";
2021-07-30 20:18:11 +00:00
export default {
name: "VueCharts",
mixins: [],
components: {
2021-08-04 16:25:56 +00:00
VueChartLvZero,
2021-07-30 20:18:11 +00:00
VueChartLvOne,
2021-08-12 19:05:50 +00:00
VueChartLvTwo,
2021-08-17 18:46:57 +00:00
VueChartLvThree,
2021-07-30 20:18:11 +00:00
},
2021-09-27 22:05:05 +00:00
props: ["levels"],
2021-07-30 20:18:11 +00:00
data() {
2021-09-27 22:05:05 +00:00
let that = this;
2021-07-30 20:18:11 +00:00
return {
2021-09-27 22:05:05 +00:00
key1: _.random(0, 100),
key2: _.random(0, 100),
key3: _.random(0, 100),
2021-08-16 18:54:43 +00:00
settingsBreadCrumbs: [
{
class: "fas fa-info-circle",
onClick() {},
},
],
2021-07-30 20:18:11 +00:00
};
},
created() {},
mounted() {},
watch: {},
computed: {
2021-09-27 22:05:05 +00:00
level: function () {
return _.find(this.levels, { active: true }).level;
},
},
2021-07-30 20:18:11 +00:00
updated() {},
beforeCreate() {},
2021-08-12 19:05:50 +00:00
methods: {
/**
* Set data level 0
*/
updateDataLevel(data) {
this.$emit("onChangeLevel", data);
this.updateKey(data.level);
2021-08-16 18:54:43 +00:00
},
updateKey(level) {
switch (level) {
2021-08-16 18:54:43 +00:00
case 0:
break;
case 1:
this.key1++;
break;
case 2:
2021-08-26 20:33:59 +00:00
this.key2++;
2021-08-16 18:54:43 +00:00
break;
case 3:
2021-08-26 20:33:59 +00:00
this.key3++;
2021-08-16 18:54:43 +00:00
break;
}
2021-08-12 19:05:50 +00:00
},
2021-08-26 21:10:56 +00:00
/**
* Format data for data beadcrumbs
*/
2021-08-16 18:54:43 +00:00
dataBreadCrumbs() {
let res = [],
that = this,
index = 0;
_.each(this.levels, (el) => {
2021-08-26 21:10:56 +00:00
if (index <= that.level && el.data) {
2021-08-16 18:54:43 +00:00
res.push({
label: el.name,
onClick() {
2021-09-27 22:05:05 +00:00
this.$emit("onChangeLevel", el);
2021-08-16 18:54:43 +00:00
},
2021-09-24 14:09:20 +00:00
data: el,
2021-08-16 18:54:43 +00:00
});
}
});
switch (this.level) {
case 0:
return {
data: res,
settings: this.settingsBreadCrumbs,
};
break;
default:
return {
data: res,
settings: this.settingsBreadCrumbs,
};
break;
}
2021-09-27 22:05:05 +00:00
},
2021-08-12 19:05:50 +00:00
},
2021-07-30 20:18:11 +00:00
};
</script>
<style>
</style>