Browse Source

表格优化提交

main
likunming 1 year ago
parent
commit
a6db7ae8c5
  1. 58
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

58
io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

@ -690,7 +690,21 @@ const buttonObj = {
name: ButtonEnum.resetDefaultValues, name: ButtonEnum.resetDefaultValues,
icon: 'bi-copy', icon: 'bi-copy',
label: '恢复默认值', label: '恢复默认值',
click: (selected, context) => {}, click: (selected, context) => {
let requestParams: any = {
method: 'POST',
url: url.dataUrl + '/resetDefaultValues',
};
axios(requestParams)
.then((resp) => {
NotifyManager.info('操作成功');
onRequest({ pagination: state.pagination });
})
.catch((error) => {
console.info('error====', error);
NotifyManager.error('操作失败');
});
},
}, },
}; };
const expandFun = (arr, treeExpand) => { const expandFun = (arr, treeExpand) => {
@ -858,7 +872,7 @@ const allColumnMap = new Map();
// map // map
const columnToMap = (column: any) => { const columnToMap = (column: any) => {
if (column && column.childrenColumns && column.childrenColumns.length > 0) { if (column && column.columns && column.columns.length > 0) {
allColumnMap.set(column.name, column); allColumnMap.set(column.name, column);
moreColumnTitleMap.set(column.name, { moreColumnTitleMap.set(column.name, {
name: column.name, name: column.name,
@ -872,7 +886,7 @@ const columnToMap = (column: any) => {
classes: column.classes, classes: column.classes,
parents: [], parents: [],
}); });
column.childrenColumns.forEach((item) => { column.columns.forEach((item) => {
columnToMap(item); columnToMap(item);
}); });
} else { } else {
@ -891,15 +905,17 @@ const columnToMap = (column: any) => {
}); });
} }
}; };
let tmpChildrenLevel = 0;
let tmpColspan = 0; let tmpColspan = 0;
const getChildrenLevel = (column) => { const deepArr = [];
if (column && column.childrenColumns && column.childrenColumns.length > 0) { const getChildrenLevel = (column, deep, deepArr) => {
tmpChildrenLevel += 1; if (column && column.columns && column.columns.length > 0) {
column.childrenColumns.forEach((item) => { deep++;
getChildrenLevel(item); column.columns.forEach((item) => {
getChildrenLevel(item, deep, deepArr);
}); });
} else if (column) { } else if (column) {
// deep++;
deepArr.push(deep);
tmpColspan += 1; tmpColspan += 1;
} }
}; };
@ -911,8 +927,8 @@ function findParents(arrData: any, name: any) {
if (arrData[i].name == name) { if (arrData[i].name == name) {
return []; return [];
} else { } else {
if (arrData[i].childrenColumns) { if (arrData[i].columns) {
const res = findParents(arrData[i].childrenColumns, name); const res = findParents(arrData[i].columns, name);
if (res !== undefined) { if (res !== undefined) {
return res.concat(arrData[i].name).reverse(); return res.concat(arrData[i].name).reverse();
} }
@ -928,12 +944,15 @@ const handlerMoreRowColumnTitle = () => {
let maxColumnChildrenLevel = 0; let maxColumnChildrenLevel = 0;
for (let key of allColumnMap.keys()) { for (let key of allColumnMap.keys()) {
// childrenLevel // childrenLevel
getChildrenLevel(allColumnMap.get(key)); let tmpChildrenLevel = 0;
moreColumnTitleMap.get(key)!.childrenLevel = tmpChildrenLevel; getChildrenLevel(allColumnMap.get(key), 0, deepArr);
if (tmpChildrenLevel > 0 && tmpChildrenLevel > maxColumnChildrenLevel) { tmpChildrenLevel = Math.max(...deepArr);
if (tmpChildrenLevel > maxColumnChildrenLevel) {
maxColumnChildrenLevel = tmpChildrenLevel; maxColumnChildrenLevel = tmpChildrenLevel;
} }
tmpChildrenLevel = 0; deepArr.splice(0, deepArr.length);
moreColumnTitleMap.get(key)!.childrenLevel = tmpChildrenLevel;
// colspan // colspan
moreColumnTitleMap.get(key)!.colspan = tmpColspan; moreColumnTitleMap.get(key)!.colspan = tmpColspan;
tmpColspan = 0; tmpColspan = 0;
@ -1556,10 +1575,10 @@ const stickyHeaderColumn = (time = 500) => {
} }
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBodyPadding', bodyPadding); tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBodyPadding', bodyPadding);
tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBodyHeight', (denseBodyComputed.value ? 24 : 48) + 'px'); tableRef.value.$el.getElementsByTagName('table')[0].style.setProperty('--tableBodyHeight', (denseBodyComputed.value ? 24 : 48) + 'px');
if (denseBottomComputed.value) { if (denseBottomComputed.value && !attrs.hideBottom) {
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 33 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 33 + 'px');
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 24 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 24 + 'px');
} else { } else if (!attrs.hideBottom) {
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 50 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomHeight', 50 + 'px');
tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 40 + 'px'); tableRef.value.$el.getElementsByClassName('q-table__bottom')[0].style.setProperty('--tableBottomButtonHeight', 40 + 'px');
} }
@ -1608,8 +1627,8 @@ const getMoreRowColumnTitleIndex = (name: any) => {
const handlerStickyChildrenColumn = (item, columns) => { const handlerStickyChildrenColumn = (item, columns) => {
columns.push(item); columns.push(item);
if (item.childrenColumns && item.childrenColumns.length > 0) { if (item.columns && item.columns.length > 0) {
item.childrenColumns.forEach((children) => { item.columns.forEach((children) => {
handlerStickyChildrenColumn(children, columns); handlerStickyChildrenColumn(children, columns);
}); });
} }
@ -1804,7 +1823,6 @@ const tableClassComputed = computed(() => {
} }
} }
} else { } else {
console.info('excludeColumnNum======', excludeColumnNum.value);
// //
if (excludeColumnNum.value === 2) { if (excludeColumnNum.value === 2) {
classArr.push('sticky-header-column-table-tr-1' + '-' + 1); classArr.push('sticky-header-column-table-tr-1' + '-' + 1);

Loading…
Cancel
Save