修复bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 11m14s

This commit is contained in:
sexygoat
2026-04-08 10:19:25 +08:00
parent ff087abd44
commit b510b4539f
55 changed files with 2274 additions and 2612 deletions

View File

@@ -47,6 +47,21 @@
<!-- 动态列 -->
<slot v-if="tableData.length"></slot>
<!-- 操作列固定在右侧 -->
<el-table-column
v-if="actions && tableData.length > 0"
label="操作"
:width="actionsWidth"
fixed="right"
align="left"
>
<template #default="{ row }">
<div class="table-actions">
<component :is="renderActions(row)" />
</div>
</template>
</el-table-column>
<!-- 空数据 -->
<template #empty>
<el-empty :description="emptyText" v-show="!loading" />
@@ -78,10 +93,20 @@
</template>
<script setup lang="ts">
import { h } from 'vue'
import { ElButton, ElDropdown, ElDropdownMenu, ElDropdownItem, ElIcon } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
import { useTableStore } from '@/store/modules/table'
const { width } = useWindowSize()
const isMobile = computed(() => width.value < 500)
interface TableAction {
label: string
handler: (row: any) => void
type?: 'primary' | 'danger'
permission?: string
}
interface TableProps {
/** 表格数据源 */
data?: any[]
@@ -135,6 +160,10 @@
treeProps?: { children?: string; hasChildren?: string }
/** 是否默认展开所有行 */
defaultExpandAll?: boolean
/** 操作列配置 */
actions?: ((row: any) => TableAction[]) | null
/** 操作列宽度 */
actionsWidth?: number
}
const props = withDefaults(defineProps<TableProps>(), {
@@ -161,7 +190,9 @@
showHeaderBackground: null,
marginTop: 20,
treeProps: undefined,
defaultExpandAll: false
defaultExpandAll: false,
actions: null,
actionsWidth: 140
})
/*
@@ -324,6 +355,78 @@
}
})
}
// 渲染操作列
const renderActions = (row: any) => {
if (!props.actions) return null
const actionList = props.actions(row)
// 如果操作数量 <= 2直接显示所有按钮
if (actionList.length <= 2) {
return h(
'div',
{ style: 'display: flex; gap: 8px;' },
actionList.map((action) =>
h(
ElButton,
{
type: action.type === 'danger' ? 'danger' : 'primary',
link: true,
onClick: () => action.handler(row)
},
() => action.label
)
)
)
}
// 如果操作数量 > 2显示第一个 + 更多下拉菜单
const firstAction = actionList[0]
const moreActions = actionList.slice(1)
return h('div', { style: 'display: flex; gap: 12px; align-items: center;' }, [
h(
ElButton,
{
type: firstAction.type === 'danger' ? 'danger' : 'primary',
link: true,
onClick: () => firstAction.handler(row)
},
() => firstAction.label
),
h(
ElDropdown,
{
onCommand: (handler: (row: any) => void) => handler(row)
},
{
default: () =>
h(
'span',
{
style:
'display: flex; align-items: center; cursor: pointer; color: var(--el-color-primary);'
},
[h('span', '更多'), h(ElIcon, { style: 'margin-left: 4px;' }, () => h(ArrowDown))]
),
dropdown: () =>
h(ElDropdownMenu, {}, () =>
moreActions.map((action) =>
h(
ElDropdownItem,
{
command: () => action.handler(row),
style: action.type === 'danger' ? 'color: var(--el-color-danger);' : ''
},
() => action.label
)
)
)
}
)
])
}
</script>
<style lang="scss" scoped>
@@ -365,9 +468,15 @@
}
// 解决el-image 和 el-table冲突层级冲突问题
::v-deep(.el-table__cell) {
// 只对包含图片的单元格应用,避免影响 fixed 列
::v-deep(.el-table__cell:has(.el-image)) {
position: static !important;
}
// 确保固定列能正常工作
:deep(.el-table__fixed-right) {
right: 0 !important;
}
}
// 移动端分页

View File

@@ -12,7 +12,7 @@
controls-position="right"
style="width: 100%"
/>
<div style=" margin-top: 4px; font-size: 12px;color: #909399">单位: KB/s</div>
<div style="margin-top: 4px; font-size: 12px; color: #909399">单位: KB/s</div>
</ElFormItem>
<ElFormItem label="上行速率" prop="upload_speed">
<ElInputNumber
@@ -22,7 +22,7 @@
controls-position="right"
style="width: 100%"
/>
<div style=" margin-top: 4px; font-size: 12px;color: #909399">单位: KB/s</div>
<div style="margin-top: 4px; font-size: 12px; color: #909399">单位: KB/s</div>
</ElFormItem>
</ElForm>
<template #footer>

View File

@@ -1,6 +1,6 @@
<template>
<ElDialog v-model="visible" title="切换SIM卡" width="600px" @close="handleClose">
<div v-if="loading" style=" padding: 40px;text-align: center">
<div v-if="loading" style="padding: 40px; text-align: center">
<ElIcon class="is-loading" :size="40"><Loading /></ElIcon>
<div style="margin-top: 16px">加载设备绑定的卡列表中...</div>
</div>