业务逻辑修改

This commit is contained in:
Lxq
2026-02-08 17:02:10 +08:00
parent e36faaf94f
commit e304c012ce
8 changed files with 2867 additions and 1309 deletions

View File

@@ -1,5 +1,51 @@
<script setup lang="ts"> <script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router' import { RouterLink, RouterView } from 'vue-router'
import { onMounted, onBeforeUnmount } from 'vue'
import { useAuthStore } from '@/stores/auth'
// 清除token和用户信息
const clearAuthInfo = () => {
const authStore = useAuthStore()
// 清除token这会自动同步到持久化存储
authStore.removeToken()
// 清除localStorage中的用户信息
localStorage.removeItem('username')
// 清除Pinia持久化存储的auth数据pinia-plugin-persistedstate默认使用'pinia-{storeName}'格式)
localStorage.removeItem('pinia-auth')
}
// 页面关闭时清除信息
onMounted(() => {
// 监听页面关闭/刷新事件beforeunload在页面关闭或刷新前触发
const handleBeforeUnload = () => {
clearAuthInfo()
}
// 监听页面卸载事件unload在页面卸载时触发
const handleUnload = () => {
clearAuthInfo()
}
// 监听页面隐藏事件pagehide更可靠可以区分刷新和关闭
const handlePageHide = (event: PageTransitionEvent) => {
// 如果页面被缓存bfcache不清除信息
// 只有在真正关闭时才清除
if (!event.persisted) {
clearAuthInfo()
}
}
window.addEventListener('beforeunload', handleBeforeUnload)
window.addEventListener('unload', handleUnload)
window.addEventListener('pagehide', handlePageHide)
// 清理事件监听器
onBeforeUnmount(() => {
window.removeEventListener('beforeunload', handleBeforeUnload)
window.removeEventListener('unload', handleUnload)
window.removeEventListener('pagehide', handlePageHide)
})
})
</script> </script>
<template> <template>

View File

@@ -44,4 +44,28 @@ export function devparamselect(data: any) {
method: 'get', method: 'get',
params: data, params: data,
}) })
}
// 为参数增加设备的devId
export function devparamaddDevId(devId: number, paramId: number) {
return request({
url: '/devParam/addDevId',
method: 'post',
params: {
devId,
paramId,
},
})
}
// 为参数减少设备的devId
export function devparamdelDevId(devId: number, paramId: number) {
return request({
url: '/devParam/delDevId',
method: 'post',
params: {
devId,
paramId,
},
})
} }

View File

@@ -60,6 +60,11 @@ const router = createRouter({
name: 'island-info', name: 'island-info',
component: () => import('../views/islandInfo/index.vue'), component: () => import('../views/islandInfo/index.vue'),
}, },
{
path: '/devparam',
name: 'devparam',
component: () => import('../views/devparam/index.vue'),
},
{ {
path: '/devinfo', path: '/devinfo',
name: 'devinfo', name: 'devinfo',

View File

@@ -32,68 +32,72 @@
:collapse="false" :collapse="false"
> >
<el-menu-item index="/home"> <el-menu-item index="/home">
<el-icon><HomeFilled /></el-icon> <el-icon><component :is="getMenuIcon('首页')" /></el-icon>
<span>首页</span> <span>首页</span>
</el-menu-item> </el-menu-item>
<el-sub-menu index="system"> <el-sub-menu index="system">
<template #title> <template #title>
<el-icon><Setting /></el-icon> <el-icon><component :is="getMenuIcon('系统管理')" /></el-icon>
<span>系统管理</span> <span>系统管理</span>
</template> </template>
<el-menu-item index="/user"> <el-menu-item index="/user">
<el-icon><User /></el-icon> <el-icon><component :is="getMenuIcon('用户管理')" /></el-icon>
<span>用户管理</span> <span>用户管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/role"> <el-menu-item index="/role">
<el-icon><Avatar /></el-icon> <el-icon><component :is="getMenuIcon('角色管理')" /></el-icon>
<span>角色管理</span> <span>角色管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/department"> <el-menu-item index="/department">
<el-icon><OfficeBuilding /></el-icon> <el-icon><component :is="getMenuIcon('部门管理')" /></el-icon>
<span>部门管理</span> <span>部门管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/position"> <el-menu-item index="/position">
<el-icon><Briefcase /></el-icon> <el-icon><component :is="getMenuIcon('职位管理')" /></el-icon>
<span>职位管理</span> <span>职位管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/manage-log"> <el-menu-item index="/manage-log">
<el-icon><Document /></el-icon> <el-icon><component :is="getMenuIcon('操作日志管理')" /></el-icon>
<span>操作日志管理</span> <span>操作日志管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/user-role"> <el-menu-item index="/user-role">
<el-icon><UserFilled /></el-icon> <el-icon><component :is="getMenuIcon('用户角色管理')" /></el-icon>
<span>用户角色管理</span> <span>用户角色管理</span>
</el-menu-item> </el-menu-item>
</el-sub-menu> </el-sub-menu>
<el-sub-menu index="island"> <el-sub-menu index="island">
<template #title> <template #title>
<el-icon><Grid /></el-icon> <el-icon><component :is="getMenuIcon('业务管理')" /></el-icon>
<span>业务管理</span> <span>业务管理</span>
</template> </template>
<el-menu-item index="/plc-devinfo"> <el-menu-item index="/plc-devinfo">
<el-icon><Connection /></el-icon> <el-icon><component :is="getMenuIcon('PLC设备管理')" /></el-icon>
<span>PLC设备管理</span> <span>PLC设备管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/devparam">
<el-icon><component :is="getMenuIcon('动作参数管理')" /></el-icon>
<span>动作参数管理</span>
</el-menu-item>
<el-menu-item index="/devinfo"> <el-menu-item index="/devinfo">
<el-icon><Monitor /></el-icon> <el-icon><component :is="getMenuIcon('动作管理')" /></el-icon>
<span>设备管理</span> <span>动作管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/island-info"> <el-menu-item index="/island-info">
<el-icon><Setting /></el-icon> <el-icon><component :is="getMenuIcon('功能岛管理')" /></el-icon>
<span>功能岛管理</span> <span>功能岛管理</span>
</el-menu-item> </el-menu-item>
</el-sub-menu> </el-sub-menu>
<el-sub-menu index="flow"> <el-sub-menu index="flow">
<template #title> <template #title>
<el-icon><List /></el-icon> <el-icon><component :is="getMenuIcon('流程管理')" /></el-icon>
<span>流程管理</span> <span>流程管理</span>
</template> </template>
<el-menu-item index="/plc-device-control"> <el-menu-item index="/plc-device-control">
<el-icon><Connection /></el-icon> <el-icon><component :is="getMenuIcon('PLC设备控制')" /></el-icon>
<span>PLC设备控制</span> <span>PLC设备控制</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/goods-info"> <el-menu-item index="/goods-info">
<el-icon><Filter /></el-icon> <el-icon><component :is="getMenuIcon('样品管理')" /></el-icon>
<span>样品管理</span> <span>样品管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/flow-info"> <el-menu-item index="/flow-info">
@@ -101,7 +105,7 @@
<span>标准流程管理</span> <span>标准流程管理</span>
</el-menu-item> </el-menu-item>
<el-menu-item index="/step-info"> <el-menu-item index="/step-info">
<el-icon><EditPen /></el-icon> <el-icon><component :is="getMenuIcon('流程创建')" /></el-icon>
<span>流程创建</span> <span>流程创建</span>
</el-menu-item> </el-menu-item>
</el-sub-menu> </el-sub-menu>
@@ -120,7 +124,26 @@
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import { useRouter, useRoute } from 'vue-router' import { useRouter, useRoute } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { User, Setting, Avatar, OfficeBuilding, Briefcase, Document, CaretBottom, UserFilled, Grid, Monitor, Connection, List, EditPen, Files, Tickets, Management, FolderOpened, Box, Filter, HomeFilled } from '@element-plus/icons-vue' import {
User,
Setting,
Avatar,
OfficeBuilding,
Briefcase,
Document,
CaretBottom,
UserFilled,
Grid,
Monitor,
Connection,
List,
EditPen,
Files,
Box,
Operation,
Tools,
House,
} from '@element-plus/icons-vue'
import { useAuthStore } from '@/stores/auth' import { useAuthStore } from '@/stores/auth'
const router = useRouter() const router = useRouter()
@@ -140,17 +163,31 @@ const activeMenu = computed(() => {
// 根据菜单名称获取图标 // 根据菜单名称获取图标
const getMenuIcon = (menuName: string) => { const getMenuIcon = (menuName: string) => {
const iconMap: Record<string, any> = { const iconMap: Record<string, any> = {
// 一级
首页: House,
系统管理: Setting,
业务管理: Grid,
流程管理: List,
// 系统管理
用户管理: User,
角色管理: Avatar,
部门管理: OfficeBuilding,
职位管理: Briefcase,
操作日志管理: Document,
用户角色管理: UserFilled,
// 业务管理
PLC设备管理: Connection,
动作参数管理: Tools,
动作管理: Monitor,
功能岛管理: Grid,
// 流程管理
PLC设备控制: Operation,
样品管理: Box,
'标准流程管理': Files, // 文件图标,适合标准流程管理 '标准流程管理': Files, // 文件图标,适合标准流程管理
'流程创建': EditPen, '流程创建': EditPen,
'用户管理': User,
'角色管理': Avatar,
'部门管理': OfficeBuilding,
'职位管理': Briefcase,
'操作日志管理': Document,
'用户角色管理': UserFilled,
'功能岛管理': Setting,
'设备管理': Monitor,
'PLC设备管理': Connection,
} }
return iconMap[menuName] || EditPen return iconMap[menuName] || EditPen
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -108,7 +108,7 @@
v-model="drawerVisible" v-model="drawerVisible"
:title="drawerTitle" :title="drawerTitle"
direction="rtl" direction="rtl"
size="500px" size="600px"
:before-close="handleDrawerClose" :before-close="handleDrawerClose"
> >
<el-form <el-form
@@ -150,41 +150,39 @@
clearable clearable
/> />
</el-form-item> </el-form-item>
<el-form-item v-if="isEdit" label="绑定设备"> <el-form-item v-if="isEdit" label="动作信息">
<div class="bind-device-wrapper"> <div class="device-list-wrapper">
<el-button type="primary" @click="handleBindDevice"> <el-table
<el-icon><Plus /></el-icon> v-if="deviceList.length > 0"
绑定设备 v-loading="deviceLoading"
</el-button> :data="deviceList"
<div v-if="boundDevices.length > 0" class="bound-devices-table-wrapper"> border
<el-table stripe
:data="boundDevices" size="small"
border style="width: 100%"
stripe >
size="small" <el-table-column type="index" label="序号" width="60" :index="getDeviceIndex" />
style="width: 100%; margin-top: 12px" <el-table-column prop="devName" label="动作名称" width="180" show-overflow-tooltip>
> <template #default="{ row }">
<el-table-column type="index" label="序号" width="60" :index="getBoundDeviceIndex" /> {{ row.devName || '暂无' }}
<el-table-column prop="devName" label="设备名称" min-width="120" show-overflow-tooltip> </template>
<template #default="{ row }"> </el-table-column>
{{ row.devName || '暂无' }} <el-table-column prop="plcAddr" label="PLC映射地址" width="140" show-overflow-tooltip>
</template> <template #default="{ row }">
</el-table-column> {{ row.plcAddr ?? '暂无' }}
<el-table-column prop="status" label="状态" width="100" align="center"> </template>
<template #default="{ row }"> </el-table-column>
<el-tag :type="getStatusType(row.status)" size="small"> <el-table-column prop="status" label="状态" width="80" align="center">
{{ getStatusText(row.status) }} <template #default="{ row }">
</el-tag> <el-tag :type="getStatusType(row.status)" size="small">
</template> {{ getStatusText(row.status) }}
</el-table-column> </el-tag>
<el-table-column prop="devDesc" label="描述" min-width="150" show-overflow-tooltip> </template>
<template #default="{ row }"> </el-table-column>
{{ row.devDesc || '暂无' }} </el-table>
</template> <div v-if="deviceList.length === 0 && !deviceLoading" class="no-devices">
</el-table-column> 该功能岛暂无动作
</el-table>
</div> </div>
<div v-else class="no-bound-devices">暂无绑定设备</div>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>
@@ -198,67 +196,6 @@
</template> </template>
</el-drawer> </el-drawer>
<!-- 绑定设备对话框 -->
<el-dialog
v-if="isEdit"
v-model="bindDeviceDialogVisible"
:title="isEdit ? '绑定/解绑设备' : '绑定设备'"
width="800px"
:before-close="handleBindDialogClose"
>
<el-table
ref="deviceTableRef"
v-loading="deviceLoading"
:data="deviceListForBind"
border
stripe
style="width: 100%"
@selection-change="handleDeviceSelectionChange"
>
<el-table-column type="selection" width="55" />
<el-table-column type="index" label="序号" width="60" :index="getDeviceIndex" />
<el-table-column prop="devName" label="设备名称" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
{{ row.devName || '暂无' }}
</template>
</el-table-column>
<el-table-column prop="devModel" label="设备型号" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
{{ row.devModel || '暂无' }}
</template>
</el-table-column>
<el-table-column prop="ipAddr" label="IP地址" min-width="120" show-overflow-tooltip>
<template #default="{ row }">
{{ row.ipAddr || '暂无' }}
</template>
</el-table-column>
<el-table-column prop="port" label="端口" width="80">
<template #default="{ row }">
{{ row.port !== null && row.port !== undefined ? row.port : '暂无' }}
</template>
</el-table-column>
<el-table-column prop="protocolType" label="协议" min-width="100" show-overflow-tooltip>
<template #default="{ row }">
{{ row.protocolType || '暂无' }}
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="100" align="center">
<template #default="{ row }">
<el-tag :type="getStatusType(row.status)" size="small">
{{ getStatusText(row.status) }}
</el-tag>
</template>
</el-table-column>
</el-table>
<template #footer>
<div class="dialog-footer">
<el-button @click="handleBindDialogClose">取消</el-button>
<el-button type="primary" @click="handleSaveDeviceBind" :loading="savingDeviceBind">
保存
</el-button>
</div>
</template>
</el-dialog>
</div> </div>
</template> </template>
@@ -307,13 +244,12 @@ import {
islandInfolist, islandInfolist,
islandInfobyid, islandInfobyid,
} from '@/api/tb/islandinfo' } from '@/api/tb/islandinfo'
import { devselect, devInfoupd } from '@/api/tb/devinfo' import { devselect } from '@/api/tb/devinfo'
// 加载状态 // 加载状态
const loading = ref(false) const loading = ref(false)
const submitting = ref(false) const submitting = ref(false)
const deviceLoading = ref(false) const deviceLoading = ref(false)
const savingDeviceBind = ref(false)
// 功能岛列表 // 功能岛列表
const islandList = ref<any[]>([]) const islandList = ref<any[]>([])
@@ -344,12 +280,8 @@ const formData = reactive({
islandDesc: '', islandDesc: '',
}) })
// 绑定设备相关 // 动作列表相关
const bindDeviceDialogVisible = ref(false) const deviceList = ref<any[]>([])
const deviceListForBind = ref<any[]>([])
const deviceTableRef = ref()
const selectedDevices = ref<any[]>([])
const boundDevices = ref<any[]>([])
// 表单验证规则 // 表单验证规则
const formRules = { const formRules = {
@@ -426,16 +358,11 @@ const getStatusText = (status: number | null | undefined) => {
return '未知' return '未知'
} }
// 获取设备序号 // 获取动作序号
const getDeviceIndex = (index: number) => { const getDeviceIndex = (index: number) => {
return index + 1 return index + 1
} }
// 获取已绑定设备序号
const getBoundDeviceIndex = (index: number) => {
return index + 1
}
// 获取功能岛列表 // 获取功能岛列表
const getIslandList = async () => { const getIslandList = async () => {
try { try {
@@ -513,8 +440,7 @@ const resetForm = () => {
formData.islandName = '' formData.islandName = ''
formData.islandCode = '' formData.islandCode = ''
formData.islandDesc = '' formData.islandDesc = ''
boundDevices.value = [] deviceList.value = []
selectedDevices.value = []
formRef.value?.clearValidate() formRef.value?.clearValidate()
} }
@@ -540,9 +466,9 @@ const handleEdit = async (item: any) => {
// 优先使用后端的 desc 字段,兼容其他可能的字段名 // 优先使用后端的 desc 字段,兼容其他可能的字段名
formData.islandDesc = data.desc ?? data.islandDesc ?? data.description ?? '' formData.islandDesc = data.desc ?? data.islandDesc ?? data.description ?? ''
// 加载已绑定的设备 // 加载该功能岛下的动作列表
if (formData.id) { if (formData.id) {
await loadBoundDevices(formData.id) await loadDeviceList(formData.id)
} }
isEdit.value = true isEdit.value = true
@@ -559,39 +485,51 @@ const handleEdit = async (item: any) => {
} }
} }
// 加载已绑定的设备 // 加载该功能岛下的动作列表
const loadBoundDevices = async (islandId: number | string) => { const loadDeviceList = async (islandId: number | string) => {
try { try {
deviceLoading.value = true
const res: any = await devselect({}) const res: any = await devselect({})
const allDevices = res?.data ?? res ?? [] const allDevices = res?.data ?? res ?? []
if (Array.isArray(allDevices)) { if (Array.isArray(allDevices)) {
boundDevices.value = allDevices.filter((device: any) => // 过滤出该功能岛下的动作并排除PLC动作
device.islandId && (device.islandId === islandId || device.islandId === String(islandId)) deviceList.value = allDevices.filter((device: any) => {
) const devModel = device.devModel || ''
const isNotPlc = devModel.toUpperCase() !== 'PLC'
const isBelongToIsland = device.islandId && (device.islandId === islandId || device.islandId === String(islandId))
return isNotPlc && isBelongToIsland
})
} else {
deviceList.value = []
} }
} catch (error) { } catch (error) {
console.error('加载已绑定设备失败:', error) console.error('加载动作列表失败:', error)
boundDevices.value = [] deviceList.value = []
} finally {
deviceLoading.value = false
} }
} }
// 删除功能岛 // 删除功能岛
const handleDelete = async (item: any) => { const handleDelete = async (item: any) => {
try { try {
// 检查是否绑定了设备 // 检查是否绑定了动作
const res: any = await devselect({}) const res: any = await devselect({})
const allDevices = res?.data ?? res ?? [] const allDevices = res?.data ?? res ?? []
const boundDevicesList = Array.isArray(allDevices) const boundDevicesList = Array.isArray(allDevices)
? allDevices.filter((device: any) => ? allDevices.filter((device: any) => {
device.islandId && (device.islandId === item.id || device.islandId === String(item.id)) const devModel = device.devModel || ''
) const isNotPlc = devModel.toUpperCase() !== 'PLC'
const isBelongToIsland = device.islandId && (device.islandId === item.id || device.islandId === String(item.id))
return isNotPlc && isBelongToIsland
})
: [] : []
if (boundDevicesList.length > 0) { if (boundDevicesList.length > 0) {
const deviceNames = boundDevicesList.map((d: any) => d.devName || '未命名设备').join('、') const deviceNames = boundDevicesList.map((d: any) => d.devName || '未命名动作').join('、')
const islandName = item.islandName || item.name || '未命名' const islandName = item.islandName || item.name || '未命名'
await ElMessageBox.alert( await ElMessageBox.alert(
`${islandName}已绑定${deviceNames},请先完成设备解绑`, `${islandName}下还有${deviceNames}${boundDevicesList.length}个动作,请先完成动作解绑`,
'提示', '提示',
{ {
confirmButtonText: '确定', confirmButtonText: '确定',
@@ -674,164 +612,6 @@ const handleSubmit = async () => {
} }
} }
// 打开绑定设备对话框
const handleBindDevice = async () => {
if (!isEdit.value || !formData.id) {
// 新增功能岛不允许绑定设备(仅新增功能岛信息)
return
}
try {
deviceLoading.value = true
const res: any = await devselect({})
const allDevices = res?.data ?? res ?? []
if (Array.isArray(allDevices)) {
// 编辑模式:显示未绑定的设备 + 已绑定该功能岛的设备排除设备型号为PLC的设备
deviceListForBind.value = allDevices.filter((device: any) => {
// 排除设备型号为PLC的设备
if (device.devModel && String(device.devModel).toUpperCase() === 'PLC') {
return false
}
// 筛选条件islandId为0或空的设备或者已绑定该功能岛的设备
return (
!device.islandId ||
device.islandId === formData.id ||
device.islandId === String(formData.id) ||
device.islandId === 0 ||
device.islandId === '0'
)
})
} else {
deviceListForBind.value = []
}
bindDeviceDialogVisible.value = true
// 等待DOM更新后设置已选中的设备
await new Promise(resolve => setTimeout(resolve, 100))
if (deviceTableRef.value && isEdit.value && formData.id) {
// 编辑模式:默认选中已绑定的设备
const boundDeviceIds = boundDevices.value.map((d: any) => d.id)
deviceListForBind.value.forEach((device: any) => {
if (boundDeviceIds.includes(device.id)) {
deviceTableRef.value.toggleRowSelection(device, true)
}
})
}
} catch (error) {
console.error('获取设备列表失败:', error)
ElMessage.error('获取设备列表失败')
} finally {
deviceLoading.value = false
}
}
// 设备选择变化
const handleDeviceSelectionChange = (selection: any[]) => {
selectedDevices.value = selection
}
// 保存设备绑定
const handleSaveDeviceBind = async () => {
try {
savingDeviceBind.value = true
// 获取当前选中的设备ID列表
const selectedDeviceIds = selectedDevices.value.map((d: any) => d.id)
if (!isEdit.value || !formData.id) return
// 编辑模式:立即保存绑定关系
// 获取之前已绑定的设备ID列表
const previousBoundDeviceIds = boundDevices.value.map((d: any) => d.id)
// 需要绑定的设备(新增的)
const devicesToBind = selectedDeviceIds.filter((id: any) => !previousBoundDeviceIds.includes(id))
// 需要解绑的设备(取消选中的)
const devicesToUnbind = previousBoundDeviceIds.filter((id: any) => !selectedDeviceIds.includes(id))
// 执行绑定操作
const bindPromises = devicesToBind.map((deviceId: any) => {
const device = deviceListForBind.value.find((d: any) => d.id === deviceId)
if (device) {
// 包含设备名称等必填字段
return devInfoupd({
id: deviceId,
devName: device.devName, // 必填字段
islandId: formData.id,
})
}
return Promise.resolve()
})
// 执行解绑操作
const unbindPromises = devicesToUnbind.map((deviceId: any) => {
const device =
deviceListForBind.value.find((d: any) => d.id === deviceId) ||
boundDevices.value.find((d: any) => d.id === deviceId)
if (device) {
// 包含设备名称等必填字段
return devInfoupd({
id: deviceId,
devName: device.devName, // 必填字段
islandId: 0, // 解绑时设置为0
})
}
return Promise.resolve()
})
// 执行所有操作
const allPromises = [...bindPromises, ...unbindPromises]
if (allPromises.length > 0) {
const results = await Promise.all(allPromises)
// 检查是否有失败的请求
const failedResults = results.filter((res: any) => {
if (!res) return false
// 检查响应数据(可能是直接返回的数据对象)
const data = res.data || res
return data && (data.code !== '0' && data.code !== 0 && data.code !== undefined && !data.success)
})
if (failedResults.length > 0) {
const firstFailed = failedResults[0]
const errorData = firstFailed?.data || firstFailed
throw new Error(errorData?.message || errorData?.msg || '部分设备绑定/解绑失败')
}
}
// 更新已绑定设备列表
await loadBoundDevices(formData.id)
ElMessage.success('保存成功')
bindDeviceDialogVisible.value = false
} catch (error: any) {
console.error('保存设备绑定失败:', error)
// 处理不同类型的错误
let errorMessage = '保存设备绑定失败'
if (error?.message) {
errorMessage = error.message
} else if (error?.response?.data?.message) {
errorMessage = error.response.data.message
} else if (error?.response?.data?.msg) {
errorMessage = error.response.data.msg
} else if (typeof error === 'string') {
errorMessage = error
}
ElMessage.error(errorMessage)
} finally {
savingDeviceBind.value = false
}
}
// 关闭绑定设备对话框
const handleBindDialogClose = () => {
bindDeviceDialogVisible.value = false
selectedDevices.value = []
if (deviceTableRef.value) {
deviceTableRef.value.clearSelection()
}
}
// 关闭抽屉 // 关闭抽屉
const handleDrawerClose = () => { const handleDrawerClose = () => {
@@ -1048,15 +828,11 @@ onMounted(() => {
gap: 10px; gap: 10px;
} }
.bind-device-wrapper { .device-list-wrapper {
width: 100%; width: 100%;
} }
.bound-devices-table-wrapper { .no-devices {
width: 100%;
}
.no-bound-devices {
margin-top: 12px; margin-top: 12px;
padding: 12px; padding: 12px;
text-align: center; text-align: center;
@@ -1067,12 +843,6 @@ onMounted(() => {
border: 1px dashed #dcdfe6; border: 1px dashed #dcdfe6;
} }
.dialog-footer {
display: flex;
justify-content: flex-end;
gap: 10px;
}
// 功能岛卡片动画:从下往上滑动 // 功能岛卡片动画:从下往上滑动
@keyframes slideUpIn { @keyframes slideUpIn {
from { from {

File diff suppressed because it is too large Load Diff