报表 API
获取API
- 在设置-统计分析-报表 新建报表并保存
- 在设置-统计分析-报表 报表详细页,开发标签下复制API
API 格式:
{ROOT_URL}/analytics/api/amis/question/{questionId}
获取结果
- 在浏览器访问API,获取报表数据
- 返回结果为JSON格式
报表数据结构
{
"status": 0, // 0 表示成功
"msg": "ok",
"data": {
"count": {count}, // 数据行数
"rows": [ // 数据
{
"{key}": "{value}",
...
},
],
"cols": [ // 数据列定义
{
"id": "",
"name": "",
"display_name": "",
"base_type": "",
"effective_type": "",
"semantic_type": null,
"field_ref": [
"field",
"",
null
],
"source": "",
"visibility_type": "",
"table_id": "",
...
},
]
}
}
报表数据示例
{
"status": 0,
"msg": "ok",
"data": {
"count": 10,
"rows": [
{
"_id": "65d6a69b1b9cab05bf584fc5_65a49dca55d1b305bf065324",
"category": "65d6a69b1b9cab05bf584fc5_659cb4a972192405bf822170",
"type": "火车票",
"invoice_date": "2023-07-05T00:00:00.000Z",
"invoice_num": "149Z058272",
"invoice_amount": 91.5,
"seller_name": null,
"purchaser_name": null,
"name": "Demo-FP-00001",
"verify_status": "不查验",
"created": "2024-02-22T09:42:52.159Z",
"external_category": "交通费"
},
{
"_id": "65d6a69b1b9cab05bf584fc5_65a49e1f55d1b305bf06532a",
"category": "65d6a69b1b9cab05bf584fc5_659cb4a972192405bf822170",
"type": "出租车票",
"invoice_date": "2023-06-07T00:00:00.000Z",
"invoice_num": "02833771",
"invoice_amount": 26,
"seller_name": null,
"purchaser_name": null,
"name": "Demo-FP-00002",
"verify_status": "不查验",
"created": "2024-02-22T09:42:52.159Z",
"external_category": "交通费"
},
],
"cols": [
{
"description": null,
"database_type": "java.lang.String",
"semantic_type": "type/PK", // 主键
"table_id": "invoices",
"coercion_strategy": null,
"name": "_id",
"fingerprint_version": 0,
"has_field_values": "search",
"settings": null,
"caveats": null,
"fk_target_field_id": null,
"dimensions": [],
"dimension_options": [],
"updated_at": "2023-08-04T05:39:33.039939",
"custom_position": 0,
"effective_type": "type/Text",
"active": true,
"nfc_path": null,
"parent_id": null,
"id": "invoices._id",
"last_analyzed": null,
"database_is_auto_increment": false,
"position": 0,
"visibility_type": "normal",
"default_dimension_option": null,
"target": null,
"preview_display": true,
"display_name": "ID",
"database_position": 0,
"database_required": false,
"fingerprint": null,
"created_at": "2023-08-04T05:39:33.039939",
"base_type": "type/Text",
"points_of_interest": null
},
{
"id": "invoices.category",
"name": "category",
"display_name": "费用类别",
"base_type": "type/Text",
"effective_type": "type/Text",
"semantic_type": "type/FK", // 外键
"field_ref": [
"field",
"invoices.category",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices",
"remapped_to": "external_category"
},
{
"id": "invoices.type",
"name": "type",
"display_name": "发票类型",
"base_type": "type/Text",
"effective_type": "type/Text",
"semantic_type": null,
"field_ref": [
"field",
"invoices.type",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.invoice_date",
"name": "invoice_date",
"display_name": "发票日期",
"base_type": "type/Date",
"effective_type": "type/Date",
"semantic_type": null,
"field_ref": [
"field",
"invoices.invoice_date",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.invoice_num",
"name": "invoice_num",
"display_name": "发票号码",
"base_type": "type/Text",
"effective_type": "type/Text",
"semantic_type": null,
"field_ref": [
"field",
"invoices.invoice_num",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.invoice_amount",
"name": "invoice_amount",
"display_name": "发票含税金额",
"base_type": "type/Float",
"effective_type": "type/Float",
"semantic_type": "type/Score",
"field_ref": [
"field",
"invoices.invoice_amount",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.seller_name",
"name": "seller_name",
"display_name": "销售方名称",
"base_type": "type/Text",
"effective_type": "type/Text",
"semantic_type": null,
"field_ref": [
"field",
"invoices.seller_name",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.purchaser_name",
"name": "purchaser_name",
"display_name": "购方名称",
"base_type": "type/Text",
"effective_type": "type/Text",
"semantic_type": null,
"field_ref": [
"field",
"invoices.purchaser_name",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.name",
"name": "name",
"display_name": "发票编号",
"base_type": "type/Text",
"effective_type": "type/Text",
"semantic_type": null,
"field_ref": [
"field",
"invoices.name",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.verify_status",
"name": "verify_status",
"display_name": "查验状态",
"base_type": "type/Text",
"effective_type": "type/Text",
"semantic_type": null,
"field_ref": [
"field",
"invoices.verify_status",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"id": "invoices.created",
"name": "created",
"display_name": "创建时间",
"base_type": "type/DateTime",
"effective_type": "type/DateTime",
"semantic_type": null,
"field_ref": [
"field",
"invoices.created",
null
],
"source": "fields",
"visibility_type": "normal",
"table_id": "invoices"
},
{
"description": null,
"semantic_type": "type/Name",
"table_id": "expense_category",
"coercion_strategy": null,
"name": "external_category",
"settings": null,
"source": "fields",
"remapped_from": "category",
"fk_field_id": "category",
"field_ref": [
"field",
"expense_category.name",
{
"source-field": "invoices.category"
}
],
"effective_type": "type/Text",
"nfc_path": null,
"parent_id": null,
"id": "expense_category.name",
"visibility_type": "normal",
"display_name": "费用类别"
}
]
}
}