@7365admin1/layer-common 4.97.1-staging.517 → 4.97.1-staging.519

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/assets/css/screens.css +11 -0
  3. package/components/Nfc/NFCPatrolReportMain.vue +61 -72
  4. package/components/Nfc/NFCPatrolRouteMain.vue +21 -31
  5. package/components/Nfc/NFCRouteScheduleTimes.vue +83 -0
  6. package/components/Nfc/PatrolReport/DailyReportTab.vue +24 -3
  7. package/components/Nfc/PatrolReport/MonthlyReportTab.vue +32 -3
  8. package/components/Nfc/PatrolReport/MonthlyReportTable.vue +29 -1
  9. package/components/Nfc/PatrolReport/PatrolActivityTable.vue +24 -2
  10. package/components/Nfc/PatrolReport/PatrolMonthDialog.vue +195 -0
  11. package/components/Nfc/PatrolReport/PatrolReportTab.vue +11 -2
  12. package/components/Nfc/PatrolReport/PatrolRouteDetailsDialog.vue +214 -0
  13. package/components/Nfc/PatrolReport/ReportLocationHeader.vue +4 -1
  14. package/components/Nfc/PatrolReport/SkipPhotoDetails.vue +137 -0
  15. package/components/Nfc/PatrolReport/SkipPhotoThumb.vue +132 -0
  16. package/components/Nfc/PatrolReport/SummaryReportTable.vue +42 -1
  17. package/composables/useCommonPermission.ts +10 -0
  18. package/composables/useNFCPatrolDailyReport.ts +4 -18
  19. package/composables/useNFCPatrolMonthlyReport.ts +34 -5
  20. package/composables/useReportPdf.ts +220 -0
  21. package/composables/useSecurityPermission.ts +38 -0
  22. package/composables/useSettingsPermission.ts +16 -1
  23. package/constants/permissions.ts +3 -0
  24. package/package.json +1 -1
  25. package/types/nfc-patrol-report.ts +14 -0
  26. package/utils/nfc-patrol-report.ts +239 -1
  27. package/utils/nfc-patrol-schedule.ts +73 -0
  28. package/utils/report-export.ts +120 -0
@@ -0,0 +1,195 @@
1
+ <!--
2
+ Every patrol run of one month of the yearly report, opened from its month's
3
+ row: by day, then by scheduled start. A run opens the same Patrol Route
4
+ Details dialog as the daily summary - checkpoints, remarks, skip photos.
5
+
6
+ The month's totals sit in the title row so the list can be checked against
7
+ the yearly table it came from.
8
+
9
+ Ten runs a page, paged the way the app's tables are ("1-10 of 124" and the
10
+ two arrows). The month is already loaded, so paging asks the server nothing.
11
+ -->
12
+ <template>
13
+ <v-dialog
14
+ :model-value="modelValue"
15
+ max-width="960"
16
+ @update:model-value="emit('update:modelValue', $event)"
17
+ >
18
+ <v-card class="screen-modal">
19
+ <div class="month-dialog__head">
20
+ <div>
21
+ <v-card-title class="pa-0">{{ title }}</v-card-title>
22
+ <p class="month-dialog__sub">
23
+ {{ routeName }} · {{ rows.length }} {{ rows.length === 1 ? "patrol" : "patrols" }} ·
24
+ {{ checked }} checked · {{ missed }} missed
25
+ </p>
26
+ </div>
27
+ <v-btn
28
+ class="screen-modal__close"
29
+ icon="mdi-close"
30
+ variant="flat"
31
+ aria-label="Close"
32
+ @click="close"
33
+ />
34
+ </div>
35
+
36
+ <div class="screen-modal__body px-6 pb-6">
37
+ <div class="table-card table-card__shrink">
38
+ <div class="month-dialog__pager">
39
+ <span class="table-card__range">{{ pageRange }}</span>
40
+ <v-btn
41
+ icon="mdi-chevron-left"
42
+ variant="text"
43
+ density="comfortable"
44
+ aria-label="Previous page"
45
+ :disabled="page <= 1"
46
+ @click="page--"
47
+ />
48
+ <v-btn
49
+ icon="mdi-chevron-right"
50
+ variant="text"
51
+ density="comfortable"
52
+ aria-label="Next page"
53
+ :disabled="page >= pages"
54
+ @click="page++"
55
+ />
56
+ </div>
57
+ <v-table>
58
+ <thead>
59
+ <tr>
60
+ <th>Date</th>
61
+ <th>Security Check Schedule</th>
62
+ <th>Security Personnel</th>
63
+ <th>Checked</th>
64
+ <th>Missed</th>
65
+ <th>Status</th>
66
+ </tr>
67
+ </thead>
68
+ <tbody>
69
+ <tr
70
+ v-for="row in pageRows"
71
+ :key="row.id"
72
+ class="month-dialog__row"
73
+ tabindex="0"
74
+ title="View patrol route details"
75
+ @click="open(row)"
76
+ @keydown.enter="open(row)"
77
+ >
78
+ <td class="text-no-wrap">{{ formatReportDate(row.date ?? "") }}</td>
79
+ <td>
80
+ <v-icon size="small" class="mr-1">mdi-clock-outline</v-icon>
81
+ {{ row.securityCheckSchedule }}
82
+ </td>
83
+ <td>{{ row.guardName || "-" }}</td>
84
+ <td>{{ row.checked }}</td>
85
+ <td>{{ row.missed }}</td>
86
+ <td>
87
+ <span :class="row.status === 'Completed' ? 'text-success' : 'text-error'">
88
+ {{ row.status }}
89
+ </span>
90
+ </td>
91
+ </tr>
92
+ </tbody>
93
+ </v-table>
94
+ </div>
95
+ </div>
96
+
97
+ <div class="screen-modal__footer">
98
+ <v-btn variant="outlined" class="screen-btn-ghost" @click="close">Close</v-btn>
99
+ </div>
100
+
101
+ <PatrolRouteDetailsDialog v-model="detailsOpen" :row="selected" />
102
+ </v-card>
103
+ </v-dialog>
104
+ </template>
105
+
106
+ <script setup lang="ts">
107
+ import type { NFCPatrolReportSummaryRow } from "../../../types/nfc-patrol-report";
108
+ import { formatReportDate } from "../../../utils/report-export";
109
+ import PatrolRouteDetailsDialog from "./PatrolRouteDetailsDialog.vue";
110
+
111
+ const props = defineProps<{
112
+ modelValue: boolean;
113
+ /** "October 2026" */
114
+ title: string;
115
+ routeName: string;
116
+ rows: NFCPatrolReportSummaryRow[];
117
+ }>();
118
+
119
+ const emit = defineEmits<{
120
+ "update:modelValue": [value: boolean];
121
+ }>();
122
+
123
+ const PAGE_SIZE = 10;
124
+ const page = ref(1);
125
+ const pages = computed(() => Math.max(1, Math.ceil(props.rows.length / PAGE_SIZE)));
126
+ const pageRows = computed(() => props.rows.slice((page.value - 1) * PAGE_SIZE, page.value * PAGE_SIZE));
127
+ const pageRange = computed(() => {
128
+ const total = props.rows.length;
129
+ if (!total) return "0 of 0";
130
+ const from = (page.value - 1) * PAGE_SIZE + 1;
131
+ return `${from}-${Math.min(total, page.value * PAGE_SIZE)} of ${total}`;
132
+ });
133
+
134
+ // Another month opens on its first page.
135
+ watch(
136
+ () => props.rows,
137
+ () => {
138
+ page.value = 1;
139
+ },
140
+ );
141
+
142
+ const checked = computed(() => props.rows.reduce((sum, row) => sum + row.checked, 0));
143
+ const missed = computed(() => props.rows.reduce((sum, row) => sum + row.missed, 0));
144
+
145
+ const detailsOpen = ref(false);
146
+ const selected = ref<NFCPatrolReportSummaryRow | null>(null);
147
+
148
+ function open(row: NFCPatrolReportSummaryRow) {
149
+ selected.value = row;
150
+ detailsOpen.value = true;
151
+ }
152
+
153
+ function close() {
154
+ detailsOpen.value = false;
155
+ emit("update:modelValue", false);
156
+ }
157
+ </script>
158
+
159
+ <style scoped>
160
+ .month-dialog__head {
161
+ display: flex;
162
+ align-items: flex-start;
163
+ justify-content: space-between;
164
+ gap: 12px;
165
+ padding: 20px 24px;
166
+ }
167
+
168
+ .month-dialog__sub {
169
+ margin: 4px 0 0;
170
+ font-size: var(--fs-cell);
171
+ color: var(--text2);
172
+ }
173
+
174
+ .month-dialog__pager {
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: flex-end;
178
+ gap: 2px;
179
+ padding: 6px 12px;
180
+ border-bottom: 1px solid var(--border);
181
+ }
182
+
183
+ .month-dialog__pager .table-card__range {
184
+ margin-right: 6px;
185
+ }
186
+
187
+ .month-dialog__row {
188
+ cursor: pointer;
189
+ }
190
+
191
+ .month-dialog__row:focus-visible {
192
+ outline: 2px solid var(--accent);
193
+ outline-offset: -2px;
194
+ }
195
+ </style>
@@ -4,7 +4,7 @@
4
4
  :model-value="filters"
5
5
  :options="options"
6
6
  @update:model-value="$emit('update:filters', $event)"
7
- @export="(type) => $emit('export', type)"
7
+ @export="(type) => $emit('export', type, csvSections())"
8
8
  />
9
9
  <div class="report-export">
10
10
  <v-divider :thickness="1" class="border-opacity-100" />
@@ -47,6 +47,8 @@ import type {
47
47
  NFCPatrolReportFilters,
48
48
  } from "../../../types/nfc-patrol-report";
49
49
  import { useNFCPatrolReport } from "../../../composables/useNFCPatrolReport";
50
+ import { patrolReportCsv } from "../../../utils/nfc-patrol-report";
51
+ import type { CsvSection } from "../../../utils/report-export";
50
52
  import PatrolActivityTable from "./PatrolActivityTable.vue";
51
53
  import PatrolRouteSummary from "./PatrolRouteSummary.vue";
52
54
  import RemarksDialog from "./RemarksDialog.vue";
@@ -63,7 +65,8 @@ const props = defineProps<{
63
65
 
64
66
  defineEmits<{
65
67
  "update:filters": [value: NFCPatrolReportFilters];
66
- export: [type: "pdf" | "csv"];
68
+ /** `csv` is the report's tables, built from its data rather than read off the screen. */
69
+ export: [type: "pdf" | "csv", csv: CsvSection[]];
67
70
  }>();
68
71
 
69
72
  const {
@@ -77,6 +80,12 @@ const {
77
80
  openRemarksDialog,
78
81
  } = useNFCPatrolReport(props.filters, props.site);
79
82
 
83
+ const { getFileUrl } = useFile();
84
+
85
+ function csvSections() {
86
+ return report.value ? patrolReportCsv(report.value, getFileUrl) : [];
87
+ }
88
+
80
89
  watch(
81
90
  () => [props.filters.route, props.filters.timeRange, props.filters.date, props.active],
82
91
  () => {
@@ -0,0 +1,214 @@
1
+ <!--
2
+ One run of a patrol route, opened from a row of the daily Patrol Route
3
+ Summary: who patrolled it, schedule against actual, and every checkpoint.
4
+
5
+ A skipped checkpoint shows the guard's remarks and, when one was attached,
6
+ the photo taken at the skip (`SkipPhotoThumb`), which opens full size.
7
+
8
+ Status colours follow `PatrolActivityTable`: `success`/`error` are the
9
+ design's `--ok`/`--err` by way of `utils/theme.ts`. A checkpoint still
10
+ `Pending` (a run not finished) stays neutral rather than red.
11
+ -->
12
+ <template>
13
+ <v-dialog
14
+ :model-value="modelValue"
15
+ max-width="960"
16
+ @update:model-value="emit('update:modelValue', $event)"
17
+ >
18
+ <v-card v-if="row?.detail" class="screen-modal">
19
+ <div class="route-details__head">
20
+ <div>
21
+ <v-card-title class="pa-0">Patrol Route Details</v-card-title>
22
+ <p class="route-details__sub">
23
+ {{ row.detail.routeSummary.routeName || "-" }} ·
24
+ <template v-if="row.date">{{ formatReportDate(row.date) }} · </template>
25
+ {{ row.detail.routeSummary.schedule.start }} - {{ row.detail.routeSummary.schedule.end }}
26
+ </p>
27
+ </div>
28
+ <v-btn
29
+ class="screen-modal__close"
30
+ icon="mdi-close"
31
+ variant="flat"
32
+ aria-label="Close"
33
+ @click="close"
34
+ />
35
+ </div>
36
+
37
+ <div class="screen-modal__body px-6 pb-6">
38
+ <dl class="route-details__facts">
39
+ <div>
40
+ <dt>Security Personnel</dt>
41
+ <dd>{{ row.guardName || "-" }}</dd>
42
+ </div>
43
+ <div>
44
+ <dt>Signature</dt>
45
+ <dd>
46
+ <v-img
47
+ v-if="row.guardSignatureFileId"
48
+ :src="getFileUrl(row.guardSignatureFileId)"
49
+ :alt="`${row.guardName || worker.one} signature`"
50
+ class="route-details__signature"
51
+ contain
52
+ />
53
+ <span v-else>-</span>
54
+ </dd>
55
+ </div>
56
+ <div>
57
+ <dt>Checked</dt>
58
+ <dd>{{ row.checked }}</dd>
59
+ </div>
60
+ <div>
61
+ <dt>Missed</dt>
62
+ <dd>{{ row.missed }}</dd>
63
+ </div>
64
+ <div>
65
+ <dt>Status</dt>
66
+ <dd :class="row.status === 'Completed' ? 'text-success' : 'text-error'">
67
+ {{ row.status }}
68
+ </dd>
69
+ </div>
70
+ </dl>
71
+
72
+ <PatrolRouteSummary :summary="row.detail.routeSummary" />
73
+
74
+ <div class="table-card table-card__shrink">
75
+ <div class="route-details__table-head">
76
+ <span class="screen-card-title">Checkpoints</span>
77
+ </div>
78
+
79
+ <v-table>
80
+ <thead>
81
+ <tr>
82
+ <th>Checkpoint</th>
83
+ <th>Start - End Time</th>
84
+ <th>Status</th>
85
+ <th>Remarks</th>
86
+ <th>Skip Photo</th>
87
+ </tr>
88
+ </thead>
89
+ <tbody>
90
+ <tr
91
+ v-for="(activity, index) in row.detail.activities"
92
+ :key="`${activity.id}-${index}`"
93
+ >
94
+ <td>{{ activity.checkpoint }}</td>
95
+ <td class="text-no-wrap">
96
+ <v-icon size="small" class="mr-1">mdi-clock-outline</v-icon>
97
+ {{ activity.startTime }}
98
+ <v-icon size="small" class="mx-2">mdi-arrow-right</v-icon>
99
+ <v-icon size="small" class="mr-1">mdi-clock-outline</v-icon>
100
+ {{ activity.endTime }}
101
+ </td>
102
+ <td>
103
+ <v-chip :color="statusColor(activity.status)" size="small" variant="flat">
104
+ {{ activity.status }}
105
+ <v-icon v-if="activity.status === 'Skipped'" size="small" class="ml-1">
106
+ mdi-flag
107
+ </v-icon>
108
+ </v-chip>
109
+ </td>
110
+ <td class="route-details__remarks">
111
+ <template v-if="activity.status === 'Skipped'">
112
+ {{ activity.remarks || "No remarks provided" }}
113
+ </template>
114
+ <template v-else>-</template>
115
+ </td>
116
+ <td>
117
+ <SkipPhotoThumb :activity="activity" :size="64" />
118
+ </td>
119
+ </tr>
120
+ </tbody>
121
+ </v-table>
122
+ </div>
123
+ </div>
124
+
125
+ <div class="screen-modal__footer">
126
+ <v-btn variant="outlined" class="screen-btn-ghost" @click="close">Close</v-btn>
127
+ </div>
128
+ </v-card>
129
+ </v-dialog>
130
+ </template>
131
+
132
+ <script setup lang="ts">
133
+ import useWorkerTerm from "../../../composables/useWorkerTerm";
134
+ import type { NFCPatrolReportSummaryRow } from "../../../types/nfc-patrol-report";
135
+ import { formatReportDate } from "../../../utils/report-export";
136
+ import PatrolRouteSummary from "./PatrolRouteSummary.vue";
137
+ import SkipPhotoThumb from "./SkipPhotoThumb.vue";
138
+
139
+ defineProps<{
140
+ modelValue: boolean;
141
+ row: NFCPatrolReportSummaryRow | null;
142
+ }>();
143
+
144
+ const emit = defineEmits<{
145
+ "update:modelValue": [value: boolean];
146
+ }>();
147
+
148
+ const worker = useWorkerTerm();
149
+ const { getFileUrl } = useFile();
150
+
151
+ function statusColor(status: string) {
152
+ if (status === "Completed") return "success";
153
+ if (status === "Skipped") return "error";
154
+ return undefined;
155
+ }
156
+
157
+ function close() {
158
+ emit("update:modelValue", false);
159
+ }
160
+ </script>
161
+
162
+ <style scoped>
163
+ .route-details__head {
164
+ display: flex;
165
+ align-items: flex-start;
166
+ justify-content: space-between;
167
+ gap: 12px;
168
+ padding: 20px 24px;
169
+ }
170
+
171
+ .route-details__sub {
172
+ margin: 4px 0 0;
173
+ font-size: var(--fs-cell);
174
+ color: var(--text2);
175
+ }
176
+
177
+ .route-details__facts {
178
+ display: grid;
179
+ grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
180
+ gap: 16px;
181
+ margin: 0 0 24px;
182
+ }
183
+
184
+ .route-details__facts dt {
185
+ display: block;
186
+ margin-bottom: 4px;
187
+ font-size: var(--fs-section-label);
188
+ font-weight: var(--fw-section-label);
189
+ text-transform: uppercase;
190
+ letter-spacing: 0.04em;
191
+ color: var(--muted);
192
+ }
193
+
194
+ .route-details__facts dd {
195
+ margin: 0;
196
+ font-weight: var(--fw-cell);
197
+ color: var(--text);
198
+ }
199
+
200
+ .route-details__signature {
201
+ width: 80px;
202
+ height: 40px;
203
+ }
204
+
205
+ .route-details__table-head {
206
+ padding: 14px var(--cellpad-x);
207
+ border-bottom: 1px solid var(--border);
208
+ }
209
+
210
+ .route-details__remarks {
211
+ min-width: 160px;
212
+ white-space: pre-line;
213
+ }
214
+ </style>
@@ -9,9 +9,12 @@
9
9
  The two type classes are Vuetify's Roboto scale. `--fs-card-title` and
10
10
  `--text2` are the design's, and `--text2` measures 9.62:1 on a card where
11
11
  `--medium-emphasis` is an opacity applied to the theme ink.
12
+
13
+ `data-pdf-hide` leaves the card out of the PDF, whose page header names the
14
+ site instead (`useReportPdf`).
12
15
  -->
13
16
  <template>
14
- <div class="app-card text-center pa-8 mt-2">
17
+ <div class="app-card text-center pa-8 mt-2" data-pdf-hide>
15
18
  <v-icon size="64" class="mb-4">mdi-office-building</v-icon>
16
19
  <p class="location-header__name">{{ location.name }}</p>
17
20
  <p class="location-header__address mb-0">{{ location.address }}</p>
@@ -0,0 +1,137 @@
1
+ <!--
2
+ Skipped checkpoints with their photo, time and remarks, drawn in a report's
3
+ PDF directly under the row they belong to: under the checkpoint's own row
4
+ on the Patrol report (`inline`: one photo beside its remarks), under the
5
+ patrol run's row on the Daily report (a grid, one card per checkpoint). A
6
+ photo is never pooled away from the checkpoint and run it was taken at.
7
+
8
+ Plain `<img>` with `crossorigin`, not `v-img`: html2canvas ignores
9
+ `object-fit`, so each photo keeps its own proportions inside its frame (both
10
+ sides `auto` under max caps, never stretched), and it loads at once rather
11
+ than when scrolled into view - the rows it sits in are hidden on screen.
12
+ -->
13
+ <template>
14
+ <div class="skip-details" :class="{ 'skip-details--inline': inline }">
15
+ <figure
16
+ v-for="(activity, index) in activities"
17
+ :key="`${activity.id}-${index}`"
18
+ class="skip-details__item"
19
+ >
20
+ <div class="skip-details__frame">
21
+ <img
22
+ v-if="activity.skippedPhotoFileId"
23
+ :src="getFileUrl(activity.skippedPhotoFileId)"
24
+ :alt="`Skip photo for ${activity.checkpoint}`"
25
+ crossorigin="anonymous"
26
+ />
27
+ <span v-else class="skip-details__none">No photo attached</span>
28
+ </div>
29
+ <figcaption>
30
+ <span v-if="!inline" class="skip-details__checkpoint">{{ activity.checkpoint }}</span>
31
+ <span class="skip-details__meta">Skipped at {{ activity.endTime }}</span>
32
+ <span class="skip-details__label">Remarks</span>
33
+ <span class="skip-details__remarks">{{ activity.remarks || "No remarks provided" }}</span>
34
+ </figcaption>
35
+ </figure>
36
+ </div>
37
+ </template>
38
+
39
+ <script setup lang="ts">
40
+ import type { NFCPatrolActivity } from "../../../types/nfc-patrol-report";
41
+
42
+ defineProps<{
43
+ activities: NFCPatrolActivity[];
44
+ /** Under the checkpoint's own row: one photo beside its remarks, no name. */
45
+ inline?: boolean;
46
+ }>();
47
+
48
+ const { getFileUrl } = useFile();
49
+ </script>
50
+
51
+ <style scoped>
52
+ .skip-details {
53
+ display: grid;
54
+ grid-template-columns: repeat(4, minmax(0, 1fr));
55
+ gap: 16px;
56
+ font-family: var(--font-sans);
57
+ font-size: var(--fs-cell);
58
+ font-weight: 500;
59
+ color: var(--text);
60
+ }
61
+
62
+ .skip-details__item {
63
+ margin: 0;
64
+ }
65
+
66
+ .skip-details__frame {
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ height: 170px;
71
+ border: 1px solid var(--border);
72
+ border-radius: var(--r-inner);
73
+ background: var(--thead);
74
+ overflow: hidden;
75
+ }
76
+
77
+ /* Both sides `auto` under the two caps keeps the photo's own proportions -
78
+ html2canvas draws the box it is given. */
79
+ .skip-details__frame img {
80
+ display: block;
81
+ width: auto;
82
+ height: auto;
83
+ max-width: 100%;
84
+ max-height: 100%;
85
+ }
86
+
87
+ .skip-details__none {
88
+ color: var(--muted);
89
+ }
90
+
91
+ .skip-details__item figcaption {
92
+ display: flex;
93
+ flex-direction: column;
94
+ gap: 2px;
95
+ margin-top: 8px;
96
+ }
97
+
98
+ .skip-details__checkpoint {
99
+ font-weight: 700;
100
+ }
101
+
102
+ .skip-details__meta {
103
+ color: var(--text2);
104
+ }
105
+
106
+ .skip-details__label {
107
+ margin-top: 4px;
108
+ font-size: var(--fs-section-label);
109
+ font-weight: var(--fw-section-label);
110
+ text-transform: uppercase;
111
+ letter-spacing: 0.04em;
112
+ color: var(--muted);
113
+ }
114
+
115
+ .skip-details__remarks {
116
+ white-space: pre-line;
117
+ }
118
+
119
+ .skip-details--inline {
120
+ display: block;
121
+ }
122
+
123
+ .skip-details--inline .skip-details__item {
124
+ display: flex;
125
+ align-items: flex-start;
126
+ gap: 16px;
127
+ }
128
+
129
+ .skip-details--inline .skip-details__frame {
130
+ flex: 0 0 280px;
131
+ height: 200px;
132
+ }
133
+
134
+ .skip-details--inline .skip-details__item figcaption {
135
+ margin-top: 0;
136
+ }
137
+ </style>