fix: 修复明细表删除行时,会删除第一页数据的bug
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
<a-table :bordered="showFormBorder" :columns="headColums.length > 0 ? headColums : columns" :data-source="addDataKey(data)" :pagination="showPagination ? { defaultPageSize: 10 } : false" :scroll="{ x: 'max-content' }">
|
||||
<template #summary>
|
||||
<a-table-summary-row v-if="columns.some((x) => x.componentProps?.subTotal)">
|
||||
@ -54,11 +53,11 @@
|
||||
<template v-else-if="column.key !== 'index'">
|
||||
<component
|
||||
:is="componentMap.get(column.componentType)"
|
||||
:key="column.dataIndex + record['_key_']"
|
||||
v-model:value="record[column.dataIndex]"
|
||||
:bordered="showComponentBorder"
|
||||
:index="index"
|
||||
:mainKey="mainKey"
|
||||
:key="column.dataIndex + record['_key_']"
|
||||
:row="record"
|
||||
v-bind="getComponentsProps(column.componentProps, column.dataIndex, record, index)"
|
||||
@blur="onFieldBlur(column, record, index)"
|
||||
@ -68,7 +67,7 @@
|
||||
</FormItem>
|
||||
</template>
|
||||
<template v-if="column.key === 'action' && !disabled">
|
||||
<MinusCircleOutlined style="padding-bottom: 20px" @click="remove(index)" />
|
||||
<MinusCircleOutlined style="padding-bottom: 20px" @click="remove(record)" />
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
@ -113,6 +112,7 @@
|
||||
import { getDicDetailList } from '/@/api/system/dic';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { MutipleHeadInfo } from '/@/components/Designer';
|
||||
import { buildUUID } from '/@/utils/uuid';
|
||||
|
||||
const { t } = useI18n();
|
||||
// 用于包裹弹窗的form组件 因为一个FormItem 只能收集一个表单组件 所以弹窗的form 必须排除
|
||||
@ -237,7 +237,7 @@
|
||||
function addDataKey(rows) {
|
||||
rows.forEach((row) => {
|
||||
if (!row['_key_']) {
|
||||
row['_key_'] = Math.random();
|
||||
row['_key_'] = buildUUID();
|
||||
}
|
||||
});
|
||||
return rows;
|
||||
@ -375,7 +375,8 @@
|
||||
}
|
||||
};
|
||||
|
||||
const remove = (index) => {
|
||||
const remove = (record) => {
|
||||
const index = data.value.findIndex((r) => r._key_ === record._key_);
|
||||
data.value.splice(index, 1);
|
||||
emit('change', unref(data));
|
||||
emit('update:value', unref(data));
|
||||
|
||||
Reference in New Issue
Block a user