add 设备管理页面

This commit is contained in:
Asoka 2025-06-06 15:17:12 +08:00
parent 3dbfb97137
commit 08568085b5
4 changed files with 1036 additions and 0 deletions

135
src/api/admin/TestequApi.ts Normal file
View File

@ -0,0 +1,135 @@
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/
import { ContentType, HttpClient, RequestParams } from './http-client'
import {
TestequGetPageOutput,
PageInputTestequGetPageInput,
ResultOutputPageOutputTestequGetPageOutput,
TestequGetOutput,
ResultOutputTestequGetOutput,
TestequAddInput,
TestequUpdateInput,
ResultOutputString,
ResultOutputInt64
} from './data-contracts'
export class TestequApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
/**
* @description
*
* @tags
* @name GetPage
* @summary
* @request POST:/api/admin/testing-equipment/get-page
* @secure
*/
getPage = (data: PageInputTestequGetPageInput, params: RequestParams = {}) =>
this.request<ResultOutputPageOutputTestequGetPageOutput>({
path: `/api/admin/testing-equipment/get-page`,
method: 'POST',
body: data,
secure: true,
type: ContentType.Json,
format: 'json',
...params,
})
/**
* @description
*
* @tags
* @name Get
* @summary
* @request GET:/api/admin/testing-equipment/get
* @secure
*/
get = (
query: {
/** 检测设备ID */
id: number
},
params: RequestParams = {}
) =>
this.request<ResultOutputTestequGetOutput>({
path: `/api/admin/testing-equipment/get`,
method: 'GET',
query: query,
secure: true,
format: 'json',
...params,
})
/**
* @description
*
* @tags
* @name Add
* @summary
* @request POST:/api/admin/testing-equipment/add
* @secure
*/
add = (data: TestequAddInput, params: RequestParams = {}) =>
this.request<ResultOutputInt64>({
path: `/api/admin/testing-equipment/add`,
method: 'POST',
body: data,
secure: true,
type: ContentType.Json,
format: 'json',
...params,
})
/**
* @description
*
* @tags
* @name Update
* @summary
* @request PUT:/api/admin/testing-equipment/update
* @secure
*/
update = (data: TestequUpdateInput, params: RequestParams = {}) =>
this.request<ResultOutputString>({
path: `/api/admin/testing-equipment/update`,
method: 'PUT',
body: data,
secure: true,
type: ContentType.Json,
format: 'json',
...params,
})
/**
* @description
*
* @tags
* @name SoftDelete
* @summary
* @request DELETE:/api/admin/testing-equipment/soft-delete
* @secure
*/
softDelete = (
query: {
/** 检测设备ID */
id: number
},
params: RequestParams = {}
) =>
this.request<ResultOutputString>({
path: `/api/admin/testing-equipment/soft-delete`,
method: 'DELETE',
query: query,
secure: true,
format: 'json',
...params,
})
}

View File

@ -6820,3 +6820,171 @@ export interface UspscaleGetPageOutput {
*/ */
createdTime?: string | null createdTime?: string | null
} }
/** 检测设备分页信息输入 */
export interface PageInputTestequGetPageInput {
dynamicFilter?: DynamicFilterInfo
/** 排序列表 */
sortList?: SortInput[] | null
/**
*
* @format int32
*/
currentPage?: number
/**
*
* @format int32
*/
pageSize?: number
/** 分页请求 */
filter?: TestequGetPageInput
}
/** 检测设备分页请求 */
export interface TestequGetPageInput {
/** 关键词 */
keyWord?: string | null
/** 设备类型 */
equipmentType?: number
/** 开始日期 */
stDate?: string | null
/** 结束日期 */
edDate?: string | null
}
/** 结果输出 */
export interface ResultOutputPageOutputTestequGetPageOutput {
/** 是否成功标记 */
success?: boolean
/** 编码 */
code?: string | null
/** 消息 */
msg?: string | null
/** 分页信息输出 */
data?: PageOutputTestequGetPageOutput
}
/** 分页信息输出 */
export interface PageOutputTestequGetPageOutput {
/**
*
* @format int64
*/
total?: number
/** 数据 */
list?: TestequGetPageOutput[] | null
}
/** 检测设备分页响应 */
export interface TestequGetPageOutput {
/**
*
* @format int64
*/
id?: number
/** 设备类型 */
equipmentType?: number
/** 设备编号 */
equipmentNo?: string | null
/** 序列号 */
serialNumber?: string | null
/** 私钥 */
privateKey?: string | null
/** 资产编号 */
assetNo?: string | null
/** 设备型号 */
equipmenModel?: string | null
/** 负责人ID */
principalId?: number
/** 描述 */
description?: string | null
/** 创建者 */
createdUserName?: string | null
/**
*
* @format date-time
*/
createdTime?: string | null
}
/** 结果输出 */
export interface ResultOutputTestequGetOutput {
/** 是否成功标记 */
success?: boolean
/** 编码 */
code?: string | null
/** 消息 */
msg?: string | null
/** 检测设备 */
data?: TestequGetOutput
}
/** 检测设备详情 */
export interface TestequGetOutput {
/** 设备类型 */
equipmentType?: number
/** 设备编号 */
equipmentNo?: string | null
/** 序列号 */
serialNumber?: string | null
/** 私钥 */
privateKey?: string | null
/** 资产编号 */
assetNo?: string | null
/** 设备型号 */
equipmenModel?: string | null
/** 负责人ID */
principalId?: number
/** 描述 */
description?: string | null
/**
* Id
* @format int64
*/
id: number
}
/** 检测设备添加 */
export interface TestequAddInput {
/** 设备类型 */
equipmentType?: number
/** 设备编号 */
equipmentNo?: string | null
/** 序列号 */
serialNumber?: string | null
/** 私钥 */
privateKey?: string | null
/** 资产编号 */
assetNo?: string | null
/** 设备型号 */
equipmenModel?: string | null
/** 负责人ID */
principalId?: number
/** 描述 */
description?: string | null
}
/** 检测设备修改 */
export interface TestequUpdateInput {
/** 设备类型 */
equipmentType?: number
/** 设备编号 */
equipmentNo?: string | null
/** 序列号 */
serialNumber?: string | null
/** 私钥 */
privateKey?: string | null
/** 资产编号 */
assetNo?: string | null
/** 设备型号 */
equipmenModel?: string | null
/** 负责人ID */
principalId?: number
/** 描述 */
description?: string | null
/**
* Id
* @format int64
*/
id: number
}

View File

@ -0,0 +1,394 @@
<template>
<div class="testequ-form">
<el-dialog v-model="state.isShowDialog" :title="props.title" :width="900" :close-on-click-modal="false">
<el-form ref="testequFormRef" :model="state.ruleForm" :rules="state.ruleRules" label-width="120px">
<!-- 基本信息 -->
<div class="form-section">
<div class="section-title">
<span class="title-text">基本信息</span>
<div class="title-line"></div>
</div>
<el-row :gutter="25">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="设备类型" prop="equipmentType" required>
<el-select v-model="state.ruleForm.equipmentType" placeholder="请选择设备类型" style="width: 100%">
<el-option
v-for="type in state.equipmentTypeOptions"
:key="type.value"
:label="type.label"
:value="type.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="设备编号" prop="equipmentNo" required>
<el-input v-model="state.ruleForm.equipmentNo" placeholder="请输入设备编号" />
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="25">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="资产编号" prop="assetNo" required>
<el-input v-model="state.ruleForm.assetNo" placeholder="请输入资产编号" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="设备型号" prop="equipmenModel" required>
<el-select
v-model="state.ruleForm.equipmenModel"
placeholder="请选择设备型号"
filterable
clearable
:loading="state.dictLoading"
style="width: 100%"
>
<el-option
v-for="model in state.equipmentModelOptions"
:key="model.id"
:label="model.name"
:value="model.code"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="25">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="负责人" prop="principalId" required>
<el-select
v-model="state.ruleForm.principalId"
placeholder="请选择设备负责人"
clearable
filterable
style="width: 100%"
>
<el-option
v-for="user in state.userOptions"
:key="user.id"
:label="`${user.name} (${user.userName})`"
:value="user.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
<el-form-item label="描述" prop="description">
<el-input
v-model="state.ruleForm.description"
type="textarea"
:rows="3"
placeholder="请输入设备描述"
/>
</el-form-item>
</el-col>
</el-row>
</div>
<!-- 配置信息 -->
<div class="form-section">
<div class="section-title">
<span class="title-text">配置信息</span>
<div class="title-line"></div>
</div>
<el-row :gutter="25">
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="序列号" prop="serialNumber" required>
<el-input v-model="state.ruleForm.serialNumber" placeholder="请输入序列号" />
</el-form-item>
</el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
<el-form-item label="私钥" prop="privateKey" required>
<el-input v-model="state.ruleForm.privateKey" type="password" placeholder="请输入私钥" show-password />
</el-form-item>
</el-col>
</el-row>
</div>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="onCancel">取消</el-button>
<el-button type="primary" @click="onSubmit" :loading="state.loading">确定</el-button>
</span>
</template>
</el-dialog>
</div>
</template>
<script setup lang="ts" name="TestequForm">
import { reactive, ref, getCurrentInstance, onMounted } from 'vue'
import { TestequApi } from '/@/api/admin/TestequApi'
import { UserApi } from '/@/api/admin/User'
import { DictApi } from '/@/api/admin/Dict'
import { UserGetPageOutput, PageInputUserGetPageInput, TestequAddInput, TestequUpdateInput, DictGetListOutput } from '/@/api/admin/data-contracts'
import eventBus from '/@/utils/mitt'
//
const props = defineProps({
title: String,
})
// /
const emit = defineEmits(['refresh'])
//
const testequFormRef = ref()
const { proxy } = getCurrentInstance() as any
//
type TestequFormData = {
id?: number
equipmentType: number | undefined
equipmentNo: string
serialNumber: string
privateKey: string
assetNo: string
equipmenModel: string
principalId: number | undefined
description: string
}
const state = reactive({
isShowDialog: false,
loading: false,
dictLoading: false,
ruleForm: {
id: undefined,
equipmentType: undefined,
equipmentNo: '',
serialNumber: '',
privateKey: '',
assetNo: '',
equipmenModel: '',
principalId: undefined,
description: '',
} as TestequFormData,
userOptions: [] as Array<UserGetPageOutput>,
equipmentModelOptions: [] as Array<DictGetListOutput>,
equipmentTypeOptions: [
{ label: 'BGA', value: 1 },
{ label: 'Vicell', value: 3 },
{ label: 'OSMO', value: 5 },
{ label: 'Cedex', value: 7 }
],
ruleRules: {
equipmentType: [{ required: true, message: '设备类型不能为空', trigger: 'change' }],
equipmentNo: [
{ required: true, message: '设备编号不能为空', trigger: 'blur' },
{ min: 1, max: 50, message: '设备编号长度应在1-50个字符', trigger: 'blur' }
],
assetNo: [
{ required: true, message: '资产编号不能为空', trigger: 'blur' },
{ min: 1, max: 50, message: '资产编号长度应在1-50个字符', trigger: 'blur' }
],
equipmenModel: [{ required: true, message: '设备型号不能为空', trigger: 'change' }],
principalId: [{ required: true, message: '负责人不能为空', trigger: 'change' }],
serialNumber: [
{ required: true, message: '序列号不能为空', trigger: 'blur' },
{ min: 1, max: 100, message: '序列号长度应在1-100个字符', trigger: 'blur' }
],
privateKey: [
{ required: true, message: '私钥不能为空', trigger: 'blur' },
{ min: 1, max: 200, message: '私钥长度应在1-200个字符', trigger: 'blur' }
],
},
})
onMounted(() => {
getUserOptions()
getEquipmentModelOptions()
})
//
const openDialog = async (row?: any) => {
resetForm()
//
if (state.equipmentModelOptions.length === 0) {
state.dictLoading = true
await getEquipmentModelOptions()
state.dictLoading = false
}
//
if (state.userOptions.length === 0) {
await getUserOptions()
}
if (row && row.id) {
//
try {
const res = await new TestequApi().get({ id: row.id })
if (res?.success && res.data) {
state.ruleForm = {
id: res.data.id,
equipmentType: res.data.equipmentType,
equipmentNo: res.data.equipmentNo || '',
serialNumber: res.data.serialNumber || '',
privateKey: res.data.privateKey || '',
assetNo: res.data.assetNo || '',
equipmenModel: res.data.equipmenModel || '',
principalId: res.data.principalId,
description: res.data.description || '',
}
}
} catch (error: any) {
//
if (error.response?.status === 500) {
proxy.$modal.msgError('服务器内部错误,请检查后台服务')
} else {
proxy.$modal.msgError(`获取详情失败: ${error.response?.data?.msg || error.message}`)
}
return
}
}
state.isShowDialog = true
}
//
const closeDialog = () => {
state.isShowDialog = false
resetForm()
}
//
const resetForm = () => {
state.ruleForm = {
id: undefined,
equipmentType: undefined,
equipmentNo: '',
serialNumber: '',
privateKey: '',
assetNo: '',
equipmenModel: '',
principalId: undefined,
description: '',
}
}
//
const getUserOptions = async () => {
try {
const userPageInput = {
currentPage: 1,
pageSize: 1000, //
filter: {
orgId: null,
}
} as PageInputUserGetPageInput
const res = await new UserApi().getPage(userPageInput)
if (res?.success) {
state.userOptions = res.data?.list ?? []
}
} catch (error) {
//
}
}
//
const getEquipmentModelOptions = async () => {
try {
const res = await new DictApi().getList(['TESTINGEQU'])
if (res?.success && res.data) {
// APIkey testingequ
state.equipmentModelOptions = res.data['testingequ'] || []
}
} catch (error) {
//
}
}
//
const onCancel = () => {
closeDialog()
}
//
const onSubmit = () => {
testequFormRef.value.validate(async (valid: boolean) => {
if (!valid) return false
state.loading = true
try {
let res = {} as any
if (state.ruleForm.id) {
res = await new TestequApi().update(state.ruleForm as TestequUpdateInput, { showSuccessMessage: true })
} else {
res = await new TestequApi().add(state.ruleForm as TestequAddInput, { showSuccessMessage: true })
}
if (res?.success) {
closeDialog()
emit('refresh')
eventBus.emit('refreshTestequ' as keyof MittType<any>)
}
} catch (error: any) {
//
proxy.$modal.msgError('操作失败')
} finally {
state.loading = false
}
})
}
//
defineExpose({
openDialog,
closeDialog,
})
</script>
<style scoped lang="scss">
.testequ-form {
.form-section {
margin-bottom: 30px;
&:last-child {
margin-bottom: 0;
}
}
.section-title {
display: flex;
align-items: center;
margin-bottom: 20px;
.title-text {
font-size: 16px;
font-weight: 600;
color: #303133;
margin-right: 15px;
white-space: nowrap;
}
.title-line {
flex: 1;
height: 1px;
background: linear-gradient(to right, #409eff, transparent);
}
}
:deep(.el-form-item) {
margin-bottom: 20px;
}
:deep(.el-input),
:deep(.el-select) {
width: 100%;
}
:deep(.el-textarea .el-textarea__inner) {
resize: vertical;
min-height: 80px;
}
}
</style>

View File

@ -0,0 +1,339 @@
<template>
<MyLayout>
<el-card v-show="state.showQuery" class="my-query-box mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
<el-form :inline="true" label-width="auto" @submit.stop.prevent>
<el-form-item label="关键词">
<el-input v-model="state.filter.keyWord" placeholder="设备编号、序列号、资产编号" @keyup.enter="onQuery" />
</el-form-item>
<el-form-item label="设备类型">
<el-select v-model="state.filter.equipmentType" placeholder="请选择设备类型" clearable style="width: 150px">
<el-option
v-for="type in state.equipmentTypeOptions"
:key="type.value"
:label="type.label"
:value="type.value"
/>
</el-select>
</el-form-item>
<el-form-item label="开始时间">
<el-date-picker
v-model="state.filter.stDate"
type="datetime"
placeholder="选择开始时间"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 180px"
/>
</el-form-item>
<el-form-item label="结束时间">
<el-date-picker
v-model="state.filter.edDate"
type="datetime"
placeholder="选择结束时间"
format="YYYY-MM-DD HH:mm:ss"
value-format="YYYY-MM-DD HH:mm:ss"
style="width: 180px"
/>
</el-form-item>
<el-form-item>
<el-button v-if="auth('api:admin:testing-equipment:get-page')" @click="onQuery" type="primary">
<SvgIcon name="ele-Search" />查询
</el-button>
<el-button v-auth="'api:admin:testing-equipment:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增 </el-button>
</el-form-item>
</el-form>
</el-card>
<el-card class="my-fill mt8" shadow="never">
<div class="my-tools-box mb8 my-flex my-flex-between">
<div>
</div>
</div>
<el-table
v-if="state.showTestequList"
:data="state.testequListData"
style="width: 100%"
v-loading="state.loading"
row-key="id"
default-expand-all
border
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<el-table-column prop="equipmentType" label="设备类型" width="100" align="center" show-overflow-tooltip>
<template #default="{ row }">
{{ getEquipmentTypeName(row.equipmentType) }}
</template>
</el-table-column>
<el-table-column prop="equipmentNo" label="设备编号" min-width="120" show-overflow-tooltip />
<el-table-column prop="assetNo" label="资产编号" min-width="120" show-overflow-tooltip />
<el-table-column label="设备型号" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
{{ getEquipmentModelName(row.equipmenModel) }}
</template>
</el-table-column>
<el-table-column prop="description" label="描述" min-width="150" show-overflow-tooltip />
<el-table-column prop="principalId" label="负责人" width="120" align="center" show-overflow-tooltip>
<template #default="{ row }">
{{ getUserName(row.principalId) }}
</template>
</el-table-column>
<el-table-column label="操作" width="200" fixed="right" header-align="center" align="center">
<template #default="{ row }">
<el-button
v-if="auth('api:admin:testing-equipment:update')"
icon="ele-EditPen"
size="small"
text
type="primary"
@click="onEdit(row)"
>编辑</el-button
>
<el-button
v-if="auth('api:admin:testing-equipment:soft-delete')"
icon="ele-Delete"
size="small"
text
type="danger"
@click="onDelete(row)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<div class="my-flex my-flex-end" style="margin-top: 10px">
<el-pagination
v-model:currentPage="state.pageInput.currentPage"
v-model:page-size="state.pageInput.pageSize"
:total="state.total"
:page-sizes="[10, 20, 50, 100]"
size="small"
background
@size-change="onSizeChange"
@current-change="onCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
/>
</div>
</el-card>
<testequ-form ref="testequFormRef" :title="state.testequFormTitle"></testequ-form>
</MyLayout>
</template>
<script lang="ts" setup name="admin/testequ">
import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
import { TestequApi } from '/@/api/admin/TestequApi'
import { UserApi } from '/@/api/admin/User'
import { DictApi } from '/@/api/admin/Dict'
import { UserGetPageOutput, PageInputUserGetPageInput, TestequGetPageOutput, PageInputTestequGetPageInput, DictGetListOutput } from '/@/api/admin/data-contracts'
import eventBus from '/@/utils/mitt'
import { auth } from '/@/utils/authFunction'
//
const TestequForm = defineAsyncComponent(() => import('./components/testequ-form.vue'))
const { proxy } = getCurrentInstance() as any
const testequFormRef = ref()
const state = reactive({
loading: false,
testequFormTitle: '',
filter: {
keyWord: '',
equipmentType: undefined as number | undefined,
stDate: '',
edDate: '',
},
total: 0,
pageInput: {
currentPage: 1,
pageSize: 20,
} as PageInputTestequGetPageInput,
testequListData: [] as Array<TestequGetPageOutput>,
userOptions: [] as Array<UserGetPageOutput>,
equipmentModelOptions: [] as Array<DictGetListOutput>,
equipmentTypeOptions: [
{ label: 'BGA', value: 1 },
{ label: 'Vicell', value: 3 },
{ label: 'OSMO', value: 5 },
{ label: 'Cedex', value: 7 }
],
showQuery: true,
showTestequList: true,
})
onMounted(() => {
getUserOptions()
getEquipmentModelOptions()
Query()
eventBus.off('refreshTestequ' as keyof MittType<any>)
eventBus.on('refreshTestequ' as keyof MittType<any>, () => {
Query()
})
})
onBeforeMount(() => {
eventBus.off('refreshTestequ' as keyof MittType<any>)
})
const onChangeTestequList = () => {
state.showTestequList = !state.showTestequList
if (state.showTestequList) {
Query()
}
}
//
const getUserOptions = async () => {
try {
const userPageInput = {
currentPage: 1,
pageSize: 1000, //
filter: {
orgId: null,
}
} as PageInputUserGetPageInput
const res = await new UserApi().getPage(userPageInput)
if (res?.success) {
state.userOptions = res.data?.list ?? []
}
} catch (error) {
//
}
}
//
const getEquipmentModelOptions = async () => {
try {
const res = await new DictApi().getList(['TESTINGEQU'])
if (res?.success && res.data) {
// APIkey testingequ
state.equipmentModelOptions = res.data['testingequ'] || []
}
} catch (error) {
//
}
}
//
const getEquipmentTypeName = (type: number) => {
const option = state.equipmentTypeOptions.find(item => item.value === type)
return option ? option.label : type?.toString() || ''
}
//
const getUserName = (userId?: number) => {
if (!userId) return ''
const user = state.userOptions.find(item => item.id === userId)
return user ? `${user.name} (${user.userName})` : `未知用户(${userId})`
}
//
const getEquipmentModelName = (code?: string) => {
if (!code) return ''
const model = state.equipmentModelOptions.find(item => item.code === code)
return model ? model.name : code
}
//
const Query = async () => {
state.loading = true
try {
// filter
state.pageInput.filter = {
keyWord: state.filter.keyWord || '',
equipmentType: state.filter.equipmentType ? Number(state.filter.equipmentType) : undefined,
stDate: state.filter.stDate || null,
edDate: state.filter.edDate || null,
}
const res = await new TestequApi().getPage(state.pageInput)
if (res?.success && res.data) {
state.testequListData = res.data.list || []
state.total = res.data.total || 0
} else {
proxy.$modal.msgError(res?.msg || '查询失败')
}
} catch (error: any) {
//
if (error.response) {
if (error.response.status === 500) {
proxy.$modal.msgError('服务器内部错误,请检查后台服务')
} else if (error.response.status === 401) {
proxy.$modal.msgError('认证失败,请重新登录')
} else if (error.response.status === 403) {
proxy.$modal.msgError('权限不足')
} else if (error.response.status === 405) {
proxy.$modal.msgError('API方法不被允许请检查后端路由配置')
} else {
proxy.$modal.msgError(`请求失败: ${error.response.status} ${error.response.statusText}`)
}
} else if (error.request) {
proxy.$modal.msgError('网络连接失败,请检查网络状态')
} else {
proxy.$modal.msgError(`查询失败: ${error.message}`)
}
} finally {
state.loading = false
}
}
const onQuery = () => {
state.pageInput.currentPage = 1
Query()
}
const onAdd = () => {
state.testequFormTitle = '新增检测设备'
testequFormRef.value.openDialog()
}
const onEdit = (row: TestequGetPageOutput) => {
state.testequFormTitle = '编辑检测设备'
testequFormRef.value.openDialog(row)
}
const onDelete = (row: TestequGetPageOutput) => {
// rowid
console.log('删除操作 - 传入的row对象:', row)
console.log('删除操作 - ID值:', row.id, '类型:', typeof row.id)
proxy.$modal
.confirmDelete(`确定要删除设备【${row.equipmentNo || row.assetNo || '未知设备'}】?`)
.then(async () => {
try {
console.log('发送删除请求 - ID参数:', { id: row.id! })
const res = await new TestequApi().softDelete({ id: row.id! }, { loading: true })
console.log('删除API响应:', res)
if (res?.success) {
proxy.$modal.msgSuccess('删除成功')
Query()
}
} catch (error: any) {
console.error('删除API错误:', error)
//
if (error.response?.status === 500) {
proxy.$modal.msgError('服务器内部错误,请检查后台服务')
} else {
proxy.$modal.msgError(`删除失败: ${error.response?.data?.msg || error.message}`)
}
}
})
.catch(() => {})
}
const onSizeChange = (val: number) => {
state.pageInput.pageSize = val
Query()
}
const onCurrentChange = (val: number) => {
state.pageInput.currentPage = val
Query()
}
</script>