@7365admin1/layer-common 1.10.7 → 1.10.9

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 (49) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components/AccessCardAddForm.vue +1 -1
  3. package/components/AccessCardAssignToUnitForm.vue +1 -1
  4. package/components/AccessManagement.vue +1 -1
  5. package/components/{AddSupplyForm.vue → AddEqupmentForm.vue} +5 -5
  6. package/components/BuildingManagement/units.vue +2 -2
  7. package/components/BuildingUnitFormAdd.vue +4 -4
  8. package/components/BuildingUnitFormEdit.vue +114 -68
  9. package/components/Carousel.vue +474 -0
  10. package/components/DrawImage.vue +172 -0
  11. package/components/EntryPassInformation.vue +283 -29
  12. package/components/{CheckoutItemMain.vue → EquipmentItemMain.vue} +95 -87
  13. package/components/{SupplyManagement.vue → EquipmentManagement.vue} +3 -3
  14. package/components/Feedback/Form.vue +4 -4
  15. package/components/FeedbackMain.vue +748 -145
  16. package/components/FileInput.vue +289 -0
  17. package/components/Input/DateTimePicker.vue +17 -11
  18. package/components/ManageChecklistMain.vue +379 -41
  19. package/components/StockCard.vue +11 -7
  20. package/components/TableHygiene.vue +42 -452
  21. package/components/UnitPersonCard.vue +74 -14
  22. package/components/VisitorForm.vue +193 -52
  23. package/components/VisitorFormSelection.vue +13 -2
  24. package/components/VisitorManagement.vue +83 -55
  25. package/composables/useAccessManagement.ts +41 -18
  26. package/composables/useCleaningPermission.ts +7 -7
  27. package/composables/useDashboardData.ts +2 -2
  28. package/composables/useEquipment.ts +63 -0
  29. package/composables/{useCheckout.ts → useEquipmentItem.ts} +7 -7
  30. package/composables/{useCheckoutPermission.ts → useEquipmentItemPermission.ts} +13 -13
  31. package/composables/{useSupply.ts → useEquipmentManagement.ts} +1 -1
  32. package/composables/useEquipmentManagementPermission.ts +96 -0
  33. package/composables/{useSupplyPermission.ts → useEquipmentPermission.ts} +9 -9
  34. package/composables/useFeedback.ts +53 -21
  35. package/composables/useLocalAuth.ts +29 -1
  36. package/composables/useUploadFiles.ts +94 -0
  37. package/composables/useUtils.ts +152 -53
  38. package/composables/useVehicle.ts +21 -2
  39. package/composables/useVisitor.ts +9 -7
  40. package/composables/useWorkOrder.ts +25 -3
  41. package/package.json +2 -1
  42. package/types/building.d.ts +1 -1
  43. package/types/{checkout-item.d.ts → equipment-item.d.ts} +3 -3
  44. package/types/{supply.d.ts → equipment.d.ts} +2 -2
  45. package/types/feedback.d.ts +5 -2
  46. package/types/people.d.ts +3 -1
  47. package/types/user.d.ts +1 -0
  48. package/types/vehicle.d.ts +2 -0
  49. package/types/visitor.d.ts +2 -1
@@ -10,21 +10,21 @@
10
10
  v-model:page="page"
11
11
  :pages="pages"
12
12
  :pageRange="pageRange"
13
- :no-data-text="`No supplies found for ${siteName}.`"
14
- @refresh="getCheckoutItemsRefresh"
15
- :canCreate="canCreateCheckout"
16
- createLabel="Checkout Item"
13
+ :no-data-text="`No Equipment Items found for ${siteName}.`"
14
+ @refresh="getEquipmentItemsRefresh"
15
+ :canCreate="canCreateEquipmentItem"
16
+ createLabel="Equipment Item"
17
17
  @row-click="handleRowClick"
18
18
  >
19
19
  <template #actions>
20
20
  <v-row no-gutters align="center" class="w-100">
21
- <v-col cols="auto" v-if="canCreateCheckout">
21
+ <v-col cols="auto" v-if="canCreateEquipmentItem">
22
22
  <v-btn
23
23
  class="text-none"
24
24
  rounded="pill"
25
25
  variant="tonal"
26
26
  size="large"
27
- @click="openCheckoutDialog()"
27
+ @click="openEquipmentItemDialog()"
28
28
  >
29
29
  Checkout Item
30
30
  </v-btn>
@@ -147,7 +147,7 @@
147
147
 
148
148
  <v-row no-gutters class="mb-2">
149
149
  <v-col cols="5" class="text-subtitle-2 font-weight-bold">
150
- Checkout Quantity:
150
+ Equipment Quantity:
151
151
  </v-col>
152
152
  <v-col cols="7" class="text-subtitle-2">
153
153
  {{ selectedSupply.qty || "N/A" }}
@@ -177,28 +177,28 @@
177
177
  </HygieneUpdateMoreAction>
178
178
  </v-dialog>
179
179
 
180
- <!-- Main Checkout Dialog -->
181
- <v-dialog v-model="dialogCheckoutItem" max-width="540" persistent>
180
+ <!-- Main Equipment Item Dialog -->
181
+ <v-dialog v-model="dialogEquipmentItem" max-width="540" persistent>
182
182
  <v-card>
183
183
  <v-card-title class="d-flex align-center pa-4">
184
- <span class="text-h6 font-weight-bold">Checkout Item</span>
184
+ <span class="text-h6 font-weight-bold">Equipment Item</span>
185
185
  <v-spacer />
186
186
  <v-btn
187
187
  icon="mdi-close"
188
188
  variant="text"
189
189
  size="small"
190
- @click="dialogCheckoutItem = false"
190
+ @click="dialogEquipmentItem = false"
191
191
  />
192
192
  </v-card-title>
193
193
 
194
194
  <v-divider />
195
195
 
196
196
  <v-card-text class="pa-6">
197
- <v-form ref="checkoutItemFormRef">
198
- <!-- Add Supply Section -->
197
+ <v-form ref="equipmentItemFormRef">
198
+ <!-- Add Equipment Section -->
199
199
  <v-row no-gutters class="mb-4">
200
200
  <v-col cols="12">
201
- <InputLabel for="supply" title="Add Supply" class="mb-2" />
201
+ <InputLabel for="equipment" title="Add Equipment" class="mb-2" />
202
202
  <v-autocomplete
203
203
  v-model="selectedSupplyForAdd"
204
204
  :items="supplyItems"
@@ -207,14 +207,14 @@
207
207
  item-value="value"
208
208
  density="comfortable"
209
209
  variant="outlined"
210
- placeholder="Select supply"
210
+ placeholder="Select equipment"
211
211
  @update:model-value="addSupplyToList"
212
212
  />
213
213
  </v-col>
214
214
  </v-row>
215
215
 
216
- <!-- Selected Supplies List -->
217
- <v-row no-gutters v-if="checkoutItems.length > 0" class="mb-4">
216
+ <!-- Selected Equipment List -->
217
+ <v-row no-gutters v-if="equipmentItems.length > 0" class="mb-4">
218
218
  <v-col cols="12">
219
219
  <v-divider class="mb-4" />
220
220
 
@@ -223,7 +223,7 @@
223
223
  </div>
224
224
 
225
225
  <v-sheet
226
- v-for="(item, index) in checkoutItems"
226
+ v-for="(item, index) in equipmentItems"
227
227
  :key="index"
228
228
  rounded="lg"
229
229
  variant="outlined"
@@ -234,7 +234,7 @@
234
234
  <div class="text-body-2 font-weight-medium">
235
235
  <span class="text-capitalize">{{ item.supplyName }}</span>
236
236
  - (Available:
237
- <span class="font-weight-bold">{{ item.qty }}</span
237
+ <span class="font-weight-bold">{{ item.stockQty }}</span
238
238
  >)
239
239
  </div>
240
240
  </v-col>
@@ -283,7 +283,9 @@
283
283
  >mdi-delete-outline</v-icon
284
284
  >
285
285
  </template>
286
- <v-list-item-title>Remove Supply</v-list-item-title>
286
+ <v-list-item-title
287
+ >Remove Equipment</v-list-item-title
288
+ >
287
289
  </v-list-item>
288
290
  </v-list>
289
291
  </v-menu>
@@ -342,7 +344,7 @@
342
344
  size="large"
343
345
  height="56"
344
346
  class="text-none font-weight-medium rounded-0"
345
- @click="dialogCheckoutItem = false"
347
+ @click="dialogEquipmentItem = false"
346
348
  >
347
349
  Cancel
348
350
  </v-btn>
@@ -356,9 +358,9 @@
356
358
  height="56"
357
359
  class="text-none font-weight-bold rounded-0"
358
360
  :loading="submitting"
359
- @click="_checkoutItem()"
361
+ @click="_equipmentItem()"
360
362
  >
361
- Checkout Item
363
+ Equipment Item
362
364
  </v-btn>
363
365
  </v-col>
364
366
  </v-row>
@@ -374,7 +376,7 @@
374
376
  <div>
375
377
  <div class="text-h6 font-weight-bold">Item Photos</div>
376
378
  <div class="text-caption text-medium-emphasis">
377
- {{ checkoutItems[activePhotoIndex ?? 0]?.supplyName || "Item" }}
379
+ {{ equipmentItems[activePhotoIndex ?? 0]?.supplyName || "Item" }}
378
380
  </div>
379
381
  </div>
380
382
 
@@ -438,16 +440,18 @@
438
440
  </template>
439
441
 
440
442
  <script setup lang="ts">
441
- import useCheckout from "../composables/useCheckout";
442
- import { useCheckoutPermission } from "../composables/useCheckoutPermission";
443
- import useSupply from "../composables/useSupply";
443
+ import useEquipmentItem from "../composables/useEquipmentItem";
444
+ import { useEquipmentItemPermission } from "../composables/useEquipmentItemPermission";
445
+ import useEquipmentManagement from "../composables/useEquipmentManagement";
446
+ import useFile from "../composables/useFile";
447
+ import useUtils from "../composables/useUtils";
444
448
 
445
449
  const props = defineProps({
446
450
  orgId: { type: String, default: "" },
447
451
  site: { type: String, default: "" },
448
452
  });
449
453
 
450
- const { canCreateCheckout } = useCheckoutPermission();
454
+ const { canCreateEquipmentItem } = useEquipmentItemPermission();
451
455
 
452
456
  const items = ref<Array<Record<string, any>>>([]);
453
457
  const siteName = ref<string>("");
@@ -462,10 +466,10 @@ const headers = [
462
466
  ];
463
467
 
464
468
  const {
465
- getCheckoutItems,
466
- getCheckoutItemById,
467
- checkoutItems: checkoutItemApi,
468
- } = useCheckout();
469
+ getEquipmentItems,
470
+ getEquipmentItemById,
471
+ equipmentItems: equipmentItemApi,
472
+ } = useEquipmentItem();
469
473
  const { debounce, requiredRule, formatDate } = useUtils();
470
474
 
471
475
  const searchInput = ref("");
@@ -475,16 +479,16 @@ const page = ref(1);
475
479
  const pages = ref(0);
476
480
  const pageRange = ref("-- - -- of --");
477
481
 
478
- const selectedCheckoutItemId = ref("");
482
+ const selectedEquipmentItemId = ref("");
479
483
 
480
484
  const {
481
- data: getCheckoutItemsReq,
482
- refresh: getCheckoutItemsRefresh,
485
+ data: getEquipmentItemsReq,
486
+ refresh: getEquipmentItemsRefresh,
483
487
  pending: loading,
484
488
  } = await useLazyAsyncData(
485
- "get-all-checkout-items",
489
+ "get-all-equipment-items",
486
490
  () =>
487
- getCheckoutItems({
491
+ getEquipmentItems({
488
492
  page: page.value,
489
493
  search: searchInput.value,
490
494
  site: props.site,
@@ -495,14 +499,14 @@ const {
495
499
  );
496
500
 
497
501
  watchEffect(() => {
498
- if (getCheckoutItemsReq.value) {
499
- items.value = getCheckoutItemsReq.value.items;
500
- pages.value = getCheckoutItemsReq.value.pages;
501
- pageRange.value = getCheckoutItemsReq.value.pageRange;
502
+ if (getEquipmentItemsReq.value) {
503
+ items.value = getEquipmentItemsReq.value.items;
504
+ pages.value = getEquipmentItemsReq.value.pages;
505
+ pageRange.value = getEquipmentItemsReq.value.pageRange;
502
506
  }
503
507
  });
504
508
 
505
- const debounceSearch = debounce(getCheckoutItemsRefresh, 500);
509
+ const debounceSearch = debounce(getEquipmentItemsRefresh, 500);
506
510
  watch(
507
511
  [searchInput, endDate, startDate],
508
512
  ([]) => {
@@ -511,44 +515,44 @@ watch(
511
515
  { immediate: false, deep: true }
512
516
  );
513
517
 
514
- const { data: getCheckoutItemByIdReq, refresh: getCheckoutItemByIdRefresh } =
515
- await useLazyAsyncData(
516
- "get-checkout-item-by-id",
517
- () => getCheckoutItemById(selectedCheckoutItemId.value),
518
+ const { data: getEquipmentItemByIdReq, refresh: getEquipmentItemByIdRefresh } =
519
+ await useLazyAsyncData<any>(
520
+ "get-equipment-item-by-id",
521
+ () => getEquipmentItemById(selectedEquipmentItemId.value),
518
522
  {
519
523
  immediate: false,
520
524
  }
521
525
  );
522
526
 
523
527
  watchEffect(() => {
524
- if (getCheckoutItemByIdReq.value) {
528
+ if (getEquipmentItemByIdReq.value) {
525
529
  selectedSupply.value = {
526
- _id: getCheckoutItemByIdReq.value._id,
527
- supplyName: getCheckoutItemByIdReq.value.supplyName || "N/A",
528
- qty: getCheckoutItemByIdReq.value.qty || 0,
530
+ _id: getEquipmentItemByIdReq.value._id,
531
+ supplyName: getEquipmentItemByIdReq.value.supplyName || "N/A",
532
+ qty: getEquipmentItemByIdReq.value.qty || 0,
529
533
  unitOfMeasurement:
530
- getCheckoutItemByIdReq.value.supply?.unitOfMeasurement || "N/A",
531
- status: getCheckoutItemByIdReq.value.status || "N/A",
532
- site: getCheckoutItemByIdReq.value.site || "N/A",
534
+ getEquipmentItemByIdReq.value.supply?.unitOfMeasurement || "N/A",
535
+ status: getEquipmentItemByIdReq.value.status || "N/A",
536
+ site: getEquipmentItemByIdReq.value.site || "N/A",
533
537
  supply:
534
- getCheckoutItemByIdReq.value.supply ||
535
- getCheckoutItemByIdReq.value.supply?._id ||
538
+ getEquipmentItemByIdReq.value.supply ||
539
+ getEquipmentItemByIdReq.value.supply?._id ||
536
540
  "N/A",
537
- attachment: Array.isArray(getCheckoutItemByIdReq.value.attachment)
538
- ? [...getCheckoutItemByIdReq.value.attachment]
541
+ attachment: Array.isArray(getEquipmentItemByIdReq.value.attachment)
542
+ ? [...getEquipmentItemByIdReq.value.attachment]
539
543
  : [],
540
544
  stockQty:
541
- getCheckoutItemByIdReq.value.stockQty ||
542
- getCheckoutItemByIdReq.value.supply?.stockQty ||
545
+ getEquipmentItemByIdReq.value.stockQty ||
546
+ getEquipmentItemByIdReq.value.supply?.stockQty ||
543
547
  "N/A",
544
548
  };
545
549
  }
546
550
  });
547
551
 
548
- const { getSupplies } = useSupply();
552
+ const { getSupplies } = useEquipmentManagement();
549
553
 
550
554
  const { data: getSuppliesReq } = await useLazyAsyncData(
551
- "get-supplies-for-checkout-item",
555
+ "get-supplies-for-equipment-item",
552
556
  () =>
553
557
  getSupplies({
554
558
  site: props.site,
@@ -562,13 +566,16 @@ watchEffect(() => {
562
566
  supplyItems.value = getSuppliesReq.value.items.map((item: any) => ({
563
567
  name: item.name,
564
568
  value: item._id,
569
+ stockQty: item.qty ?? 0,
565
570
  }));
566
571
  }
567
572
  });
568
573
 
569
- const supplyItems = ref<Array<{ name: string; value: string }>>([]);
574
+ const supplyItems = ref<
575
+ Array<{ name: string; value: string; stockQty: number }>
576
+ >([]);
570
577
  const selectedSupplyForAdd = ref<string>("");
571
- const checkoutItems = ref<TCheckoutItem[]>([]);
578
+ const equipmentItems = ref<TEquipmentItem[]>([]);
572
579
 
573
580
  const selectedSupply = ref<Record<string, any>>({});
574
581
  const message = ref("");
@@ -576,7 +583,7 @@ const messageSnackbar = ref(false);
576
583
  const messageColor = ref("");
577
584
 
578
585
  const dialogShowMoreActions = ref(false);
579
- const dialogCheckoutItem = ref(false);
586
+ const dialogEquipmentItem = ref(false);
580
587
  const dialogPhotoForItem = ref(false);
581
588
  const activePhotoIndex = ref<number | null>(null);
582
589
 
@@ -586,28 +593,29 @@ function showMessage(msg: string, color: string = "error") {
586
593
  messageSnackbar.value = true;
587
594
  }
588
595
 
589
- function openCheckoutDialog() {
590
- checkoutItems.value = [];
596
+ function openEquipmentItemDialog() {
597
+ equipmentItems.value = [];
591
598
  selectedSupplyForAdd.value = "";
592
- dialogCheckoutItem.value = true;
599
+ dialogEquipmentItem.value = true;
593
600
  }
594
601
 
595
602
  function addSupplyToList(supplyId: string) {
596
603
  if (!supplyId) return;
597
604
 
598
- const exists = checkoutItems.value.find((item) => item.supply === supplyId);
605
+ const exists = equipmentItems.value.find((item) => item.supply === supplyId);
599
606
  if (exists) {
600
- showMessage("Supply already added.");
607
+ showMessage("Equipment already added.");
601
608
  selectedSupplyForAdd.value = "";
602
609
  return;
603
610
  }
604
611
 
605
612
  const supply = supplyItems.value.find((s) => s.value === supplyId);
606
613
  if (supply) {
607
- checkoutItems.value.push({
614
+ equipmentItems.value.push({
608
615
  supply: supplyId,
609
616
  supplyName: supply.name,
610
617
  qty: 1,
618
+ stockQty: supply.stockQty,
611
619
  photos: [],
612
620
  photoIds: [],
613
621
  });
@@ -616,7 +624,7 @@ function addSupplyToList(supplyId: string) {
616
624
  }
617
625
 
618
626
  function removeSupplyFromList(index: number) {
619
- checkoutItems.value.splice(index, 1);
627
+ equipmentItems.value.splice(index, 1);
620
628
  }
621
629
 
622
630
  function openPhotoDialog(index: number) {
@@ -627,25 +635,25 @@ function openPhotoDialog(index: number) {
627
635
  async function handleRowClick(data: any) {
628
636
  message.value = "";
629
637
 
630
- selectedCheckoutItemId.value = data?.item?._id;
638
+ selectedEquipmentItemId.value = data?.item?._id;
631
639
 
632
- if (selectedCheckoutItemId.value) {
633
- await getCheckoutItemByIdRefresh();
640
+ if (selectedEquipmentItemId.value) {
641
+ await getEquipmentItemByIdRefresh();
634
642
  }
635
643
 
636
644
  dialogShowMoreActions.value = true;
637
645
  }
638
646
 
639
- async function _checkoutItem() {
647
+ async function _equipmentItem() {
640
648
  submitting.value = true;
641
649
  try {
642
- if (!checkoutItems.value.length) {
643
- showMessage("Add at least one supply.");
650
+ if (!equipmentItems.value.length) {
651
+ showMessage("Add at least one equipment.");
644
652
  submitting.value = false;
645
653
  return;
646
654
  }
647
655
 
648
- const items = checkoutItems.value.map((item) => ({
656
+ const items = equipmentItems.value.map((item) => ({
649
657
  supply: item.supply,
650
658
  qty: item.qty,
651
659
  ...(item.photoIds && item.photoIds.length
@@ -653,16 +661,16 @@ async function _checkoutItem() {
653
661
  : {}),
654
662
  }));
655
663
 
656
- await checkoutItemApi(props.site, { items });
664
+ await equipmentItemApi(props.site, { items });
657
665
 
658
666
  showMessage(
659
- `Checked out ${checkoutItems.value.length} item(s).`,
667
+ `Checked out ${equipmentItems.value.length} item(s).`,
660
668
  "success"
661
669
  );
662
- dialogCheckoutItem.value = false;
663
- checkoutItems.value = [];
670
+ dialogEquipmentItem.value = false;
671
+ equipmentItems.value = [];
664
672
 
665
- await getCheckoutItemsRefresh();
673
+ await getEquipmentItemsRefresh();
666
674
  } catch (error: any) {
667
675
  console.error(error);
668
676
  showMessage(error?.data?.message, "error");
@@ -682,22 +690,22 @@ function viewAttachment(attachmentId: string) {
682
690
  const currentPhotos = computed({
683
691
  get() {
684
692
  if (activePhotoIndex.value === null) return [];
685
- return checkoutItems.value[activePhotoIndex.value]?.photos || [];
693
+ return equipmentItems.value[activePhotoIndex.value]?.photos || [];
686
694
  },
687
695
  set(val) {
688
696
  if (activePhotoIndex.value === null) return;
689
- checkoutItems.value[activePhotoIndex.value].photos = val || [];
697
+ equipmentItems.value[activePhotoIndex.value].photos = val || [];
690
698
  },
691
699
  });
692
700
 
693
701
  const currentPhotoIds = computed({
694
702
  get() {
695
703
  if (activePhotoIndex.value === null) return [];
696
- return checkoutItems.value[activePhotoIndex.value]?.photoIds || [];
704
+ return equipmentItems.value[activePhotoIndex.value]?.photoIds || [];
697
705
  },
698
706
  set(val) {
699
707
  if (activePhotoIndex.value === null) return;
700
- checkoutItems.value[activePhotoIndex.value].photoIds = val || [];
708
+ equipmentItems.value[activePhotoIndex.value].photoIds = val || [];
701
709
  },
702
710
  });
703
711
  </script>
@@ -10,10 +10,10 @@
10
10
  v-model:page="page"
11
11
  :pages="pages"
12
12
  :pageRange="pageRange"
13
- :no-data-text="`No supplies found.`"
13
+ :no-data-text="`No equipments found.`"
14
14
  @refresh="updatePage"
15
15
  :canCreate="true"
16
- createLabel="Add Supply"
16
+ createLabel="Add Equipment"
17
17
  @row-click="tableRowClickHandler"
18
18
  >
19
19
  <template #actions>
@@ -25,7 +25,7 @@
25
25
  variant="tonal"
26
26
  size="large"
27
27
  >
28
- Add Supply
28
+ Add Equipment
29
29
  </v-btn>
30
30
  </v-col>
31
31
 
@@ -31,7 +31,7 @@
31
31
  <template #label> Subject <span class="text-red">*</span> </template>
32
32
  </v-autocomplete>
33
33
 
34
- <v-autocomplete
34
+ <!-- <v-autocomplete
35
35
  v-model="localFeedback.category"
36
36
  :items="categories"
37
37
  item-title="title"
@@ -45,7 +45,7 @@
45
45
  :rules="[requiredRule]"
46
46
  >
47
47
  <template #label> Category <span class="text-red">*</span> </template>
48
- </v-autocomplete>
48
+ </v-autocomplete> -->
49
49
 
50
50
  <v-text-field
51
51
  label="Location"
@@ -91,7 +91,7 @@ const props = defineProps<{
91
91
  feedback: TFeedbackCreate;
92
92
  isEditMode: boolean;
93
93
  loading: boolean;
94
- categories: { title: string; value: string }[];
94
+ // categories: { title: string; value: string }[];
95
95
  erroredImages?: string[];
96
96
  maxFiles?: number;
97
97
  }>();
@@ -133,7 +133,7 @@ const { requiredRule } = useUtils();
133
133
  const isFormValid = computed(() => {
134
134
  return (
135
135
  localFeedback.value.subject &&
136
- localFeedback.value.category &&
136
+ // localFeedback.value.category &&
137
137
  localFeedback.value.location &&
138
138
  localFeedback.value.description
139
139
  );