fix(BasicTable): column setting about action fixed and default not cache (#3441)

This commit is contained in:
xachary 2023-12-20 09:14:35 +08:00 committed by GitHub
parent 7ba83e71bf
commit 86ecb2729e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 7 deletions

View File

@ -132,6 +132,18 @@
const attrs = useAttrs();
const table = useTableContext();
const props = withDefaults(
defineProps<{
/**
* 是否缓存列的设置
*/
cache?: boolean;
}>(),
{
cache: () => false,
},
);
const getPopupContainer = () => {
return isFunction(attrs.getPopupContainer) ? attrs.getPopupContainer() : getParentContainer();
};
@ -168,7 +180,7 @@
//
tableColumnsUpdate();
//
columnOptionsSave();
props.cache && columnOptionsSave();
}
});
@ -197,7 +209,7 @@
// showIndexColumn
showIndexColumnUpdate(e.target.checked);
// showIndexColumn
tableSettingStore.setShowIndexColumn(e.target.checked);
props.cache && tableSettingStore.setShowIndexColumn(e.target.checked);
//
if (e.target.checked) {
const columns = cloneDeep(table?.getColumns());
@ -223,7 +235,7 @@
// showRowSelection
showRowSelectionUpdate(e.target.checked);
// showRowSelection
tableSettingStore.setShowRowSelection(e.target.checked);
props.cache && tableSettingStore.setShowRowSelection(e.target.checked);
};
//
@ -273,7 +285,7 @@
//
tableColumnsUpdate();
//
columnOptionsSave();
props.cache && columnOptionsSave();
};
// 沿
@ -344,6 +356,13 @@
}
}
// action
const actionIndex = columns.findIndex((o) => o.dataIndex === 'action');
if (actionIndex > -1) {
const actionCol = columns.splice(actionIndex, 1);
columns.push(actionCol[0]);
}
//
tableColumnsSet(columns);
};
@ -384,7 +403,7 @@
//
tableColumnsUpdate();
//
columnOptionsSave();
props.cache && columnOptionsSave();
},
});
}
@ -548,10 +567,10 @@
columnOptions.value = cloneDeep(options);
// removepush
diff();
props.cache && diff();
//
restore();
props.cache && restore();
//
formUpdate();

View File

@ -6,6 +6,7 @@
v-if="getSetting.setting"
@columns-change="handleColumnChange"
:getPopupContainer="getTableContainer"
:cache="false"
/>
<FullScreenSetting v-if="getSetting.fullScreen" :getPopupContainer="getTableContainer" />
</div>