Ver código fonte

库位号支持多筛选

handy 3 dias atrás
pai
commit
9b4e9a4a82
2 arquivos alterados com 24 adições e 5 exclusões
  1. 16 4
      src/App.vue
  2. 8 1
      src/components/WarehouseMap.vue

+ 16 - 4
src/App.vue

@@ -695,11 +695,14 @@ const isLocationMatchedByFilters = (loc: LocationResourceDataVO) => {
       .toUpperCase()
       .includes(normalizedLocGroupKeyword)
   const normalizedLocationIdKeyword = appliedLocationIdKeyword.value.trim().toUpperCase()
+  const normalizedLocationIdKeywords = splitLocationIdKeywords(normalizedLocationIdKeyword)
   const matchedLocationId =
     !normalizedLocationIdKeyword ||
-    String(loc.locationId || '')
-      .toUpperCase()
-      .includes(normalizedLocationIdKeyword)
+    normalizedLocationIdKeywords.some((keyword) =>
+      String(loc.locationId || '')
+        .toUpperCase()
+        .includes(keyword)
+    )
   const normalizedWcsLocationIdKeyword = appliedWcsLocationIdKeyword.value.trim().toUpperCase()
   const matchedWcsLocationId =
     !normalizedWcsLocationIdKeyword ||
@@ -954,6 +957,15 @@ const handleTitleTokenCopy = async () => {
 
 const countHyphen = (text: string) => text.split('-').length - 1
 
+const splitLocationIdKeywords = (keyword: string) =>
+  keyword
+    .split(',')
+    .map((item) => item.trim())
+    .filter(Boolean)
+
+const isLocationIdKeyword = (keyword: string) =>
+  splitLocationIdKeywords(keyword).every((item) => countHyphen(item) === 3)
+
 const applyLocationKeywordFilter = () => {
   const keyword = locationKeywordInput.value.trim()
   const hyphenCount = countHyphen(keyword)
@@ -963,7 +975,7 @@ const applyLocationKeywordFilter = () => {
     appliedLocGroupKeyword.value = ''
     appliedLocationIdKeyword.value = ''
     appliedWcsLocationIdKeyword.value = ''
-  } else if (hyphenCount === 3) {
+  } else if (isLocationIdKeyword(keyword)) {
     appliedLocationIdKeyword.value = keyword
     appliedLocGroupKeyword.value = ''
     appliedWcsLocationIdKeyword.value = ''

+ 8 - 1
src/components/WarehouseMap.vue

@@ -403,6 +403,12 @@ const gridStyle = computed(() => {
   }
 })
 
+const splitLocationIdKeywords = (keyword: string) =>
+  keyword
+    .split(',')
+    .map((item) => item.trim())
+    .filter(Boolean)
+
 const isCellMatched = (cell: GridCell) => {
   const matchedCategory = !props.selectedCategory || cell.category === props.selectedCategory
   const matchedLocationAttribute =
@@ -418,9 +424,10 @@ const isCellMatched = (cell: GridCell) => {
   const matchedLocGroup =
     !normalizedKeyword || cell.locGroup1.toUpperCase().includes(normalizedKeyword)
   const normalizedLocationIdKeyword = props.locationIdKeyword.trim().toUpperCase()
+  const normalizedLocationIdKeywords = splitLocationIdKeywords(normalizedLocationIdKeyword)
   const matchedLocationId =
     !normalizedLocationIdKeyword ||
-    cell.locationId.toUpperCase().includes(normalizedLocationIdKeyword)
+    normalizedLocationIdKeywords.some((keyword) => cell.locationId.toUpperCase().includes(keyword))
   const normalizedWcsLocationIdKeyword = props.wcsLocationIdKeyword.trim().toUpperCase()
   const matchedWcsLocationId =
     !normalizedWcsLocationIdKeyword ||