与后端接口进行首次联调

This commit is contained in:
GYYM
2024-10-31 08:51:30 +08:00
parent 6bcb22686d
commit 6c6d2fe566
9 changed files with 170 additions and 71 deletions

View File

@@ -3,9 +3,11 @@
<ProTable
ref='proTable'
:columns='columns'
:data='testSourceData'
:request-api="getTableList"
:init-param="initParam"
:data-callback="dataCallback"
>
<!-- :requestApi="getRoleList" -->
<!-- :data='testSourceData' 如果要显示静态数据就切换该配置-->
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
<el-button type='primary' :icon='CirclePlus' >新增</el-button>
@@ -44,19 +46,21 @@
const dictStore = useDictStore()
const testSourceData = testSourceDataList
// const testSourceData = testSourceDataList
// ProTable 实例
const proTable = ref<ProTableInstance>()
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
const initParam = reactive({ type: 1 })
const initParam = reactive({ pattern: 1 })//表示当前用户选择的是模拟式测试后期要读取pinia中的数据 TODO...
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
const dataCallback = (data: any) => {
return {
list: data.list,
total: data.total,
pageNum: data.pageNum,
pageSize: data.pageSize,
}
}
@@ -74,24 +78,28 @@
const { BUTTONS } = useAuthButtons()
// 表格配置项
const columns = reactive<ColumnProps<TestSource.ResTestSourceList>[]>([
const columns = reactive<ColumnProps<TestSource.TestSourceBO>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'testSourceName',
prop: 'name',
label: '名称',
search: { el: 'input' },
minWidth: 180,
},
{
prop: 'testSourceType',
label: '类型',
prop: 'devType',
label: '设备类型',
enum: dictStore.getDictData('testSourceDevType'),
fieldNames: { label: 'label', value: 'id' },
search: { el: 'select' },
minWidth: 220,
},
{
prop: 'testSourceModel',
prop: 'type',
label: '源类型',
enum: dictStore.getDictData('testSourceType'),
fieldNames: { label: 'label', value: 'id' },
search: { el: 'select' },
minWidth: 150,
},