| | |
| | | :expand-row-keys="expandRowKeys" |
| | | :show-summary="isShowSummary" |
| | | :summary-method="summaryMethod" |
| | | :default-expand-all="defaultExpandAll" |
| | | :tree-props="treeProps" |
| | | :lazy="lazy" |
| | | :load="load" |
| | | @row-click="rowClick" |
| | | @current-change="currentChange" |
| | | @selection-change="handleSelectionChange" |
| | |
| | | type: [String, Object], |
| | | default: () => ({ width: "100%" }), |
| | | }, |
| | | defaultExpandAll: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | treeProps: { |
| | | type: Object, |
| | | default: () => ({ children: "children", hasChildren: "hasChildren" }), |
| | | }, |
| | | lazy: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | load: { |
| | | type: Function, |
| | | default: null, |
| | | }, |
| | | }); |
| | | |
| | | const mergedHeaderCellStyle = computed(() => ({ |
| | |
| | | })); |
| | | |
| | | // Data |
| | | const multipleTable = ref(null); |
| | | const uploadRefs = ref([]); |
| | | const currentFiles = ref({}); |
| | | const uploadKeys = ref({}); |
| | |
| | | const handleSelectionChange = newSelection => { |
| | | emit("selection-change", newSelection); |
| | | }; |
| | | |
| | | // 展开/折叠树形节点 |
| | | const toggleRowExpansion = (row, expanded) => { |
| | | multipleTable.value?.toggleRowExpansion(row, expanded); |
| | | }; |
| | | |
| | | // 展开所有树形节点 |
| | | const expandAll = () => { |
| | | const expandRows = (rows) => { |
| | | rows?.forEach(row => { |
| | | if (row[props.treeProps.children]?.length > 0) { |
| | | multipleTable.value?.toggleRowExpansion(row, true); |
| | | expandRows(row[props.treeProps.children]); |
| | | } |
| | | }); |
| | | }; |
| | | expandRows(props.tableData); |
| | | }; |
| | | |
| | | // 折叠所有树形节点 |
| | | const collapseAll = () => { |
| | | const collapseRows = (rows) => { |
| | | rows?.forEach(row => { |
| | | if (row[props.treeProps.children]?.length > 0) { |
| | | collapseRows(row[props.treeProps.children]); |
| | | multipleTable.value?.toggleRowExpansion(row, false); |
| | | } |
| | | }); |
| | | }; |
| | | collapseRows(props.tableData); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | toggleRowExpansion, |
| | | expandAll, |
| | | collapseAll, |
| | | multipleTable |
| | | }); |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |