{% set billing_url = entire_url('/accounting/billing.dspy') %} { "widgettype": "VBox", "id": "billing_page", "options": { "width": "100%", "height": "100%", "gap": "10px" }, "subwidgets": [ { "widgettype": "InlineForm", "id": "billing_form", "options": { "fields": [ { "name": "start_date", "label": "开始日期", "uitype": "date", "required": true }, { "name": "end_date", "label": "结束日期", "uitype": "date", "required": true } ], "submit_label": "查询" }, "binds": [ { "wid": "self", "event": "submit", "actiontype": "method", "target": "app.billing_tabular", "method": "render" } ] }, { "widgettype": "HBox", "id": "billing_stats_box", "options": { "width": "100%", "gap": "20px", "align_items": "center" }, "subwidgets": [ { "widgettype": "Text", "id": "billing_stats", "options": { "text": "请输入日期范围进行查询", "css": "font-size: 14px; color: #666;" } }, { "widgettype": "Text", "id": "billing_download_btn", "options": { "text": " 下载Excel ", "bgcolor": "#52c41a", "color": "#FFFFFF", "css": "border-radius: 4px; padding: 4px 12px; cursor: pointer; font-size: 14px;" }, "binds": [ { "wid": "self", "event": "click", "actiontype": "script", "script": "var sd=document.querySelector(\"[name='start_date']\"),ed=document.querySelector(\"[name='end_date']\");if(!sd||!ed||!sd.value||!ed.value){bricks.show_error({title:'提示',message:'请先选择日期范围'});return;}var u='/accounting/billing_download.dspy?start_date='+encodeURIComponent(sd.value)+'&end_date='+encodeURIComponent(ed.value);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