This commit is contained in:
@@ -35,28 +35,14 @@
|
||||
:pageSize="pagination.page_size"
|
||||
:total="pagination.total"
|
||||
:marginTop="10"
|
||||
:row-class-name="getRowClassName"
|
||||
:actions="getActions"
|
||||
@size-change="handleSizeChange"
|
||||
@current-change="handleCurrentChange"
|
||||
@row-contextmenu="handleRowContextMenu"
|
||||
@cell-mouse-enter="handleCellMouseEnter"
|
||||
@cell-mouse-leave="handleCellMouseLeave"
|
||||
>
|
||||
<template #default>
|
||||
<el-table-column v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
|
||||
<!-- 鼠标悬浮提示 -->
|
||||
<TableContextMenuHint :visible="showContextMenuHint" :position="hintPosition" />
|
||||
|
||||
<!-- 右键菜单 -->
|
||||
<ArtMenuRight
|
||||
ref="contextMenuRef"
|
||||
:menu-items="contextMenuItems"
|
||||
:menu-width="120"
|
||||
@select="handleContextMenuSelect"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 新增/编辑对话框 -->
|
||||
@@ -256,9 +242,7 @@
|
||||
} from '@/types/api'
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { useTableContextMenu } from '@/composables/useTableContextMenu'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
|
||||
|
||||
const loading = ref(false)
|
||||
const tableData = ref<PollingConfig[]>([])
|
||||
@@ -266,8 +250,6 @@
|
||||
const dialogVisible = ref(false)
|
||||
const dialogType = ref<'create' | 'edit'>('create')
|
||||
const formRef = ref<FormInstance>()
|
||||
const contextMenuRef = ref()
|
||||
const currentClickRow = ref<PollingConfig | null>(null)
|
||||
const carrierList = ref<any[]>([])
|
||||
|
||||
// 分页数据
|
||||
@@ -327,14 +309,6 @@
|
||||
]
|
||||
}
|
||||
|
||||
const {
|
||||
showContextMenuHint,
|
||||
hintPosition,
|
||||
getRowClassName,
|
||||
handleCellMouseEnter,
|
||||
handleCellMouseLeave
|
||||
} = useTableContextMenu()
|
||||
|
||||
// 搜索表单配置
|
||||
const searchFormItems = computed<SearchFormItem[]>(() => [
|
||||
{
|
||||
@@ -501,23 +475,28 @@
|
||||
}))
|
||||
)
|
||||
|
||||
const contextMenuItems = computed<MenuItemType[]>(() => [
|
||||
{
|
||||
label: '编辑',
|
||||
key: 'edit',
|
||||
permission: 'polling_config_update'
|
||||
},
|
||||
{
|
||||
label: currentClickRow.value?.status === 1 ? '禁用' : '启用',
|
||||
key: 'toggle',
|
||||
permission: 'polling_config_update_status'
|
||||
},
|
||||
{
|
||||
const getActions = (row: PollingConfig) => {
|
||||
const actions: any[] = [
|
||||
{
|
||||
label: '编辑',
|
||||
handler: () => handleEdit(row)
|
||||
}
|
||||
]
|
||||
|
||||
actions.push({
|
||||
label: row.status === 1 ? '禁用' : '启用',
|
||||
type: row.status === 1 ? 'danger' : 'primary',
|
||||
handler: () => handleToggleStatus(row)
|
||||
})
|
||||
|
||||
actions.push({
|
||||
label: '删除',
|
||||
key: 'delete',
|
||||
permission: 'polling_config_delete'
|
||||
}
|
||||
])
|
||||
type: 'danger',
|
||||
handler: () => handleDelete(row)
|
||||
})
|
||||
|
||||
return actions
|
||||
}
|
||||
|
||||
const loadCarriers = async (carrierName?: string) => {
|
||||
try {
|
||||
@@ -708,29 +687,6 @@
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const handleRowContextMenu = (row: PollingConfig, column: any, event: MouseEvent) => {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
currentClickRow.value = row
|
||||
contextMenuRef.value?.show(event)
|
||||
}
|
||||
|
||||
const handleContextMenuSelect = (item: MenuItemType) => {
|
||||
if (!currentClickRow.value) return
|
||||
|
||||
switch (item.key) {
|
||||
case 'edit':
|
||||
handleEdit(currentClickRow.value)
|
||||
break
|
||||
case 'toggle':
|
||||
handleToggleStatus(currentClickRow.value)
|
||||
break
|
||||
case 'delete':
|
||||
handleDelete(currentClickRow.value)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadCarriers()
|
||||
loadData()
|
||||
|
||||
Reference in New Issue
Block a user