-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
insert后,不push,界面上没有数据,push后getInsertRecords返回空数组
<!-- 数据列 -->
<vxe-column v-for="col in sysMethodAnalyteRoudingColumns" :key="col.key" :field="col.key" :title="col.title"
:width="col.width" :edit-render="getEditRender(col)"></vxe-column>
<!-- 操作列 -->
<vxe-column title="操作" width="150">
<template #default="{ row }">
<a-space>
<a @click.stop.prevent="saveRow(row)">保存</a>
<a-divider type="vertical" />
<a-popconfirm title="是否确认删除" @confirm="handleDelete(row)" placement="topLeft">
<a>删除</a>
</a-popconfirm>
</a-space>
</template>
</vxe-column>
</vxe-table>
const editConfig = ref<VxeTablePropTypes.EditConfig>({
trigger: 'click',
mode: 'row',
showStatus: true,
autoClear: false,
showAsterisk: true,
showIcon: true,
})
新增按钮事件代码:
const newRecord = {
...record,
// 确保有默认值
roundingAlgorithm: record.roundingAlgorithm || '',
roundingWay: record.roundingWay || '',
roudingPrecision: record.roudingPrecision || ''
};
// 使用insertAt添加行
const { row: newRow } = await tableRef.value.insert(newRecord);
console.log('插入前dataSource:', [...tableData.value]);
tableRef.value.setEditCell(newRow, 'roudingPrecision');
// 将新行添加到数据源
//tableData.value.push(newRow);
//console.log('插入后dataSource:', [...tableData.value]);
场景:
表格中的行需要区分出来是新增还是更新,最后统一提交给后端
保存按钮需要getInsertRecords或getUpdateRecords
很奇怪的是,官方示例没有tableData.value.push(newRow);,界面上也可以显示数据:https://vxetable.cn/#/component/table/edit/handleTemp/insert
Metadata
Metadata
Assignees
Labels
No labels