Browse Source

fix: 修复BasicTable组件开启可编辑行卡顿/卡死问题

main
xingyu 2 years ago
parent
commit
1e34183e7a
  1. 6
      src/components/Table/src/components/editable/index.ts

6
src/components/Table/src/components/editable/index.ts

@ -1,5 +1,5 @@
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { h } from 'vue' import { h, toRaw } from 'vue'
import EditableCell from './EditableCell.vue' import EditableCell from './EditableCell.vue'
import type { BasicColumn } from '@/components/Table/src/types/table' import type { BasicColumn } from '@/components/Table/src/types/table'
@ -13,7 +13,7 @@ interface Params {
export function renderEditCell(column: BasicColumn) { export function renderEditCell(column: BasicColumn) {
return ({ text: value, record, index }: Params) => { return ({ text: value, record, index }: Params) => {
record.onValid = async () => { toRaw(record).onValid = async () => {
if (isArray(record?.validCbs)) { if (isArray(record?.validCbs)) {
const validFns = (record?.validCbs || []).map(fn => fn()) const validFns = (record?.validCbs || []).map(fn => fn())
const res = await Promise.all(validFns) const res = await Promise.all(validFns)
@ -24,7 +24,7 @@ export function renderEditCell(column: BasicColumn) {
} }
} }
record.onEdit = async (edit: boolean, submit = false) => { toRaw(record).onEdit = async (edit: boolean, submit = false) => {
if (!submit) if (!submit)
record.editable = edit record.editable = edit