快乐的昕的电脑
2025-10-13 dc073060ea4be3ef8de0076616b90c2e1fbc2708
components/mold.vue
@@ -127,6 +127,7 @@
      },
      methods: {
         async fetchTools(searchKey) {
            try {
            const res = await this.$post({
               url: '/MesCutterLedger/QueryTools',
               data: JSON.stringify({
@@ -149,18 +150,25 @@
                  return null;
               };
               this.filteredTools = (payload || []).map(t => ({
                  const mapped = (payload || []).map(t => ({
                  no: getField(t, 'cutterId', 'CUTTER_ID', 'cutteR_ID', 'daA001', 'no'),
                  name: getField(t, 'cutterName', 'CUTTER_NAME', 'cutteR_NAME', 'name'),
                  model: getField(t, 'cutterModel', 'CUTTER_MODEL', 'cutteR_MODEL', 'model')
               }));
               // 总数兼容多个字段名
               this.total = (res.data && (res.data.total ?? res.totalCount ?? res.total))
                  || payload.length || 0;
                  // 填充弹窗列表和下拉列表(模板中下拉使用 toolList)
                  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;
            } else {
               this.$showMessage(res.message || '查询失败');
            }
            } catch (err) {
               console.error('fetchTools 错误:', err);
               this.$showMessage('查询刀具失败,请检查网络或接口');
            }
         },
         //翻页
         async prevPage() {