Extend MachineStatusType and enhance self-serve machine status logic:
- Added `UNKNOWN` and `VALID` statuses to `MachineStatusType` with corresponding icon and style mappings. - Updated `SelfServeMachineRelayControls` to use `UNKNOWN` and `VALID` statuses for machine and customer displays. - Introduced `decimalRound` function for precise rounding in `DepartmentWeather.vue` data rendering. - Applied `decimalRound` to display hours with two decimal precision in department reports.
This commit is contained in:
@@ -220,6 +220,10 @@ const getWeather = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const decimalRound = (value, precision) => {
|
||||
return Number(value.toFixed(precision));
|
||||
};
|
||||
|
||||
watch(
|
||||
() => [props.department_ids, props.date_from, props.date_to],
|
||||
() => {
|
||||
@@ -231,6 +235,7 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -272,7 +277,7 @@ watch(
|
||||
|
||||
<tr>
|
||||
<td class="label">Hours</td>
|
||||
<td v-for="(item, index) in displayedState" :key="`hours-${getEntryKey(item, index)}`">{{ item.hours }}</td>
|
||||
<td v-for="(item, index) in displayedState" :key="`hours-${getEntryKey(item, index)}`">{{ decimalRound(item.hours,2) }}</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
||||
-1
@@ -120,7 +120,6 @@ watch(
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-half">
|
||||
<SelfServeMachineStatus :machineStatus="departmentSelfServeEnabled ? 'ON' : 'OFF'" />
|
||||
<p class="label is-small mt-2">{{ departmentSelfServeStatusLabel }}</p>
|
||||
</div>
|
||||
<div class="column is-half">
|
||||
<b-switch
|
||||
|
||||
+5
-5
@@ -97,7 +97,7 @@ const parseBillableStatus = (inProgressDetails: typeof connectivity.inProgressDe
|
||||
const washStartedAtValue = inProgressDetails.session?.wash_started_at;
|
||||
const washStartedAt = washStartedAtValue ? new Date(String(washStartedAtValue)).getTime() : Number.NaN;
|
||||
if (!Number.isFinite(washStartedAt)) {
|
||||
return MachineStatusType.ON;
|
||||
return MachineStatusType.UNKNOWN;
|
||||
}
|
||||
if (Date.now() - washStartedAt >= includedTimeMs) {
|
||||
return MachineStatusType.BILLABLE;
|
||||
@@ -296,10 +296,10 @@ onUnmounted(() => {
|
||||
<div class="column is-half">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-half">
|
||||
<SelfServeMachineStatus :machine-status="inProgressDetails.customer ? MachineStatusType.ON : MachineStatusType.OFF" />
|
||||
<SelfServeMachineStatus :machine-status="inProgressDetails.customer ? MachineStatusType.VALID : MachineStatusType.UNKNOWN" />
|
||||
</div>
|
||||
<div class="column is-half">
|
||||
<p class="label is-small">Customer: {{ customerDisplay }}</p>
|
||||
<p class="label is-small">{{ customerDisplay }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -319,10 +319,10 @@ onUnmounted(() => {
|
||||
<div class="column is-half">
|
||||
<div class="columns is-mobile">
|
||||
<div class="column is-half">
|
||||
<SelfServeMachineStatus :machine-status="inProgressDetails.vehicle ? MachineStatusType.ON : MachineStatusType.OFF" />
|
||||
<SelfServeMachineStatus :machine-status="inProgressDetails.vehicle ? MachineStatusType.VALID : MachineStatusType.UNKNOWN" />
|
||||
</div>
|
||||
<div class="column is-half">
|
||||
<p class="label is-small">Vehicle: {{ vehicleDisplay }}</p>
|
||||
<p class="label is-small">{{ vehicleDisplay }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+4
@@ -12,6 +12,8 @@ const icon = {
|
||||
OFF: "close",
|
||||
INCLUDED: "clock",
|
||||
BILLABLE: "dollar-sign",
|
||||
UNKNOWN: "question",
|
||||
VALID: "check",
|
||||
}
|
||||
const type = {
|
||||
ONLINE: "is-success",
|
||||
@@ -21,6 +23,8 @@ const type = {
|
||||
OFF: "is-danger",
|
||||
INCLUDED: "is-grey",
|
||||
BILLABLE: "is-success",
|
||||
UNKNOWN: "is-grey",
|
||||
VALID: "is-success",
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
@@ -7,6 +7,8 @@ const MachineStatus = {
|
||||
OFF: "OFF",
|
||||
INCLUDED: "INCLUDED",
|
||||
BILLABLE: "BILLABLE",
|
||||
UNKNOWN: "UNKNOWN",
|
||||
VALID: "VALID",
|
||||
} as const;
|
||||
export type { MachineStatus };
|
||||
export default MachineStatus;
|
||||
|
||||
Reference in New Issue
Block a user