{ "widgettype": "VBox", "id": "billing_page", "options": { "width": "100%", "height": "100%", "gap": "10px" }, "subwidgets": [ { "widgettype": "Form", "id": "billing_form", "options": { "title": "账单查询", "fields": [ { "name": "start_date", "label": "开始日期", "type": "date", "required": true }, { "name": "end_date", "label": "结束日期", "type": "date", "required": true } ], "submit_text": "查询" }, "binds": [ { "event": "submit", "target": "billing_tabular", "actiontype": "script", "script": "this.render(params); const statsResp = await fetch('{{entire_url(\"/accounting/billing.dspy\")}}?start_date=' + params.start_date + '&end_date=' + params.end_date); const statsData = await statsResp.json(); const statsText = bricks.getWidgetById('billing_stats'); if (statsText && statsData.stats) { statsText.dom_element.textContent = '总条数: ' + statsData.stats.total_count + ' | 借方合计: ¥' + parseFloat(statsData.stats.debit_sum).toFixed(2) + ' | 贷方合计: ¥' + parseFloat(statsData.stats.credit_sum).toFixed(2); } const dlBtn = bricks.getWidgetById('billing_download_btn'); if (dlBtn) { dlBtn.dom_element.style.display = 'inline-block'; dlBtn.dom_element.onclick = async function() { const resp = await fetch('{{entire_url(\"/accounting/billing_download.dspy\")}}?start_date=' + params.start_date + '&end_date=' + params.end_date); const data = await resp.json(); if (data.status === 'ok') { const byteChars = atob(data.data.content); const byteNumbers = new Array(byteChars.length); for (let i = 0; i < byteChars.length; i++) { byteNumbers[i] = byteChars.charCodeAt(i); } const byteArray = new Uint8Array(byteNumbers); const blob = new Blob([byteArray], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}); const url = window.URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = data.data.filename; document.body.appendChild(a); a.click(); document.body.removeChild(a); window.URL.revokeObjectURL(url); } }; }" } ] }, { "widgettype": "HBox", "id": "billing_stats_box", "options": { "width": "100%", "height": "40px", "gap": "20px", "align_items": "center" }, "subwidgets": [ { "widgettype": "Text", "id": "billing_stats", "options": { "text": "请输入日期范围进行查询", "css": "font-size: 14px; color: #666;" } }, { "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;" } } ] }, { "widgettype": "Tabular", "id": "billing_tabular", "options": { "width": "100%", "height": "100%", "css": "filler", "data_url": "{{entire_url('/accounting/billing.dspy')}}", "editable": false, "page_rows": 80, "cache_limit": 3, "row_options": { "browserfields": { "exclouded": ["row_num_"] }, "fields": [ { "name": "acc_date", "title": "日期", "type": "date", "uitype": "date", "datatype": "date", "label": "日期", "cwidth": 12 }, { "name": "acc_timestamp", "title": "时间", "type": "timestamp", "uitype": "timestamp", "datatype": "timestamp", "label": "时间", "cwidth": 16 }, { "name": "subject_name", "title": "科目", "type": "str", "length": 50, "uitype": "str", "datatype": "str", "label": "科目", "cwidth": 14 }, { "name": "acc_dir", "title": "方向", "type": "str", "length": 4, "uitype": "str", "datatype": "str", "label": "方向", "cwidth": 8 }, { "name": "summary", "title": "摘要", "type": "str", "length": 100, "uitype": "str", "datatype": "str", "label": "摘要", "cwidth": 30 }, { "name": "amount", "title": "金额", "type": "float", "length": 18, "dec": 4, "uitype": "float", "datatype": "float", "label": "金额", "cwidth": 12 }, { "name": "balance", "title": "余额", "type": "float", "length": 18, "dec": 4, "uitype": "float", "datatype": "float", "label": "余额", "cwidth": 12 } ] } } } ] }