Просмотр исходного кода

统计库位数量 实时根据筛选条件变动

handy 1 неделя назад
Родитель
Сommit
7663a4d937
1 измененных файлов с 44 добавлено и 5 удалено
  1. 44 5
      src/App.vue

+ 44 - 5
src/App.vue

@@ -14,7 +14,7 @@
       <h1 class="title">
       <h1 class="title">
         {{ systemTitle }}
         {{ systemTitle }}
         <span class="title-meta">库位
         <span class="title-meta">库位
-          <span class="title-meta-value">{{ availableLocationsCount }}/{{ locations.length }}</span></span>
+          <span class="title-meta-value">{{ filteredOccupiedLocationsCount }}/{{ filteredLocationsCount }}</span></span>
         <span class="title-fill-rate">
         <span class="title-fill-rate">
           <span
           <span
             class="title-meta title-fill-rate-item"
             class="title-meta title-fill-rate-item"
@@ -524,14 +524,53 @@ const formatFillRateDetail = (occupied: number, total: number) => {
   return `${occupied}/${total}`
   return `${occupied}/${total}`
 }
 }
 
 
-const availableLocationsCount = computed(() => {
-  return locations.value.filter((loc) => loc.locationAttribute === 'OK').length
-})
-
 const normalLocations = computed(() =>
 const normalLocations = computed(() =>
   locations.value.filter((loc) => loc.locationAttribute === 'OK')
   locations.value.filter((loc) => loc.locationAttribute === 'OK')
 )
 )
 
 
+const isLocationMatchedByFilters = (loc: LocationResourceDataVO) => {
+  const matchedCategory = !selectedCategory.value || loc.category === selectedCategory.value
+  const matchedLocationAttribute =
+    !selectedLocationAttribute.value || loc.locationAttribute === selectedLocationAttribute.value
+  const hasContainerFlag = hasContainer(loc.containerCode)
+  const matchedHasContainer =
+    !selectedHasContainer.value ||
+    (selectedHasContainer.value === 'Y' && hasContainerFlag) ||
+    (selectedHasContainer.value === 'N' && !hasContainerFlag)
+  const matchedZoneId = !selectedZoneId.value || String(loc.zoneId || '') === selectedZoneId.value
+  const normalizedLocGroupKeyword = appliedLocGroupKeyword.value.trim().toUpperCase()
+  const matchedLocGroup =
+    !normalizedLocGroupKeyword ||
+    String(loc.locGroup1 || '')
+      .toUpperCase()
+      .includes(normalizedLocGroupKeyword)
+  const normalizedLocationIdKeyword = appliedLocationIdKeyword.value.trim().toUpperCase()
+  const matchedLocationId =
+    !normalizedLocationIdKeyword ||
+    String(loc.locationId || '')
+      .toUpperCase()
+      .includes(normalizedLocationIdKeyword)
+
+  return (
+    matchedCategory &&
+    matchedLocationAttribute &&
+    matchedHasContainer &&
+    matchedZoneId &&
+    matchedLocGroup &&
+    matchedLocationId
+  )
+}
+
+const filteredLocationsCount = computed(() => {
+  return locations.value.filter((loc) => isLocationMatchedByFilters(loc)).length
+})
+
+const filteredOccupiedLocationsCount = computed(() => {
+  return locations.value.filter(
+    (loc) => isLocationMatchedByFilters(loc) && hasContainer(loc.containerCode)
+  ).length
+})
+
 const overallFillRate = computed(() => {
 const overallFillRate = computed(() => {
   const occupiedCount = normalLocations.value.filter((loc) =>
   const occupiedCount = normalLocations.value.filter((loc) =>
     hasContainer(loc.containerCode)
     hasContainer(loc.containerCode)