fix(accounting): wire up download button, fix LEFT JOIN in download DSPY

This commit is contained in:
yumoqing 2026-07-17 15:11:16 +08:00
parent 9a6723378b
commit d4e32a2292
2 changed files with 12 additions and 4 deletions

View File

@ -61,9 +61,17 @@
"widgettype": "Button",
"id": "billing_download_btn",
"options": {
"text": "下载Excel",
"css": "display: none; background-color: #52c41a; color: white; padding: 5px 15px; border-radius: 4px; cursor: pointer;"
}
"label": "下载Excel",
"css": "background-color: #52c41a; color: white; padding: 5px 15px; border-radius: 4px; cursor: pointer;"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"script": "var f=bricks.getWidgetById('billing_form');if(!f)return;var v=f.values||{};if(!v.start_date||!v.end_date){bricks.show_error({title:'提示',message:'请先选择日期范围'});return;}var u='{{download_url}}?start_date='+encodeURIComponent(v.start_date)+'&end_date='+encodeURIComponent(v.end_date);fetch(u,{credentials:'include'}).then(function(r){return r.json()}).then(function(d){if(d.status!=='ok'){bricks.show_error({title:'下载失败',message:d.data.message});return;}var b=atob(d.data.content),n=b.length,arr=new Uint8Array(n);for(var i=0;i<n;i++)arr[i]=b.charCodeAt(i);var blob=new Blob([arr],{type:'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});var a=document.createElement('a');a.href=URL.createObjectURL(blob);a.download=d.data.filename;a.click()}).catch(function(e){bricks.show_error({title:'下载失败',message:e.toString()})})"
}
]
}
]
},

View File

@ -23,7 +23,7 @@ async with get_sor_context(request._run_ns, 'accounting') as sor:
d.summary, d.amount, d.balance
from acc_detail d
join account a on d.accountid = a.id COLLATE utf8mb4_unicode_ci
join subject s on a.subjectid = s.id COLLATE utf8mb4_unicode_ci
left join subject s on a.subjectid = s.id COLLATE utf8mb4_unicode_ci
where a.orgid = ${orgid}$
and d.acc_date >= ${start_date}$
and d.acc_date <= ${end_date}$