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

fix(s8): SqlSugar 表达式翻译修复 + 异常列表 keep-alive 激活刷新

- S8WatchSchedulerService.FindPendingExceptionIdAsync:类级静态 UnclosedExceptionStatuses
  局部化以配合 SqlSugar 表达式翻译;FirstAsync 改为 Take(1).ToListAsync
  避免空集抛异常
- S8ExceptionListPage:新增 onActivated,keep-alive 二次激活时自动 loadList
YY968XX 1 месяц назад
Родитель
Сommit
e52391904d

+ 10 - 1
Web/src/views/aidop/s8/exceptions/S8ExceptionListPage.vue

@@ -60,7 +60,7 @@
 </template>
 
 <script setup lang="ts" name="aidopS8ExceptionList">
-import { onMounted, reactive, ref } from 'vue';
+import { onActivated, onMounted, reactive, ref } from 'vue';
 import { useRoute, useRouter } from 'vue-router';
 import AidopDemoShell from '../../components/AidopDemoShell.vue';
 import { s8ExceptionApi, type S8ExceptionRow } from '../api/s8ExceptionApi';
@@ -68,6 +68,7 @@ import { s8ExceptionApi, type S8ExceptionRow } from '../api/s8ExceptionApi';
 const route = useRoute();
 const router = useRouter();
 const loading = ref(false);
+const activatedOnce = ref(false);
 const rows = ref<S8ExceptionRow[]>([]);
 const total = ref(0);
 const filterOpts = reactive<{
@@ -156,6 +157,14 @@ onMounted(async () => {
 	await loadFilters();
 	await loadList();
 });
+
+onActivated(async () => {
+	if (!activatedOnce.value) {
+		activatedOnce.value = true;
+		return;
+	}
+	await loadList();
+});
 </script>
 
 <style scoped>

+ 8 - 3
server/Plugins/Admin.NET.Plugin.AiDOP/Service/S8/S8WatchSchedulerService.cs

@@ -302,15 +302,20 @@ public class S8WatchSchedulerService : ITransient
     private async Task<long> FindPendingExceptionIdAsync(
         long tenantId, long factoryId, long sourceRuleId, string relatedObjectCode)
     {
-        return await _exceptionRep.AsQueryable()
+        // SqlSugar 表达式翻译要求 Contains 数组变量必须可访问;此处将类级常量
+        // 承接到方法内局部变量,仅为表达式翻译服务,值与 UnclosedExceptionStatuses 一致。
+        var statuses = UnclosedExceptionStatuses;
+        var ids = await _exceptionRep.AsQueryable()
             .Where(x => x.TenantId == tenantId
                 && x.FactoryId == factoryId
                 && !x.IsDeleted
                 && x.SourceRuleId == sourceRuleId
                 && x.RelatedObjectCode == relatedObjectCode
-                && UnclosedExceptionStatuses.Contains(x.Status))
+                && statuses.Contains(x.Status))
             .Select(x => x.Id)
-            .FirstAsync();
+            .Take(1)
+            .ToListAsync();
+        return ids.Count > 0 ? ids[0] : 0L;
     }
 
     /// <summary>