layui进行分页处理,后端返回数据没有count字段,需要单独获取再添加到数据中,再进行项渲染,另有layui表格数据增删改查前后端交互

整体效果图如下:
layui进行分页处理,后端返回数据没有count字段,需要单独获取再添加到数据中,再进行项渲染,另有layui表格数据增删改查前后端交互_第1张图片

(1)分页前端界面处理

layui进行分页处理,后端返回数据没有count字段,需要单独获取再添加到数据中,再进行项渲染,另有layui表格数据增删改查前后端交互_第2张图片

(2)分页后端的数据处理
layui进行分页处理,后端返回数据没有count字段,需要单独获取再添加到数据中,再进行项渲染,另有layui表格数据增删改查前后端交互_第3张图片

具体代码如下:
前端界面代码:包括分页,增删改查,刷新(搜索功能还没做,后端是java代码)




    
    
    
    
    Data-Table 表格
    
    
    
    
    





批量添加 采集设备总数 添加
搜索条件:
//这是修改弹出框的代码style="display:none是界面的隐藏,只有调用才会在界面显示

添加功能的界面和代码
layui进行分页处理,后端返回数据没有count字段,需要单独获取再添加到数据中,再进行项渲染,另有layui表格数据增删改查前后端交互_第4张图片

添加界面代码:




    
    
    
    
    表单
    
    
    
    


添加采集设备

后端的分页数据返回代码

  //获取采集设备总记录数
     String getCollectorInfoTotalRow="";
    @RequestMapping("/getCollectorInfoTotalRow")
    public  String getCollectorInfoTotalRow() throws Exception {
        String url = "/getCollectorInfoTotalRow";
        String equirments = equipmentService.getEquirement(url);
        JSONObject json = JSONObject.parseObject(equirments);
        getCollectorInfoTotalRow=json.get("count").toString();
        System.out.print(equirments);
        return equirments;
    }
    //获取采集设备信息
    @RequestMapping("getCollectorInfo")
    public  String getCollectorInfo(int page,int limit) throws Exception {
        String url = "/getCollectorInfo?page="+page+"&pageSize="+limit;
        String equirments = equipmentService.getEquirement(url);
        JSONObject json = JSONObject.parseObject(equirments);//将数据转化为json对象
        json.put("count",getCollectorInfoTotalRow);//把对象的count,进行赋值
        System.out.println(json.toString());
        return json.toString();
    }
返回的数据为:
//返回数据的总的记录数
{"msg":"200","code":0,"count":4}
//返回后台的数据不带count字段
{"returnCode":"200","data":[{"eqptIdCode":"075500005","eqptTypeName":"北电国网I型集中器","creator":"dyd","createTime":"2018-09-04 19:26:54","eqptName":"075500005","eqptType":"0a0003biac"},{"eqptIdCode":"075500006","eqptTypeName":"北电国网I型集中器","creator":"dyd","createTime":"2018-09-04 19:27:02","eqptName":"075500006","eqptType":"0a0003biac"},{"eqptIdCode":"000075500907","eqptTypeName":"北电以太网采集器","creator":"dyd","createTime":"2018-09-07 14:17:33","eqptName":"无锡展会zigbee网关","eqptType":"0a0003ahup"},{"eqptIdCode":"075500009","eqptTypeName":"北电国网I型集中器","creator":"dyd","createTime":"2018-09-10 13:51:21","eqptName":"水电集中器","eqptType":"0a0003biac"}]}

//经过处理后的字段,返回前端需要自动渲染的格式:
{"msg":"200","code":0,"data":[{"eqptIdCode":"075500005","eqptTypeName":"北电国网I型集中器","creator":"dyd","createTime":"2018-09-04 19:26:54","eqptName":"075500005","eqptType":"0a0003biac"},{"eqptIdCode":"075500006","eqptTypeName":"北电国网I型集中器","creator":"dyd","createTime":"2018-09-04 19:27:02","eqptName":"075500006","eqptType":"0a0003biac"},{"eqptIdCode":"000075500907","eqptTypeName":"北电以太网采集器","creator":"dyd","createTime":"2018-09-07 14:17:33","eqptName":"无锡展会zigbee网关","eqptType":"0a0003ahup"},{"eqptIdCode":"075500009","eqptTypeName":"北电国网I型集中器","creator":"dyd","createTime":"2018-09-10 13:51:21","eqptName":"水电集中器","eqptType":"0a0003biac"}],"count":"4"}

你可能感兴趣的:(springboot,layui框架)