用相同jsp,js文件,同样的接口实现多页面构建

用相同jsp,js文件,同样的接口实现多页面构建

话不多说, 先上代码
在Controller文件中这两个接口返回的都是同一个页面,但是通过给model加上一个属性,但赋予不同的值,用来区别两个不同页面

 @RequestMapping("/page.htm")
    public String page(Model model) {
        model.addAttribute("roleType", getRoleType());
        model.addAttribute("isSupportActivity",YesNoEnum.YES.getCode());
        return "activity/applyAuditPage";
    }
    @RequestMapping("/disSupportPage.htm")
    public String disSupportPage(Model model){
        model.addAttribute("roleType", getRoleType());
        model.addAttribute("isSupportActivity",YesNoEnum.NO.getCode());
        return "activity/applyAuditPage";
    }

在jsp文件中给页面加上这两个属性

<script type="text/javascript">
    var pageObj = {roleType: '${roleType}', isSupportActivity: '${isSupportActivity}'};
</script>

在js文件中

   search: function () {
            var condition = pageObj.getSearchForm().jqForm("getValue");
            condition.id = pageObj.applyId;
            condition.isApplySupport = pageObj.isSupportActivity;
            pageObj.getDataGrid().jqGrid("setRequestData", {
                condition: condition,
                pageInfo: {
                    currentPage: 1    //指定查询页
                }
            }).jqGrid("reloadGrid");
        },

先将属性值加到condition中,再将condition放到requestData中,这样在网页请求中,请求的参数中就会有isApplySupport字段,在调用Controller中getByPage.json接口,接口通过
if ("1".equals(condition.getIsApplySupport()))
去分别两个页面

 @RequestMapping("/getByPage.json")
    @ResponseBody
    public Page getByPage(@JsonPathParam("$.pageInfo") Page page, @JsonPathParam("$.condition") ApplyVOExt condition) {
        if (getCurrentUser().getRoleType().equals(RoleTypeEnum.TYPE_3.getCode())) {
            if ("1".equals(condition.getIsApplySupport())){
            condition.setManageArea(getCurrentUser().getAreaCode());
            condition.setExpertScoreType(ExpertScoreTypeEnum.TYPE_1.getCode());
            condition.setIsApplySupport(YesNoEnum.YES.getCode());
            }else{
                condition.setManageArea(getCurrentUser().getAreaCode());
                condition.setExpertScoreType(ExpertScoreTypeEnum.TYPE_1.getCode());
                condition.setIsApplySupport(YesNoEnum.NO.getCode());
            }
        }
        if (getCurrentUser().getRoleType().equals(RoleTypeEnum.TYPE_4.getCode())) {
            condition.setExpertUserId(getCurrentUserId());
            condition.setExpertScoreType(ExpertScoreTypeEnum.TYPE_2.getCode());
            condition.setReportStatus(YesNoEnum.YES.getCode());
        }
        return applyService.getPage(null, page, condition);
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值