与后端接口进行首次联调

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

@@ -41,6 +41,7 @@
<script lang="ts" setup>
import { FormInstance,FormItemRule } from 'element-plus'
import { ProTableInstance } from '@/components/ProTable/interface'
import { ref,computed } from 'vue'
import { Role } from '@/api/role/interface'
import {dialogSmall} from '@/utils/elementBind'
@@ -51,10 +52,11 @@
} from '@/api/role/role'
const dictStore = useDictStore()
const {dialogVisible,title,data,openType} = defineProps<{
const {dialogVisible,title,data,openType,getTableList} = defineProps<{
dialogVisible:boolean;
title:string;
openType:string;
getTableList:Function;
data:{
id?: string; //角色类型ID
name: string; //角色类型名称
@@ -81,11 +83,9 @@
}
const handleOK = () => {
console.log(data,11111)
ElMessage.info('角色数据提交')
try {
formRuleRef.value?.validate((valid: boolean) => {
try {
formRuleRef.value?.validate((valid: boolean) => {
if (valid) {
// 将表单数据转为json,发送到后端
// let confirmFormData = JSON.parse(JSON.stringify(form.value))
@@ -96,7 +96,7 @@
if(res.code === "200")
{
ElMessage.success(res.message)
updataList()
getTableList()
}
else
ElMessage.error(res.message)
@@ -109,7 +109,7 @@
if(res.code === "200")
{
ElMessage.success(res.message)
updataList()
getTableList()
}
else
ElMessage.error(res.message)

View File

@@ -30,8 +30,10 @@
:title=rolePopupTitle
:data=rolePopupData
:openType=openType
:getTableList="proTable?.getTableList || (() => {})"
@update:visible='rolePopupVisible = $event'
/>
<!-- :proTable="proTable || {} as ProTableInstance" -->
<permissionUnit
:dialogVisible=permissionUnitVisible
:title=permissionUnitTitle
@@ -55,8 +57,6 @@ import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } f
import { useDictStore } from '@/stores/modules/dict'
import {
getRoleList,
addRole,
editRole,
deleteRole,
} from '@/api/role/role'
import { deleteUser } from '@/api/user/user'
@@ -89,9 +89,9 @@ const proTable = ref<ProTableInstance>()
const dataCallback = (data: any) => {
return {
list: data.list,
total: Number(data.total),
pageNum: Number(data.pageNum),
pageSize: Number(data.pageSize),
total: data.total,
pageNum: data.pageNum,
pageSize: data.pageSize,
}
}
@@ -125,11 +125,11 @@ const columns = reactive<ColumnProps<Role.RoleBO>[]>([
minWidth: 180,
},
{
prop: 'Type',
prop: 'type',
label: '类型',
enum: dictStore.getDictData('roleType'),
fieldNames: { label: 'label', value: 'code' },
search: { el: 'input' },
search: { el: 'select' },
minWidth: 180,
},
{
@@ -143,16 +143,10 @@ const columns = reactive<ColumnProps<Role.RoleBO>[]>([
// 删除角色信息
const deleteAccount = async (params: Role.RoleBO) => {
if (params.id) {
let deleteData = { id: [params.id] }
deleteRole(deleteData).then(res => {
if (res.code === '200') {
ElMessage.success(res.message)
proTable.value?.getTableList();
} else
ElMessage.error(res.message)
})
await useHandleData(deleteRole, { id:[params.id] }, '删除所选角色信息')
proTable.value?.clearSelection()
proTable.value?.getTableList()
}
}
// 批量删除角色信息

View File

@@ -3,9 +3,11 @@
<ProTable
ref='proTable'
:columns='columns'
:data='testScriptData'
:request-api="getTableList"
:init-param="initParam"
:data-callback="dataCallback"
>
<!-- :requestApi="getRoleList" -->
<!-- :data='testScriptData' 如果要显示静态数据就切换该配置 -->
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
<el-button type='primary' :icon='CirclePlus' >新增</el-button>
@@ -45,12 +47,12 @@ import { useDictStore } from '@/stores/modules/dict'
const dictStore = useDictStore()
const testScriptData = testScriptDataList
// const testScriptData = testScriptDataList
// ProTable 实例
const proTable = ref<ProTableInstance>()
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
const initParam = reactive({ type: 1 })
const initParam = reactive({ pattern: 1 })//表示当前用户选择的是模拟式测试后期要读取pinia中的数据 TODO...
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
@@ -58,6 +60,8 @@ const dataCallback = (data: any) => {
return {
list: data.list,
total: data.total,
pageNum: data.pageNum,
pageSize: data.pageSize,
}
}
@@ -75,24 +79,38 @@ const getTableList = (params: any) => {
const { BUTTONS } = useAuthButtons()
// 表格配置项
const columns = reactive<ColumnProps<TestScript.ResTestScriptList>[]>([
const columns = reactive<ColumnProps<TestScript.TestScriptBO>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'testScriptName',
prop: 'name',
label: '名称',
search: { el: 'input' },
minWidth: 350,
},
{
prop: 'testScriptValueType',
prop: 'standardName',
label: '参照标准名称',
minWidth: 150,
},
{
prop: 'standardTime',
label: '标准推行时间',
minWidth: 150,
},
{
prop: 'valueType',
label: '值类型',
enum: dictStore.getDictData('testScriptValueType'),
fieldNames: { label: 'label', value: 'id' },
search: { el: 'select' },
minWidth: 150,
},
{
prop: 'testScriptType',
prop: 'type',
label: '模板类型',
enum: dictStore.getDictData('testScriptType'),
fieldNames: { label: 'label', value: 'id' },
search: { el: 'select' },
minWidth: 150,
},

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,
},