add 设备管理页面
This commit is contained in:
parent
3dbfb97137
commit
08568085b5
135
src/api/admin/TestequApi.ts
Normal file
135
src/api/admin/TestequApi.ts
Normal 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,
|
||||||
|
})
|
||||||
|
}
|
@ -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
|
||||||
|
}
|
||||||
|
394
src/views/admin/testequ/components/testequ-form.vue
Normal file
394
src/views/admin/testequ/components/testequ-form.vue
Normal 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) {
|
||||||
|
// 注意:API返回的key是小写的 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>
|
339
src/views/admin/testequ/index.vue
Normal file
339
src/views/admin/testequ/index.vue
Normal 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) {
|
||||||
|
// 注意:API返回的key是小写的 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) => {
|
||||||
|
// 临时调试:检查传递的row对象和id
|
||||||
|
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>
|
Loading…
x
Reference in New Issue
Block a user