| | |
| | | }, |
| | | methods: { |
| | | async fetchTools(searchKey) { |
| | | try { |
| | | const res = await this.$post({ |
| | | url: '/MesCutterLedger/QueryTools', |
| | | data: JSON.stringify({ |
| | |
| | | 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() { |