@{
    ViewBag.Title = "用户信息";//AdminEditByRights
    Layout = "~/Views/Shared/_LayoutContent.cshtml";
}
@section scripts{
    <script type="text/javascript">
        var id = request("id") === "" ? -1 : request("id");
        $(function () {
            $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });
            $("#btnClose").on("click", function () {
                parent.$("#btnSearch").trigger("click");
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            });
            $("#btnSave").on("click", function () {
                $(this).blur();
                var json = { id: id, account: "", sex: "", dept: "", phone: "", realname: "", groupsid: "", ordermng: "", isread: "", status: "", iszhiying: "", zhiyingID: "", isexport: "", menu_groupsid: "", main: "", join_mng: "", stock_import_right: "", product_right: "", Promotions_right: "", postsale_groupsid: "", postsale_right: "", postsale_stock_right: "", OrderStatusid14_right: "", Stock_rights: "", Stock_Field_rights: "", Brand_rights: "", postsale_cancel_right: "" };
                for (var key in json) {
                    if (key == "id") {
                        continue;
                    }
                    else if (key == "sex"
                        || key == "status"
                        || key == "isread") {
                        json[key] = $("[name='{0}']:checked".format(key)).val();
                    }
                    else if (key == "groupsid"
                        || key == "postsale_groupsid"
                        || key == "stock_import_right"
                        || key == "product_right"
                        || key == "postsale_right"
                        || key == "postsale_stock_right"
                        || key == "Stock_Field_rights"
                        || key == "Stock_rights"
                        || key == "Brand_rights"
                        || key == "postsale_cancel_right") {
                        var dataList = [];
                        $("[name='{0}']:checked".format(key)).each(function () {
                            dataList.push($(this).val());
                        });
                        json[key] = dataList.join(",");
                    }
                    else {
                        json[key] = $("#" + key).val();
                    }
                }
                if ($.trim(json.account).length == 0) {
                    parent.layer.alert("用户名不可为空！"); return false;
                }
                if ($.trim(json.realname).length == 0) {
                    parent.layer.alert("用户姓名不可为空！"); return false;
                }
                //console.log(json);
                doAjax("post", "../Users/EditAdmin", json, false, function (msg) {
                    parent.layer.alert(msg.message, function (index) {
                        parent.layer.close(index);
                        if (msg.result) {
                            $("#btnClose").trigger("click");
                        }
                    });
                });
            });

            //直营下单 初始化隐藏
            $("#zhiyingID").hide();
            //下单权限 变更
            $("#iszhiying").on("change", function () {
                $(this).val() == 0 ? $("#zhiyingID").hide() : $("#zhiyingID").show();
            })
            //首次加载，数据填充
            doAjax("post", "../Users/GetAdminModel", { id: id }, false, function (msg) {
                //console.info(msg);
                for (var key in msg) {
                    if (key == "sex"
                        || key == "status"
                        || key == "isread") {
                        $("[name='{0}'][value='{1}']".format(key, msg[key])).iCheck("check").siblings().iCheck("uncheck");
                    }
                    else if (key == "groupsid"
                        || key == "postsale_groupsid"
                        || key == "stock_import_right"
                        || key == "product_right"
                        || key == "postsale_right"
                        || key == "postsale_stock_right"
                        || key == "Stock_Field_rights"
                        || key == "Stock_rights"
                        || key == "Brand_rights"
                        || key == "postsale_cancel_right") {
                        if ($.trim(msg[key]).length > 0) {
                            var arrayList = $.trim(msg[key]).split(",");
                            $.each(arrayList, function (index, item) {
                                $("[name='{0}'][value='{1}']".format(key, item)).iCheck("check");
                            });
                        }
                    }
                    else if (key == "iszhiying") {
                        msg[key] == 0 ? $("#zhiyingID").hide() : $("#zhiyingID").show();
                    }
                    else {
                        $("#" + key).val(msg[key]);
                    }

                }
            });
        });
    </script>
}
<div class="wrapper wrapper-content animated zoomIn">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>@ViewBag.Title</h5>
                </div>
                <div class="ibox-content ">
                    <div class="form-horizontal m-t">
                        <div class="form-group">
                            <label class="col-sm-1 control-label">帐户:</label>
                            <div class="col-sm-4">
                                <input id="account" type="text" minlength="2" class="form-control">
                            </div>
                            <label class="col-sm-2 control-label">姓名:</label>
                            <div class="col-sm-4">
                                <input id="realname" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">部门:</label>
                            <div class="col-sm-4">
                                <input id="dept" class="form-control" />
                            </div>
                            <label class="col-sm-2 control-label">电话:</label>
                            <div class="col-sm-4">
                                <input id="phone" type="text" class="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label">性别:</label>
                            <div class="col-sm-4">
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="男" name="sex" checked> 男
                                    </label>
                                </div>
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="女" name="sex"> 女
                                    </label>
                                </div>
                            </div>
                            <label class="col-sm-2 control-label">状态:</label>
                            <div class="col-sm-4">
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="1" name="status" checked> 启用
                                    </label>
                                </div>
                                <div class="radio i-checks inline">
                                    <label>
                                        <input type="radio" value="0" name="status"> 禁用
                                    </label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="ibox-title">
                    <h5>权限设置</h5>
                </div>
                <div class="ibox-content ">
                    <div class="form-horizontal m-t">
                        @* 1、只读权限: *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">1、只读权限:</label>
                            <div class="col-sm-4">
                                <div class="checkbox i-checks inline">
                                    <label>
                                        <input type="checkbox" name="isread" value="1" />系统只读权限
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  2、后台下单权限：<br />(直营内购下单): *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">
                                2、后台下单权限：<br />(直营内购下单):
                            </label>
                            <div class="col-sm-4">
                                <select class="form-control" id="iszhiying">
                                    <option value="0">1、没有 直营/内购 下单权限</option>
                                    <option value="1">2、有 直营/内购 下单权限</option>
                                </select>
                            </div>
                            <div class="col-sm-4">
                                <select class="form-control" id="zhiyingID">
                                    <option value="">--请选择下单帐号--</option>
                                    @Html.Raw(ViewData["zhiyingID"])
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  3、订单导出权限: *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">3、订单导出权限:</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="isexport">
                                    <option value="0">0、没有订单导出权限</option>
                                    <option value="1">1、订单基础信息导出权限</option>
                                    <option value="3">2、直营订单导出权限</option>
                                    <option value="4">3、加盟管理员订单导出权限</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  4、订单管理权限: *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">4、订单管理权限:</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="ordermng">
                                    <option value="0">0、无管理权限</option>
                                    <option value="1">1、查看权限</option>
                                    <option value="2">2、总司权限</option>
                                    <option value="3">3、直营权限</option>
                                    <option value="4">4、加盟管理员权限</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  5、订单列表分组权限:<br />(不选无权限) *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">5、订单列表分组权限:<br />(不选无权限)</label>
                            <div class="col-sm-8">
                                <div class="checkbox i-checks inline">
                                    @Html.Raw(ViewData["groupsid"])
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  6、售后列表分组权限:<br />(不选无权限) *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">6、售后列表分组权限:<br />(不选无权限)</label>
                            <div class="col-sm-8">
                                <div class="checkbox i-checks inline">
                                    @Html.Raw(ViewData["postsale_groupsid"])
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  7、维护加盟商 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">7、维护加盟商:</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="join_mng">
                                    <option value="">--请选择--</option>
                                    <option value="1">只读权限</option>
                                    <!-- <option value="2">部分写权限</option> -->
                                    <option value="3">写权限</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  8、充值确认权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">8、充值确认权限：</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="mcc_mng">
                                    <option value="0">无权限</option>
                                    <option value="1">读权限</option>
                                    <option value="2">写权限</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  9、页面访问权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">9、页面访问权限：</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="menu_groupsid">
                                    <option value="">--请选择--</option>
                                    @Html.Raw(ViewData["menu_groupsid"])
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  10、登陆默认首页 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">10、登陆默认首页：</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="main">
                                    <option value="">--登陆默认首页--</option>
                                    @Html.Raw(ViewData["main"])
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  11、库存导入权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">11、库存导入权限：</label>
                            <div class="col-sm-9">
                                <div class="row">
                                    <label class="col-sm-3  text-left">11.1、导入形式：</label>
                                </div>
                                <div class="row">
                                    <div class="col-sm-9">
                                        <div class="checkbox i-checks inline">
                                            <label><input type="checkbox" value="a1" name="stock_import_right"> 库存累加</label>
                                            <label><input type="checkbox" value="a2" name="stock_import_right"> 库存覆盖</label>
                                            <label><input type="checkbox" value="a3" name="stock_import_right"> 库存扣减</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="row">
                                    <label class="col-sm-3  text-left">11.2、导入仓库：</label>
                                </div>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <div class="checkbox i-checks inline">
                                            @Html.Raw(ViewData["stock_import_right"])
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  12、产品管理编辑权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">12、产品管理编辑权限：</label>
                            <div class="col-sm-9">
                                <div class="row">
                                    <div class="col-sm-9">
                                        <div class="checkbox i-checks inline">
                                            <label><input type="checkbox" value="viewjoinprice" name="product_right"> 查看加盟价</label>
                                            <label><input type="checkbox" value="chanagenumber" name="product_right"> 库存调整申请确认</label>
                                            <label><input type="checkbox" value="editproduct" name="product_right"> 编辑产品权限</label>
                                            <label><input type="checkbox" value="viewprice" name="product_right"> 查看成本价和毛利率</label>
                                            <label><input type="checkbox" value="locknumber" name="product_right"> 锁定库存</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <div class="checkbox i-checks inline">
                                            @Html.Raw(ViewData["product_right"])
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  13、促销设置权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">13、促销设置权限：</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="Promotions_right">
                                    <option value="1">察看</option>
                                    <option value="2">添加促销</option>
                                    <option value="3">确认促销</option>
                                    <option value="4">添加&确认</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  14、售后权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">14、售后权限：</label>
                            <div class="col-sm-9">
                                <div class="row">
                                    <label class="col-sm-4  text-left">
                                        14.1、售后按钮权限：
                                    </label>
                                </div>
                                <div class="row">
                                    <div class="col-sm-9">
                                        <div class="checkbox i-checks inline">
                                            <label><input type="checkbox" value="1" name="postsale_right"> 修改|提交</label>
                                            <label><input type="checkbox" value="2" name="postsale_right"> 出纳审核</label>
                                            <label><input type="checkbox" value="3" name="postsale_right"> 审核加盟退货</label>
                                            <label><input type="checkbox" value="4" name="postsale_right"> 加盟退货信息</label>
                                            <label><input type="checkbox" value="5" name="postsale_right"> 仓库确认退件</label>
                                            <label><input type="checkbox" value="6" name="postsale_right"> 店铺确认退款</label>
                                            <label><input type="checkbox" value="7" name="postsale_right"> 完结-待汇总</label>
                                            <label><input type="checkbox" value="8" name="postsale_right"> 完结-已汇总</label>
                                            <label><input type="checkbox" value="12" name="postsale_right"> 反审核</label>
                                        </div>
                                    </div>
                                </div>
                                <div class="hr-line-dashed"></div>
                                <div class="row">
                                    <label class="col-sm-4  text-left">14.2、确认退货仓库权限：</label>
                                </div>
                                <div class="row">
                                    <div class="col-sm-12">
                                        <div class="checkbox i-checks inline">
                                            @Html.Raw(ViewData["postsale_stock_right"])
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  15、发货单权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">15、发货单权限：</label>
                            <div class="col-sm-4">
                                <select class="form-control" id="OrderStatusid14_right">
                                    <option value="0">无权限</option>
                                    <option value="1">未锁定前操作权限(客服权限)</option>
                                    <option value="2">发货权限(仓库操作权限)</option>
                                </select>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  16、发货单页面按钮权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">16、发货单页面按钮权限：</label>
                            <div class="col-sm-9">
                                <div class="checkbox i-checks inline">
                                    <label><input type="checkbox" value="chk" name="Stock_Field_rights"> 选择</label>
                                    <label><input type="checkbox" value="setnumbers" name="Stock_Field_rights"> 生成取货序号/锁定</label>
                                    <label><input type="checkbox" value="export_kuaidi" name="Stock_Field_rights"> 导出快递单/填写快递单</label>
                                    <label><input type="checkbox" value="export_quhuo" name="Stock_Field_rights"> 导出取货单</label>
                                    <label><input type="checkbox" value="export_kucun" name="Stock_Field_rights"> 导出扣库存</label>
                                    <label><input type="checkbox" value="export_yewu" name="Stock_Field_rights"> 导出业务单</label>
                                    <label><input type="checkbox" value="ExpressPrint" name="Stock_Field_rights"> 快递单打印</label>
                                    <label><input type="checkbox" value="quhuoPrint" name="Stock_Field_rights"> 取货单打印</label>
                                    <label><input type="checkbox" value="quxiaobiaoji" name="Stock_Field_rights"> 取消标记/解锁</label>
                                    <label><input type="checkbox" value="quxiaotuikuan" name="Stock_Field_rights"> 取消退款</label>
                                    <label><input type="checkbox" value="wuhuozhuangquguohuo" name="Stock_Field_rights"> 转全国货(无货 and 有货</label>
                                    <label><input type="checkbox" value="genggai" name="Stock_Field_rights"> 更改</label>
                                    <label><input type="checkbox" value="chukudanPrint" name="Stock_Field_rights"> 出库单打印</label>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  17、仓库权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">17、仓库权限：</label>
                            <div class="col-sm-9">
                                <div class="checkbox i-checks inline">
                                    <label><input type="checkbox" value="all" name="Stock_rights"> All Stock</label>
                                    @Html.Raw(ViewData["Stock_rights"])
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        @*  18、品牌权限 *@
                        <div class="form-group">
                            <label class="col-sm-2 text-right">18、品牌权限：</label>
                            <div class="col-sm-9">
                                <div class="checkbox i-checks inline">
                                    <label><input type="checkbox" value="all" name="Brand_rights"> All Brands</label>
                                    <label><input type="checkbox" value="ST&SAT" name="Brand_rights"> ST&SAT</label>
                                    <label><input type="checkbox" value="D:FUSE" name="Brand_rights"> D:FUSE</label>
                                    <label><input type="checkbox" value="SAFIYA" name="Brand_rights"> SAFIYA</label>
                                    <label><input type="checkbox" value="FONDBERYL" name="Brand_rights"> FONDBERYL</label>
                                    <label><input type="checkbox" value="KILLAH" name="Brand_rights"> KILLAH</label>
                                    <label><input type="checkbox" value="RIZZO" name="Brand_rights"> RIZZO</label>
                                    <label><input type="checkbox" value="IIXVIIX" name="Brand_rights"> IIXVIIX</label>
                                    <label><input type="checkbox" value="STONEFLY" name="Brand_rights"> STONEFLY</label>
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 text-right">19、开通预取消功能：</label>
                            <div class="col-sm-9">
                                <div class="checkbox i-checks inline">
                                    @Html.Raw(ViewData["postsale_cancel_right"])
                                </div>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-5">
                                <button id="btnSave" class="btn btn-default" type="button">提交</button>
                                <button id="btnClose" class="btn btn-info" type="button">取消</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>