93 lines
2.6 KiB
Vue
93 lines
2.6 KiB
Vue
<template>
|
|
<div>
|
|
<div class="n-layout-page-header">
|
|
<n-card :bordered="false" title="IM审计日志"></n-card>
|
|
</div>
|
|
<n-card :bordered="false" class="proCard">
|
|
<BasicForm
|
|
ref="searchFormRef"
|
|
@register="register"
|
|
@submit="reloadTable"
|
|
@reset="handleReset"
|
|
@keyup.enter="reloadTable"
|
|
/>
|
|
<BasicTable
|
|
ref="actionRef"
|
|
:columns="columns"
|
|
:request="loadDataTable"
|
|
:row-key="(row) => row.tenantId + '-' + row.id"
|
|
:actionColumn="actionColumn"
|
|
:scroll-x="scrollX"
|
|
:resizeHeightOffset="-10000"
|
|
/>
|
|
</n-card>
|
|
<ViewModal ref="viewRef" />
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, h, onMounted, reactive, ref } from 'vue';
|
|
import { useMessage } from 'naive-ui';
|
|
import { BasicTable, TableAction } from '@/components/Table';
|
|
import { BasicForm, useForm } from '@/components/Form/index';
|
|
import { List } from '@/api/imAuditLog';
|
|
import { columns, loadTenantOptions, schemas, State, tenantOptions } from './model';
|
|
import { adaTableScrollX } from '@/utils/hotgo';
|
|
import ViewModal from './view.vue';
|
|
|
|
const message = useMessage();
|
|
const actionRef = ref();
|
|
const searchFormRef = ref<any>({});
|
|
const viewRef = ref();
|
|
|
|
const actionColumn = reactive({
|
|
width: 100,
|
|
title: '操作',
|
|
key: 'action',
|
|
fixed: 'right',
|
|
render(record: State) {
|
|
return h(TableAction as any, {
|
|
style: 'button',
|
|
actions: [{ label: '详情', onClick: () => viewRef.value.openModal(record), auth: ['/imAuditLog/view'] }],
|
|
});
|
|
},
|
|
});
|
|
|
|
const scrollX = computed(() => adaTableScrollX(columns, actionColumn.width));
|
|
|
|
const [register, { setFieldsValue }] = useForm({
|
|
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
|
|
labelWidth: 90,
|
|
schemas,
|
|
});
|
|
|
|
const loadDataTable = async (res) => {
|
|
const params = { ...searchFormRef.value?.formModel, ...res };
|
|
if (!params.tenantId) return { list: [], page: 1, pageCount: 0, totalCount: 0 };
|
|
return await List(params);
|
|
};
|
|
|
|
function reloadTable() {
|
|
actionRef.value?.reload();
|
|
}
|
|
|
|
async function handleReset() {
|
|
const defaults: Recordable = {};
|
|
if (tenantOptions.value.length > 0) defaults.tenantId = tenantOptions.value[0].value;
|
|
await setFieldsValue(defaults);
|
|
reloadTable();
|
|
}
|
|
|
|
onMounted(async () => {
|
|
await loadTenantOptions();
|
|
if (tenantOptions.value.length > 0) {
|
|
await setFieldsValue({ tenantId: tenantOptions.value[0].value });
|
|
reloadTable();
|
|
} else {
|
|
message.warning('暂无可用租户');
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<style lang="less" scoped></style>
|