add 空气泵页面但存在打不开弹窗
This commit is contained in:
parent
4aec0f677c
commit
a671524610
63
src/api/admin/AirPumpApi.ts
Normal file
63
src/api/admin/AirPumpApi.ts
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
import { PageInputPumpGetPageInput, PumpGetPageOutput, PumpAddInput, PumpUpdateInput } from './data-contracts'
|
||||||
|
import { RequestParams } from './http-client'
|
||||||
|
import { ContentType, HttpClient } from './http-client'
|
||||||
|
|
||||||
|
export class AirPumpApi extends HttpClient {
|
||||||
|
/**
|
||||||
|
* 获取分页列表
|
||||||
|
*/
|
||||||
|
getPage = (data: PageInputPumpGetPageInput, params: RequestParams = {}) =>
|
||||||
|
this.request<any>({
|
||||||
|
path: `/api/admin/equ-pump/get-page`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
type: ContentType.Json,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取单条数据
|
||||||
|
*/
|
||||||
|
get = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||||
|
this.request<any>({
|
||||||
|
path: `/api/admin/equ-pump/get`,
|
||||||
|
method: 'GET',
|
||||||
|
query: params,
|
||||||
|
...requestParams,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增
|
||||||
|
*/
|
||||||
|
add = (data: PumpAddInput, params: RequestParams = {}) =>
|
||||||
|
this.request<any>({
|
||||||
|
path: `/api/admin/equ-pump/add`,
|
||||||
|
method: 'POST',
|
||||||
|
body: data,
|
||||||
|
type: ContentType.Json,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新
|
||||||
|
*/
|
||||||
|
update = (data: PumpUpdateInput, params: RequestParams = {}) =>
|
||||||
|
this.request<any>({
|
||||||
|
path: `/api/admin/equ-pump/update`,
|
||||||
|
method: 'PUT',
|
||||||
|
body: data,
|
||||||
|
type: ContentType.Json,
|
||||||
|
...params,
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 软删除
|
||||||
|
*/
|
||||||
|
softDelete = (params: { id: number }, requestParams: RequestParams = {}) =>
|
||||||
|
this.request<any>({
|
||||||
|
path: `/api/admin/equ-pump/soft-delete`,
|
||||||
|
method: 'DELETE',
|
||||||
|
query: params,
|
||||||
|
...requestParams,
|
||||||
|
})
|
||||||
|
}
|
414
src/views/admin/airpump/components/airpump-form.vue
Normal file
414
src/views/admin/airpump/components/airpump-form.vue
Normal file
@ -0,0 +1,414 @@
|
|||||||
|
<template>
|
||||||
|
<div class="airpump-form">
|
||||||
|
<el-dialog
|
||||||
|
v-model="state.isShowDialog"
|
||||||
|
destroy-on-close
|
||||||
|
:title="props.title"
|
||||||
|
draggable
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:close-on-press-escape="false"
|
||||||
|
width="900px"
|
||||||
|
>
|
||||||
|
<el-form ref="airpumpFormRef" :model="state.ruleForm" :rules="state.ruleRules" label-width="120px">
|
||||||
|
|
||||||
|
<!-- 基本信息 -->
|
||||||
|
<div class="form-section">
|
||||||
|
<div class="section-title">基本信息</div>
|
||||||
|
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="设备编号" prop="deviceNo" required>
|
||||||
|
<el-input v-model="state.ruleForm.deviceNo" placeholder="请输入设备编号" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<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-row>
|
||||||
|
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="设备型号" prop="model" required>
|
||||||
|
<el-select
|
||||||
|
v-model="state.ruleForm.model"
|
||||||
|
placeholder="请选择设备型号"
|
||||||
|
style="width: 100%"
|
||||||
|
filterable
|
||||||
|
allow-create
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="model in state.modelOptions"
|
||||||
|
:key="model.value"
|
||||||
|
:label="model.name"
|
||||||
|
:value="model.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="specification" required>
|
||||||
|
<el-input v-model="state.ruleForm.specification" 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="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="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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 技术参数 -->
|
||||||
|
<div class="form-section">
|
||||||
|
<div class="section-title">技术参数</div>
|
||||||
|
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="泵速(g/min)" prop="pumpSpeed" required>
|
||||||
|
<el-input-number
|
||||||
|
v-model="state.ruleForm.pumpSpeed"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
style="width: 100%"
|
||||||
|
placeholder="请输入泵速"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="超时(s)" prop="pumpTimeout" required>
|
||||||
|
<el-input-number
|
||||||
|
v-model="state.ruleForm.pumpTimeout"
|
||||||
|
:min="0"
|
||||||
|
style="width: 100%"
|
||||||
|
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="speedCoefficient" required>
|
||||||
|
<el-input-number
|
||||||
|
v-model="state.ruleForm.speedCoefficient"
|
||||||
|
:min="0"
|
||||||
|
:precision="3"
|
||||||
|
style="width: 100%"
|
||||||
|
placeholder="请输入泵速系数"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="维护状态" prop="maintenanceFlag">
|
||||||
|
<el-select
|
||||||
|
v-model="state.ruleForm.maintenanceFlag"
|
||||||
|
placeholder="请选择维护状态"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="status in state.maintenanceStatusOptions"
|
||||||
|
:key="status.value"
|
||||||
|
:label="status.label"
|
||||||
|
:value="status.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 网络配置 -->
|
||||||
|
<div class="form-section">
|
||||||
|
<div class="section-title">网络配置</div>
|
||||||
|
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="IP地址" prop="ip" required>
|
||||||
|
<el-input v-model="state.ruleForm.ip" placeholder="请输入IP地址" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
|
||||||
|
<el-form-item label="端口号" prop="port" required>
|
||||||
|
<el-input v-model="state.ruleForm.port" placeholder="请输入端口号" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row :gutter="25">
|
||||||
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
|
||||||
|
<el-form-item label="服务名称" prop="serviceName">
|
||||||
|
<el-input v-model="state.ruleForm.serviceName" placeholder="请输入服务名称" />
|
||||||
|
</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="AirPumpForm">
|
||||||
|
import { reactive, ref, getCurrentInstance, onMounted } from 'vue'
|
||||||
|
import { AirPumpApi } from '/@/api/admin/AirPumpApi'
|
||||||
|
import { UserApi } from '/@/api/admin/User'
|
||||||
|
import { FeedingConfigApi } from '/@/api/admin/FeedingConfigApi'
|
||||||
|
import { DictApi } from '/@/api/admin/Dict'
|
||||||
|
import { UserGetPageOutput, PageInputUserGetPageInput, PumpAddInput, PumpUpdateInput, FeedingConfigGetListOutput, DictGetListOutput } from '/@/api/admin/data-contracts'
|
||||||
|
import eventBus from '/@/utils/mitt'
|
||||||
|
|
||||||
|
// 定义父组件传过来的值
|
||||||
|
const props = defineProps({
|
||||||
|
title: String,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 定义子组件向父组件传值/事件
|
||||||
|
const emit = defineEmits(['refresh'])
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const airpumpFormRef = ref()
|
||||||
|
const { proxy } = getCurrentInstance() as any
|
||||||
|
|
||||||
|
// 临时类型定义
|
||||||
|
type AirPumpFormData = {
|
||||||
|
id?: number
|
||||||
|
deviceNo: string
|
||||||
|
assetNo: string
|
||||||
|
model: string
|
||||||
|
specification: string
|
||||||
|
pumpSpeed: number
|
||||||
|
principalId: number | undefined
|
||||||
|
pumpTimeout: number
|
||||||
|
maintenanceFlag: number
|
||||||
|
ip: string
|
||||||
|
port: string
|
||||||
|
speedCoefficient: number
|
||||||
|
serviceName: string
|
||||||
|
isAirPump: boolean
|
||||||
|
configId: number | undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
isShowDialog: false,
|
||||||
|
loading: false,
|
||||||
|
configLoading: false,
|
||||||
|
ruleForm: {
|
||||||
|
id: undefined,
|
||||||
|
deviceNo: '',
|
||||||
|
assetNo: '',
|
||||||
|
model: '',
|
||||||
|
specification: '',
|
||||||
|
pumpSpeed: 0,
|
||||||
|
principalId: undefined,
|
||||||
|
pumpTimeout: 0,
|
||||||
|
maintenanceFlag: 1,
|
||||||
|
ip: '',
|
||||||
|
port: '',
|
||||||
|
speedCoefficient: 0,
|
||||||
|
serviceName: '',
|
||||||
|
isAirPump: true, // 默认为气泵
|
||||||
|
configId: undefined,
|
||||||
|
} as AirPumpFormData,
|
||||||
|
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>,
|
||||||
|
configOptions: [] as Array<FeedingConfigGetListOutput>,
|
||||||
|
modelOptions: [] as Array<DictGetListOutput>,
|
||||||
|
maintenanceStatusOptions: [
|
||||||
|
{ value: 0, label: 'Offline' },
|
||||||
|
{ value: 1, label: 'Idle' },
|
||||||
|
{ value: 2, label: 'Busy' },
|
||||||
|
{ value: 3, label: 'Error' },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取用户选项
|
||||||
|
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 getConfigOptions = async () => {
|
||||||
|
state.configLoading = true
|
||||||
|
try {
|
||||||
|
const res = await new FeedingConfigApi().getList()
|
||||||
|
if (res?.success) {
|
||||||
|
state.configOptions = res.data ?? []
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// 静默处理错误
|
||||||
|
} finally {
|
||||||
|
state.configLoading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取设备型号选项
|
||||||
|
const getModelOptions = async () => {
|
||||||
|
try {
|
||||||
|
const res = await new DictApi().getList(['model'])
|
||||||
|
if (res?.success) {
|
||||||
|
state.modelOptions = res.data?.model ?? []
|
||||||
|
}
|
||||||
|
} 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 = () => {
|
||||||
|
state.isShowDialog = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
const onSubmit = async () => {
|
||||||
|
await airpumpFormRef.value?.validate(async (valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
state.loading = true
|
||||||
|
try {
|
||||||
|
const api = new AirPumpApi()
|
||||||
|
const formData = {
|
||||||
|
...state.ruleForm,
|
||||||
|
maintenanceFlag: Number(state.ruleForm.maintenanceFlag)
|
||||||
|
}
|
||||||
|
const res = state.ruleForm.id
|
||||||
|
? await api.update(formData as unknown as PumpUpdateInput)
|
||||||
|
: await api.add(formData as unknown as PumpAddInput)
|
||||||
|
|
||||||
|
if (res?.success) {
|
||||||
|
proxy.$modal.msgSuccess(state.ruleForm.id ? '修改成功' : '新增成功')
|
||||||
|
state.isShowDialog = false
|
||||||
|
emit('refresh')
|
||||||
|
eventBus.emit('refreshAirPump' as keyof MittType<any>)
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
proxy.$modal.msgError(`操作失败: ${error.response?.data?.msg || error.message}`)
|
||||||
|
} finally {
|
||||||
|
state.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 页面加载时
|
||||||
|
onMounted(() => {
|
||||||
|
getUserOptions()
|
||||||
|
getConfigOptions()
|
||||||
|
getModelOptions()
|
||||||
|
})
|
||||||
|
|
||||||
|
// 对外暴露方法
|
||||||
|
defineExpose({
|
||||||
|
openDialog,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.airpump-form {
|
||||||
|
.form-section {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #f5f7fa;
|
||||||
|
border-radius: 4px;
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
329
src/views/admin/airpump/index.vue
Normal file
329
src/views/admin/airpump/index.vue
Normal file
@ -0,0 +1,329 @@
|
|||||||
|
<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.queryForm.keyWord" placeholder="设备编号、资产编号" @keyup.enter="Query" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="开始时间">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="state.queryForm.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.queryForm.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:equ-pump:get-page')" @click="Query" type="primary">
|
||||||
|
<SvgIcon name="ele-Search" />查询
|
||||||
|
</el-button>
|
||||||
|
<el-button v-auth="'api:admin:equ-pump: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
|
||||||
|
v-loading="state.loading"
|
||||||
|
:data="state.tableData"
|
||||||
|
stripe
|
||||||
|
border
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<el-table-column prop="deviceNo" 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="specification" label="规格" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column prop="pumpSpeed" label="泵速(g/min)" width="110" align="center" />
|
||||||
|
<el-table-column prop="principalId" label="负责人" width="120" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<span>{{ getPrincipalName(row.principalId) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="maintenanceFlag" label="维护状态" width="100" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="getMaintenanceStatusType(row.maintenanceFlag)">
|
||||||
|
{{ getMaintenanceStatusText(row.maintenanceFlag) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="createdTime" label="创建时间" width="160" show-overflow-tooltip />
|
||||||
|
<el-table-column label="操作" width="200" fixed="right" align="center">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
@click="onEdit(row)"
|
||||||
|
v-auth="'api:admin:equ-pump:update'"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="danger"
|
||||||
|
@click="onDelete(row)"
|
||||||
|
v-auth="'api:admin:equ-pump:soft-delete'"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</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.queryForm.currentPage"
|
||||||
|
v-model:page-size="state.queryForm.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>
|
||||||
|
|
||||||
|
<airpump-form ref="airpumpFormRef" :title="state.title" @refresh="Query"></airpump-form>
|
||||||
|
</MyLayout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup name="admin/airpump">
|
||||||
|
import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent, nextTick } from 'vue'
|
||||||
|
import { ElMessageBox } from 'element-plus'
|
||||||
|
import { AirPumpApi } from '/@/api/admin/AirPumpApi'
|
||||||
|
import { UserApi } from '/@/api/admin/User'
|
||||||
|
import { PumpGetPageOutput, PageInputPumpGetPageInput, UserGetPageOutput, PageInputUserGetPageInput } from '/@/api/admin/data-contracts'
|
||||||
|
import eventBus from '/@/utils/mitt'
|
||||||
|
import { auth } from '/@/utils/authFunction'
|
||||||
|
|
||||||
|
// 引入组件
|
||||||
|
const AirPumpForm = defineAsyncComponent(() => import('./components/airpump-form.vue'))
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const airpumpFormRef = ref<InstanceType<typeof AirPumpForm> | null>(null)
|
||||||
|
const { proxy } = getCurrentInstance() as any
|
||||||
|
|
||||||
|
const state = reactive({
|
||||||
|
loading: false,
|
||||||
|
title: '',
|
||||||
|
filter: {
|
||||||
|
keyWord: '',
|
||||||
|
stDate: '',
|
||||||
|
edDate: '',
|
||||||
|
},
|
||||||
|
total: 0,
|
||||||
|
pageInput: {
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
} as PageInputPumpGetPageInput,
|
||||||
|
queryForm: {
|
||||||
|
keyWord: '',
|
||||||
|
stDate: '',
|
||||||
|
edDate: '',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
},
|
||||||
|
tableData: [] as Array<PumpGetPageOutput>,
|
||||||
|
userOptions: [] as Array<UserGetPageOutput>,
|
||||||
|
showQuery: true,
|
||||||
|
showAirPumpList: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
getUserOptions()
|
||||||
|
Query()
|
||||||
|
eventBus.off('refreshAirPump' as keyof MittType<any>)
|
||||||
|
eventBus.on('refreshAirPump' as keyof MittType<any>, () => {
|
||||||
|
Query()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
onBeforeMount(() => {
|
||||||
|
eventBus.off('refreshAirPump' as keyof MittType<any>)
|
||||||
|
})
|
||||||
|
|
||||||
|
// 获取用户选项
|
||||||
|
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 getPrincipalName = (principalId?: number) => {
|
||||||
|
if (!principalId) return '-'
|
||||||
|
const user = state.userOptions.find(u => u.id === principalId)
|
||||||
|
return user ? `${user.name} (${user.userName})` : '-'
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取维护状态文本
|
||||||
|
const getMaintenanceStatusText = (status?: number) => {
|
||||||
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
return 'Offline'
|
||||||
|
case 1:
|
||||||
|
return 'Idle'
|
||||||
|
case 2:
|
||||||
|
return 'Busy'
|
||||||
|
case 3:
|
||||||
|
return 'Error'
|
||||||
|
default:
|
||||||
|
return '未知'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取维护状态标签类型
|
||||||
|
const getMaintenanceStatusType = (status?: number) => {
|
||||||
|
switch (status) {
|
||||||
|
case 0:
|
||||||
|
return 'info'
|
||||||
|
case 1:
|
||||||
|
return 'success'
|
||||||
|
case 2:
|
||||||
|
return 'warning'
|
||||||
|
case 3:
|
||||||
|
return 'danger'
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询
|
||||||
|
const Query = async () => {
|
||||||
|
state.loading = true
|
||||||
|
try {
|
||||||
|
const queryParams = {
|
||||||
|
currentPage: state.queryForm.currentPage,
|
||||||
|
pageSize: state.queryForm.pageSize,
|
||||||
|
filter: {
|
||||||
|
keyWord: state.queryForm.keyWord || null,
|
||||||
|
stDate: state.queryForm.stDate || null,
|
||||||
|
edDate: state.queryForm.edDate || null,
|
||||||
|
isAirPump: true, // 固定为true,只查询气泵
|
||||||
|
}
|
||||||
|
} as PageInputPumpGetPageInput
|
||||||
|
|
||||||
|
const res = await new AirPumpApi().getPage(queryParams)
|
||||||
|
if (res?.success) {
|
||||||
|
state.tableData = res.data?.list ?? []
|
||||||
|
state.total = res.data?.total ?? 0
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
proxy.$modal.msgError(`查询失败: ${error.response?.data?.msg || error.message}`)
|
||||||
|
} finally {
|
||||||
|
state.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置查询
|
||||||
|
const onReset = () => {
|
||||||
|
state.queryForm = {
|
||||||
|
keyWord: '',
|
||||||
|
stDate: '',
|
||||||
|
edDate: '',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 20,
|
||||||
|
}
|
||||||
|
Query()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增
|
||||||
|
const onAdd = () => {
|
||||||
|
state.title = '新增气泵'
|
||||||
|
nextTick(() => {
|
||||||
|
if (airpumpFormRef.value) {
|
||||||
|
airpumpFormRef.value.openDialog()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑
|
||||||
|
const onEdit = (row: PumpGetPageOutput) => {
|
||||||
|
state.title = '编辑气泵'
|
||||||
|
nextTick(() => {
|
||||||
|
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) => {
|
||||||
|
ElMessageBox.confirm(`确定要删除设备编号为"${row.deviceNo}"的气泵吗?`, '提示', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
.then(async () => {
|
||||||
|
try {
|
||||||
|
if (row.id) {
|
||||||
|
const res = await new AirPumpApi().softDelete({ id: row.id })
|
||||||
|
if (res?.success) {
|
||||||
|
proxy.$modal.msgSuccess('删除成功')
|
||||||
|
Query()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
proxy.$modal.msgError(`删除失败: ${error.response?.data?.msg || error.message}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页大小改变
|
||||||
|
const onSizeChange = (val: number) => {
|
||||||
|
state.queryForm.pageSize = val
|
||||||
|
Query()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页页码改变
|
||||||
|
const onCurrentChange = (val: number) => {
|
||||||
|
state.queryForm.currentPage = val
|
||||||
|
Query()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user