This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
import { PackageSeriesService } from '@/api/modules'
|
||||
import type { PackageSeriesResponse } from '@/types/api'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import { getEnableStatusText } from '@/config/constants'
|
||||
|
||||
defineOptions({ name: 'PackageSeriesDetail' })
|
||||
|
||||
@@ -72,7 +73,7 @@
|
||||
{
|
||||
label: '启用状态',
|
||||
formatter: (_, data) => {
|
||||
return data.one_time_commission_config?.enable ? '已启用' : '未启用'
|
||||
return getEnableStatusText(data.one_time_commission_config?.enable || false)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -151,7 +152,9 @@
|
||||
{
|
||||
label: '启用状态',
|
||||
formatter: (_, data) => {
|
||||
return data.one_time_commission_config?.enable_force_recharge ? '已启用' : '未启用'
|
||||
return getEnableStatusText(
|
||||
data.one_time_commission_config?.enable_force_recharge || false
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -180,7 +183,7 @@
|
||||
formatter: (_, data) => {
|
||||
const config = data.one_time_commission_config
|
||||
if (!config?.validity_type) return '-'
|
||||
const typeMap = {
|
||||
const typeMap: Record<string, string> = {
|
||||
permanent: '永久',
|
||||
fixed_date: '固定日期',
|
||||
relative: '相对时长'
|
||||
|
||||
@@ -35,29 +35,15 @@
|
||||
: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>
|
||||
<ElTableColumn v-for="col in columns" :key="col.prop || col.type" v-bind="col" />
|
||||
</template>
|
||||
</ArtTable>
|
||||
|
||||
<!-- 鼠标悬浮提示 -->
|
||||
<TableContextMenuHint :visible="showContextMenuHint" :position="hintPosition" />
|
||||
|
||||
<!-- 套餐系列操作右键菜单 -->
|
||||
<ArtMenuRight
|
||||
ref="seriesOperationMenuRef"
|
||||
:menu-items="seriesOperationMenuItems"
|
||||
:menu-width="140"
|
||||
@select="handleSeriesOperationMenuSelect"
|
||||
/>
|
||||
|
||||
<!-- 新增/编辑对话框 -->
|
||||
<ElDialog
|
||||
v-model="dialogVisible"
|
||||
@@ -404,18 +390,16 @@
|
||||
import type { SearchFormItem } from '@/types'
|
||||
import { useCheckedColumns } from '@/composables/useCheckedColumns'
|
||||
import { useAuth } from '@/composables/useAuth'
|
||||
import { useTableContextMenu } from '@/composables/useTableContextMenu'
|
||||
import ArtButtonTable from '@/components/core/forms/ArtButtonTable.vue'
|
||||
import ArtMenuRight from '@/components/core/others/ArtMenuRight.vue'
|
||||
import TableContextMenuHint from '@/components/core/others/TableContextMenuHint.vue'
|
||||
import type { MenuItemType } from '@/components/core/others/ArtMenuRight.vue'
|
||||
import CodeGeneratorButton from '@/components/business/CodeGeneratorButton.vue'
|
||||
import { formatDateTime } from '@/utils/business/format'
|
||||
import {
|
||||
CommonStatus,
|
||||
getStatusText,
|
||||
frontendStatusToApi,
|
||||
apiStatusToFrontend
|
||||
apiStatusToFrontend,
|
||||
STATUS_SELECT_OPTIONS,
|
||||
ENABLE_STATUS_OPTIONS,
|
||||
getEnableStatusText
|
||||
} from '@/config/constants'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
@@ -430,15 +414,11 @@
|
||||
const tableRef = ref()
|
||||
const formRef = ref<FormInstance>()
|
||||
|
||||
// 右键菜单
|
||||
const seriesOperationMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
|
||||
const currentOperatingSeries = ref<PackageSeriesResponse | null>(null)
|
||||
|
||||
// 搜索表单初始值
|
||||
const initialSearchState = {
|
||||
series_name: '',
|
||||
status: undefined as number | undefined,
|
||||
enable_one_time_commission: undefined as boolean | undefined
|
||||
status: undefined,
|
||||
enable_one_time_commission: undefined
|
||||
}
|
||||
|
||||
// 搜索表单
|
||||
@@ -463,10 +443,7 @@
|
||||
clearable: true,
|
||||
placeholder: '请选择状态'
|
||||
},
|
||||
options: () => [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 2 }
|
||||
]
|
||||
options: STATUS_SELECT_OPTIONS
|
||||
},
|
||||
{
|
||||
label: '一次性佣金',
|
||||
@@ -476,10 +453,7 @@
|
||||
clearable: true,
|
||||
placeholder: '请选择'
|
||||
},
|
||||
options: () => [
|
||||
{ label: '已启用', value: true },
|
||||
{ label: '未启用', value: false }
|
||||
]
|
||||
options: ENABLE_STATUS_OPTIONS
|
||||
}
|
||||
]
|
||||
|
||||
@@ -557,14 +531,19 @@
|
||||
label: '系列名称',
|
||||
minWidth: 150,
|
||||
formatter: (row: PackageSeriesResponse) => {
|
||||
const hasPermission = hasAuth('package_series:detail')
|
||||
return h(
|
||||
'span',
|
||||
{
|
||||
style: 'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;',
|
||||
onClick: (e: MouseEvent) => {
|
||||
e.stopPropagation()
|
||||
handleNameClick(row)
|
||||
}
|
||||
style: hasPermission
|
||||
? 'color: var(--el-color-primary); cursor: pointer; text-decoration: underline;'
|
||||
: '',
|
||||
onClick: hasPermission
|
||||
? (e: MouseEvent) => {
|
||||
e.stopPropagation()
|
||||
handleNameClick(row)
|
||||
}
|
||||
: undefined
|
||||
},
|
||||
row.series_name
|
||||
)
|
||||
@@ -582,10 +561,10 @@
|
||||
return h(
|
||||
ElTag,
|
||||
{
|
||||
type: row.one_time_commission_config.enable ? 'success' : 'info',
|
||||
type: row.one_time_commission_config?.enable ? 'success' : 'info',
|
||||
size: 'small'
|
||||
},
|
||||
() => (row.one_time_commission_config.enable ? '已启用' : '未启用')
|
||||
() => getEnableStatusText(row.one_time_commission_config?.enable || false)
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -641,10 +620,10 @@
|
||||
return h(
|
||||
ElTag,
|
||||
{
|
||||
type: row.one_time_commission_config.enable_force_recharge ? 'warning' : 'info',
|
||||
type: row.one_time_commission_config?.enable_force_recharge ? 'warning' : 'info',
|
||||
size: 'small'
|
||||
},
|
||||
() => (row.one_time_commission_config.enable_force_recharge ? '已启用' : '未启用')
|
||||
() => getEnableStatusText(row.one_time_commission_config?.enable_force_recharge || false)
|
||||
)
|
||||
}
|
||||
},
|
||||
@@ -738,63 +717,22 @@
|
||||
}
|
||||
])
|
||||
|
||||
// 操作列配置
|
||||
const getActions = (row: PackageSeriesResponse) => {
|
||||
const actions: any[] = []
|
||||
if (hasAuth('package_series:edit')) {
|
||||
actions.push({ label: '编辑', handler: () => showDialog('edit', row), type: 'primary' })
|
||||
}
|
||||
if (hasAuth('package_series:delete')) {
|
||||
actions.push({ label: '删除', handler: () => deleteSeries(row), type: 'danger' })
|
||||
}
|
||||
return actions
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTableData()
|
||||
})
|
||||
|
||||
// 套餐系列操作菜单项配置
|
||||
const seriesOperationMenuItems = computed((): MenuItemType[] => {
|
||||
const items: MenuItemType[] = []
|
||||
|
||||
// 编辑
|
||||
if (hasAuth('package_series:edit')) {
|
||||
items.push({
|
||||
key: 'edit',
|
||||
label: '编辑'
|
||||
})
|
||||
}
|
||||
|
||||
// 删除
|
||||
if (hasAuth('package_series:delete')) {
|
||||
items.push({
|
||||
key: 'delete',
|
||||
label: '删除'
|
||||
})
|
||||
}
|
||||
|
||||
return items
|
||||
})
|
||||
|
||||
// 显示套餐系列操作右键菜单
|
||||
const showSeriesOperationMenu = (e: MouseEvent, row: PackageSeriesResponse) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
currentOperatingSeries.value = row
|
||||
seriesOperationMenuRef.value?.show(e)
|
||||
}
|
||||
|
||||
// 处理表格行右键菜单
|
||||
const handleRowContextMenu = (row: PackageSeriesResponse, column: any, event: MouseEvent) => {
|
||||
// 如果用户有编辑或删除权限,显示右键菜单
|
||||
if (hasAuth('package_series:edit') || hasAuth('package_series:delete')) {
|
||||
showSeriesOperationMenu(event, row)
|
||||
}
|
||||
}
|
||||
|
||||
// 处理套餐系列操作菜单选择
|
||||
const handleSeriesOperationMenuSelect = (item: MenuItemType) => {
|
||||
if (!currentOperatingSeries.value) return
|
||||
|
||||
switch (item.key) {
|
||||
case 'edit':
|
||||
showDialog('edit', currentOperatingSeries.value)
|
||||
break
|
||||
case 'delete':
|
||||
deleteSeries(currentOperatingSeries.value)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// 获取套餐系列列表
|
||||
const getTableData = async () => {
|
||||
loading.value = true
|
||||
@@ -1121,27 +1059,10 @@
|
||||
ElMessage.warning('您没有查看详情的权限')
|
||||
}
|
||||
}
|
||||
|
||||
// 使用表格右键菜单功能
|
||||
const {
|
||||
showContextMenuHint,
|
||||
hintPosition,
|
||||
getRowClassName,
|
||||
handleCellMouseEnter,
|
||||
handleCellMouseLeave
|
||||
} = useTableContextMenu()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.package-series-page {
|
||||
// 可以添加特定样式
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
:deep(.el-table__row.table-row-with-context-menu) {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user