diff --git a/src/components/BelongPeople/BelongPeople.tsx b/src/components/BelongPeople/BelongPeople.tsx index 0db4892..8a1b55b 100644 --- a/src/components/BelongPeople/BelongPeople.tsx +++ b/src/components/BelongPeople/BelongPeople.tsx @@ -67,6 +67,7 @@ type propsInfo = { closeModal?: any }; export default function BelongPeople(props: propsInfo) { + // const [propsShow,setPropsShow] = useState(props.belongPeopleInfo.authorId?true) // const nav = useNavigate(); // const pathParams = useParams(); const [messageApi, contextHolder] = message.useMessage(); @@ -127,15 +128,43 @@ export default function BelongPeople(props: propsInfo) { selectedRowKeys, onChange: (selectedRowKeys: React.Key[], selectedRows: typeof tableBelongData[0][]) => { setSelectedRowKeys(selectedRowKeys); - if (selectedRows.length > 0) { - setauthorName(selectedRows[0].name); - setauthorIdCardType(selectedRows[0].idCardType); - setauthorIdCard(selectedRows[0].idCardNo); - setauthorType(selectedRows[0].type); - setauthorProvinceCity(selectedRows[0].provinceCity); - setauthorCrcAccount(selectedRows[0].isCrcAccount); - setAuthorId(selectedRows[0].projOwnerId); + // if (selectedRows.length > 0) { + // setauthorName(selectedRows[0].name); + // setauthorIdCardType(selectedRows[0].idCardType); + // setauthorIdCard(selectedRows[0].idCardNo); + // setauthorType(selectedRows[0].type); + // setauthorProvinceCity(selectedRows[0].provinceCity); + // setauthorCrcAccount(selectedRows[0].isCrcAccount); + // setAuthorId(selectedRows[0].projOwnerId); + // } + const isClearingSelection = selectedRowKeys.length === 0; + if (isClearingSelection) { + setauthorName(''); + setauthorIdCardType(''); + setauthorIdCard(''); + setauthorType(''); + // setauthorNameEn(''); + setauthorProvinceCity(''); + setauthorCrcAccount(0); + // setauthorCrcAccountPassword(''); + // setauthorCrcAccountUsername(''); + setAuthorId(''); + } else { + // 正常选中时,更新相关状态 + setSelectedRowKeys(selectedRowKeys); + const firstSelectedRow = selectedRows[0]; + setauthorName(firstSelectedRow.name); + setauthorIdCardType(firstSelectedRow.idCardType); + setauthorIdCard(firstSelectedRow.idCardNo); + setauthorType(firstSelectedRow.type); + // setauthorNameEn(firstSelectedRow.nameEn); + setauthorProvinceCity(firstSelectedRow.provinceCity); + setauthorCrcAccount(firstSelectedRow.isCrcAccount); + // setauthorCrcAccountPassword(firstSelectedRow.crcAccountPassword); + // setauthorCrcAccountUsername(firstSelectedRow.crcAccountUsername); + setAuthorId(firstSelectedRow.projOwnerId); } + }, }; // 单行选择触发单选 @@ -483,20 +512,44 @@ export default function BelongPeople(props: propsInfo) {