This commit is contained in:
2022-02-28 20:50:55 +00:00
parent fc385a53e7
commit ee635eeb6d
3 changed files with 63 additions and 195 deletions

View File

@@ -19,7 +19,12 @@ export default {
icon: "$ayiListAlt",
type: "GzDashWorkorderUnscheduledOpenList",
singleOnly: false,
settings: {}
settings: {
customTitle: null,
wotags: [],
woitemtags: [],
wostatus: null
}
},
{
roles: [

View File

@@ -2,16 +2,16 @@
<gz-dash
icon="$ayiUser"
:show-context-button="true"
:update-frequency="900000"
:update-frequency="300000"
v-bind="[$props, $attrs]"
@dash-refresh="getDataFromApi()"
@dash-context="showContext()"
v-on="$listeners"
>
<template slot="main">
<div>
<gz-chart-bar :chart-data="chartData" :options="chartOptions" />
</div>
<v-sheet height="400">
{{ obj }}
</v-sheet>
</template>
<template slot="settings">
@@ -30,21 +30,41 @@
</v-card-title>
<v-card-text>
<v-select
v-model="localSettings.timeSpan"
:items="selectLists.dateFilterTokens"
<v-autocomplete
v-model="localSettings.wostatus"
class="mt-5"
:items="selectLists.wostatus"
item-text="name"
item-value="id"
:label="$ay.t('TimeSpan')"
></v-select>
<v-select
v-model="localSettings.interval"
:items="selectLists.units"
item-text="name"
item-value="id"
:label="$ay.t('Interval')"
></v-select>
dense
:label="$ay.t('WorkOrderStatus')"
>
<template v-slot:item="data">
<v-list-item-avatar>
<v-icon :color="data.item.color">$ayiFlag</v-icon>
</v-list-item-avatar>
<v-list-item-content>
<v-list-item-title
><span class="text-subtitle-2">{{ data.item.name }}</span
><v-icon
v-if="data.item.locked"
small
color="disabled"
class="ml-2"
>$ayiLock</v-icon
>
<!-- <v-icon
v-if="data.item.completed"
color="disabled"
class="ml-1"
small
>$ayiCheckCircle</v-icon
> -->
</v-list-item-title>
</v-list-item-content>
<v-list-item-action> </v-list-item-action>
</template>
</v-autocomplete>
<gz-tag-picker
v-model="localSettings.wotags"
@@ -60,13 +80,6 @@
v-model="localSettings.customTitle"
:label="$ay.t('Name')"
></v-text-field>
<v-color-picker
v-model="localSettings.color"
hide-mode-switch
hide-inputs
mode="hexa"
></v-color-picker>
</v-card-text>
<v-divider></v-divider>
@@ -105,50 +118,12 @@ export default {
localSettings: {},
selectLists: {
dateFilterTokens: [],
units: []
},
chartOptions: {
responsive: true,
maintainAspectRatio: false,
scales: {
xAxes: [
{
type: "time",
time: {
unit: "day"
},
gridLines: {
drawOnChartArea: false
}
}
],
yAxes: [
{
gridLines: {
drawOnChartArea: false
},
ticks: {
beginAtZero: true
}
}
]
}
units: [],
wostatus: []
}
};
},
computed: {
chartData() {
return {
datasets: [
{
label: this.$ay.t("WorkOrderItemLaborServiceRateQuantity"),
backgroundColor: this.settings.color ?? "#000000",
data: this.obj
}
]
};
}
},
computed: {},
async created() {
await initWidget(this);
},
@@ -165,9 +140,7 @@ export default {
updateSettings: function() {
//copy settings from local to parent settings, need to do it this way or get error about mutating prop directly which is vexing and has no easy solution seemingly
this.settings.customTitle = this.localSettings.customTitle;
this.settings.timeSpan = this.localSettings.timeSpan;
this.settings.interval = this.localSettings.interval;
this.settings.color = this.localSettings.color;
this.settings.wostatus = this.localSettings.wostatus;
this.settings.wotags = this.localSettings.wotags;
this.settings.woitemtags = this.localSettings.woitemtags;
@@ -182,8 +155,7 @@ export default {
const res = await window.$gz.api.post("kpi", {
KPIName: "WorkOrderItemLaborQuantitySummary",
criteria: {
timeSpan: this.settings.timeSpan,
interval: this.settings.interval,
wostatus: this.settings.wostatus,
wotags: this.settings.wotags,
woitemtags: this.settings.woitemtags
},
@@ -192,13 +164,6 @@ export default {
if (res.error) {
this.errorMessage = res.error;
} else {
this.chartOptions.scales.xAxes[0].time.unit = this.settings.interval;
res.data.forEach(z => {
z.x = new Date(z.x) //convert to locale timezone and output in the closest thing to iso-8601 format
.toLocaleString("sv-SE", {
timeZone: this.timeZoneName
});
});
this.obj = res.data;
}
} catch (error) {
@@ -213,7 +178,8 @@ export default {
//
async function initWidget(vm) {
await fetchTranslatedText();
populateSelectionLists(vm);
await fetchWorkorderStatusList(vm);
//populateSelectionLists(vm);
}
//////////////////////////////////////////////////////////
@@ -222,125 +188,20 @@ async function initWidget(vm) {
//
async function fetchTranslatedText() {
await window.$gz.translation.cacheTranslations([
"Filter",
"GridRowFilterDropDownBlanksItem",
"GridRowFilterDropDownNonBlanksItem",
"GridRowFilterDropDownEquals",
"GridRowFilterDropDownNotEquals",
"GridRowFilterDropDownDoesNotContain",
"GridRowFilterDropDownContains",
"DateRangeYesterday",
"DateRangeToday",
"DateRangeLastWeek",
"DateRangeThisWeek",
"DateRangeNextWeek",
"DateRangeLastMonth",
"DateRangeThisMonth",
"DateRangeNextMonth",
"DateRange14DayWindow",
"DateRangePast",
"DateRangeLastYear",
"DateRangeThisYear",
"DateRangeInTheLastThreeMonths",
"DateRangeInTheLastSixMonths",
"DateRangePastYear",
"DateRangePast90Days",
"DateRangePast30Days",
"DateRangePast7Days",
"DateRangePast24Hours",
"DateRangePast6Hours",
"DateRangeJanuary",
"DateRangeFebruary",
"DateRangeMarch",
"DateRangeApril",
"DateRangeMay",
"DateRangeJune",
"DateRangeJuly",
"DateRangeAugust",
"DateRangeSeptember",
"DateRangeOctober",
"DateRangeNovember",
"DateRangeDecember",
"DateRangePreviousYearThisMonth",
"DateRangePreviousYearLastMonth",
"DateRangePreviousYearNextMonth",
"TimeSpanDays",
"TimeSpanMonths",
"WorkOrderItemLaborServiceRateQuantity",
"Name",
"TimeSpan",
"Interval",
"WorkOrder",
"WorkOrderItem"
"WorkOrderItem",
"WorkOrderStatus"
]);
}
/////////////////////////////////
//
//
function populateSelectionLists(vm) {
vm.selectLists.dateFilterTokens.push(
...[
// { name: vm.$ay.t("DateRangeYesterday"), id: "*yesterday*" },
// { name: vm.$ay.t("DateRangeToday"), id: "*today*" },
{ name: vm.$ay.t("DateRangeThisYear"), id: "*thisyear*" },
{ name: vm.$ay.t("DateRangeThisMonth"), id: "*thismonth*" },
{ name: vm.$ay.t("DateRangeThisWeek"), id: "*thisweek*" },
{ name: vm.$ay.t("DateRangeLastYear"), id: "*lastyear*" }, //prior year from jan to dec
{ name: vm.$ay.t("DateRangeLastMonth"), id: "*lastmonth*" },
{ name: vm.$ay.t("DateRangeLastWeek"), id: "*lastweek*" },
//-------------------------- rando ones -------------------
{ name: vm.$ay.t("DateRange14DayWindow"), id: "*14daywindow*" },
{ name: vm.$ay.t("DateRangePast"), id: "*past*" },
{
name: vm.$ay.t("DateRangeInTheLastThreeMonths"),
id: "*last3months*"
},
{
name: vm.$ay.t("DateRangeInTheLastSixMonths"),
id: "*last6months*"
},
{ name: vm.$ay.t("DateRangePastYear"), id: "*pastyear*" }, //last 365 days
{ name: vm.$ay.t("DateRangePast90Days"), id: "*past90days*" },
{ name: vm.$ay.t("DateRangePast30Days"), id: "*past30days*" },
{ name: vm.$ay.t("DateRangePast7Days"), id: "*past7days*" },
// { name: vm.$ay.t("DateRangePast24Hours"), id: "*past24hours*" },
// { name: vm.$ay.t("DateRangePast6Hours"), id: "*past6hours*" },
{ name: vm.$ay.t("DateRangeJanuary"), id: "*january*" },
{ name: vm.$ay.t("DateRangeFebruary"), id: "*february*" },
{ name: vm.$ay.t("DateRangeMarch"), id: "*march*" },
{ name: vm.$ay.t("DateRangeApril"), id: "*april*" },
{ name: vm.$ay.t("DateRangeMay"), id: "*may*" },
{ name: vm.$ay.t("DateRangeJune"), id: "*june*" },
{ name: vm.$ay.t("DateRangeJuly"), id: "*july*" },
{ name: vm.$ay.t("DateRangeAugust"), id: "*august*" },
{ name: vm.$ay.t("DateRangeSeptember"), id: "*september*" },
{ name: vm.$ay.t("DateRangeOctober"), id: "*october*" },
{ name: vm.$ay.t("DateRangeNovember"), id: "*november*" },
{ name: vm.$ay.t("DateRangeDecember"), id: "*december*" },
{
name: vm.$ay.t("DateRangePreviousYearThisMonth"),
id: "*lastyearthismonth*"
},
{
name: vm.$ay.t("DateRangePreviousYearLastMonth"),
id: "*lastyearlastmonth*"
},
{
name: vm.$ay.t("DateRangePreviousYearNextMonth"),
id: "*lastyearnextmonth*"
}
]
);
vm.selectLists.units.push(
...[
{ name: vm.$ay.t("TimeSpanDays"), id: "day" },
{
name: vm.$ay.t("TimeSpanMonths"),
id: "month"
}
]
);
async function fetchWorkorderStatusList(vm) {
let res = await window.$gz.api.get("work-order-status/list");
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.selectLists.wostatus = res.data.all.filter(z => z.completed == false); //TODO: weed out closed status
}
}
</script>

View File

@@ -91,6 +91,7 @@ import GzDashTodayReminders from "../components/dash-today-reminders.vue";
import GzDashTodayReviews from "../components/dash-today-reviews.vue";
import GzDashLaborHoursPersonalLine from "../components/dash-labor-hours-personal-line.vue";
import GzDashLaborHoursPersonalBar from "../components/dash-labor-hours-personal-bar.vue";
import GzDashWorkorderUnscheduledOpenList from "../components/dash-workorder-unscheduled-open-list.vue";
export default {
components: {
@@ -100,7 +101,8 @@ export default {
GzDashTestLineWidgetMonthlyTotalPrice,
GzDashTodayScheduledWo,
GzDashTodayReminders,
GzDashTodayReviews
GzDashTodayReviews,
GzDashWorkorderUnscheduledOpenList
},
data() {
return {