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,
icon: 'bi-copy',
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) => {
@ -858,7 +872,7 @@ const allColumnMap = new Map();
// map
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);
moreColumnTitleMap.set(column.name, {
name: column.name,
@ -872,7 +886,7 @@ const columnToMap = (column: any) => {
classes: column.classes,
parents: [],
});
column.childrenColumns.forEach((item) => {
column.columns.forEach((item) => {
columnToMap(item);
});
} else {
@ -891,15 +905,17 @@ const columnToMap = (column: any) => {
});
}
};
let tmpChildrenLevel = 0;
let tmpColspan = 0;
const getChildrenLevel = (column) => {
if (column && column.childrenColumns && column.childrenColumns.length > 0) {
tmpChildrenLevel += 1;
column.childrenColumns.forEach((item) => {
getChildrenLevel(item);
const deepArr = [];
const getChildrenLevel = (column, deep, deepArr) => {
if (column && column.columns && column.columns.length > 0) {
deep++;
column.columns.forEach((item) => {
getChildrenLevel(item, deep, deepArr);
});
} else if (column) {
// deep++;
deepArr.push(deep);
tmpColspan += 1;
}
};
@ -911,8 +927,8 @@ function findParents(arrData: any, name: any) {
if (arrData[i].name == name) {
return [];
} else {
if (arrData[i].childrenColumns) {
const res = findParents(arrData[i].childrenColumns, name);
if (arrData[i].columns) {
const res = findParents(arrData[i].columns, name);
if (res !== undefined) {
return res.concat(arrData[i].name).reverse();
}
@ -928,12 +944,15 @@ const handlerMoreRowColumnTitle = () => {
let maxColumnChildrenLevel = 0;
for (let key of allColumnMap.keys()) {
// childrenLevel
getChildrenLevel(allColumnMap.get(key));
moreColumnTitleMap.get(key)!.childrenLevel = tmpChildrenLevel;
if (tmpChildrenLevel > 0 && tmpChildrenLevel > maxColumnChildrenLevel) {
let tmpChildrenLevel = 0;
getChildrenLevel(allColumnMap.get(key), 0, deepArr);
tmpChildrenLevel = Math.max(...deepArr);
if (tmpChildrenLevel > maxColumnChildrenLevel) {
maxColumnChildrenLevel = tmpChildrenLevel;
}
tmpChildrenLevel = 0;
deepArr.splice(0, deepArr.length);
moreColumnTitleMap.get(key)!.childrenLevel = tmpChildrenLevel;
// colspan
moreColumnTitleMap.get(key)!.colspan = tmpColspan;
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('--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('--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('--tableBottomButtonHeight', 40 + 'px');
}
@ -1608,8 +1627,8 @@ const getMoreRowColumnTitleIndex = (name: any) => {
const handlerStickyChildrenColumn = (item, columns) => {
columns.push(item);
if (item.childrenColumns && item.childrenColumns.length > 0) {
item.childrenColumns.forEach((children) => {
if (item.columns && item.columns.length > 0) {
item.columns.forEach((children) => {
handlerStickyChildrenColumn(children, columns);
});
}
@ -1804,7 +1823,6 @@ const tableClassComputed = computed(() => {
}
}
} else {
console.info('excludeColumnNum======', excludeColumnNum.value);
//
if (excludeColumnNum.value === 2) {
classArr.push('sticky-header-column-table-tr-1' + '-' + 1);

Loading…
Cancel
Save