|
@@ -37,6 +37,7 @@ interface iTableContentPorps {
|
|
|
}
|
|
|
|
|
|
const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, history, type }) => {
|
|
|
+ const [ expandedRowKeys, setRowKeys ] = useState<string[]>([])
|
|
|
|
|
|
const [ sectionTemplate, setSectionTemplate ] = useState<iShowTemplateState>({
|
|
|
isShow: false,
|
|
@@ -92,6 +93,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
|
|
|
})
|
|
|
} else {
|
|
|
contractStore.updateTree(data.sectionTree.children)
|
|
|
+ setRowKeys(expandTree(data.sectionTree.children))
|
|
|
}
|
|
|
}
|
|
|
// 初始化时如果id存在说明只是table更新了,那么要将store里面的合同数据也一起更新,防止合同详情不是最新的数据
|
|
@@ -265,7 +267,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
|
|
|
if (dataIndex === 'code') {
|
|
|
codeChange(value, row)
|
|
|
} else {
|
|
|
- handleUpdateContractName({ id: row.id, bidsectionId: row.bidsectionId, treeType: type === 'income' ? 0 : 1, name: value })
|
|
|
+ handleUpdateContractName({ id: row.id, bidsectionId: row.bidsectionId, treeType: type === ContractType.INCOME ? 0 : 1, name: value })
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -280,10 +282,12 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
|
|
|
editable: col.editable,
|
|
|
dataIndex: col.dataIndex,
|
|
|
title: col.title,
|
|
|
+ expandedRowKeys,
|
|
|
handleSave
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
return sectionTemplate.isShow ?
|
|
|
<Modal
|
|
|
visible={sectionTemplate.isShow}
|
|
@@ -358,6 +362,15 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
|
|
|
// rowKey={record => record.id}
|
|
|
defaultExpandAllRows={true}
|
|
|
onRow={onClickRow}
|
|
|
+ expandable={{ expandedRowKeys, onExpand: (expanded, record: any) => {
|
|
|
+ if (expanded) {
|
|
|
+ const ids = [ ...expandedRowKeys, record.id ]
|
|
|
+ setRowKeys(ids)
|
|
|
+ } else {
|
|
|
+ const ids = expandedRowKeys.filter(item => item !== record.id)
|
|
|
+ setRowKeys(ids)
|
|
|
+ }
|
|
|
+ } }}
|
|
|
rowClassName={handleRowClass}
|
|
|
style={{ height: '100%', overflowY: 'scroll' }}
|
|
|
/>
|
|
@@ -422,4 +435,18 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
|
|
|
</div>
|
|
|
}
|
|
|
|
|
|
+function expandTree(data: ContractTree[]): string[] {
|
|
|
+ let idArr: Array<string> = []
|
|
|
+
|
|
|
+ data.forEach((item: ContractTree) => {
|
|
|
+ if (item.children?.length) {
|
|
|
+ idArr.push(item.id)
|
|
|
+ const childIds = expandTree(item.children)
|
|
|
+ idArr = [ ...idArr, ...childIds ]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return idArr
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
export default observer(GCsheet)
|