Browse Source

Update useColumns.ts

修复 分组表头可编辑表格失效问题
pull/7333/head
Remember Ye 1 month ago committed by GitHub
parent
commit
61c6ff2b77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 45
      jeecgboot-vue3/src/components/Table/src/hooks/useColumns.ts

45
jeecgboot-vue3/src/components/Table/src/hooks/useColumns.ts

@ -56,23 +56,14 @@ function handleIndexColumn(propsRef: ComputedRef<BasicTableProps>, getPagination
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;
const isFixedLeft = columns.some((item) => item.fixed === 'left');
columns.unshift({
flag: INDEX_COLUMN_FLAG,
// update-begin--author:liaozhiyang---date:20240724---forTV360X-1634
width: propsRef.value.size === 'large' ? 65 : 50,
// update-end--author:liaozhiyang---date:20240724---forTV360X-1634
width: 50,
title: t('component.table.index'),
align: 'center',
customRender: ({ index }) => {
@ -116,13 +107,7 @@ export function useColumns(
const getColumnsRef = computed(() => {
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);
handleActionColumn(propsRef, columns);
// update-begin--author:sunjianlei---date:220230630---forQQYUN-5571
@ -161,20 +146,17 @@ export function useColumns(
const viewColumns = sortFixedColumn(unref(getColumnsRef));
const columns = cloneDeep(viewColumns);
const result = columns
.filter((column) => {
return hasPermission(column.auth) && isIfShow(column);
})
.map((column) => {
// update-begin--author:liaozhiyang---date:20230718---for: issues-179antd3 ()
if(column.slots?.customRender) {
const formatEditColumn = (columns) => {
for (let i = 0;i < columns.length;i++) {
const column = columns[i];
if (column.slots?.customRender) {
// slots
column.slotsBak = column.slots;
delete column.slots;
}
// 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) {
// column.slots = { title: `header-${dataIndex}`, ...(slots || {}) };
@ -198,9 +180,13 @@ export function useColumns(
if ((edit || editRow) && !isDefaultAction) {
column.customRender = renderEditCell(column);
}
return reactive(column);
});
// update-begin--author:liaozhiyang---date:20230919---forQQYUN-6387
if (children) {
formatEditColumn(children.filter((item) => hasPermission(column.auth) && isIfShow(column)));
}
}
return columns
}
const result = reactive(formatEditColumn(columns).filter((item) => hasPermission(item.auth) && isIfShow(item)));
if (propsRef.value.expandedRowKeys && !propsRef.value.isTreeTable) {
let index = 0;
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;
}
}

Loading…
Cancel
Save