add 报警器相关界面
This commit is contained in:
parent
a671524610
commit
7d0b4e76c5
126
src/api/admin/AlarmApi.ts
Normal file
126
src/api/admin/AlarmApi.ts
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
/* tslint:disable */
|
||||||
|
/*
|
||||||
|
* ---------------------------------------------------------------
|
||||||
|
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
|
||||||
|
* ## ##
|
||||||
|
* ## AUTHOR: adademo / https://github.com/adademo/swagger-typescript-api ##
|
||||||
|
* ## SOURCE: https://github.com/adademo/swagger-typescript-api ##
|
||||||
|
* ---------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
AlarmAddInput,
|
||||||
|
AlarmUpdateInput,
|
||||||
|
PageInputAlarmGetPageInput,
|
||||||
|
ResultOutputAlarmGetOutput,
|
||||||
|
ResultOutputPageOutputAlarmGetPageOutput,
|
||||||
|
ResultOutputInt64,
|
||||||
|
} from './data-contracts';
|
||||||
|
import { ContentType, HttpClient, RequestParams } from './http-client';
|
||||||
|
import { AxiosResponse } from 'axios';
|
||||||
|
|
||||||
|
export class AlarmApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
|
||||||
|
/**
|
||||||
|
* @description No description
|
||||||
|
* @tags Alarm - 报警器管理
|
||||||
|
* @name Get
|
||||||
|
* @summary 查询报警器
|
||||||
|
* @request GET:/api/admin/usp-alarm/get
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
get = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number;
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<ResultOutputAlarmGetOutput, any>({
|
||||||
|
path: `/api/admin/usp-alarm/get`,
|
||||||
|
method: 'GET',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description No description
|
||||||
|
* @tags Alarm - 报警器管理
|
||||||
|
* @name GetPage
|
||||||
|
* @summary 查询报警器分页
|
||||||
|
* @request POST:/api/admin/usp-alarm/get-page
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
getPage = (data: PageInputAlarmGetPageInput, params: RequestParams = {}) =>
|
||||||
|
this.request<ResultOutputPageOutputAlarmGetPageOutput, any>({
|
||||||
|
path: `/api/admin/usp-alarm/get-page`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description No description
|
||||||
|
* @tags Alarm - 报警器管理
|
||||||
|
* @name Add
|
||||||
|
* @summary 新增报警器
|
||||||
|
* @request POST:/api/admin/usp-alarm/add
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
add = (data: AlarmAddInput, params: RequestParams = {}) =>
|
||||||
|
this.request<ResultOutputInt64, any>({
|
||||||
|
path: `/api/admin/usp-alarm/add`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
format: 'json',
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description No description
|
||||||
|
* @tags Alarm - 报警器管理
|
||||||
|
* @name Update
|
||||||
|
* @summary 修改报警器
|
||||||
|
* @request PUT:/api/admin/usp-alarm/update
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
update = (data: AlarmUpdateInput, params: RequestParams = {}) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/usp-alarm/update`,
|
||||||
|
method: 'PUT',
|
||||||
|
body: data,
|
||||||
|
secure: true,
|
||||||
|
type: ContentType.Json,
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description No description
|
||||||
|
* @tags Alarm - 报警器管理
|
||||||
|
* @name SoftDelete
|
||||||
|
* @summary 删除报警器
|
||||||
|
* @request DELETE:/api/admin/usp-alarm/soft-delete
|
||||||
|
* @secure
|
||||||
|
*/
|
||||||
|
softDelete = (
|
||||||
|
query?: {
|
||||||
|
/** @format int64 */
|
||||||
|
id?: number;
|
||||||
|
},
|
||||||
|
params: RequestParams = {}
|
||||||
|
) =>
|
||||||
|
this.request<AxiosResponse, any>({
|
||||||
|
path: `/api/admin/usp-alarm/soft-delete`,
|
||||||
|
method: 'DELETE',
|
||||||
|
query: query,
|
||||||
|
secure: true,
|
||||||
|
...params,
|
||||||
|
});
|
||||||
|
}
|
@ -7295,3 +7295,180 @@ export interface FeedingConfigGetListOutput {
|
|||||||
/** 启用状态 */
|
/** 启用状态 */
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 报警器分页 */
|
||||||
|
export interface PageOutputAlarmGetPageOutput {
|
||||||
|
/**
|
||||||
|
* 数据总数
|
||||||
|
* @format int64
|
||||||
|
*/
|
||||||
|
total?: number;
|
||||||
|
/** 数据 */
|
||||||
|
list?: AlarmGetPageOutput[] | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================================================
|
||||||
|
// 报警器管理
|
||||||
|
// ===================================================
|
||||||
|
|
||||||
|
/** 添加报警器 */
|
||||||
|
export interface AlarmAddInput {
|
||||||
|
/** 设备编号 */
|
||||||
|
deviceNo?: string | null;
|
||||||
|
/** 资产编号 */
|
||||||
|
assetNo?: string | null;
|
||||||
|
/** 房间ID */
|
||||||
|
roomId?: number;
|
||||||
|
/** IP地址 */
|
||||||
|
ip?: string | null;
|
||||||
|
/** 端口 */
|
||||||
|
port?: string | null;
|
||||||
|
/** 服务名称 */
|
||||||
|
serviceName?: string | null;
|
||||||
|
/** 启用状态 */
|
||||||
|
status?: boolean;
|
||||||
|
/** 运行状态 */
|
||||||
|
isRuning?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 修改报警器 */
|
||||||
|
export interface AlarmUpdateInput {
|
||||||
|
/**
|
||||||
|
* 主键Id
|
||||||
|
* @format int64
|
||||||
|
*/
|
||||||
|
id: number;
|
||||||
|
/** 设备编号 */
|
||||||
|
deviceNo?: string | null;
|
||||||
|
/** 资产编号 */
|
||||||
|
assetNo?: string | null;
|
||||||
|
/** 房间ID */
|
||||||
|
roomId?: number;
|
||||||
|
/** IP地址 */
|
||||||
|
ip?: string | null;
|
||||||
|
/** 端口 */
|
||||||
|
port?: string | null;
|
||||||
|
/** 服务名称 */
|
||||||
|
serviceName?: string | null;
|
||||||
|
/** 启用状态 */
|
||||||
|
status?: boolean;
|
||||||
|
/** 运行状态 */
|
||||||
|
isRuning?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 报警器分页查询条件 */
|
||||||
|
export interface AlarmGetPageInput {
|
||||||
|
/** 关键词 */
|
||||||
|
keyWord?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 报警器信息 */
|
||||||
|
export interface AlarmGetOutput {
|
||||||
|
/**
|
||||||
|
* 主键Id
|
||||||
|
* @format int64
|
||||||
|
*/
|
||||||
|
id: number;
|
||||||
|
/** 设备编号 */
|
||||||
|
deviceNo?: string | null;
|
||||||
|
/** 资产编号 */
|
||||||
|
assetNo?: string | null;
|
||||||
|
/** 房间ID */
|
||||||
|
roomId?: number;
|
||||||
|
/** IP地址 */
|
||||||
|
ip?: string | null;
|
||||||
|
/** 端口 */
|
||||||
|
port?: string | null;
|
||||||
|
/** 服务名称 */
|
||||||
|
serviceName?: string | null;
|
||||||
|
/** 启用状态 */
|
||||||
|
status?: boolean;
|
||||||
|
/** 运行状态 */
|
||||||
|
isRunning?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 报警器分页信息 */
|
||||||
|
export interface AlarmGetPageOutput {
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
* @format int64
|
||||||
|
*/
|
||||||
|
id?: number;
|
||||||
|
/** 设备编号 */
|
||||||
|
deviceNo?: string | null;
|
||||||
|
/** 资产编号 */
|
||||||
|
assetNo?: string | null;
|
||||||
|
/** 房间ID */
|
||||||
|
roomId?: number;
|
||||||
|
/** IP地址 */
|
||||||
|
ip?: string | null;
|
||||||
|
/** 端口 */
|
||||||
|
port?: string | null;
|
||||||
|
/** 服务名称 */
|
||||||
|
serviceName?: string | null;
|
||||||
|
/** 启用状态 */
|
||||||
|
status?: boolean;
|
||||||
|
/** 运行状态 */
|
||||||
|
isRunning?: number;
|
||||||
|
/** 创建者 */
|
||||||
|
createdUserName?: string | null;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
* @format date-time
|
||||||
|
*/
|
||||||
|
createdTime?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 报警器分页查询 */
|
||||||
|
export interface PageInputAlarmGetPageInput {
|
||||||
|
dynamicFilter?: DynamicFilterInfo;
|
||||||
|
/** 排序列表 */
|
||||||
|
sortList?: SortInput[] | null;
|
||||||
|
/**
|
||||||
|
* 当前页标
|
||||||
|
* @format int32
|
||||||
|
*/
|
||||||
|
currentPage?: number;
|
||||||
|
/**
|
||||||
|
* 每页大小
|
||||||
|
* @format int32
|
||||||
|
*/
|
||||||
|
pageSize?: number;
|
||||||
|
/** 分页请求 */
|
||||||
|
filter?: AlarmGetPageInput;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单条报警器查询结果 */
|
||||||
|
export interface ResultOutputAlarmGetOutput {
|
||||||
|
/** 是否成功标记 */
|
||||||
|
success?: boolean;
|
||||||
|
/** 编码 */
|
||||||
|
code?: string | null;
|
||||||
|
/** 消息 */
|
||||||
|
msg?: string | null;
|
||||||
|
/** 报警器信息 */
|
||||||
|
data?: AlarmGetOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 报警器分页查询结果 */
|
||||||
|
export interface ResultOutputPageOutputAlarmGetPageOutput {
|
||||||
|
/** 是否成功标记 */
|
||||||
|
success?: boolean;
|
||||||
|
/** 编码 */
|
||||||
|
code?: string | null;
|
||||||
|
/** 消息 */
|
||||||
|
msg?: string | null;
|
||||||
|
/** 分页信息输出 */
|
||||||
|
data?: PageOutputAlarmGetPageOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 报警器分页 */
|
||||||
|
export interface PageOutputAlarmGetPageOutput {
|
||||||
|
/**
|
||||||
|
* 数据总数
|
||||||
|
* @format int64
|
||||||
|
*/
|
||||||
|
total?: number;
|
||||||
|
/** 数据 */
|
||||||
|
list?: AlarmGetPageOutput[] | null;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="airpump-form">
|
<div class="pump-form">
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="state.isShowDialog"
|
v-model="state.isShowDialog"
|
||||||
destroy-on-close
|
destroy-on-close
|
||||||
@ -9,7 +9,7 @@
|
|||||||
:close-on-press-escape="false"
|
:close-on-press-escape="false"
|
||||||
width="900px"
|
width="900px"
|
||||||
>
|
>
|
||||||
<el-form ref="airpumpFormRef" :model="state.ruleForm" :rules="state.ruleRules" label-width="120px">
|
<el-form ref="pumpFormRef" :model="state.ruleForm" :rules="state.ruleRules" label-width="120px">
|
||||||
|
|
||||||
<!-- 基本信息 -->
|
<!-- 基本信息 -->
|
||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
@ -73,24 +73,6 @@
|
|||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
|
||||||
<el-form-item label="泵速策略" prop="configId">
|
|
||||||
<el-select
|
|
||||||
v-model="state.ruleForm.configId"
|
|
||||||
placeholder="请选择泵速策略"
|
|
||||||
clearable
|
|
||||||
style="width: 100%"
|
|
||||||
:loading="state.configLoading"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="config in state.configOptions"
|
|
||||||
:key="config.id"
|
|
||||||
:label="`${config.name} (${config.pumpSpeed}g/min)`"
|
|
||||||
:value="config.id"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -100,20 +82,20 @@
|
|||||||
|
|
||||||
<el-row :gutter="25">
|
<el-row :gutter="25">
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
<el-form-item label="泵速(g/min)" prop="pumpSpeed" required>
|
<el-form-item label="工作泵速(g/min)" prop="workingSpeed" required>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="state.ruleForm.pumpSpeed"
|
v-model="state.ruleForm.workingSpeed"
|
||||||
:min="0"
|
:min="0"
|
||||||
:precision="2"
|
:precision="2"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
placeholder="请输入泵速"
|
placeholder="请输入工作泵速"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
<el-form-item label="超时(s)" prop="pumpTimeout" required>
|
<el-form-item label="时长:(s)" prop="workingTime" required>
|
||||||
<el-input-number
|
<el-input-number
|
||||||
v-model="state.ruleForm.pumpTimeout"
|
v-model="state.ruleForm.workingTime"
|
||||||
:min="0"
|
:min="0"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
placeholder="请输入超时时间"
|
placeholder="请输入超时时间"
|
||||||
@ -190,9 +172,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="AirPumpForm">
|
<script setup lang="ts" name="PumpForm">
|
||||||
import { reactive, ref, getCurrentInstance, onMounted } from 'vue'
|
import { reactive, ref, getCurrentInstance, onMounted } from 'vue'
|
||||||
import { AirPumpApi } from '/@/api/admin/AirPumpApi'
|
import { PumpApi } from '/@/api/admin/PumpApi'
|
||||||
import { UserApi } from '/@/api/admin/User'
|
import { UserApi } from '/@/api/admin/User'
|
||||||
import { FeedingConfigApi } from '/@/api/admin/FeedingConfigApi'
|
import { FeedingConfigApi } from '/@/api/admin/FeedingConfigApi'
|
||||||
import { DictApi } from '/@/api/admin/Dict'
|
import { DictApi } from '/@/api/admin/Dict'
|
||||||
@ -208,11 +190,11 @@ const props = defineProps({
|
|||||||
const emit = defineEmits(['refresh'])
|
const emit = defineEmits(['refresh'])
|
||||||
|
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const airpumpFormRef = ref()
|
const pumpFormRef = ref()
|
||||||
const { proxy } = getCurrentInstance() as any
|
const { proxy } = getCurrentInstance() as any
|
||||||
|
|
||||||
// 临时类型定义
|
// 临时类型定义
|
||||||
type AirPumpFormData = {
|
type PumpFormData = {
|
||||||
id?: number
|
id?: number
|
||||||
deviceNo: string
|
deviceNo: string
|
||||||
assetNo: string
|
assetNo: string
|
||||||
@ -227,7 +209,9 @@ type AirPumpFormData = {
|
|||||||
speedCoefficient: number
|
speedCoefficient: number
|
||||||
serviceName: string
|
serviceName: string
|
||||||
isAirPump: boolean
|
isAirPump: boolean
|
||||||
configId: number | undefined
|
configId: number | undefined,
|
||||||
|
workingSpeed: number,
|
||||||
|
workingTime: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@ -241,6 +225,8 @@ const state = reactive({
|
|||||||
model: '',
|
model: '',
|
||||||
specification: '',
|
specification: '',
|
||||||
pumpSpeed: 0,
|
pumpSpeed: 0,
|
||||||
|
workingSpeed: 0,
|
||||||
|
workingTime: 0,
|
||||||
principalId: undefined,
|
principalId: undefined,
|
||||||
pumpTimeout: 0,
|
pumpTimeout: 0,
|
||||||
maintenanceFlag: 1,
|
maintenanceFlag: 1,
|
||||||
@ -248,32 +234,141 @@ const state = reactive({
|
|||||||
port: '',
|
port: '',
|
||||||
speedCoefficient: 0,
|
speedCoefficient: 0,
|
||||||
serviceName: '',
|
serviceName: '',
|
||||||
isAirPump: true, // 默认为气泵
|
isAirPump: false,
|
||||||
configId: undefined,
|
configId: undefined,
|
||||||
} as AirPumpFormData,
|
} as PumpFormData,
|
||||||
ruleRules: {
|
|
||||||
deviceNo: [{ required: true, message: '请输入设备编号', trigger: 'blur' }],
|
|
||||||
assetNo: [{ required: true, message: '请输入资产编号', trigger: 'blur' }],
|
|
||||||
model: [{ required: true, message: '请选择设备型号', trigger: 'change' }],
|
|
||||||
specification: [{ required: true, message: '请输入设备规格', trigger: 'blur' }],
|
|
||||||
pumpSpeed: [{ required: true, message: '请输入泵速', trigger: 'blur' }],
|
|
||||||
principalId: [{ required: true, message: '请选择设备负责人', trigger: 'change' }],
|
|
||||||
pumpTimeout: [{ required: true, message: '请输入超时时间', trigger: 'blur' }],
|
|
||||||
ip: [{ required: true, message: '请输入IP地址', trigger: 'blur' }],
|
|
||||||
port: [{ required: true, message: '请输入端口号', trigger: 'blur' }],
|
|
||||||
speedCoefficient: [{ required: true, message: '请输入泵速系数', trigger: 'blur' }],
|
|
||||||
},
|
|
||||||
userOptions: [] as Array<UserGetPageOutput>,
|
userOptions: [] as Array<UserGetPageOutput>,
|
||||||
configOptions: [] as Array<FeedingConfigGetListOutput>,
|
configOptions: [] as Array<FeedingConfigGetListOutput>,
|
||||||
modelOptions: [] as Array<DictGetListOutput>,
|
modelOptions: [] as Array<DictGetListOutput>,
|
||||||
maintenanceStatusOptions: [
|
maintenanceStatusOptions: [
|
||||||
{ value: 0, label: 'Offline' },
|
{ label: 'Offline', value: 0 },
|
||||||
{ value: 1, label: 'Idle' },
|
{ label: 'Idle', value: 1 },
|
||||||
{ value: 2, label: 'Busy' },
|
{ label: 'Busy', value: 2 },
|
||||||
{ value: 3, label: 'Error' },
|
{ label: 'Error', value: 3 },
|
||||||
],
|
],
|
||||||
|
ruleRules: {
|
||||||
|
deviceNo: [
|
||||||
|
{ 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' }
|
||||||
|
],
|
||||||
|
model: [{ required: true, message: '设备型号不能为空', trigger: 'change' }],
|
||||||
|
specification: [
|
||||||
|
{ required: true, message: '规格不能为空', trigger: 'blur' },
|
||||||
|
{ min: 1, max: 100, message: '规格长度应在1-100个字符', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
principalId: [{ required: true, message: '设备负责人不能为空', trigger: 'change' }],
|
||||||
|
pumpSpeed: [{ required: true, message: '泵速不能为空', trigger: 'blur' }],
|
||||||
|
pumpTimeout: [{ required: true, message: '超时时间不能为空', trigger: 'blur' }],
|
||||||
|
workingSpeed: [{ required: true, message: '工作泵速不能为空', trigger: 'blur' }],
|
||||||
|
workingTime: [{ required: true, message: '时长不能为空', trigger: 'blur' }],
|
||||||
|
speedCoefficient: [{ required: true, message: '泵速系数不能为空', trigger: 'blur' }],
|
||||||
|
ip: [
|
||||||
|
{ required: true, message: 'IP地址不能为空', trigger: 'blur' },
|
||||||
|
{ pattern: /^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$/, message: '请输入正确的IP地址格式', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
port: [
|
||||||
|
{ required: true, message: '端口号不能为空', trigger: 'blur' },
|
||||||
|
{ pattern: /^([0-9]|[1-9]\d{1,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$/, message: '请输入正确的端口号(1-65535)', trigger: 'blur' }
|
||||||
|
],
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getUserOptions()
|
||||||
|
getConfigOptions()
|
||||||
|
getModelOptions()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 打开弹窗
|
||||||
|
const openDialog = async (row?: any) => {
|
||||||
|
resetForm()
|
||||||
|
|
||||||
|
// 确保用户数据已加载
|
||||||
|
if (state.userOptions.length === 0) {
|
||||||
|
await getUserOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保配置数据已加载
|
||||||
|
if (state.configOptions.length === 0) {
|
||||||
|
await getConfigOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保设备型号数据已加载
|
||||||
|
if (state.modelOptions.length === 0) {
|
||||||
|
await getModelOptions()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row && row.id) {
|
||||||
|
// 编辑模式,获取详情
|
||||||
|
try {
|
||||||
|
const res = await new PumpApi().get({ id: row.id })
|
||||||
|
if (res?.success && res.data) {
|
||||||
|
state.ruleForm = {
|
||||||
|
id: res.data.id,
|
||||||
|
deviceNo: res.data.deviceNo || '',
|
||||||
|
assetNo: res.data.assetNo || '',
|
||||||
|
model: res.data.model || '',
|
||||||
|
specification: res.data.specification || '',
|
||||||
|
pumpSpeed: res.data.pumpSpeed || 0,
|
||||||
|
principalId: res.data.principalId,
|
||||||
|
pumpTimeout: res.data.pumpTimeout || 0,
|
||||||
|
maintenanceFlag: res.data.maintenanceFlag ?? 1,
|
||||||
|
ip: res.data.ip || '',
|
||||||
|
port: res.data.port || '',
|
||||||
|
speedCoefficient: res.data.speedCoefficient || 0,
|
||||||
|
serviceName: res.data.serviceName || '',
|
||||||
|
isAirPump: true, // 固定为false
|
||||||
|
configId: res.data.configId,
|
||||||
|
workingSpeed: res.data.workingSpeed || 0,
|
||||||
|
workingTime: res.data.workingTime || 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} 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,
|
||||||
|
deviceNo: '',
|
||||||
|
assetNo: '',
|
||||||
|
model: '',
|
||||||
|
specification: '',
|
||||||
|
pumpSpeed: 0,
|
||||||
|
principalId: undefined,
|
||||||
|
pumpTimeout: 0,
|
||||||
|
maintenanceFlag: 1,
|
||||||
|
ip: '',
|
||||||
|
port: '',
|
||||||
|
speedCoefficient: 0,
|
||||||
|
serviceName: '',
|
||||||
|
isAirPump: false,
|
||||||
|
configId: undefined,
|
||||||
|
workingSpeed: 0,
|
||||||
|
workingTime: 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 获取用户选项
|
// 获取用户选项
|
||||||
const getUserOptions = async () => {
|
const getUserOptions = async () => {
|
||||||
try {
|
try {
|
||||||
@ -299,8 +394,8 @@ const getConfigOptions = async () => {
|
|||||||
state.configLoading = true
|
state.configLoading = true
|
||||||
try {
|
try {
|
||||||
const res = await new FeedingConfigApi().getList()
|
const res = await new FeedingConfigApi().getList()
|
||||||
if (res?.success) {
|
if (res?.success && res.data) {
|
||||||
state.configOptions = res.data ?? []
|
state.configOptions = res.data
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 静默处理错误
|
// 静默处理错误
|
||||||
@ -312,103 +407,92 @@ const getConfigOptions = async () => {
|
|||||||
// 获取设备型号选项
|
// 获取设备型号选项
|
||||||
const getModelOptions = async () => {
|
const getModelOptions = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await new DictApi().getList(['model'])
|
const res = await new DictApi().getList(['PUMPTYPE'])
|
||||||
if (res?.success) {
|
if (res?.success && res.data) {
|
||||||
state.modelOptions = res.data?.model ?? []
|
// 注意:API返回的key是小写的 pumptype
|
||||||
|
state.modelOptions = res.data['pumptype'] || []
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// 静默处理错误
|
// 静默处理错误
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打开弹窗
|
|
||||||
const openDialog = (row?: AirPumpFormData) => {
|
|
||||||
state.isShowDialog = true
|
|
||||||
if (row) {
|
|
||||||
state.ruleForm = { ...row }
|
|
||||||
} else {
|
|
||||||
state.ruleForm = {
|
|
||||||
id: undefined,
|
|
||||||
deviceNo: '',
|
|
||||||
assetNo: '',
|
|
||||||
model: '',
|
|
||||||
specification: '',
|
|
||||||
pumpSpeed: 0,
|
|
||||||
principalId: undefined,
|
|
||||||
pumpTimeout: 0,
|
|
||||||
maintenanceFlag: 1,
|
|
||||||
ip: '',
|
|
||||||
port: '',
|
|
||||||
speedCoefficient: 0,
|
|
||||||
serviceName: '',
|
|
||||||
isAirPump: true, // 默认为气泵
|
|
||||||
configId: undefined,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
const onCancel = () => {
|
const onCancel = () => {
|
||||||
state.isShowDialog = false
|
closeDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
const onSubmit = async () => {
|
const onSubmit = () => {
|
||||||
await airpumpFormRef.value?.validate(async (valid: boolean) => {
|
pumpFormRef.value.validate(async (valid: boolean) => {
|
||||||
if (valid) {
|
if (!valid) return false
|
||||||
|
|
||||||
state.loading = true
|
state.loading = true
|
||||||
try {
|
try {
|
||||||
const api = new AirPumpApi()
|
let res = {} as any
|
||||||
const formData = {
|
// 确保 isAirPump 为 false
|
||||||
...state.ruleForm,
|
const formData = { ...state.ruleForm, isAirPump: true }
|
||||||
maintenanceFlag: Number(state.ruleForm.maintenanceFlag)
|
|
||||||
|
if (formData.id) {
|
||||||
|
res = await new PumpApi().update(formData as any, { showSuccessMessage: true })
|
||||||
|
} else {
|
||||||
|
res = await new PumpApi().add(formData as any, { showSuccessMessage: true })
|
||||||
}
|
}
|
||||||
const res = state.ruleForm.id
|
|
||||||
? await api.update(formData as unknown as PumpUpdateInput)
|
|
||||||
: await api.add(formData as unknown as PumpAddInput)
|
|
||||||
|
|
||||||
if (res?.success) {
|
if (res?.success) {
|
||||||
proxy.$modal.msgSuccess(state.ruleForm.id ? '修改成功' : '新增成功')
|
closeDialog()
|
||||||
state.isShowDialog = false
|
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
eventBus.emit('refreshAirPump' as keyof MittType<any>)
|
eventBus.emit('refreshAirPump' as keyof MittType<any>)
|
||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
proxy.$modal.msgError(`操作失败: ${error.response?.data?.msg || error.message}`)
|
proxy.$modal.msgError('操作失败')
|
||||||
} finally {
|
} finally {
|
||||||
state.loading = false
|
state.loading = false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 页面加载时
|
// 暴露变量
|
||||||
onMounted(() => {
|
|
||||||
getUserOptions()
|
|
||||||
getConfigOptions()
|
|
||||||
getModelOptions()
|
|
||||||
})
|
|
||||||
|
|
||||||
// 对外暴露方法
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDialog,
|
openDialog,
|
||||||
|
closeDialog,
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style scoped lang="scss">
|
||||||
.airpump-form {
|
.form-section {
|
||||||
.form-section {
|
margin-bottom: 24px;
|
||||||
margin-bottom: 20px;
|
|
||||||
padding: 20px;
|
|
||||||
background-color: #f5f7fa;
|
|
||||||
border-radius: 4px;
|
|
||||||
|
|
||||||
.section-title {
|
&:last-child {
|
||||||
font-size: 16px;
|
margin-bottom: 0;
|
||||||
font-weight: bold;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
color: #303133;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #303133;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding-bottom: 8px;
|
||||||
|
border-bottom: 2px solid #f0f0f0;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
bottom: -2px;
|
||||||
|
width: 40px;
|
||||||
|
height: 2px;
|
||||||
|
background: #409eff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-form-item) {
|
||||||
|
margin-bottom: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-switch__label) {
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
@ -26,10 +26,10 @@
|
|||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button v-if="auth('api:admin:equ-pump:get-page')" @click="Query" type="primary">
|
<el-button v-if="auth('api:admin:equ-airpump:get-page')" @click="Query" type="primary">
|
||||||
<SvgIcon name="ele-Search" />查询
|
<SvgIcon name="ele-Search" />查询
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button v-auth="'api:admin:equ-pump:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增 </el-button>
|
<el-button v-auth="'api:admin:equ-airpump:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增 </el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
<el-table-column prop="assetNo" label="资产编号" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="assetNo" label="资产编号" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column prop="model" label="设备型号" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="model" label="设备型号" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column prop="specification" label="规格" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="specification" label="规格" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column prop="pumpSpeed" label="泵速(g/min)" width="110" align="center" />
|
<el-table-column prop="workingSpeed" label="工作泵速(g/min)" width="110" align="center" />
|
||||||
<el-table-column prop="principalId" label="负责人" width="120" align="center">
|
<el-table-column prop="principalId" label="负责人" width="120" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<span>{{ getPrincipalName(row.principalId) }}</span>
|
<span>{{ getPrincipalName(row.principalId) }}</span>
|
||||||
@ -66,7 +66,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
type="primary"
|
type="primary"
|
||||||
@click="onEdit(row)"
|
@click="onEdit(row)"
|
||||||
v-auth="'api:admin:equ-pump:update'"
|
v-auth="'api:admin:equ-airpump:update'"
|
||||||
>
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
type="danger"
|
type="danger"
|
||||||
@click="onDelete(row)"
|
@click="onDelete(row)"
|
||||||
v-auth="'api:admin:equ-pump:soft-delete'"
|
v-auth="'api:admin:equ-airpump:soft-delete'"
|
||||||
>
|
>
|
||||||
删除
|
删除
|
||||||
</el-button>
|
</el-button>
|
||||||
@ -97,24 +97,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<airpump-form ref="airpumpFormRef" :title="state.title" @refresh="Query"></airpump-form>
|
<pump-form ref="pumpFormRef" :title="state.title" @refresh="Query"></pump-form>
|
||||||
</MyLayout>
|
</MyLayout>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup name="admin/airpump">
|
<script lang="ts" setup name="admin/airpump">
|
||||||
import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent, nextTick } from 'vue'
|
import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
|
||||||
import { ElMessageBox } from 'element-plus'
|
import { ElMessageBox } from 'element-plus'
|
||||||
import { AirPumpApi } from '/@/api/admin/AirPumpApi'
|
import { PumpApi } from '/@/api/admin/PumpApi'
|
||||||
import { UserApi } from '/@/api/admin/User'
|
import { UserApi } from '/@/api/admin/User'
|
||||||
import { PumpGetPageOutput, PageInputPumpGetPageInput, UserGetPageOutput, PageInputUserGetPageInput } from '/@/api/admin/data-contracts'
|
import { PumpGetPageOutput, PageInputPumpGetPageInput, UserGetPageOutput, PageInputUserGetPageInput } from '/@/api/admin/data-contracts'
|
||||||
import eventBus from '/@/utils/mitt'
|
import eventBus from '/@/utils/mitt'
|
||||||
import { auth } from '/@/utils/authFunction'
|
import { auth } from '/@/utils/authFunction'
|
||||||
|
|
||||||
// 引入组件
|
// 引入组件
|
||||||
const AirPumpForm = defineAsyncComponent(() => import('./components/airpump-form.vue'))
|
const PumpForm = defineAsyncComponent(() => import('./components/pump-form.vue'))
|
||||||
|
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const airpumpFormRef = ref<InstanceType<typeof AirPumpForm> | null>(null)
|
const pumpFormRef = ref()
|
||||||
const { proxy } = getCurrentInstance() as any
|
const { proxy } = getCurrentInstance() as any
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
@ -140,7 +140,7 @@ const state = reactive({
|
|||||||
tableData: [] as Array<PumpGetPageOutput>,
|
tableData: [] as Array<PumpGetPageOutput>,
|
||||||
userOptions: [] as Array<UserGetPageOutput>,
|
userOptions: [] as Array<UserGetPageOutput>,
|
||||||
showQuery: true,
|
showQuery: true,
|
||||||
showAirPumpList: true,
|
showPumpList: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -225,11 +225,11 @@ const Query = async () => {
|
|||||||
keyWord: state.queryForm.keyWord || null,
|
keyWord: state.queryForm.keyWord || null,
|
||||||
stDate: state.queryForm.stDate || null,
|
stDate: state.queryForm.stDate || null,
|
||||||
edDate: state.queryForm.edDate || null,
|
edDate: state.queryForm.edDate || null,
|
||||||
isAirPump: true, // 固定为true,只查询气泵
|
isAirPump: true, // 固定为false,只查询空气泵
|
||||||
}
|
}
|
||||||
} as PageInputPumpGetPageInput
|
} as PageInputPumpGetPageInput
|
||||||
|
|
||||||
const res = await new AirPumpApi().getPage(queryParams)
|
const res = await new PumpApi().getPage(queryParams)
|
||||||
if (res?.success) {
|
if (res?.success) {
|
||||||
state.tableData = res.data?.list ?? []
|
state.tableData = res.data?.list ?? []
|
||||||
state.total = res.data?.total ?? 0
|
state.total = res.data?.total ?? 0
|
||||||
@ -253,77 +253,50 @@ const onReset = () => {
|
|||||||
Query()
|
Query()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页大小变化
|
||||||
|
const onSizeChange = (size: number) => {
|
||||||
|
state.queryForm.pageSize = size
|
||||||
|
Query()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当前页变化
|
||||||
|
const onCurrentChange = (page: number) => {
|
||||||
|
state.queryForm.currentPage = page
|
||||||
|
Query()
|
||||||
|
}
|
||||||
|
|
||||||
// 新增
|
// 新增
|
||||||
const onAdd = () => {
|
const onAdd = () => {
|
||||||
state.title = '新增气泵'
|
state.title = '新增空气泵'
|
||||||
nextTick(() => {
|
pumpFormRef.value.openDialog()
|
||||||
if (airpumpFormRef.value) {
|
|
||||||
airpumpFormRef.value.openDialog()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑
|
// 编辑
|
||||||
const onEdit = (row: PumpGetPageOutput) => {
|
const onEdit = (row: PumpGetPageOutput) => {
|
||||||
state.title = '编辑气泵'
|
state.title = '编辑空气泵'
|
||||||
nextTick(() => {
|
pumpFormRef.value.openDialog(row)
|
||||||
if (airpumpFormRef.value) {
|
|
||||||
const formData = {
|
|
||||||
id: row.id,
|
|
||||||
deviceNo: row.deviceNo || '',
|
|
||||||
assetNo: row.assetNo || '',
|
|
||||||
model: row.model || '',
|
|
||||||
specification: row.specification || '',
|
|
||||||
pumpSpeed: row.pumpSpeed || 0,
|
|
||||||
principalId: row.principalId,
|
|
||||||
pumpTimeout: row.pumpTimeout || 0,
|
|
||||||
maintenanceFlag: Number(row.maintenanceFlag) || 1,
|
|
||||||
ip: row.ip || '',
|
|
||||||
port: row.port || '',
|
|
||||||
speedCoefficient: row.speedCoefficient || 0,
|
|
||||||
serviceName: row.serviceName || '',
|
|
||||||
isAirPump: true,
|
|
||||||
configId: row.configId,
|
|
||||||
}
|
|
||||||
airpumpFormRef.value.openDialog(formData)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const onDelete = (row: PumpGetPageOutput) => {
|
const onDelete = (row: PumpGetPageOutput) => {
|
||||||
ElMessageBox.confirm(`确定要删除设备编号为"${row.deviceNo}"的气泵吗?`, '提示', {
|
ElMessageBox.confirm(`确定要删除空气泵【${row.deviceNo}】吗?`, '提示', {
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
try {
|
try {
|
||||||
if (row.id) {
|
const res = await new PumpApi().softDelete({ id: row.id! })
|
||||||
const res = await new AirPumpApi().softDelete({ id: row.id })
|
|
||||||
if (res?.success) {
|
if (res?.success) {
|
||||||
proxy.$modal.msgSuccess('删除成功')
|
proxy.$modal.msgSuccess('删除成功')
|
||||||
Query()
|
Query()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
proxy.$modal.msgError(`删除失败: ${error.response?.data?.msg || error.message}`)
|
proxy.$modal.msgError(`删除失败: ${error.response?.data?.msg || error.message}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 分页大小改变
|
|
||||||
const onSizeChange = (val: number) => {
|
|
||||||
state.queryForm.pageSize = val
|
|
||||||
Query()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 分页页码改变
|
|
||||||
const onCurrentChange = (val: number) => {
|
|
||||||
state.queryForm.currentPage = val
|
|
||||||
Query()
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
151
src/views/admin/alarm/components/alarm-form.vue
Normal file
151
src/views/admin/alarm/components/alarm-form.vue
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-dialog v-model="state.showDialog" destroy-on-close :title="title" draggable :close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false" width="700px">
|
||||||
|
<el-form :model="form" ref="formRef" size="default" label-width="100px">
|
||||||
|
<div class="form-section">
|
||||||
|
<div class="section-title">基本信息</div>
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="设备编号" prop="deviceNo"
|
||||||
|
:rules="[{ required: true, message: '请输入设备编号', trigger: ['blur', 'change'] }]">
|
||||||
|
<el-input v-model="form.deviceNo" clearable placeholder="请输入设备编号" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="资产编号" prop="assetNo">
|
||||||
|
<el-input v-model="form.assetNo" clearable placeholder="请输入资产编号" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
<div class="form-section">
|
||||||
|
<div class="section-title">网络配置</div>
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="IP地址" prop="ip" :rules="[{ required: true, message: '请输入IP地址', trigger: 'blur' }]">
|
||||||
|
<el-input v-model="form.ip" clearable placeholder="请输入IP地址" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="端口" prop="port" :rules="[{ required: true, message: '请输入端口', trigger: 'blur' }]">
|
||||||
|
<el-input v-model="form.port" clearable placeholder="请输入端口" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="服务名称" prop="serviceName">
|
||||||
|
<el-input v-model="form.serviceName" clearable placeholder="请输入服务名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="onCancel" size="default">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="onSure" size="default" :loading="state.sureLoading">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup name="platform/nppusp/device/alarm-form">
|
||||||
|
import { reactive, toRefs, ref, onMounted } from 'vue';
|
||||||
|
import { AlarmUpdateInput, RoomGetPageOutput, PageInputRoomGetPageInput, AlarmAddInput } from '/@/api/admin/data-contracts';
|
||||||
|
import { AlarmApi } from '/@/api/admin/AlarmApi';
|
||||||
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emits = defineEmits(['refresh']);
|
||||||
|
|
||||||
|
const formRef = ref();
|
||||||
|
const state = reactive({
|
||||||
|
showDialog: false,
|
||||||
|
sureLoading: false,
|
||||||
|
form: {
|
||||||
|
status: true,
|
||||||
|
isRuning: 0,
|
||||||
|
} as AlarmUpdateInput,
|
||||||
|
roomOptions: [] as Array<RoomGetPageOutput>,
|
||||||
|
});
|
||||||
|
|
||||||
|
const { form } = toRefs(state);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const open = async (row: any = { id: 0 }) => {
|
||||||
|
if (row.id > 0) {
|
||||||
|
const res = await new AlarmApi().get({ id: row.id });
|
||||||
|
if (res?.success) {
|
||||||
|
state.form = res.data as AlarmUpdateInput;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
state.form = {
|
||||||
|
id: 0,
|
||||||
|
deviceNo: '',
|
||||||
|
assetNo: '',
|
||||||
|
roomId: undefined,
|
||||||
|
ip: '',
|
||||||
|
port: '',
|
||||||
|
serviceName: '',
|
||||||
|
status: true,
|
||||||
|
isRuning: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
state.showDialog = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCancel = () => {
|
||||||
|
state.showDialog = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSure = () => {
|
||||||
|
formRef.value.validate(async (valid: boolean) => {
|
||||||
|
if (!valid) return;
|
||||||
|
state.sureLoading = true;
|
||||||
|
let res;
|
||||||
|
state.form.isRuning = state.form.isRuning ?? 0;
|
||||||
|
if (state.form.id > 0) {
|
||||||
|
res = await new AlarmApi().update(state.form as AlarmUpdateInput);
|
||||||
|
} else {
|
||||||
|
res = await new AlarmApi().add(state.form as AlarmAddInput);
|
||||||
|
}
|
||||||
|
state.sureLoading = false;
|
||||||
|
|
||||||
|
if (res?.success) {
|
||||||
|
ElMessage.success('操作成功');
|
||||||
|
emits('refresh');
|
||||||
|
onCancel();
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res?.msg as string);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.form-section {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
padding-left: 10px;
|
||||||
|
border-left: 4px solid var(--el-color-primary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
138
src/views/admin/alarm/index.vue
Normal file
138
src/views/admin/alarm/index.vue
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
<template>
|
||||||
|
<my-layout>
|
||||||
|
<el-card 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>
|
||||||
|
<el-button type="primary" icon="ele-Search" @click="onQuery"> 查询 </el-button>
|
||||||
|
<el-button v-auth="'api:admin:usp-alarm: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">
|
||||||
|
<el-table :data="state.alarmListData" style="width: 100%" v-loading="state.loading" row-key="id" border>
|
||||||
|
<el-table-column prop="deviceNo" label="设备编号" min-width="150" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="assetNo" label="资产编号" min-width="150" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="ip" label="IP地址" min-width="130" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="port" label="端口" min-width="80" align="center" />
|
||||||
|
<el-table-column prop="serviceName" label="服务名称" min-width="150" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="isRunning" label="运行状态" width="100" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag type="primary" v-if="row.isRuning">运行中</el-tag>
|
||||||
|
<el-tag type="info" v-else>停止</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="180" fixed="right" header-align="center" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button v-auth="'api:admin:usp-alarm:update'" icon="ele-EditPen" size="small" text type="primary" @click="onEdit(row)">编辑</el-button>
|
||||||
|
<el-button v-auth="'api:admin:usp-alarm: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>
|
||||||
|
|
||||||
|
<alarm-form ref="alarmFormRef" :title="state.alarmFormTitle" @refresh="onQuery" />
|
||||||
|
</my-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup name="/admin/alarm">
|
||||||
|
import { ref, reactive, onMounted, getCurrentInstance, defineAsyncComponent } from 'vue';
|
||||||
|
import { PageInputAlarmGetPageInput, AlarmGetPageOutput } from '/@/api/admin/data-contracts';
|
||||||
|
import { AlarmApi } from '/@/api/admin/AlarmApi';
|
||||||
|
import { ElMessageBox, ElMessage } from 'element-plus';
|
||||||
|
import { auth } from '/@/utils/authFunction'
|
||||||
|
|
||||||
|
const AlarmForm = defineAsyncComponent(() => import('./components/alarm-form.vue'));
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance() as any;
|
||||||
|
|
||||||
|
const alarmFormRef = ref();
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
loading: false,
|
||||||
|
alarmFormTitle: '',
|
||||||
|
filter: {
|
||||||
|
keyWord: '',
|
||||||
|
},
|
||||||
|
total: 0,
|
||||||
|
pageInput: {
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
filter: {},
|
||||||
|
} as PageInputAlarmGetPageInput,
|
||||||
|
alarmListData: [] as Array<AlarmGetPageOutput>,
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
onQuery();
|
||||||
|
});
|
||||||
|
|
||||||
|
const onQuery = async () => {
|
||||||
|
state.loading = true;
|
||||||
|
state.pageInput.filter = state.filter;
|
||||||
|
const res = await new AlarmApi().getPage(state.pageInput).catch(() => {
|
||||||
|
state.loading = false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res?.success) {
|
||||||
|
state.alarmListData = res.data?.list ?? [];
|
||||||
|
state.total = res.data?.total ?? 0;
|
||||||
|
}
|
||||||
|
state.loading = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onAdd = () => {
|
||||||
|
state.alarmFormTitle = '新增报警器';
|
||||||
|
alarmFormRef.value.open();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onEdit = (row: AlarmGetPageOutput) => {
|
||||||
|
state.alarmFormTitle = '编辑报警器';
|
||||||
|
alarmFormRef.value.open(row);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDelete = (row: AlarmGetPageOutput) => {
|
||||||
|
ElMessageBox.confirm(`确定要删除报警器【${row.deviceNo}】吗?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
const res = await new AlarmApi().softDelete({ id: row.id });
|
||||||
|
if (res?.success) {
|
||||||
|
ElMessage.success('删除成功');
|
||||||
|
onQuery();
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res?.msg as string);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSizeChange = (val: number) => {
|
||||||
|
state.pageInput.pageSize = val;
|
||||||
|
onQuery();
|
||||||
|
};
|
||||||
|
|
||||||
|
const onCurrentChange = (val: number) => {
|
||||||
|
state.pageInput.currentPage = val;
|
||||||
|
onQuery();
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
x
Reference in New Issue
Block a user