| | |
| | | this.filteredTools = mapped; |
| | | this.toolList = mapped.slice(); |
| | | |
| | | // 总数优先取顶层 totalCount,再取嵌套 total,再退回 payload 长度 |
| | | this.total = Number(res.totalCount ?? res.data?.total ?? res.data?.totalCount ?? res.total ?? mapped.length ?? 0) || 0; |
| | | // 处理 total:当后端 totalCount 为 0 时,回退到嵌套 total 或映射数组长度 |
| | | const totalFromRes = Number(res.totalCount); |
| | | if (Number.isFinite(totalFromRes) && totalFromRes > 0) { |
| | | this.total = totalFromRes; |
| | | } else { |
| | | this.total = Number(res.data?.total ?? res.data?.totalCount ?? res.total ?? mapped.length) || 0; |
| | | } |
| | | } else { |
| | | this.$showMessage(res.message || '查询失败'); |
| | | } |
| | |
| | | })); |
| | | |
| | | // 如果后端返回了 totalCount,可以更新 total(用于分页显示) |
| | | this.total = Number(res.totalCount ?? res.data?.total ?? res.data?.totalCount ?? this.toolRecords.length ?? 0) || 0; |
| | | const totalFromRes = Number(res.totalCount); |
| | | if (Number.isFinite(totalFromRes) && totalFromRes > 0) { |
| | | this.total = totalFromRes; |
| | | } else { |
| | | this.total = Number(res.data?.total ?? res.data?.totalCount ?? this.toolRecords.length) || 0; |
| | | } |
| | | } else { |
| | | this.$showMessage(res.message || '获取表单数据失败'); |
| | | } |