fix: sb_buscar_por_id chama metodo correto (id numerico), tenta id primeiro no openConsultaRegistro
This commit is contained in:
@@ -437,9 +437,9 @@ pub fn sb_listar_recentes(
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn sb_buscar_por_id(
|
pub fn sb_buscar_por_id(
|
||||||
sb: State<'_, SupabaseClient>,
|
sb: State<'_, SupabaseClient>,
|
||||||
id: String,
|
id: i64,
|
||||||
) -> Result<Option<serde_json::Value>, SupabaseError> {
|
) -> Result<Option<serde_json::Value>, SupabaseError> {
|
||||||
sb.buscar_por_uuid(&id)
|
sb.buscar_por_id(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
+8
-5
@@ -2179,14 +2179,17 @@ window.openConsultaRegistro = async function(idx) {
|
|||||||
|
|
||||||
let full = null;
|
let full = null;
|
||||||
try {
|
try {
|
||||||
if (item.uuid) {
|
// 1. Tentar por id numérico (campo "id" da tabela, pk)
|
||||||
|
if (item.id) {
|
||||||
|
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_id', { id: item.id }); } catch(e) {}
|
||||||
|
}
|
||||||
|
// 2. Tentar por uuid externo
|
||||||
|
if (!full && item.uuid) {
|
||||||
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_uuid', { uuid: item.uuid }); } catch(e) {}
|
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_uuid', { uuid: item.uuid }); } catch(e) {}
|
||||||
}
|
}
|
||||||
|
// 3. Tentar por id_fechamento (ex: uniao_2026-06-11_filipe)
|
||||||
if (!full && item.id_fechamento) {
|
if (!full && item.id_fechamento) {
|
||||||
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_id_fechamento', { id_fechamento: item.id_fechamento }); } catch(e) {}
|
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_id_fechamento', { idFechamento: item.id_fechamento }); } catch(e) {}
|
||||||
}
|
|
||||||
if (!full && item.id) {
|
|
||||||
try { full = await window.__TAURI__.core.invoke('sb_buscar_por_id', { id: String(item.id) }); } catch(e) {}
|
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.warn('Erro buscando registro:', e);
|
console.warn('Erro buscando registro:', e);
|
||||||
|
|||||||
Reference in New Issue
Block a user