修改工单: 右键 给角色分配权限
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m45s

This commit is contained in:
sexygoat
2026-02-26 10:06:11 +08:00
parent dccad819cf
commit 3570b062a1
7 changed files with 302 additions and 80 deletions

View File

@@ -56,6 +56,7 @@
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
@selection-change="handleSelectionChange"
@row-contextmenu="handleRowContextMenu"
>
<template #default>
<ElTableColumn type="selection" width="55" />
@@ -1073,32 +1074,18 @@
{
prop: 'operation',
label: '操作',
width: 200,
width: 120,
fixed: 'right',
formatter: (row: Device) => {
const buttons = []
if (hasAuth('devices:look_binding')) {
buttons.push(
h(ArtButtonTable, {
text: '查看卡片',
onClick: () => handleViewCards(row)
})
)
}
// Show "更多操作" only if user has at least one operation permission
const hasAnyOperationPermission = hasAuth('devices:delete')
const hasAnyOperationPermission = hasAuth('devices:delete') || hasAuth('devices:look_binding')
if (hasAnyOperationPermission) {
buttons.push(
h(ArtButtonTable, {
text: '更多操作',
onContextmenu: (e: MouseEvent) => showDeviceOperationMenu(e, row.device_no)
})
)
return h(ArtButtonTable, {
text: '更多操作',
onContextmenu: (e: MouseEvent) => showDeviceOperationMenu(e, row.device_no)
})
}
return h('div', { style: 'display: flex; gap: 0; align-items: center;' }, buttons)
return null
}
}
])
@@ -1432,6 +1419,9 @@
// 设备操作路由
const handleDeviceOperation = (command: string, deviceNo: string) => {
switch (command) {
case 'view-cards':
handleViewCardsByDeviceNo(deviceNo)
break
case 'reboot':
handleRebootDevice(deviceNo)
break
@@ -1453,6 +1443,16 @@
}
}
// 通过设备号查看卡片
const handleViewCardsByDeviceNo = (deviceNo: string) => {
const device = deviceList.value.find(d => d.device_no === deviceNo)
if (device) {
handleViewCards(device)
} else {
ElMessage.error('未找到该设备')
}
}
// 通过设备号删除设备
const handleDeleteDeviceByNo = async (deviceNo: string) => {
// 先根据设备号找到设备对象
@@ -1628,7 +1628,17 @@
// 设备操作菜单项配置
const deviceOperationMenuItems = computed((): MenuItemType[] => {
const items: MenuItemType[] = [
const items: MenuItemType[] = []
// 添加查看卡片到菜单最前面
if (hasAuth('devices:look_binding')) {
items.push({
key: 'view-cards',
label: '查看卡片'
})
}
items.push(
{
key: 'reboot',
label: '重启设备'
@@ -1649,7 +1659,7 @@
key: 'set-wifi',
label: '设置WiFi'
}
]
)
if (hasAuth('devices:delete')) {
items.push({
@@ -1676,6 +1686,11 @@
handleDeviceOperation(item.key, deviceNo)
}
// 处理表格行右键菜单
const handleRowContextMenu = (row: Device, column: any, event: MouseEvent) => {
showDeviceOperationMenu(event, row.device_no)
}
</script>
<style scoped lang="scss">