快乐的昕的电脑
2025-10-13 db1cb9a6a19e6dac99878835cf7775a210d257db
更新 total
已修改1个文件
16 ■■■■ 文件已修改
components/mold.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
components/mold.vue
@@ -160,8 +160,13 @@
                        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 || '查询失败');
                    }
@@ -331,7 +336,12 @@
                        }));
                        // 如果后端返回了 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 || '获取表单数据失败');
                    }