This commit is contained in:
Henry Jordan
2021-09-25 00:01:50 +00:00
parent 13ee44e596
commit cce2adb3de
4 changed files with 59 additions and 58 deletions

View File

@@ -69,7 +69,6 @@ export default {
results: [], results: [],
allColumns: false, allColumns: false,
localSelected: [], localSelected: [],
selected: [],
}; };
}, },
mounted() { mounted() {
@@ -138,7 +137,7 @@ export default {
res.push(o.key); res.push(o.key);
}); });
} }
this.selected = res; this.localSelected = res;
}, },
/** /**
* Handler when change options event * Handler when change options event

View File

@@ -10,6 +10,7 @@
<modal-new-request ref="newRequest"></modal-new-request> <modal-new-request ref="newRequest"></modal-new-request>
<div class="d-inline-flex p-2"> <div class="d-inline-flex p-2">
<vue-charts <vue-charts
:key="random"
ref="pm-vue-chart" ref="pm-vue-chart"
@onChangeLevel="changeLevel" @onChangeLevel="changeLevel"
:levels="visited" :levels="visited"
@@ -17,7 +18,7 @@
<div class="vp-6"></div> <div class="vp-6"></div>
<drill-down :visited="visited" @onChangeLevel="changeLevel" /> <drill-down :visited="visited" @onChangeLevel="changeLevel" />
</div> </div>
</div> </div>
</template> </template>
<script> <script>
@@ -27,11 +28,12 @@ import DrillDown from "./DrillDown.vue";
import VueCharts from "./VueCharts.vue"; import VueCharts from "./VueCharts.vue";
import defaultMixins from "./defaultMixins"; import defaultMixins from "./defaultMixins";
import _ from "lodash";
export default { export default {
name: "TaskMetrics", name: "TaskMetrics",
mixins: [defaultMixins], mixins: [defaultMixins],
components: { components: {
ButtonFleft, ButtonFleft,
ModalNewRequest, ModalNewRequest,
DrillDown, DrillDown,
VueCharts, VueCharts,
@@ -40,13 +42,17 @@ export default {
data() { data() {
let that = this; let that = this;
return { return {
visited: this.settings && this.settings.visited ? this.settings.visited : [ random: _.random(0, 100000),
{ visited:
level: 0, this.settings && this.settings.visited
active: true, ? this.settings.visited
id: _.random(0,100), : [
} {
] level: 0,
active: true,
id: _.random(0, 100),
},
],
}; };
}, },
created() {}, created() {},
@@ -59,27 +65,28 @@ export default {
* Change level in drill down * Change level in drill down
*/ */
changeLevel(data) { changeLevel(data) {
let item = _.find(this.visited, data); let item = _.findIndex(this.visited, data);
this.visited.forEach(function (elem) { this.visited.forEach(function (elem) {
elem.active = false; elem.active = false;
}); });
if(!item) { data.active = true;
item != -1 ? this.visited.splice(item, 1, data) : null;
if (item == -1) {
data.active = true; data.active = true;
this.visited = _.filter(this.visited, function(o) { this.visited = _.filter(this.visited, function (o) {
return o.level < data.level; return o.level < data.level;
}); });
this.visited.push(data); this.visited.push(data);
} else {
item.active = true;
} }
this.random = _.random(0, 100000);
this.$emit("updateSettings", { this.$emit("updateSettings", {
data: this.visited, data: this.visited,
key: "visited", key: "visited",
page: "task-metrics", page: "task-metrics",
type: "normal", type: "normal",
id: this.id id: this.id,
}); });
}, },
}, },
}; };
</script> </script>

View File

@@ -11,6 +11,7 @@
/> />
<ProcessPopover <ProcessPopover
:options="optionsProcesses" :options="optionsProcesses"
:selected="selectedProcesses"
@onChange="onChangeSearchPopover" @onChange="onChangeSearchPopover"
target="pm-task-process" target="pm-task-process"
ref="pm-task-process" ref="pm-task-process"
@@ -25,7 +26,6 @@
:show-labels="false" :show-labels="false"
track-by="id" track-by="id"
label="name" label="name"
@select="changeOption"
></multiselect> ></multiselect>
</div> </div>
<label class="vp-inline-block vp-padding-l20">{{ <label class="vp-inline-block vp-padding-l20">{{
@@ -124,7 +124,7 @@ export default {
optionsCategory: [], optionsCategory: [],
optionsProcesses: [], optionsProcesses: [],
selectedProcesses: [], selectedProcesses: [],
top: true, top: this.data[2] ? this.data[2].data.top : true,
width: 0, width: 0,
totalCases: [], totalCases: [],
currentSelection: null, currentSelection: null,
@@ -188,7 +188,20 @@ export default {
this.getCategories(); this.getCategories();
this.getProcesses(); this.getProcesses();
}, },
watch: {}, watch: {
category(nvalue, old) {
this.changeOption();
},
optionsCategory(nvalue, old) {
this.category = this.data[2] ? this.data[2].data.category : nvalue[0];
},
optionsProcesses(nvalue, old) {
this.selectedProcesses = this.data[2]
? this.data[2].data.selectedProcesses
: _.flatMap(nvalue, (n) => n.key);
this.changeOption();
},
},
computed: {}, computed: {},
updated() {}, updated() {},
beforeCreate() {}, beforeCreate() {},
@@ -223,10 +236,6 @@ export default {
.processList(query || "") .processList(query || "")
.then((response) => { .then((response) => {
that.formatDataProcesses(response.data); that.formatDataProcesses(response.data);
that.changeOption({
id: "all",
paged: false,
});
}) })
.catch((e) => { .catch((e) => {
console.error(err); console.error(err);
@@ -250,25 +259,19 @@ export default {
array.push({ name: el["CATEGORY_NAME"], id: el["CATEGORY_ID"] }); array.push({ name: el["CATEGORY_NAME"], id: el["CATEGORY_ID"] });
}); });
this.optionsCategory = array; this.optionsCategory = array;
this.category = array[0];
}, },
/** /**
* Format processes for popover * Format processes for popover
* @param {*} data * @param {*} data
*/ */
formatDataProcesses(data) { formatDataProcesses(data) {
let sels = [], let labels = [],
labels = [],
array = []; array = [];
_.each(data, (el) => { _.each(data, (el) => {
array.push({ value: el["PRO_TITLE"], key: el["PRO_ID"] }); array.push({ value: el["PRO_TITLE"], key: el["PRO_ID"] });
sels.push(el["PRO_ID"]);
labels; labels;
}); });
this.optionsProcesses = array; this.optionsProcesses = array;
this.selectedProcesses = sels;
//Update the labels //Update the labels
this.dataProcesses = data; this.dataProcesses = data;
}, },
@@ -276,17 +279,17 @@ export default {
* Change the options in TOTAL CASES BY PROCESS * Change the options in TOTAL CASES BY PROCESS
* @param {*} option * @param {*} option
*/ */
changeOption(option) { changeOption() {
let that = this, let that = this,
dt = {}; dt = {};
if (this.data.length > 1) { if (this.category && this.selectedProcesses.length > 0 && this.data[1]) {
dt = { dt = {
category: option.id, category: this.category.id,
caseList: this.data[1].id.toLowerCase(), caseList: this.data[1].id.toLowerCase(),
processes: this.selectedProcesses, processes: this.selectedProcesses,
top: this.top, top: this.top,
}; };
option.id == "all" ? delete dt.category : null; this.category.id == "all" ? delete dt.category : null;
Api.process Api.process
.totalCasesByProcess(dt) .totalCasesByProcess(dt)
.then((response) => { .then((response) => {
@@ -294,7 +297,7 @@ export default {
that.formatTotalCases(response.data); that.formatTotalCases(response.data);
}) })
.catch((e) => { .catch((e) => {
console.error(err); console.error(e);
}); });
} }
}, },
@@ -330,17 +333,8 @@ export default {
* @param {*} data * @param {*} data
*/ */
onUpdateColumnSettings(data) { onUpdateColumnSettings(data) {
let res;
this.selectedProcesses = data; this.selectedProcesses = data;
res = _.intersectionBy(this.totalCases, data, (el) => { this.changeOption();
if (_.isNumber(el)) {
return el;
}
if (_.isObject(el) && el["PRO_ID"]) {
return el["PRO_ID"];
}
});
this.formatTotalCases(res);
}, },
/** /**
* Update labels in chart * Update labels in chart
@@ -368,9 +362,7 @@ export default {
* Force update view when update level * Force update view when update level
*/ */
forceUpdateView() { forceUpdateView() {
this.changeOption({ this.changeOption();
id: 0,
});
}, },
/** /**
* Event handler change input search popover * Event handler change input search popover
@@ -405,7 +397,11 @@ export default {
id: this.currentSelection["PRO_ID"], id: this.currentSelection["PRO_ID"],
name: this.currentSelection["PRO_TITLE"], name: this.currentSelection["PRO_TITLE"],
level: 2, level: 2,
data: this.currentSelection, data: {
top: this.top,
category: this.category,
selectedProcesses: this.selectedProcesses,
},
}); });
}, },
/** /**
@@ -481,6 +477,5 @@ export default {
.vp-flex1 { .vp-flex1 {
flex: 1; flex: 1;
} }
</style> </style>
<style src="vue-multiselect/dist/vue-multiselect.min.css"></style> <style src="vue-multiselect/dist/vue-multiselect.min.css"></style>

View File

@@ -1,24 +1,24 @@
<template> <template>
<div id="v-pm-charts" ref="v-pm-charts" class="v-pm-charts vp-inline-block"> <div id="v-pm-charts" ref="v-pm-charts" class="v-pm-charts vp-inline-block">
<vue-chart-lv-zero <vue-chart-lv-zero
v-show="level === 0" v-if="level === 0"
@updateDataLevel="updateDataLevel" @updateDataLevel="updateDataLevel"
/> />
<vue-chart-lv-one <vue-chart-lv-one
:key="key1" :key="key1"
v-show="level === 1" v-if="level === 1"
:data="levels" :data="levels"
@updateDataLevel="updateDataLevel" @updateDataLevel="updateDataLevel"
/> />
<vue-chart-lv-two <vue-chart-lv-two
:key="key2" :key="key2"
v-show="level === 2" v-if="level === 2"
:data="levels" :data="levels"
@updateDataLevel="updateDataLevel" @updateDataLevel="updateDataLevel"
/> />
<vue-chart-lv-three <vue-chart-lv-three
:key="key3" :key="key3"
v-show="level === 3" v-if="level === 3"
:data="levels" :data="levels"
/> />
</div> </div>