Эх сурвалжийг харах

perf(系统模块): 接口日志、登录日志添加租户支持

shizhongming 2 жил өмнө
parent
commit
c8d1498444

+ 1 - 1
src/modules/smart-system/views/log/SystemLogComponent.api.ts

@@ -1,7 +1,7 @@
 import { ApiServiceEnum, defHttp } from '@/utils/http/axios';
 
 enum Api {
-  list = 'sys/log/list',
+  list = 'sys/log/listWithTenant',
   getById = 'sys/log/getById',
 }
 

+ 24 - 1
src/modules/smart-system/views/log/SystemLogComponent.config.ts

@@ -1,5 +1,6 @@
 import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable';
 import dayjs from 'dayjs';
+import { Ref, unref } from 'vue';
 
 export type LoginIdent = 'LOGIN_LOG' | 'INTERFACE_LOG';
 
@@ -33,6 +34,14 @@ const tableColumns: Array<SmartColumn & { ident?: LoginIdent[] }> = [
     field: 'createBy',
     width: 120,
   },
+  {
+    title: '{system.views.log.title.tenant}',
+    field: 'tenantId',
+    width: 120,
+    formatter: ({ row }) => {
+      return row.tenant?.tenantShortName || row.tenant?.tenantName;
+    },
+  },
   {
     title: '{system.views.log.title.ip}',
     field: 'ip',
@@ -172,8 +181,13 @@ export const getOperationTypeEnum = (t: Function) => {
  * 获取搜索表单
  * @param t
  * @param ident
+ * @param getIsPlatformTenant
  */
-export const getSearchFormSchemas = (t: Function, ident: LoginIdent) => {
+export const getSearchFormSchemas = (
+  t: Function,
+  ident: LoginIdent,
+  getIsPlatformTenant: Ref<boolean>,
+) => {
   const schemas: Array<SmartSearchFormSchema & { ident?: LoginIdent[] }> = [
     {
       label: t('system.views.log.title.operation'),
@@ -226,6 +240,15 @@ export const getSearchFormSchemas = (t: Function, ident: LoginIdent) => {
         options: getOperationTypeEnum(t),
       },
     },
+    {
+      label: t('system.views.exception.title.tenant'),
+      field: 'tenantId',
+      slot: 'search-tenantId',
+      searchSymbol: '=',
+      ifShow() {
+        return unref(getIsPlatformTenant);
+      },
+    },
   ];
   return schemas.filter((item) => item.ident === undefined || item.ident.includes(ident));
 };

+ 8 - 1
src/modules/smart-system/views/log/SystemLogComponent.vue

@@ -14,6 +14,9 @@
           {{ row.useTime }}
         </a-tag>
       </template>
+      <template #search-tenantId="{ model, field }">
+        <SysTenantSelect style="width: 100px" allowClear v-model:value="model[field]" />
+      </template>
     </SmartTable>
     <LogDetailModal @register="registerModal" />
   </div>
@@ -39,6 +42,9 @@
   import { listApi } from './SystemLogComponent.api';
   import { getTableColumns, getSearchFormSchemas } from './SystemLogComponent.config';
   import LogDetailModal from './components/LogDetailModal.vue';
+  import { SysTenantSelect } from '@/modules/smart-system/components';
+  import { storeToRefs } from 'pinia';
+  import { useUserStore } from '@/store/modules/user';
 
   const props = defineProps({
     ident: {
@@ -49,6 +55,7 @@
 
   const { t } = useI18n();
   const { getTableSize } = useSizeSetting();
+  const { getIsPlatformTenant } = storeToRefs(useUserStore());
 
   const [registerModal, { openModal }] = useModal();
 
@@ -108,7 +115,7 @@
       compact: true,
       colon: true,
       searchWithSymbol: true,
-      schemas: getSearchFormSchemas(t, props.ident),
+      schemas: getSearchFormSchemas(t, props.ident, getIsPlatformTenant),
     },
     sortConfig: {
       remote: true,

+ 1 - 0
src/modules/smart-system/views/log/lang/zh_CN.ts

@@ -25,6 +25,7 @@ export default {
           params: '请求参数',
           result: '返回结果',
           errorMessage: '异常信息',
+          tenant: '租户',
         },
       },
     },