diff --git a/package/component/package.json b/package/component/package.json index f69e683a..4b29ad3d 100644 --- a/package/component/package.json +++ b/package/component/package.json @@ -1,6 +1,6 @@ { "name": "@layui/layui-vue", - "version": "1.3.12", + "version": "1.3.13", "author": "就眠儀式", "license": "MIT", "description": "a component library for Vue 3 base on layui-vue", diff --git a/package/component/src/component/table/TableRow.vue b/package/component/src/component/table/TableRow.vue index 9cc74fe5..f2ff3217 100644 --- a/package/component/src/component/table/TableRow.vue +++ b/package/component/src/component/table/TableRow.vue @@ -84,9 +84,7 @@ const tableSelectedKey: WritableComputedRef = computed({ const isExpand: WritableComputedRef = computed({ get() { - return tableExpandAll.value - ? true - : tableExpandKeys.value.includes(props.data[props.id]); + return tableExpandAll.value ? true : tableExpandKeys.value.includes(props.data[props.id]); }, set(val) { let newTableExpandKeys = [...tableExpandKeys.value]; diff --git a/package/component/src/component/table/index.vue b/package/component/src/component/table/index.vue index 16658233..b7812640 100644 --- a/package/component/src/component/table/index.vue +++ b/package/component/src/component/table/index.vue @@ -64,8 +64,8 @@ const props = withDefaults(defineProps(), { expandIndex: 0, rowStyle: "", cellStyle: "", - spanMethod: () => {}, defaultExpandAll: false, + spanMethod: () => { }, expandKeys: () => [], }); @@ -97,6 +97,7 @@ const tableColumnKeys = ref( ); const tableSelectedKeys = ref([...props.selectedKeys]); +const tableExpandKeys = ref([...props.expandKeys]); watch( () => props.selectedKeys, @@ -106,6 +107,14 @@ watch( { deep: true } ); +watch( + () => props.expandKeys, + () => { + tableExpandKeys.value = props.expandKeys; + }, + { deep: true } +); + const tableSelectedKey: WritableComputedRef = computed({ get() { return props.selectedKey; @@ -115,15 +124,6 @@ const tableSelectedKey: WritableComputedRef = computed({ }, }); -const tableExpandKeys: WritableComputedRef = computed({ - get() { - return [...props.expandKeys]; - }, - set(val) { - emit("update:expandKeys", val); - }, -}); - watch( () => props.dataSource, () => { @@ -132,7 +132,7 @@ watch( { deep: true } ); -const changeAll = function (checked: any) { +const changeAll = (checked: any) => { const ids = props.dataSource.map((item: any) => { return item[props.id]; }); @@ -164,6 +164,12 @@ watch( { deep: true, immediate: true } ); +watch(tableExpandKeys, () => { + emit("update:expandKeys", tableExpandKeys.value); +}, + { deep: true, immediate: true } +) + const change = function (page: any) { emit("change", page); }; @@ -201,7 +207,7 @@ const exportData = () => { throw new Error("exception"); } }); - } catch (e) {} + } catch (e) { } }); tableDataSource.value.forEach((item) => { let obj: any = []; @@ -433,31 +439,15 @@ const renderTotalRowCell = (column: any) => { -
+
-
+
@@ -465,59 +455,40 @@ const renderTotalRowCell = (column: any) => {
-
+
-