|
@@ -80,14 +80,41 @@ const crudRef = ref(null); //crudRef.value 获取avue-crud对象
|
|
|
|
|
|
const commonTableEmits = defineEmits(["selectedSure"]);
|
|
|
|
|
|
+const calculateColumnWidth = (column) => {
|
|
|
+ if (!column.label) {
|
|
|
+ return column.minWidth;
|
|
|
+ }
|
|
|
+ // 字宽度
|
|
|
+ const fontSize = 17;
|
|
|
+ let width = fontSize * (column.label.length + 2);
|
|
|
+ // 如果开启过滤
|
|
|
+ if (column.filters) {
|
|
|
+ width += 12;
|
|
|
+ }
|
|
|
+ // 如果开启排序
|
|
|
+ if (column.sortable) {
|
|
|
+ width += 24;
|
|
|
+ }
|
|
|
+ return width;
|
|
|
+};
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
url.value = tableConfig[props.tableType].url;
|
|
|
option.value = Object.assign(option.value, {
|
|
|
menu: false,
|
|
|
highlightCurrentRow: true,
|
|
|
addBtn: false,
|
|
|
+ height: "500",
|
|
|
+ overHidden: true,
|
|
|
+ indexWidth: "120px",
|
|
|
column: tableConfig[props.tableType].column,
|
|
|
});
|
|
|
+ // 列处理
|
|
|
+ if (option.value.column) {
|
|
|
+ for (let col of option.value.column) {
|
|
|
+ col.minWidth = calculateColumnWidth(col);
|
|
|
+ }
|
|
|
+ }
|
|
|
// dataList();
|
|
|
});
|
|
|
watch(
|
|
@@ -98,8 +125,16 @@ watch(
|
|
|
menu: false,
|
|
|
highlightCurrentRow: true,
|
|
|
addBtn: false,
|
|
|
+ height: "500",
|
|
|
+ overHidden: true,
|
|
|
column: tableConfig[props.tableType].column,
|
|
|
});
|
|
|
+ // 列处理
|
|
|
+ if (option.value.column) {
|
|
|
+ for (let col of option.value.column) {
|
|
|
+ col.minWidth = calculateColumnWidth(col);
|
|
|
+ }
|
|
|
+ }
|
|
|
dataList();
|
|
|
}
|
|
|
);
|