与后端接口进行首次联调

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

@@ -87,6 +87,89 @@ const dictData: Dict[] = [
},
],
},
{
id: "5",
code: 'testScriptValueType',
label: '检测脚本值类型',
children: [
{
id: "0",
label: '相对值',
code: 0,
},
{
id: "1",
label: '绝对值',
code: 1,
},
],
},
{
id: "6",
code: 'testScriptType',
label: '检测脚本模板类型',
children: [
{
id: "0",
label: '脚本',
code: 0,
},
{
id: "1",
label: '模板',
code: 1,
},
],
},
{
id: "7",
code: 'testSourceDevType',
label: '检测源设备类型',
children: [
{
id: "0",
label: 'FLUKE6100A电能功率标准源',
code: 0,
},
{
id: "1",
label: 'ANGLI-FP2高性能数字信号源',
code: 1,
},
{
id: "2",
label: 'DKLN-1电能质量测试分析仪智能检定装置',
code: 2,
},
{
id: "3",
label: 'PQC600A高精度电能功率标准源',
code: 3,
},
{
id: "4",
label: 'PQV-520电能质量检测装置',
code: 4,
},
],
},
{
id: "8",
code: 'testSourceType',
label: '检测源类型',
children: [
{
id: "0",
label: '标准源',
code: 0,
},
{
id: "1",
label: '高精度设备',
code: 1,
},
],
},
]
export default dictData

View File

@@ -3,22 +3,19 @@ import type { ReqPage } from '@/api/interface'
// 检测脚本模块
export namespace TestScript {
// 检测脚本列表
export interface ResTestScriptList {
id: string; //检测脚本ID
testScriptModel: string; //检测脚本模式 模拟 数字 比对
testScriptType: string; //检测脚本类型 脚本 模板
testScriptValueType: string;//检测脚本值类型名称 相对值 绝对值
testScriptName: string; //检测脚本名称
// 检测脚本接口
export interface TestScriptBO {
id?: string; //检测脚本ID
name: string; //检测脚本名称
type: string; //检测脚本类型(字典表Code字段脚本还是模板)
pattern: string;//检测脚本模式(字典表Code字段数字、模拟、比对)
valueType: string;//脚本值类型(字典表Code字段相对值脚本、绝对值脚本、无)
standardName: string;//参照标准名称
standardTime: string;//标准推行时间
}
// 检测脚本参数
// 检测脚本参数
export interface ReqTestScriptParams extends ReqPage {
id: string; //检测脚本ID
testScriptModel: string; //检测脚本模式 模拟 数字 比对
testScriptType: string; //检测脚本类型 脚本 模板
testScriptValueType: string;//检测脚本值类型名称 相对值 绝对值
testScriptName: string; //检测脚本名称
// 检测脚本+分页
export interface ReqTestScriptParams extends ReqPage,TestScriptBO {
}
}

View File

@@ -8,6 +8,6 @@ import http from '@/api'
*/
// 获取检测脚本列表
export const getTestScriptList = (params: TestScript.ReqTestScriptParams) => {
return http.post<ResPage<TestScript.ResTestScriptList>>(`/RoleList_Post`, params)
return http.post<ResPage<TestScript.TestScriptBO>>(`/testScript/list`, params)
// return http.post<ResPage<Role.ResRoleList>>(`${rePrefix}/testScript/list`, params)
}

View File

@@ -3,19 +3,18 @@ import type { ReqPage } from '@/api/interface'
// 检测源模块
export namespace TestSource {
// 检测源列表
export interface ResTestSourceList {
id: string; //检测源ID
testSourceName: string; //检测源名称
testSourceType: string; //检测源类型
testSourceModel: string; //检测源模式 标准源 高精度
// 检测源接口
export interface TestSourceBO {
id?: string; //检测源ID
name: string; //检测源名称
pattern: string;//检测源模式(字典表Code字段数字、模拟、比对)
type: string; //检测源类型(字典表Code字段标准源高精度设备)
devType: string;//检测源设备类型(字典表Code字段)
parameters: string;//源参数JSON字符串
}
// 检测源参数
export interface ReqTestSourceParams extends ReqPage {
id: string; //检测源ID
testSourceName: string; //检测源名称
testSourceType: string; //检测源类型
testSourceModel: string; //检测源模式 标准源 高精度源
// 检测源+分页
export interface ReqTestSourceParams extends ReqPage,TestSourceBO {
}
}

View File

@@ -8,6 +8,6 @@ import http from '@/api'
*/
// 获取检测脚本列表
export const getTestSourceList = (params: TestSource.ReqTestSourceParams) => {
return http.post<ResPage<TestSource.ResTestSourceList>>(`/RoleList_Post`, params)
return http.post<ResPage<TestSource.TestSourceBO>>(`/testSource/list`, params)
// return http.post<ResPage<Role.ResRoleList>>(`${rePrefix}/testSource/list`, params)
}

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