96 lines
3.2 KiB
Vue
96 lines
3.2 KiB
Vue
<template>
|
|
<div>
|
|
<div class="n-layout-page-header"><n-card :bordered="false" title="用户登录历史" /></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"
|
|
:scroll-x="scrollX"
|
|
:resizeHeightOffset="-10000"
|
|
>
|
|
<template #tableTitle
|
|
><n-button
|
|
v-if="hasPermission(['/imUserLoginHistory/export'])"
|
|
type="primary"
|
|
@click="handleExport"
|
|
><template #icon
|
|
><n-icon><ExportOutlined /></n-icon></template
|
|
>导出</n-button
|
|
></template
|
|
>
|
|
</BasicTable>
|
|
</n-card>
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { computed, onMounted, ref } from 'vue';
|
|
import { useMessage } from 'naive-ui';
|
|
import { ExportOutlined } from '@vicons/antd';
|
|
import { BasicForm, useForm } from '@/components/Form/index';
|
|
import { BasicTable } from '@/components/Table';
|
|
import { usePermission } from '@/hooks/web/usePermission';
|
|
import { useUserStore } from '@/store/modules/user';
|
|
import { adaTableScrollX } from '@/utils/hotgo';
|
|
import { Export, List } from '@/api/imUserLoginHistory';
|
|
import { imQueryTenantOptions, loadImQueryTenantOptions } from '@/views/imAdminQueryShared';
|
|
import { columns, loadOptions, schemas } from './model';
|
|
|
|
const message = useMessage();
|
|
const { hasPermission } = usePermission();
|
|
const userStore = useUserStore();
|
|
const isPlatformAdmin = computed(() => userStore.isCompanyDept);
|
|
const actionRef = ref();
|
|
const searchFormRef = ref<any>({});
|
|
const tenantSchema = schemas.value.find((item) => item.field === 'tenantId');
|
|
if (tenantSchema) tenantSchema.ifShow = () => isPlatformAdmin.value;
|
|
const scrollX = computed(() => adaTableScrollX(columns, 0));
|
|
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 (isPlatformAdmin.value && !params.tenantId)
|
|
return { list: [], page: 1, pageCount: 0, totalCount: 0 };
|
|
return List(params);
|
|
};
|
|
function reloadTable() {
|
|
actionRef.value?.reload();
|
|
}
|
|
async function handleReset() {
|
|
const defaults: Recordable = {};
|
|
if (isPlatformAdmin.value) defaults.tenantId = imQueryTenantOptions.value[0]?.value;
|
|
await setFieldsValue(defaults);
|
|
reloadTable();
|
|
}
|
|
function handleExport() {
|
|
const params = { ...searchFormRef.value?.formModel };
|
|
if (isPlatformAdmin.value && !params.tenantId) {
|
|
message.warning('请选择租户');
|
|
return;
|
|
}
|
|
Export(params);
|
|
}
|
|
onMounted(async () => {
|
|
loadOptions();
|
|
if (isPlatformAdmin.value) {
|
|
await loadImQueryTenantOptions();
|
|
if (imQueryTenantOptions.value.length)
|
|
await setFieldsValue({ tenantId: imQueryTenantOptions.value[0].value });
|
|
else message.warning('暂无可用租户');
|
|
}
|
|
reloadTable();
|
|
});
|
|
</script>
|