Browse Source

update frontend in search_eval

guantao 1 day ago
parent
commit
582d461960
1 changed files with 45 additions and 3 deletions
  1. 45 3
      examples/process_pipeline/script/search_eval/index.html

+ 45 - 3
examples/process_pipeline/script/search_eval/index.html

@@ -1842,6 +1842,14 @@
     function selectQueryByActiveCellAndControls(aName, tName) {
       const activeTool = st.tools[0] || null;
       let match = findQuery(aName, tName, st.lens, activeTool);
+      
+      const isProcedureView = st.matrixView === 'procedures';
+      const isHitsView = st.matrixView === 'hits';
+      const hasContent = q => {
+        if (isProcedureView) return getFormProcedureCount(q) > 0;
+        if (isHitsView) return getFormReportCount(q) > 0;
+        return q.hits > 0;
+      };
 
       if (match) {
         st.qi = DATA.queries.indexOf(match);
@@ -1859,8 +1867,10 @@
           const hasToolConstraint = q.dims.constraint && q.dims.constraint.kind === "工具类型";
           if (activeTool) {
             if (!hasToolConstraint || q.dims.constraint.value !== activeTool) return false;
+          } else {
+            if (hasToolConstraint) return false;
           }
-          return q.hits > 0;
+          return hasContent(q);
         });
 
         if (matches.length > 0) {
@@ -1870,7 +1880,9 @@
               const hasY = y.dims.constraint && y.dims.constraint.kind === "工具类型";
               if (hasX !== hasY) return hasX ? 1 : -1;
             }
-            return (y.hits || 0) - (x.hits || 0);
+            const countX = isProcedureView ? getFormProcedureCount(x) : (isHitsView ? getFormReportCount(x) : x.hits);
+            const countY = isProcedureView ? getFormProcedureCount(y) : (isHitsView ? getFormReportCount(y) : y.hits);
+            return countY - countX;
           });
           const anyMatch = matches[0];
           st.qi = DATA.queries.indexOf(anyMatch);
@@ -2111,9 +2123,19 @@
         document.getElementById("navC").innerHTML = '';
         return;
       }
+      
+      const isProcedureView = st.matrixView === 'procedures';
+      const resultsFilter = r => {
+        if (isProcedureView) {
+          return r.procedure_html && r.procedure_html !== "";
+        }
+        return true;
+      };
+      
+      const filteredResults = f.results.filter(resultsFilter);
       const chans = ["all", ...f.platforms];
       document.getElementById("navC").innerHTML = chans.map(c => {
-        const n = c === "all" ? f.results.length : f.results.filter(r => r.platformKey === c).length;
+        const n = c === "all" ? filteredResults.length : filteredResults.filter(r => r.platformKey === c).length;
         return `<span class="tab ${c === st.channel ? 'on' : ''}" data-c="${c}">${c === "all" ? "全部" : (PLATC[c] || c)} <small>${n}</small></span>`;
       }).join("");
     }
@@ -2132,6 +2154,9 @@
       }
       
       let it = f.results;
+      if (st.matrixView === 'procedures') {
+        it = it.filter(r => r.procedure_html && r.procedure_html !== "");
+      }
       if (st.channel !== "all") it = it.filter(r => r.platformKey === st.channel);
       const valid = it.filter(r => !r.anomaly);
       const rep = valid.filter(r => !isItemDiscarded(r)).length;
@@ -2172,6 +2197,9 @@
       const f = curForm();
       if (!f) return [];
       let it = f.results.slice();
+      if (st.matrixView === 'procedures') {
+        it = it.filter(r => r.procedure_html && r.procedure_html !== "");
+      }
       if (st.channel !== "all") it = it.filter(r => r.platformKey === st.channel);
 
       const s = document.getElementById("sort").value;
@@ -2430,7 +2458,21 @@
       else if (mode === 'hits') document.getElementById('btnMxHits').classList.add('on');
       else if (mode === 'procedures') document.getElementById('btnMxProcedures').classList.add('on');
       
+      if (st.selectedAction && st.selectedType) {
+        selectQueryByActiveCellAndControls(st.selectedAction, st.selectedType);
+      }
+
       renderMatrix();
+
+      if (openCell) {
+        const ai = +openCell.dataset.ai, ti = +openCell.dataset.ti;
+        const newCell = document.querySelector(`td.cell[data-ai="${ai}"][data-ti="${ti}"]`);
+        if (newCell) {
+          showPop(newCell, parseInt(pop.style.left), parseInt(pop.style.top));
+        }
+      }
+
+      rerender(true);
     }
 
     function loadData(keep) {