|
|
@ -882,7 +882,7 @@ const buttonObj = reactive({ |
|
|
|
const expandFun = (arr, treeExpand) => { |
|
|
|
arr.forEach((item) => { |
|
|
|
if (props.tree && item.children && item.children.length > 0) { |
|
|
|
item.expand = !treeExpand; |
|
|
|
item[rowDataExtraPropertyName.expand] = !treeExpand; |
|
|
|
expandFun(item.children, treeExpand); |
|
|
|
} |
|
|
|
}); |
|
|
@ -1379,7 +1379,7 @@ const rowDbClick = (evt, row, index) => { |
|
|
|
} else if (!Tools.isEmpty(row) && props.dbClickOperation === buttonObj.clone.name) { |
|
|
|
clone(row); |
|
|
|
} else if (!Tools.isEmpty(row) && props.dbClickOperation === buttonObj.expand.name) { |
|
|
|
row['expand'] = Tools.isEmpty(row['expand']) ? true : !row['expand']; |
|
|
|
row[rowDataExtraPropertyName.expand] = Tools.isEmpty(row[rowDataExtraPropertyName.expand]) ? true : !row[rowDataExtraPropertyName.expand]; |
|
|
|
} else { |
|
|
|
view(); |
|
|
|
} |
|
|
@ -1505,6 +1505,19 @@ const requestHandler = async (ops) => { |
|
|
|
}); |
|
|
|
return resp; |
|
|
|
}; |
|
|
|
|
|
|
|
const expandDatas = <any>[]; |
|
|
|
const extractExpandStatus = (arr) => { |
|
|
|
arr.forEach((item) => { |
|
|
|
if (item[rowDataExtraPropertyName.expand]) { |
|
|
|
expandDatas.push(item[props.primaryKey]); |
|
|
|
} |
|
|
|
if (item.children?.length > 0) { |
|
|
|
extractExpandStatus(item.children); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const onRequest = async (ops: any) => { |
|
|
|
state.loading = true; |
|
|
|
const resp: any = await requestHandler(ops); |
|
|
@ -1525,6 +1538,10 @@ const onRequest = async (ops: any) => { |
|
|
|
table.rows = []; |
|
|
|
} |
|
|
|
} else if (resp && resp.data && props.tree) { |
|
|
|
if (!table.treeExpand && table.rows.length > 0) { |
|
|
|
expandDatas.splice(0, expandDatas.length); |
|
|
|
extractExpandStatus(toRaw(table.rows)); |
|
|
|
} |
|
|
|
const responseData = resp.data; |
|
|
|
if (Array.isArray(responseData)) { |
|
|
|
state.pagination.rowsNumber = responseData.length; |
|
|
@ -1579,8 +1596,12 @@ const initRowDataExtraProperty = (rowData) => { |
|
|
|
rowData[rowDataExtraPropertyName.rowKey] = Tools.uuid(); |
|
|
|
rowData[rowDataExtraPropertyName.ticked] = rowData[rowDataExtraPropertyName.ticked] || false; |
|
|
|
rowData[rowDataExtraPropertyName.selected] = rowData[rowDataExtraPropertyName.selected] || false; |
|
|
|
if (props.tree && Tools.isEmpty(rowData[rowDataExtraPropertyName.expand])) { |
|
|
|
rowData[rowDataExtraPropertyName.expand] = false; |
|
|
|
if (props.tree) { |
|
|
|
if (expandDatas.length > 0 && expandDatas.includes(rowData[props.primaryKey])) { |
|
|
|
rowData[rowDataExtraPropertyName.expand] = true; |
|
|
|
} else if (Tools.isEmpty(rowData[rowDataExtraPropertyName.expand])) { |
|
|
|
rowData[rowDataExtraPropertyName.expand] = false; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
/** |
|
|
|