merge code pull
This commit is contained in:
@@ -52,7 +52,18 @@ const openDialog = async (id: string) => {
|
||||
try {
|
||||
const res = await getDetail(id)
|
||||
if (res.data) {
|
||||
detailData.value = res.data
|
||||
// 根据接口文档,返回的数据可能是 { records: [...], total: ... } 格式
|
||||
// 如果是列表格式,取第一条;如果是对象,直接使用
|
||||
if (res.data.records && Array.isArray(res.data.records) && res.data.records.length > 0) {
|
||||
detailData.value = res.data.records[0]
|
||||
} else if (res.data.records && Array.isArray(res.data.records)) {
|
||||
// 列表为空
|
||||
useMessage().warning('未找到详情数据')
|
||||
visible.value = false
|
||||
} else {
|
||||
// 直接是对象
|
||||
detailData.value = res.data
|
||||
}
|
||||
}
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg || '获取详情失败')
|
||||
|
||||
Reference in New Issue
Block a user