fix(账号管理): 调度批量结果明细与刷新优化
补充批量调度返回 success_ids/failed_ids 并增加合约/单测 前端加入降级处理与部分失败提示,表格行使用稳定 key 测试: make test-frontend 测试: go test ./internal/service -run BulkUpdateAccounts -tags=unit 测试: go test ./internal/server -run APIContracts -tags=unit
This commit is contained in:
@@ -83,7 +83,7 @@
|
||||
<tr
|
||||
v-else
|
||||
v-for="(row, index) in sortedData"
|
||||
:key="index"
|
||||
:key="resolveRowKey(row, index)"
|
||||
class="hover:bg-gray-50 dark:hover:bg-dark-800"
|
||||
>
|
||||
<td
|
||||
@@ -210,6 +210,7 @@ interface Props {
|
||||
stickyActionsColumn?: boolean
|
||||
expandableActions?: boolean
|
||||
actionsCount?: number // 操作按钮总数,用于判断是否需要展开功能
|
||||
rowKey?: string | ((row: any) => string | number)
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
@@ -222,6 +223,18 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
const sortKey = ref<string>('')
|
||||
const sortOrder = ref<'asc' | 'desc'>('asc')
|
||||
const actionsExpanded = ref(false)
|
||||
const resolveRowKey = (row: any, index: number) => {
|
||||
if (typeof props.rowKey === 'function') {
|
||||
const key = props.rowKey(row)
|
||||
return key ?? index
|
||||
}
|
||||
if (typeof props.rowKey === 'string' && props.rowKey) {
|
||||
const key = row?.[props.rowKey]
|
||||
return key ?? index
|
||||
}
|
||||
const key = row?.id
|
||||
return key ?? index
|
||||
}
|
||||
|
||||
// 数据/列变化时重新检查滚动状态
|
||||
// 注意:不能监听 actionsExpanded,因为 checkActionsColumnWidth 会临时修改它,会导致无限循环
|
||||
|
||||
@@ -13,6 +13,7 @@ A generic data table component with sorting, loading states, and custom cell ren
|
||||
- `columns: Column[]` - Array of column definitions with key, label, sortable, and formatter
|
||||
- `data: any[]` - Array of data objects to display
|
||||
- `loading?: boolean` - Show loading skeleton
|
||||
- `rowKey?: string | (row: any) => string | number` - Row key field or resolver (defaults to `row.id`, falls back to index)
|
||||
|
||||
**Slots:**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user