弹出层列表父子页面传值

1 篇文章 0 订阅

需求: 

 若将layer弹出层作为单独的插件引用的话,需要先引入jQuery1.8以上版本和layer.js以及layer.css。(layer文档

 $("#addressBtn").click(function () {
            var dept = $("#OrderDepts").val();
            if (dept == 0) {
                $.MsgBox.Alert("温馨提示", "请选择采购部门!");
                return;
            }
            layer.open({
                        type: 2,
                        title: '个人地址信息列表',
                        shadeClose: true,
                        shade: false,
                        maxmin: true, 
                        area: ['1000px', '500px'],
                        content: "@Url.Action("GetAddressByDept", "Member")?deptId=" + $("#OrderDepts").val()
                    });
        });
@section scripts{
    <script type="text/javascript">
        $(function () {
            LoadData();
        })
        //初始化表格  根据查询条件读取数据
        function LoadData() {
            var DeptId = "@ViewBag.DeptId";
            //先销毁表格
            $('#table').bootstrapTable('destroy');
            //初始化表格,动态从服务器加载数据
            $('#table').bootstrapTable({
                url: '@Url.Action("GetAddressByDept2", "Member")',     //请求后台的URL(*)
                toolbar: '#toolbar',                //工具按钮用哪个容器
                striped: false,                     //是否显示行间隔色
                cache: true,                        //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
                pagination: true,                  //是否显示分页(*)
                sortable: false,                    //是否启用排序
                sortOrder: "asc",                   //排序方式
                sidePagination: "client",           //分页方式:client客户端分页,server服务端分页(*)
                pageNumber: 1,                      //初始化加载第一页,默认第一页
                pageSize: 20,                       //每页的记录行数(*)
                pageList: [20, 50, 100],        //可供选择的每页的行数(*)
                search: false,                      //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
                strictSearch: false,                //设置为 true启用 全匹配搜索,否则为模糊搜索
                showRefresh: false,                 //是否显示刷新按钮
                clickToSelect: true,                //是否启用点击选中行
                singleSelect: true,
                uniqueId: "Id",                  //每一行的唯一标识,一般为主键列
                queryParamsType: "undefined",
                fixedColumns: false,
                fixedNumber: 1,
                queryParams: function queryParams(params) {
                    var param = {
                        deptId: DeptId,
                        key: $("#name").val()
                    };
                    return param;
                },
                onLoadSuccess: function () { },
                onLoadError: function () { }
            });
        }


        $("#submitAddress").click(function () {
            var address = $("#table").bootstrapTable('getSelections');
            if (address.length == 0) {
                $.MsgBox.Alert("温馨提示", "还未选择收货人信息!");
                return;
            }
            else { //给父页面传值
                $.MsgBox.Confirm("提示", "确定要提交该记录吗?", function () {
                    var realName = address[0].RealName;
                    var addressDetail = address[0].Province + "." + address[0].City + "." + address[0].Area + "." + address[0].Address;
                    var mobile_telphone = address[0].Mobile + "/" + address[0].Telphone;     
                    parent.$(".addresslist.receipt.current").removeClass("current");
                    parent.$(".checkicon.current").removeClass("current");
                    var addressHtml = '<div class="addresslist receipt current" onclick="GetCurrentAddress(this)">'+
                        '<span class="checkicon current" > ' +
                        '<svg class="icon" aria-hidden="true">'+
                               '<use xlink: href="#icon-wancheng">'+'</use>'+
                                    '</svg >'+
                               ' </span >'+
                        '<span id="realName">' + realName+'</span>'+
                    '<span id="addressDetail">' + addressDetail+'</span>'+
                        '<span id="mobile_telphone">' + mobile_telphone + '</span>' +
                        '<span id="tempMemberId" style="display:none">' + address[0].Id + '</span>' +
                        '</div>';
                    parent.$("#addresslist").append(addressHtml);
                    parent.$(".addresslist.receipt.current").trigger("click");
                    $.MsgBox.Confirm("提示", "收货人信息已经更改,返回结算页面吗?", function () {
                        parent.layer.closeAll();
                    });
                });
            }
        });
  </script>
}
public ActionResult GetAddressByDept2(int deptId,string key)
        {
            BaseManage<Member> bm = new BaseManage<Member>();
            QueryOption<Member> option = new QueryOption<Member>();
            option.Conditions.Add(new QueryCondition() { Field = "DeptId", SymbolEnum = QueryConditionSymbol.Equals, Val = deptId });
            if (!string.IsNullOrEmpty(key))
            {
                option.Conditions.Add(new QueryCondition() { Field = "RealName", SymbolEnum = QueryConditionSymbol.Contains, Val = key.Trim() });
            }
            var members = bm.Query(option).Items;
            var address = (from m in members
                           select new AddressInfo() {
                               Id = m.Id,
                               RealName = m.RealName,
                               Province = m.Province,
                               City = m.City, Area = m.Area,
                               Address = m.Address ,
                               Mobile =m.Mobile,
                               Telphone =m.Telphone}).ToList();
            return Json(address,JsonRequestBehavior.AllowGet);
        }

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值