与后端接口进行首次联调

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 export default dictData

View File

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

View File

@@ -8,6 +8,6 @@ import http from '@/api'
*/ */
// 获取检测脚本列表 // 获取检测脚本列表
export const getTestScriptList = (params: TestScript.ReqTestScriptParams) => { 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) // 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 namespace TestSource {
// 检测源列表 // 检测源接口
export interface ResTestSourceList { export interface TestSourceBO {
id: string; //检测源ID id?: string; //检测源ID
testSourceName: string; //检测源名称 name: string; //检测源名称
testSourceType: string; //检测源类型 pattern: string;//检测源模式(字典表Code字段数字、模拟、比对)
testSourceModel: string; //检测源模式 标准源 高精度 type: string; //检测源类型(字典表Code字段标准源高精度设备)
devType: string;//检测源设备类型(字典表Code字段)
parameters: string;//源参数JSON字符串
} }
// 检测源参数 // 检测源+分页
export interface ReqTestSourceParams extends ReqPage { export interface ReqTestSourceParams extends ReqPage,TestSourceBO {
id: string; //检测源ID
testSourceName: string; //检测源名称
testSourceType: string; //检测源类型
testSourceModel: string; //检测源模式 标准源 高精度源
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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