This commit is contained in:
@@ -14,16 +14,7 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tableData"
|
||||
border
|
||||
stripe
|
||||
:row-class-name="getRowClassName"
|
||||
@row-contextmenu="handleRowContextMenu"
|
||||
@cell-mouse-enter="handleCellMouseEnter"
|
||||
@cell-mouse-leave="handleCellMouseLeave"
|
||||
>
|
||||
<el-table v-loading="loading" :data="tableData" border stripe>
|
||||
<el-table-column prop="task_type" label="任务类型" min-width="200" />
|
||||
<el-table-column prop="task_type_name" label="任务名称" min-width="150" />
|
||||
<el-table-column prop="max_concurrency" label="最大并发数" min-width="120" align="center" />
|
||||
@@ -50,18 +41,13 @@
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="180" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleEdit(row)">修改配置</el-button>
|
||||
<el-button type="danger" link @click="handleReset(row)">重置</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 鼠标悬浮提示 -->
|
||||
<TableContextMenuHint :visible="showContextMenuHint" :position="hintPosition" />
|
||||
|
||||
<!-- 右键菜单 -->
|
||||
<ArtMenuRight
|
||||
ref="contextMenuRef"
|
||||
:menu-items="contextMenuItems"
|
||||
:menu-width="120"
|
||||
@select="handleContextMenuSelect"
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<!-- 编辑对话框 -->
|
||||
@@ -94,22 +80,16 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import type { FormInstance, FormRules } from 'element-plus'
|
||||
import { PollingConcurrencyService } from '@/api/modules'
|
||||
import type { PollingConcurrency, UpdateConcurrencyParams } from '@/types/api'
|
||||
import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'
|
||||
import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'
|
||||
import { useTableContextMenu } from '@/composables/useTableContextMenu'
|
||||
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
|
||||
|
||||
const loading = ref(false)
|
||||
const tableData = ref<PollingConcurrency[]>([])
|
||||
const dialogVisible = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const contextMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
|
||||
const currentClickRow = ref<PollingConcurrency | null>(null)
|
||||
|
||||
const currentRow = ref<PollingConcurrency>({
|
||||
task_type: '',
|
||||
@@ -131,27 +111,6 @@
|
||||
]
|
||||
}
|
||||
|
||||
const {
|
||||
showContextMenuHint,
|
||||
hintPosition,
|
||||
getRowClassName,
|
||||
handleCellMouseEnter,
|
||||
handleCellMouseLeave
|
||||
} = useTableContextMenu()
|
||||
|
||||
const contextMenuItems = computed<MenuItemType[]>(() => [
|
||||
{
|
||||
label: '修改配置',
|
||||
key: 'edit',
|
||||
permission: 'polling_concurrency_update'
|
||||
},
|
||||
{
|
||||
label: '重置',
|
||||
key: 'reset',
|
||||
permission: 'polling_concurrency_reset'
|
||||
}
|
||||
])
|
||||
|
||||
const getUtilizationColor = (percentage: number) => {
|
||||
if (percentage >= 90) return '#f56c6c'
|
||||
if (percentage >= 70) return '#e6a23c'
|
||||
@@ -240,28 +199,6 @@
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
// 处理表格行右键菜单
|
||||
const handleRowContextMenu = (row: PollingConcurrency, 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 'reset':
|
||||
handleReset(currentClickRow.value)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadData()
|
||||
})
|
||||
|
||||
@@ -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