使用:row-selection=“rowSelection”
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/5f778a581c58d6f79f48839ea310af49.png)
table列表 html
<a-table
:columns="columnsTan"
:data-source="submitForm.tableDatTan"
:pagination="paginationTan"
@change="handleTableChangeTan"
:loading="tableLoadingTan"
rowKey="id"
:row-selection="rowSelection"
:scroll="{ x: 'max-content', y: 500 }"
v-if="submitDialogText === '1' || submitDialogText === '2'"
>
<template #index="{ index }">
{{ index + 1 }}
</template>
</a-table>
JS:
const rowSelection = reactive({
type: "radio",
selectedRowKeys: [],
selectTable: [],
onChange: (e, b) => {
console.log(e, b)
console.log(b, '#############')
rowSelection.selectedRowKeys = e
console.log(rowSelection.selectedRowKeys)
getAdministrativeDetail()
}
})
const getAdministrativeDetail = () => {
confirmLoading.value = true
post(API.resource.getAdministrativeDetail, {
params: {
id: rowSelection.selectedRowKeys + ""
}
})
.then((res) => {
submitForm.orgStage = res.data.orgStage === 'READY' ? false : true
if (res.data.categoryCode) {
submitForm.categoryCode = getParentNodesCode(searchForm.treeList, res.data.categoryCode, 'categoryCode');
getEmergencyOrgListByCategory(submitForm.categoryCode[submitForm.categoryCode.length - 1], res.data.parentId)
console.log(submitForm.categoryCode)
}
submitForm.id = res.data.id
submitForm.name = res.data.name ? res.data.name : ""
submitForm.shortName = res.data.shortName ? res.data.shortName : ""
submitForm.level = res.data.level ? res.data.level.slice(0, 2) + "" : undefined
getDictionaryListByCategoryCodes(submitForm.level, '2')
submitForm.fax = res.data.fax ? res.data.fax : ""
submitForm.area[0] = res.data.province ? res.data.province : ""
submitForm.area[1] = res.data.city ? res.data.city : ""
submitForm.area[2] = res.data.district ? res.data.district : ""
submitForm.responsibility = res.data.responsibility ? res.data.responsibility : ""
submitForm.lon = res.data.lon ? res.data.lon + "" : ""
submitForm.lat = res.data.lat ? res.data.lat + "" : ""
submitForm.remark = res.data.remark ? res.data.remark : ""
submitForm.managerName = res.data.managerName ? res.data.managerName : ""
submitForm.emergencyOrgPost = res.data.emergencyOrgPost ? res.data.emergencyOrgPost : ""
submitForm.officePhone = res.data.officePhone ? res.data.officePhone : ""
submitForm.mobilePhone = res.data.mobilePhone ? res.data.mobilePhone : ""
submitForm.personMemberList = res.data.memberOrg ? res.data.memberOrg : ""
setTimeout(() => {
submitForm.orgType = res.data.orgType ? res.data.orgType + "" : undefined
}, 500)
toCenterMap()
confirmLoading.value = false
})
.catch((res) => {
confirmLoading.value = false
message.error(res);
});
}