🔄 fix: improve vendor-tab filtering & counts, resolve SQL ambiguity, and reload data correctly

Backend
• model/model_meta.go
  – Import strconv
  – SearchModels: support numeric vendor ID filter vs. fuzzy name search
  – Explicitly order by `models.id` to avoid “ambiguous column name: id” error

Frontend
• hooks/useModelsData.js
  – Change vendor-filter API to pass vendor ID
  – Automatically reload models when `activeVendorKey` changes
  – Update vendor counts only when viewing “All” to preserve other tab totals
• Add missing effect in EditModelModal to refresh vendor list only when modal visible
• Other minor updates to keep lints clean

Result
Tabs now:
1. Trigger API requests on click
2. Show accurate per-vendor totals
3. Filter models without resetting other counts
Backend search handles both vendor IDs and names without SQL errors.
This commit is contained in:
t0ng7u
2025-07-31 23:30:45 +08:00
parent 6a37efb871
commit 232612898b
3 changed files with 26 additions and 15 deletions

View File

@@ -75,9 +75,10 @@ const EditModelModal = (props) => {
};
useEffect(() => {
fetchVendors();
}, []);
if (props.visiable) {
fetchVendors();
}
}, [props.visiable]);
const getInitValues = () => ({
model_name: '',