amis crud 结合 service使用时,通过service获取表格数据时,total无效

cedebl8k  于 4个月前  发布在  其他
关注(0)|答案(5)|浏览(98)

问题详细描述:我用一个service做父容器,加载了CRUD需要的数据,并且处理好为CRUD需要的数据格式,CRUD通过 source获取,渲染表格数据正确,但是获取total失败,导致组件无法显示总条目数

amis sdk v2.8.0

code 请直接复制

{
  "type": "service",
  "name": "component_authorityList_service",
  "id": "component_authorityList_service",
  "api": {
    "url": "${window:host}/rest/ums/authority/listFunction",
    "method": "post",
    "data": {
      "parentId": "${selectSystem.value.id}"
    },
    "sendOn": "${selectSystem!=null}",
    "adaptor": "return window.crudRes.apply(this,arguments)",
    "requestAdaptor": "return window.crudReq.apply(this,arguments)"
  },
  "body": {
    "alwaysShowPagination": true,
    "syncLocation": false,
    “source”:"${items}"
    "perPage": 10000000,
    "perPageAvailable": [],
    "columns": [
      {
        "type": "operation",
        "label": {
          "name": "checkboxAll",
          "type": "checkbox",
          "label": "全选",
          "value": "${systemcheckboxAll}",
          "onEvent": {
            "change": {
              "actions": [
                {
                  "actionType": "custom",
                  "script": "authority_select_list_page.selectCheckBox.apply(this,arguments)"
                },
                {
                  "actionType": "setValue",
                  "componentId": "page",
                  "args": {
                    "value": {
                      "systemcheckboxAll": "${checkboxAll}"
                    }
                  }
                },
                {
                  "actionType": "reload",
                  "target": "component_authorityList_crud",
                  "componentId": "component_authorityList_crud"
                }
              ]
            }
          }
        },
        "width": "10%",
        "buttons": [
          {
            "name": "checkbox",
            "type": "checkbox",
            "value": "${checkbox}",
            "label": "",
            "onEvent": {
              "change": {
                "actions": [
                  {
                    "actionType": "custom",
                    "script": "authority_select_list_page.selectCheckBox.apply(this,arguments)"
                  }
                ]
              }
            }
          }
        ]
      },
      {
        "name": "name",
        "label": "功能",
        "type": "text"
      },
      {
        "name": "groupName",
        "label": "功能组",
        "type": "text"
      },
      {
        "name": "path",
        "label": "路径",
        "type": "text"
      }
    ],
    "type": "crud",
    "name": "component_authorityList_crud",
    "id": "component_authorityList_crud",
    "className": "authority_select_list_page_crud"
  }
}

kq0g1dla

kq0g1dla3#

非预期用法,要显示总量的用 crud,或者自己用 tpl 写 footerToolbar,然后用 拼出总量

11dmarpk

11dmarpk4#

核心是取不了total就没法分页 展示都是其次

mrfwxfqh

mrfwxfqh5#

后端分页只能是 crud + api,前端分页的话倒是可以(不过也要用最新的 3.5.2 版本)

相关问题