zoukankan      html  css  js  c++  java
  • 00002-layui 右侧呼出页面,PopupLayer

    我这里的功能是弹出 右侧搜索 的页面:

    top.layui.admin.popupRight({
                  id: 'LAY_business_PopupLayer'
                  ,area: '350px'
                  ,success: function(layero,index){
                      var sexArr = top.layui.dict.options("sex");
                      var statusArr = top.layui.dict.options("status");
                      top.layui.view(this.id).render('business/businessUserSearch',$.extend(search_field,{
                          sexArr:sexArr,
                          statusArr:statusArr
    })).done(
                          function () {
                              top.layui.form.render();
                          }
                      );
                  }
              });
    

    重点是: top.layui.admin.popupRight
    而不是:admin.popupRight
    同时:PopupLayer 的内容是模板页面,打开代码是:

    top.layui.view(this.id).render('business/businessUserSearch');
    

    若有第二个参数,则为传到 businessUserSearch.html模板页的参数。

    这里,business/businessUserSearch, 相对目录默认是: /layuiadmin/tpl/ , 且页面默认为html

    businessUserSearch.html 代码为:

    <script type="text/html" template id="TPL_businessUser">
      <div class="layui-form" style="padding-top:20px;padding-right:10px;height: 90%;" id="businessUserSearch">
    
        <div class="layui-form-item">
          <label class="layui-form-label">用户帐号</label>
          <div class="layui-input-block">
            <input class="layui-input" name="userName" value="{{d.params.userName}}" autocomplete="off">
          </div>
        </div>
    
        <div class="layui-form-item">
          <label class="layui-form-label">姓名</label>
          <div class="layui-input-block">
            <input class="layui-input" name="name" value="{{d.params.name}}" autocomplete="off">
          </div>
        </div>
    
        <div class="layui-form-item">
          <label class="layui-form-label">部门</label>
          <div class="layui-input-block">
            <input class="layui-input" name="department" value="{{d.params.department}}" autocomplete="off">
          </div>
        </div>
    
        <div class="layui-form-item">
          <label class="layui-form-label">角色</label>
          <div class="layui-input-block">
            <input class="layui-input" name="role" value="{{d.params.role}}" autocomplete="off">
          </div>
        </div>
    
        <div class="layui-form-item">
          <label class="layui-form-label">职位信息</label>
          <div class="layui-input-block">
            <input class="layui-input" name="position" value="{{d.params.position}}" autocomplete="off">
          </div>
        </div>
    
        <div class="layui-form-item">
          <label class="layui-form-label">手机</label>
          <div class="layui-input-block">
            <input class="layui-input" name="tel" value="{{d.params.tel}}" autocomplete="off">
          </div>
        </div>
    
        <div class="layui-form-item">
          <label class="layui-form-label">性别</label>
          <div class="layui-input-block">
            <select name="sex"  id="sex" >
              <option value="">请选择</option>
              {{#
              layui.each(d.params.sexArr, function(index, item){
              }}
              <option value="{{item[0]}}" {{d.params.sex==item[0]?'selected':''}}>{{item[1]}}</option>
              {{# }) }}
            </select>
          </div>
        </div>
    
        <div class="layui-form-item">
          <label class="layui-form-label">状态</label>
          <div class="layui-input-block">
            <select name="status"  id="status" >
              <option value="">请选择</option>
              {{#
              layui.each(d.params.statusArr, function(index, item){
              }}
              <option value="{{item[0]}}" {{d.params.status==item[0]?'selected':''}}>{{item[1]}}</option>
              {{# }) }}
            </select>
          </div>
        </div>
        
    
    
    
        <div class="layui-form-item" >
          <span class="layui-form-label"></span>
          <div class="layui-input-block" style="margin-right:0">
            <button class="layui-btn" lay-submit lay-filter="businessUser-list-search" id="businessUser-list-search">
              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="businessUser-list-refresh">
              <i class="layui-icon layui-icon-refresh-3 layuiadmin-button-btn"></i>
            </button>
          </div>
        </div>
    
    
    
      </div>
    </script>
    
    

    {{d.params.name}} 是父页面传过来的参数。

    父页面监听按钮事件:

    top.layui.form.on('submit(businessUser-list-search)', function(data){
        var field = data.field;
        table.reload('businessUserListTable', {
            where: field
        });
        search_field = field;
        top.layui.layer.close(top.layui.admin.popup.index);
    });
    top.layui.form.on('submit(businessUser-list-refresh)', function(data){
        top.layui.$(':input').not(':button, :submit, :reset').val('').removeAttr('selected').removeAttr('checked')
        search_field = {};
        top.layui.form.render();
        table.reload('businessUserListTable', {
            where: null
        });
    });
    

    页面重新渲染、关闭页面、监听事件, 都要 加 :top.layui.

    写写代码。 blog文章中不懂的,可+v:keep4ing。 在线乐意解答。
  • 相关阅读:
    <转>浅谈DNS体系结构:DNS系列之一
    SOA和NS区别
    《浅析各类DDoS攻击放大技术》
    《转》DNS放大攻击
    Linux创建公钥
    MATLAB 中有哪些命令,让人相见恨晚
    SQL中的declare用法
    SQl server 附加数据库失败如何解决
    VS中代码对齐等快捷键
    C#窗口控件Dock的位置顺序调整方法
  • 原文地址:https://www.cnblogs.com/jianquan100/p/12891659.html
Copyright © 2011-2022 走看看