fix: bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 2m9s

This commit is contained in:
sexygoat
2026-04-23 14:59:05 +08:00
parent a9467e8a0c
commit a5e76313cb
28 changed files with 1284 additions and 702 deletions

View File

@@ -28,28 +28,13 @@
:pageSize="pagination.pageSize"
:total="pagination.total"
:marginTop="10"
:row-class-name="getRowClassName"
@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="contextMenuRef"
:menu-items="contextMenuItems"
:menu-width="120"
@select="handleContextMenuSelect"
/>
</ElCard>
</div>
</ArtTableFullScreen>
@@ -58,7 +43,7 @@
<script setup lang="ts">
import { h } from 'vue'
import { useRouter } from 'vue-router'
import { CardService } from '@/api/modules'
import { CardService, ShopService } from '@/api/modules'
import { ElMessage, ElTag } from 'element-plus'
import type { SearchFormItem } from '@/types'
import { useCheckedColumns } from '@/composables/useCheckedColumns'
@@ -67,28 +52,14 @@
import { formatDateTime } from '@/utils/business/format'
import type { AssetAllocationRecord, AllocationTypeEnum, AssetTypeEnum } from '@/types/api/card'
import { RoutesAlias } from '@/router/routesAlias'
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'
defineOptions({ name: 'AssetAllocationRecords' })
const { hasAuth } = useAuth()
const router = useRouter()
// 使用表格右键菜单功能
const {
showContextMenuHint,
hintPosition,
getRowClassName,
handleCellMouseEnter,
handleCellMouseLeave
} = useTableContextMenu()
const loading = ref(false)
const tableRef = ref()
const contextMenuRef = ref<InstanceType<typeof ArtMenuRight>>()
const currentRow = ref<AssetAllocationRecord | null>(null)
// 搜索表单初始值
const initialSearchState = {
@@ -99,6 +70,7 @@
from_shop_id: undefined as number | undefined,
to_shop_id: undefined as number | undefined,
operator_id: undefined as number | undefined,
dateRange: [] as string[],
created_at_start: '',
created_at_end: ''
}
@@ -159,16 +131,51 @@
placeholder: 'ICCID或设备号'
}
},
{
label: '来源店铺',
prop: 'from_shop_id',
type: 'select',
config: {
clearable: true,
filterable: true,
remote: true,
remoteMethod: (query: string) => searchShops(query, 'from'),
placeholder: '请选择或搜索来源店铺'
},
options: () =>
fromShopOptions.value.map((shop) => ({
label: shop.shop_name,
value: shop.id
}))
},
{
label: '目标店铺',
prop: 'to_shop_id',
type: 'select',
config: {
clearable: true,
filterable: true,
remote: true,
remoteMethod: (query: string) => searchShops(query, 'to'),
placeholder: '请选择或搜索目标店铺'
},
options: () =>
toShopOptions.value.map((shop) => ({
label: shop.shop_name,
value: shop.id
}))
},
{
label: '创建时间',
prop: 'created_at_range',
prop: 'dateRange',
type: 'date',
config: {
type: 'datetimerange',
type: 'daterange',
clearable: true,
startPlaceholder: '开始时间',
endPlaceholder: '结束时间',
valueFormat: 'YYYY-MM-DDTHH:mm:ssZ'
rangeSeparator: '',
startPlaceholder: '开始日期',
endPlaceholder: '结束日期',
valueFormat: 'YYYY-MM-DD'
}
}
]
@@ -186,6 +193,33 @@
{ label: '创建时间', prop: 'created_at' }
]
// 店铺搜索选项
const fromShopOptions = ref<any[]>([])
const toShopOptions = ref<any[]>([])
// 搜索店铺
const searchShops = async (query: string, type: 'from' | 'to') => {
try {
const params: any = {
page: 1,
page_size: 20
}
if (query) {
params.shop_name = query
}
const res = await ShopService.getShops(params)
if (res.code === 0) {
if (type === 'from') {
fromShopOptions.value = res.data.items || []
} else {
toShopOptions.value = res.data.items || []
}
}
} catch (error) {
console.error('搜索店铺失败:', error)
}
}
const recordList = ref<AssetAllocationRecord[]>([])
// 获取分配类型标签类型
@@ -246,12 +280,38 @@
{
prop: 'from_owner_name',
label: '来源所有者',
width: 150
width: 150,
formatter: (row: AssetAllocationRecord) => row.from_owner_name || '-'
},
{
prop: 'from_owner_type',
label: '来源类型',
width: 100,
formatter: (row: AssetAllocationRecord) => {
const typeMap: Record<string, string> = {
platform: '平台',
shop: '店铺'
}
return typeMap[row.from_owner_type] || row.from_owner_type || '-'
}
},
{
prop: 'to_owner_name',
label: '目标所有者',
width: 150
width: 150,
formatter: (row: AssetAllocationRecord) => row.to_owner_name || '-'
},
{
prop: 'to_owner_type',
label: '目标类型',
width: 100,
formatter: (row: AssetAllocationRecord) => {
const typeMap: Record<string, string> = {
platform: '平台',
shop: '店铺'
}
return typeMap[row.to_owner_type] || row.to_owner_type || '-'
}
},
{
prop: 'operator_name',
@@ -279,6 +339,8 @@
onMounted(() => {
getTableData()
searchShops('', 'from')
searchShops('', 'to')
})
// 获取分配记录列表
@@ -291,13 +353,6 @@
...formFilters
}
// 处理日期范围
if ((params as any).created_at_range && (params as any).created_at_range.length === 2) {
params.created_at_start = (params as any).created_at_range[0]
params.created_at_end = (params as any).created_at_range[1]
delete (params as any).created_at_range
}
// 清理空值
Object.keys(params).forEach((key) => {
if (params[key] === '' || params[key] === undefined) {
@@ -327,6 +382,14 @@
// 搜索
const handleSearch = () => {
// 处理日期范围
if (formFilters.dateRange && Array.isArray(formFilters.dateRange)) {
formFilters.created_at_start = formFilters.dateRange[0] || ''
formFilters.created_at_end = formFilters.dateRange[1] || ''
} else {
formFilters.created_at_start = ''
formFilters.created_at_end = ''
}
pagination.page = 1
getTableData()
}
@@ -362,40 +425,10 @@
ElMessage.warning('您没有查看详情的权限')
}
}
// 右键菜单项配置
const contextMenuItems = computed((): MenuItemType[] => {
const items: MenuItemType[] = []
return items
})
// 处理表格行右键菜单
const handleRowContextMenu = (row: AssetAllocationRecord, column: any, event: MouseEvent) => {
event.preventDefault()
event.stopPropagation()
currentRow.value = row
contextMenuRef.value?.show(event)
}
// 处理右键菜单选择
const handleContextMenuSelect = (item: MenuItemType) => {
if (!currentRow.value) return
switch (
item.key
// No cases available
) {
}
}
</script>
<style lang="scss" scoped>
.asset-allocation-records-page {
// Allocation records page styles
}
:deep(.el-table__row.table-row-with-context-menu) {
cursor: pointer;
}
</style>