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

136 lines
2.7 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">
<vue-chart-lv-zero
v-show="level === 0"
@updateDataLevel="updateDataLevel"
2021-08-16 18:54:43 +00:00
:breadCrumbs="dataBreadCrumbs()"
2021-08-12 19:05:50 +00:00
/>
<vue-chart-lv-one
2021-08-16 18:54:43 +00:00
:key="key1"
v-show="level === 1"
2021-08-12 19:05:50 +00:00
:data="data"
@onChangeLevel="onChangeLevel"
@updateDataLevel="updateDataLevel"
2021-08-16 18:54:43 +00:00
:breadCrumbs="dataBreadCrumbs()"
2021-08-12 19:05:50 +00:00
/>
<vue-chart-lv-two
2021-08-16 18:54:43 +00:00
v-show="level === 2"
2021-08-12 19:05:50 +00:00
:data="data"
@onChangeLevel="onChangeLevel"
2021-08-16 18:54:43 +00:00
:breadCrumbs="dataBreadCrumbs()"
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-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-07-30 20:18:11 +00:00
},
props: [],
data() {
let that = this;
return {
2021-08-12 19:05:50 +00:00
level: 0,
2021-08-16 18:54:43 +00:00
key1: 1,
2021-08-12 19:05:50 +00:00
data: [],
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: {},
updated() {},
beforeCreate() {},
2021-08-12 19:05:50 +00:00
methods: {
/**
* Set data level 0
*/
updateDataLevel(data) {
this.data.push(data);
this.level = data.level + 1;
2021-08-16 18:54:43 +00:00
this.$emit("onChangeLevel", data.level + 1);
this.updateKey();
},
updateKey() {
switch (this.level) {
case 0:
break;
case 1:
this.key1++;
break;
case 2:
break;
case 3:
break;
}
2021-08-12 19:05:50 +00:00
},
/**
* Format data to vue charts any level
*/
formatData() {
return {
level: this.level,
data: this.data,
};
},
onChangeLevel(lv) {
2021-08-16 18:54:43 +00:00
_.remove(this.data, function (n) {
return n.level >= lv;
});
2021-08-12 19:05:50 +00:00
this.level = lv;
this.$emit("onChangeLevel", this.level);
},
2021-08-16 18:54:43 +00:00
dataBreadCrumbs() {
let res = [],
that = this,
index = 0;
_.each(this.data, (el) => {
if (index <= that.level) {
res.push({
label: el.name,
onClick() {
that.onChangeLevel(el.level);
},
});
}
});
res.push({
label: "Select the drill option",
onClick() {},
});
switch (this.level) {
case 0:
return {
data: res,
settings: this.settingsBreadCrumbs,
};
break;
default:
return {
data: res,
settings: this.settingsBreadCrumbs,
};
break;
}
},
2021-08-12 19:05:50 +00:00
},
2021-07-30 20:18:11 +00:00
};
</script>
<style>
</style>