博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
页面下拉数据公共方法(以客户服务为例cust)
阅读量:7056 次
发布时间:2019-06-28

本文共 1971 字,大约阅读时间需要 6 分钟。

hot3.png

1.前端页面对下拉框添加属性datasource="xxx_educationid(此名称与basecode.properties中内容一致)" dropdown

 

<label class="col-lg-2  control-label">学历:</label>

<div class="col-lg-4 col-lg-4_1" style="float: left;">

<select class="form-control" id="educationId" name="educationId" style="width:100%"  datasource="xxx_educationid" dropdown>                      </select></div>

2.Js中添加公用方法

/*----------初始化下拉数据-----start-------*/

function initDropDown(){

    for(i=0;i<$("select[dropdown]").length;i++){

       var id = $($("select[dropdown]")[i]).attr("id");

       var datasource = $($("select[dropdown]")[i]).attr("datasource");

       $("#"+id).empty();

       $("#"+id).append("<option value=''></option>");

       initobjectid(datasource,id);

    }

}

function initobjectid(datasource,downid){

    $.ajax({

       url : interfaces.searchBasecodeByObjectId + datasource +"/basecodes",

       type : "GET",

       data : {},

       async : false,

       dataType : "JSON",

       success : function(result) {

           if (result != null) {

              for(var i =0;i<result.length;i++){

$("#"+downid).append("<option value='"+result[i].id+"'>"+result[i].name+"</option>");

              }

           }

       },

       error : function() {

           showTip("danger","获取下拉数据失败!");

       }

    });

}  

/*----------初始化下拉数据-----end-------*/

 

3. 在interfacesConfig.js添加searchBasecodeByObjectId:domain+"cust/v1/customers/"//查询下拉数据 公共方法。

4.添加公共CommController文件

/**

     * 根据objectid查询基础编码表

     * FIXME

     * objectIdString

     *

     */

  @RequestMapping(value="/cust/v1/customers/{objectId}/basecodes",method=RequestMethod.GET, produces = "application/json;charset=UTF-8")

    @ResponseBody

public List<Map<String, Object>> searchBasecodeByObjectId(@PathVariable(value = "objectId") String objectIdString){

        Integer objectId = Integer.parseInt(CommConfig.getRefreshProperty(objectIdString).trim());

        List<Map<String, Object>> map = baseCodeService.searchByObjectId(objectId);

       return map;

}

其中CommConfig.getRefreshProperty(objectIdString).trim()为根据传入参数获取配置文件内容

5.添加获取类CommConfig.java 和配置文件basecode.properties,basecode.properties内容是 对象名称对应的id 通过id可以获取基础编码数据, id与数据对象表id值保持一致。_

 

转载于:https://my.oschina.net/Seaside20151225/blog/668104

你可能感兴趣的文章
数组(全部子集)二
查看>>
我的友情链接
查看>>
IRichBolt和IBasicBolt/BaseBasicBolt对比
查看>>
我的友情链接
查看>>
我的友情链接
查看>>
Linux特殊权限:setuid、setgid、粘贴位
查看>>
Cisco路由器的安全配置方案
查看>>
基于2.6.23.1内核,用netfilter抓包,并且用proc文件输出,实现源码
查看>>
MySql主从复制(1主2从)
查看>>
Hive 1.0 HWI安装
查看>>
jenkins部署
查看>>
2-2 RHEL7安装Samba服务
查看>>
彻底搞懂编码 GBK 和 UTF8
查看>>
yii2使用多个数据库的案例
查看>>
成人高考科目
查看>>
动态域名搭建exchang邮箱服务器
查看>>
Jquery实现新闻上下滚动效果
查看>>
CGI?
查看>>
使用postMessage实现跨窗口消息传递
查看>>
VIM跳转和小改动
查看>>