فهرست منبع

table增加动态列功能
动态赋值table的columns之后,调用tableRef.value.refreshColumns()刷新表格列,实现动态列功能。

Signed-off-by: inypeacock <1300856@qq.com>

inypeacock 1 سال پیش
والد
کامیت
3bc2410270
1فایلهای تغییر یافته به همراه11 افزوده شده و 7 حذف شده
  1. 11 7
      Web/src/components/table/index.vue

+ 11 - 7
Web/src/components/table/index.vue

@@ -447,12 +447,7 @@ const switchFixed = () => {
 	}
 };
 
-onMounted(() => {
-	if (props.defaultSort) {
-		state.page.field = props.defaultSort.prop;
-		state.page.order = props.defaultSort.order;
-	}
-	state.page.pageSize = props.config.pageSize ?? 10;
+const refreshColumns = () => {
 	state.oldColumns = JSON.parse(JSON.stringify(props.columns));
 	state.columns = props.columns;
 	for (let item of state.columns) {
@@ -465,6 +460,15 @@ onMounted(() => {
 			}
 		}
 	}
+};
+
+onMounted(() => {
+	if (props.defaultSort) {
+		state.page.field = props.defaultSort.prop;
+		state.page.order = props.defaultSort.order;
+	}
+	state.page.pageSize = props.config.pageSize ?? 10;
+	refreshColumns();
 	handleList();
 });
 
@@ -475,7 +479,7 @@ defineExpose({
 	toggleSelection,
 	getTableData,
 	setTableData,
-	switchFixed,
+	refreshColumns,
 });
 </script>