• js初始化对象


     1  var safe = {
     2             safe_type:<%=safe_type_tab %>,
     3             detailList:<%=tempDetailList %>,
     4             moduleList:<%=moduleList %>,
     5             utmList:<%=utmList %>,
     6             params:{type1:<%=tempValueId%>,moduleValueId:<%=moduleValueId%>},
     7             inInControl:function(){
     8                 safe.bind_safe1();
     9                 safe.bing_safe3();
    10                 safe.bind_safe2(safe.params.type1);
    11                 $("#selTempList").change(function(){
    12                     var tempID = $(this).val();
    13                     $("#dataTempDatialTable tbody tr").remove();
    14                     if(tempID!=0){
    15                         safe.bind_safe2(tempID);
    16                     }
    17                 });
    18                 $("#selUtNavList").change(function(){
    19                     $("#hidNavModuleUrl").val($(this).attr("data-url"));
    20                 });
    21                
    22                 //修改时绑定下拉对象
    23                 var id = getQueryString('mid');
    24                 var idEdit = (id != null);
    25                 if(idEdit){
    26                     if(safe.params.type1==1){
    27                         $("#selTempList").val(safe.params.type1);
    28                         $("#dataTempDatialTable tbody tr").remove();
    29                         safe.bind_safe2(safe.params.type1);
    30                     }
    31                 }
    32             },
    33             bind_safe1:function(){
    34                 var type1 = $("#selTempList");
    35                 $.each(safe.safe_type.ds,function(i,item) {
    36                     var selTmep = safe.params.type1 == item.ID ? 'selected="selected"' : '';
    37                     type1.append('<option value="'+item.ID+'" '+selTmep+'>'+item.TempName+'</option>');
    38                 });
    39             },
    40             bind_safe2:function(id){
    41                 var type2 = $("#dataTempDatialTable tbody");
    42                 var num = 0;
    43                 var IsBoolutm = false;
    44                 var sel = "";
    45                 //模框
    46                 $.each(safe.detailList.ds,function(i,ite) {
    47                     if (ite.TempID == id){
    48                         ++num;
    49                         var htmlSelect = '<select id="selModuleList'+num+'" name="selModuleList" style=" 200px;"></select>';
    50                         
    51                         type2.append("<tr><td>"+num+"<td>"+ite.ID+"</td><td>"+ite.RectangleName+"</td><td>"+ite.DivID+"</td><td>"+ite.Width+"</td><td>"+ite.Height+"</td><td style='210px;'>"+htmlSelect+"</td></tr>");
    52                         
    53                         //模块
    54                         var modul = $("#selModuleList"+num);
    55                         $.each(safe.moduleList.ds, function(j, item) {
    56                             //模框与模块关系列表
    57                             if(safe.utmList != null){
    58                                 $.each(safe.utmList.ds, function(k, tem) {
    59                                     if (tem.TempDetailD == ite.ID && tem.ModuleID == item.ID) {
    60                                         IsBoolutm = true;
    61                                         sel = IsBoolutm ? 'selected = "selected"' : '';//编辑时默认选中对应的模块
    62                                     }
    63                                 });
    64                             }
    65                             if(item.Type != 4){
    66                                 modul.append('<option value="'+item.ID+'" '+sel+' >'+item.DisplayName+'</option>');
    67                             }
    68                             if(sel != "" || IsBoolutm == true){
    69                                 sel = "";
    70                                 IsBoolutm = false;
    71                             }
    72                         });
    73                     }
    74                 });
    75             },
    76             bing_safe3:function(){
    77                 var utNav = $("#selUtNavList");
    78                 $.each(safe.moduleList.ds, function(i, navItem) {
    79                     if(navItem.Type == 4){
    80                         var selModule = safe.params.moduleValueId == navItem.ID ? 'selected="selected"' : '';
    81                         utNav.append('<option data-url="'+navItem.Url+'" value="'+navItem.ID+'" '+selModule+'>'+navItem.DisplayName+'</option>');
    82                     }
    83                 });
    84                 //导航url初始值
    85                 $("#hidNavModuleUrl").val(utNav.find("option:selected").attr("data-url"));
    86             }
    87         };
    View Code
    收藏
    关注
    评论
  • 相关阅读:
    maven基础依赖外部lib包(依赖钉钉sdk为例)
    JVM的内存区域划分
    EF6 根据数据库字段说明,生成字段注释
    js上传图片,js图片转换为Base64
    Jquery用append()方法新增加的元素事件失效
    MVC添加区域路由问题
    JObject获取JSON格式字符串数据
    百度地图WebApi根据地址解析经纬度和根据经纬度解析地址
    sqlserver函数根据经纬度计算两点之间的距离
    AdminLTE-2.4.0-rc文件添加到项目中报错 错误 1 “tsc.exe”已退出,代码为 1。 M.Website
  • 原文地址:https://www.cnblogs.com/yidengbone/p/6510793.html
Copyright © 2020-2023  润新知