admin-vben5/apps/web-antd/src/views/monitor/logininfor/index.vue

90 lines
2.2 KiB
Vue
Raw Normal View History

2024-08-07 08:57:56 +08:00
<script setup lang="ts">
2024-09-12 09:51:59 +08:00
import type { Recordable } from '@vben/types';
import type { LoginLog } from '#/api/monitor/logininfo/model';
import { onMounted, ref } from 'vue';
import { Page, useVbenModal } from '@vben/common-ui';
2024-09-24 11:23:02 +08:00
import { Card, Space, Table } from 'ant-design-vue';
2024-09-12 09:51:59 +08:00
2024-09-24 11:23:02 +08:00
import { useVbenForm } from '#/adapter';
2024-09-19 10:10:33 +08:00
import { loginInfoClean, loginInfoList } from '#/api/monitor/logininfo';
import { confirmDeleteModal } from '#/utils/modal';
2024-09-12 09:51:59 +08:00
2024-09-24 11:23:02 +08:00
import { columns, querySchema } from './data';
2024-09-12 09:51:59 +08:00
import loginInfoModal from './login-info-modal.vue';
const [LoginInfoModal, modalApi] = useVbenModal({
connectedComponent: loginInfoModal,
});
const loginDataList = ref<LoginLog[]>([]);
async function reload() {
const resp = await loginInfoList({ pageNum: 1, pageSize: 20 });
loginDataList.value = resp.rows;
}
onMounted(reload);
function handlePreview(record: Recordable<any>) {
modalApi.setData(record);
modalApi.open();
}
2024-09-19 10:10:33 +08:00
function handleClear() {
confirmDeleteModal({
onValidated: async () => {
await loginInfoClean();
},
});
}
2024-09-24 11:23:02 +08:00
const [QueryForm] = useVbenForm({
// 默认展开
collapsed: false,
// 所有表单项共用,可单独在表单内覆盖
commonConfig: {
// 所有表单项
componentProps: {
class: 'w-full',
},
},
schema: querySchema(),
// 是否可展开
showCollapseButton: true,
submitButtonOptions: {
text: '查询',
},
wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4',
});
2024-08-07 08:57:56 +08:00
</script>
<template>
2024-09-19 10:10:33 +08:00
<Page content-class="flex flex-col gap-[6px]">
2024-09-24 11:23:02 +08:00
<Card>
<QueryForm />
</Card>
2024-09-19 10:10:33 +08:00
<div class="flex justify-end">
<a-button @click="handleClear">{{ $t('pages.common.clear') }}</a-button>
</div>
2024-09-12 09:51:59 +08:00
<Table :columns="columns" :data-source="loginDataList" size="middle">
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'action'">
<Space>
<a-button
size="small"
type="primary"
@click="handlePreview(record)"
>
{{ $t('pages.common.info') }}
</a-button>
</Space>
</template>
</template>
</Table>
<LoginInfoModal />
</Page>
2024-08-07 08:57:56 +08:00
</template>