Commit c031163f34d7ec16aa5a7a406d5467a18e527c79

Authored by vben
1 parent a2c89d2e

fix(table): fix edit-table not work

src/components/Table/src/components/editable/EditableCell.vue
@@ -148,16 +148,10 @@ @@ -148,16 +148,10 @@
148 }); 148 });
149 149
150 watchEffect(() => { 150 watchEffect(() => {
151 - console.log('======================');  
152 - console.log(1);  
153 - console.log('======================');  
154 defaultValueRef.value = props.value; 151 defaultValueRef.value = props.value;
155 }); 152 });
156 153
157 watchEffect(() => { 154 watchEffect(() => {
158 - console.log('======================');  
159 - console.log(2);  
160 - console.log('======================');  
161 const { editable } = props.column; 155 const { editable } = props.column;
162 if (isBoolean(editable) || isBoolean(unref(getRowEditable))) { 156 if (isBoolean(editable) || isBoolean(unref(getRowEditable))) {
163 isEdit.value = !!editable || unref(getRowEditable); 157 isEdit.value = !!editable || unref(getRowEditable);
src/components/Table/src/hooks/useColumns.ts
@@ -117,7 +117,8 @@ export function useColumns( @@ -117,7 +117,8 @@ export function useColumns(
117 } 117 }
118 const { ellipsis } = unref(propsRef); 118 const { ellipsis } = unref(propsRef);
119 119
120 - columns.forEach((item) => { 120 + const cloneColumns = cloneDeep(columns);
  121 + cloneColumns.forEach((item) => {
121 const { customRender, slots } = item; 122 const { customRender, slots } = item;
122 123
123 handleItem( 124 handleItem(
@@ -125,7 +126,7 @@ export function useColumns( @@ -125,7 +126,7 @@ export function useColumns(
125 Reflect.has(item, 'ellipsis') ? !!item.ellipsis : !!ellipsis && !customRender && !slots 126 Reflect.has(item, 'ellipsis') ? !!item.ellipsis : !!ellipsis && !customRender && !slots
126 ); 127 );
127 }); 128 });
128 - return columns; 129 + return cloneColumns;
129 }); 130 });
130 131
131 const getViewColumns = computed(() => { 132 const getViewColumns = computed(() => {
@@ -152,7 +153,7 @@ export function useColumns( @@ -152,7 +153,7 @@ export function useColumns(
152 column.customRender = renderEditCell(column); 153 column.customRender = renderEditCell(column);
153 } 154 }
154 }); 155 });
155 - return viewColumns; 156 + return columns;
156 }); 157 });
157 158
158 watch( 159 watch(