Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7d0c416248 | |||
| 60ec60bf29 |
@@ -247,12 +247,14 @@ impl SupabaseClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Atualiza campos específicos de um fechamento pelo id numérico (PATCH).
|
/// Atualiza campos específicos de um fechamento pelo id numérico (pk) ou UUID.
|
||||||
pub fn atualizar_fechamento(&self, id: i64, updates: &serde_json::Value) -> Result<Value, SupabaseError> {
|
pub fn atualizar_fechamento(&self, id: Option<i64>, uuid: &str, updates: &serde_json::Value) -> Result<Value, SupabaseError> {
|
||||||
let url = format!(
|
// Se temos id numerico, usa id=eq.; senao usa id=eq.UUID
|
||||||
"{}/rest/v1/fechamentos_web?id=eq.{}",
|
let url = if let Some(num) = id {
|
||||||
self.base_url, id
|
format!("{}/rest/v1/fechamentos_web?id=eq.{}", self.base_url, num)
|
||||||
);
|
} else {
|
||||||
|
format!("{}/rest/v1/fechamentos_web?id=eq.{}", self.base_url, uuid)
|
||||||
|
};
|
||||||
|
|
||||||
let resp = self
|
let resp = self
|
||||||
.http
|
.http
|
||||||
@@ -262,7 +264,7 @@ impl SupabaseClient {
|
|||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
if resp.status().is_success() {
|
if resp.status().is_success() {
|
||||||
Ok(serde_json::json!({ "ok": true, "id": id }))
|
Ok(serde_json::json!({ "ok": true, "id": id.unwrap_or(0) }))
|
||||||
} else {
|
} else {
|
||||||
let status = resp.status();
|
let status = resp.status();
|
||||||
let body = resp.text().unwrap_or_default();
|
let body = resp.text().unwrap_or_default();
|
||||||
@@ -462,10 +464,13 @@ pub fn sb_buscar_por_id_fechamento(
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn sb_atualizar_fechamento(
|
pub fn sb_atualizar_fechamento(
|
||||||
sb: State<'_, SupabaseClient>,
|
sb: State<'_, SupabaseClient>,
|
||||||
id: i64,
|
id: String,
|
||||||
updates: serde_json::Value,
|
updates: serde_json::Value,
|
||||||
) -> Result<serde_json::Value, SupabaseError> {
|
) -> Result<serde_json::Value, SupabaseError> {
|
||||||
sb.atualizar_fechamento(id, &updates)
|
// Tenta primeiro como i64 (id numerico), depois como String (UUID)
|
||||||
|
let id_i64 = id.parse::<i64>().ok();
|
||||||
|
let id_str = &id;
|
||||||
|
sb.atualizar_fechamento(id_i64, id_str, &updates)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
+2
-1
@@ -2324,6 +2324,7 @@ function buildRelatorioModal(full) {
|
|||||||
${obs ? `<div style="background:#fff8e1;border-radius:6px;padding:8px;margin-bottom:10px;font-size:12px"><strong>Obs:</strong> ${obs}</div>` : ''}
|
${obs ? `<div style="background:#fff8e1;border-radius:6px;padding:8px;margin-bottom:10px;font-size:12px"><strong>Obs:</strong> ${obs}</div>` : ''}
|
||||||
|
|
||||||
<div id="edit-section" style="display:none;margin-bottom:10px">
|
<div id="edit-section" style="display:none;margin-bottom:10px">
|
||||||
|
<input type="hidden" id="edit-id" value="${full.id || ''}" />
|
||||||
<div style="font-size:12px;color:#666;margin-bottom:6px">Editar campos (requer senha admin):</div>
|
<div style="font-size:12px;color:#666;margin-bottom:6px">Editar campos (requer senha admin):</div>
|
||||||
<div style="margin-bottom:6px">
|
<div style="margin-bottom:6px">
|
||||||
<label style="font-size:11px;color:#555">Saldo Esperado:</label><br>
|
<label style="font-size:11px;color:#555">Saldo Esperado:</label><br>
|
||||||
@@ -2427,7 +2428,7 @@ window.salvarEdicaoConsulta = async function() {
|
|||||||
if (!hasTauri) { alert('Tauri não disponível.'); return; }
|
if (!hasTauri) { alert('Tauri não disponível.'); return; }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const id = window._currentConsultaId;
|
const id = document.getElementById('edit-id').value || window._currentConsultaId || full.id;
|
||||||
if (!id) { alert('ID do registro não encontrado. Não é possível atualizar.'); return; }
|
if (!id) { alert('ID do registro não encontrado. Não é possível atualizar.'); return; }
|
||||||
|
|
||||||
await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id, updates });
|
await window.__TAURI__.core.invoke('sb_atualizar_fechamento', { id, updates });
|
||||||
|
|||||||
Reference in New Issue
Block a user