Update useColumns.ts

修复 分组表头可编辑表格失效问题
pull/7333/head
Remember Ye 1 month ago committed by GitHub
parent 48805484d4
commit 61c6ff2b77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -56,23 +56,14 @@ function handleIndexColumn(propsRef: ComputedRef<BasicTableProps>, getPagination
columns.splice(indIndex, 1); columns.splice(indIndex, 1);
} }
}); });
// update-begin--author:liaozhiyang---date:20240611---forTV360X-105[]
if (columns.length === 0 && showIndexColumn) {
const indIndex = columns.findIndex((column) => column.flag === INDEX_COLUMN_FLAG);
if (indIndex === -1) {
pushIndexColumns = true;
}
}
// update-end--author:liaozhiyang---date:20240611---forTV360X-105[]
if (!pushIndexColumns) return; if (!pushIndexColumns) return;
const isFixedLeft = columns.some((item) => item.fixed === 'left'); const isFixedLeft = columns.some((item) => item.fixed === 'left');
columns.unshift({ columns.unshift({
flag: INDEX_COLUMN_FLAG, flag: INDEX_COLUMN_FLAG,
// update-begin--author:liaozhiyang---date:20240724---forTV360X-1634 width: 50,
width: propsRef.value.size === 'large' ? 65 : 50,
// update-end--author:liaozhiyang---date:20240724---forTV360X-1634
title: t('component.table.index'), title: t('component.table.index'),
align: 'center', align: 'center',
customRender: ({ index }) => { customRender: ({ index }) => {
@ -116,13 +107,7 @@ export function useColumns(
const getColumnsRef = computed(() => { const getColumnsRef = computed(() => {
const columns = cloneDeep(unref(columnsRef)); const columns = cloneDeep(unref(columnsRef));
// update-begin--author:liaozhiyang---date:20240724---forissues/6908BasicColumnFormSchema
if (isArray(columns)) {
columns.forEach((item) => {
item.title = isFunction(item.title) ? item.title() : item.title;
});
}
// update-end--author:liaozhiyang---date:20240724---forissues/6908BasicColumnFormSchema
handleIndexColumn(propsRef, getPaginationRef, columns); handleIndexColumn(propsRef, getPaginationRef, columns);
handleActionColumn(propsRef, columns); handleActionColumn(propsRef, columns);
// update-begin--author:sunjianlei---date:220230630---forQQYUN-5571 // update-begin--author:sunjianlei---date:220230630---forQQYUN-5571
@ -161,20 +146,17 @@ export function useColumns(
const viewColumns = sortFixedColumn(unref(getColumnsRef)); const viewColumns = sortFixedColumn(unref(getColumnsRef));
const columns = cloneDeep(viewColumns); const columns = cloneDeep(viewColumns);
const result = columns const formatEditColumn = (columns) => {
.filter((column) => { for (let i = 0;i < columns.length;i++) {
return hasPermission(column.auth) && isIfShow(column); const column = columns[i];
}) if (column.slots?.customRender) {
.map((column) => {
// update-begin--author:liaozhiyang---date:20230718---for: issues-179antd3 ()
if(column.slots?.customRender) {
// slots // slots
column.slotsBak = column.slots; column.slotsBak = column.slots;
delete column.slots; delete column.slots;
} }
// update-end--author:liaozhiyang---date:20230718---for: issues-179antd3 () // update-end--author:liaozhiyang---date:20230718---for: issues-179antd3 ()
const { slots, customRender, format, edit, editRow, flag, title: metaTitle } = column; const { slots, customRender, format, edit, editRow, flag, title: metaTitle, children } = column;
if (!slots || !slots?.title) { if (!slots || !slots?.title) {
// column.slots = { title: `header-${dataIndex}`, ...(slots || {}) }; // column.slots = { title: `header-${dataIndex}`, ...(slots || {}) };
@ -198,9 +180,13 @@ export function useColumns(
if ((edit || editRow) && !isDefaultAction) { if ((edit || editRow) && !isDefaultAction) {
column.customRender = renderEditCell(column); column.customRender = renderEditCell(column);
} }
return reactive(column); if (children) {
}); formatEditColumn(children.filter((item) => hasPermission(column.auth) && isIfShow(column)));
// update-begin--author:liaozhiyang---date:20230919---forQQYUN-6387 }
}
return columns
}
const result = reactive(formatEditColumn(columns).filter((item) => hasPermission(item.auth) && isIfShow(item)));
if (propsRef.value.expandedRowKeys && !propsRef.value.isTreeTable) { if (propsRef.value.expandedRowKeys && !propsRef.value.isTreeTable) {
let index = 0; let index = 0;
const findIndex = result.findIndex((item) => item.key === CUS_SEL_COLUMN_KEY); const findIndex = result.findIndex((item) => item.key === CUS_SEL_COLUMN_KEY);
@ -361,4 +347,3 @@ export function formatCell(text: string, format: CellFormat, record: Recordable,
return text; return text;
} }
} }

Loading…
Cancel
Save