mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 添加请求适配adapter层应用的示例页面
This commit is contained in:
@ -1,9 +1,55 @@
|
||||
<template>
|
||||
<div>
|
||||
<n-data-table />
|
||||
<n-data-table :columns="columns" :data="tableData" :loading="loading" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts"></script>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import type { DataTableColumns } from 'naive-ui';
|
||||
import { fetchUserManagementList } from '@/service';
|
||||
import { useLoading } from '@/hooks';
|
||||
|
||||
const { loading, startLoading, endLoading } = useLoading(false);
|
||||
|
||||
const columns: DataTableColumns = [
|
||||
{
|
||||
key: 'userName',
|
||||
title: '用户名'
|
||||
},
|
||||
{
|
||||
key: 'userAge',
|
||||
title: '用户年龄'
|
||||
},
|
||||
{
|
||||
key: 'userGenderLabel',
|
||||
title: '性别'
|
||||
}
|
||||
];
|
||||
|
||||
const tableData = ref<UserManagement.UserTable[]>([]);
|
||||
|
||||
function setTableData(data: UserManagement.UserTable[]) {
|
||||
tableData.value = data;
|
||||
}
|
||||
|
||||
async function getTableData() {
|
||||
startLoading();
|
||||
const { data } = await fetchUserManagementList();
|
||||
if (data) {
|
||||
setTimeout(() => {
|
||||
setTableData(data);
|
||||
endLoading();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function init() {
|
||||
getTableData();
|
||||
}
|
||||
|
||||
// 初始化
|
||||
init();
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
|
Reference in New Issue
Block a user