From ea6f9471b88dd1aad8baa418d663fc456f0dd4af Mon Sep 17 00:00:00 2001 From: lyp Date: Fri, 14 Mar 2025 18:09:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BelongPeople/BelongPeople.tsx | 114 +++++++++++++++---- src/route/proj/ProjNew.tsx | 23 ++++ src/route/proj/edit/ProjEditStep2.tsx | 16 ++- 3 files changed, 129 insertions(+), 24 deletions(-) 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) {
{authorName ? (<> -
+
当前所属者:
请选择所属者
{authorName}/{authorType == 'PERSONAL' ? '自然人' : '企业-组织'}/{authorIdCardType == 'ID_CARD' ? '身份证' : '营业执照'}/{authorIdCard}
+
) : (<> -
+
当前所属者:
请选择所属者
{props.belongPeopleInfo.authorName}/{props.belongPeopleInfo.authorType == 'PERSONAL' ? '自然人' : '企业-组织'}/{props.belongPeopleInfo.authorIdCardType == 'ID_CARD' ? '身份证' : '营业执照'}/{props.belongPeopleInfo.authorIdCard}
+ +
)} @@ -527,10 +580,18 @@ export default function BelongPeople(props: propsInfo) { // 阻止默认的行点击事件,以避免选中行时触发其他操作 event.stopPropagation(); // 更新选中的行 - belongRowSelection.onChange([record.projOwnerId], [record]); + // belongRowSelection.onChange([record.projOwnerId], [record]); + const isSelected = belongRowSelection.selectedRowKeys.includes(record.projOwnerId); + if (isSelected) { + // 如果已经选中,则清空选中状态 + belongRowSelection.onChange([], []); + } else { + // 如果未选中,则更新选中的行 + belongRowSelection.onChange([record.projOwnerId], [record]); + } } }, - style: { cursor: 'pointer' } + style: { cursor: 'pointer' } }; }} > @@ -813,24 +874,31 @@ export default function BelongPeople(props: propsInfo) {
diff --git a/src/route/proj/ProjNew.tsx b/src/route/proj/ProjNew.tsx index cf71576..21f371f 100644 --- a/src/route/proj/ProjNew.tsx +++ b/src/route/proj/ProjNew.tsx @@ -638,6 +638,7 @@ export default function ProjNew() {
{ setBelongModal(true) }}>选择
+
{ + setValue('') + setBelongPeopleInfo({ + authorName: '', + authorType: '', + authorIdCardType: '', + authorIdCard: '', + authorCrcAccount: '', + authorId: '', + authorProvinceCity: '' + }) + }}>取消
diff --git a/src/route/proj/edit/ProjEditStep2.tsx b/src/route/proj/edit/ProjEditStep2.tsx index bb71595..c710585 100644 --- a/src/route/proj/edit/ProjEditStep2.tsx +++ b/src/route/proj/edit/ProjEditStep2.tsx @@ -770,12 +770,26 @@ export default function ProjEditStep2(props: any) { />
*/}
-
+
当前所属者:
请选择所属者
{authorName}/{authorType == 'PERSONAL' ? '自然人' : '企业-组织'}/{authorIdCardType == 'ID_CARD' ? '身份证' : '营业执照'}/{authorIdCard}
+
{/* 表格 */}