提单费用均摊处理
This commit is contained in:
@@ -238,6 +238,11 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
// 最多勾选条数,0 表示不限制
|
||||
selectionMax: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
// 是否显示序号列
|
||||
showIndex: {
|
||||
type: Boolean,
|
||||
@@ -436,10 +441,30 @@ function resetQuery() {
|
||||
getList()
|
||||
}
|
||||
|
||||
// 选中变化
|
||||
// 选中变化。超过上限时只保留先勾到的行,并同步虚拟表和普通表的勾选状态。
|
||||
let cappingSelection = false
|
||||
function handleSelectionChange(val) {
|
||||
selectionList.value = val
|
||||
emit('selection-change', val)
|
||||
if (cappingSelection) return
|
||||
const rows = Array.isArray(val) ? val.slice() : []
|
||||
const max = Number(props.selectionMax) || 0
|
||||
if (max > 0 && rows.length > max) {
|
||||
const kept = rows.slice(0, max)
|
||||
cappingSelection = true
|
||||
selectionList.value = kept
|
||||
emit('selection-change', kept)
|
||||
proxy.$modal.msgWarning(`单次最多勾选 ${max} 条`)
|
||||
nextTick(() => {
|
||||
const table = tableRef.value
|
||||
if (table?.toggleRowSelection) {
|
||||
const keys = new Set(kept.map((row) => virtualRowId(row)))
|
||||
tableData.value.forEach((row) => table.toggleRowSelection(row, keys.has(virtualRowId(row))))
|
||||
}
|
||||
cappingSelection = false
|
||||
})
|
||||
return
|
||||
}
|
||||
selectionList.value = rows
|
||||
emit('selection-change', rows)
|
||||
}
|
||||
const selectionIds = computed(() =>
|
||||
selectionList.value.map((r) => (props.rowKey ? r[props.rowKey] : r.id)).filter((v) => v !== undefined)
|
||||
|
||||
Reference in New Issue
Block a user