Pārlūkot izejas kodu

fix🐛: 修复搜索

gitboyzcf 2 dienas atpakaļ
vecāks
revīzija
c4024e8448
2 mainītis faili ar 17 papildinājumiem un 7 dzēšanām
  1. 16 6
      src/views/Home/Home.vue
  2. 1 1
      src/views/Home/components/tableData.vue

+ 16 - 6
src/views/Home/Home.vue

@@ -86,6 +86,7 @@ export interface formInfo {
   page_size: number; // 每页条数:默认20条/页
   sort_field: string; // 排序字段:默认按事件时间戳(event_timestamp)排序
   sort_asc: boolean; // 是否升序:默认false(降序,最新事件在前)
+  is_valid: number; // 是否有效:默认0(未处理),1(有效),2(无效)
 }
 
 const alertData = ref<AlertItem[]>([]);
@@ -166,7 +167,15 @@ const formatData = async (list: any[]) => {
 
 const isRequestLoading = ref(true);
 async function getDataList(form = {}) {
-  const res: any = await API_ALERT_ESEARCH_GET(Object.assign(searchForm, form));
+  const params = {...Object.assign(searchForm, form)};
+  if ([1, 2].includes(params.status)) {
+    params.is_valid = searchForm.status;
+    delete params.status;
+  } else {
+    params.status = searchForm.status
+    delete params.is_valid;
+  }
+  const res: any = await API_ALERT_ESEARCH_GET(params);
   const resF = await formatData(res.items);
   alertData.value = resF as RowData[];
   pagination.itemCount = res.total;
@@ -175,9 +184,9 @@ async function getDataList(form = {}) {
 
 const statusOptions = [
   { label: "未处理", value: 0 },
-  { label: "处理中", value: 1 },
-  { label: "已忽略", value: 2 },
   { label: "已处理", value: 3 },
+  { label: "正确报警", value: 1 },
+  { label: "错误报警", value: 2 },
 ];
 const nDatePickerV = ref<[number, number] | null>(null);
 const searchForm = reactive<formInfo>({
@@ -191,6 +200,7 @@ const searchForm = reactive<formInfo>({
   page_size: 20,
   sort_asc: false,
   sort_field: "event_timestamp",
+  is_valid: 0,
 });
 const pagination = reactive<PaginationProps>({
   page: 1,
@@ -287,14 +297,14 @@ provide("getDataList", getDataList);
       </div>
 
       <n-space size="large" class="hidden md:flex">
-        <n-statistic label="今日总告警">
+        <n-statistic label="最新告警">
           <template #default
             ><span class="text-white font-mono">{{
               alarmCount
             }}</span></template
           >
         </n-statistic>
-        <n-statistic label="待处理">
+        <!-- <n-statistic label="待处理">
           <template #default
             ><span class="text-red-500 font-mono font-bold">{{
               pendingCount
@@ -305,7 +315,7 @@ provide("getDataList", getDataList);
           <template #default
             ><span class="text-cyan-500 font-mono">98.8%</span></template
           >
-        </n-statistic>
+        </n-statistic> -->
       </n-space>
     </header>
 

+ 1 - 1
src/views/Home/components/tableData.vue

@@ -176,7 +176,7 @@ const alarmShow = (item: any) => {
 
 <template>
   <div
-    class="bg-[#141414] h-full rounded-xl border border-white/5 shadow-2xl overflow-hidden"
+    class="h-full rounded-xl border border-white/5 shadow-2xl overflow-hidden"
   >
     <n-data-table
       :columns="columns"