Vue3 重构:地区接入 TableV2 高性能表格

This commit is contained in:
YunaiV 2023-03-18 21:45:58 +08:00
parent e669dffddc
commit c56a887767
2 changed files with 57 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import request from '@/config/axios'
// 获得地区树
export const getAreaTree = async () => {
return await request.get({ url: '/system/area/tree' })
}
// 获得 IP 对应的地区名
export const getDeptApi = async (ip: string) => {
return await request.get({ url: '/system/area/get-by-ip?ip=' + ip })
}

View File

@ -0,0 +1,46 @@
<template>
<ContentWrap>
<div style="width: 100%; height: 500px">
<el-auto-resizer>
<template #default="{ height, width }">
<el-table-v2
:columns="columns"
:data="tableData"
:width="width"
:height="height"
fixed
expand-column-key="id"
/>
</template>
</el-auto-resizer>
</div>
</ContentWrap>
</template>
<script setup lang="tsx">
import { Column, ElTableV2 } from 'element-plus'
import * as AreaApi from '@/api/system/area'
const columns: Column[] = [
{
key: 'id',
dataKey: 'id', // {id:9527,name:'Mike'}id
title: '编号', //
width: 200, //
fixed: true //
},
{
key: 'name',
dataKey: 'name',
title: '地名',
width: 200
}
]
const tableData = ref([])
const getList = async () => {
tableData.value = await AreaApi.getAreaTree()
}
getList()
</script>