产品类别管理

var ProductCategoryMgr = function (e) {
    //所有的ListBox字段
    this.ddlRootProCat = null;
    this.ddlSndProCat = null;
    this.ddlThdProCat = null;
    this.ddlFthProCat = null;

    //一级菜单主要字段
    this.txtRootEnName = null;
    this.txtRootCnName = null;
    this.txtFirSort1 = null;
    this.rdoRoot = null;
    this.rdoRoot1 = null;
    this.btnAddRoot = null;
    this.btnSaveCur = null;
    this.btnDelCur = null;


    //二级菜单主要字段
    this.txtSndEnName = null;
    this.txtSndCnName = null;
    this.rdoSnd = null;
    this.rdoSnd1 = null;
    this.btnAddSnd = null;
    this.btnSaveCurSnd = null;
    this.btnDelCurSnd = null;

    //三级菜单主要字段
    this.txtThdEnName = null;
    this.txtThdCnName = null;
    this.rdoThd = null;
    this.rdoThd1 = null;
    this.btnAddThd = null;
    this.btnSaveCurThd = null;
    this.btnDelCurThd = null;

    //四级菜单主要字段
    this.txtFthEnName = null;
    this.txtFthCnName = null;
    this.rdoFth = null;
    this.rdoFth1 = null;
    this.btnAddFth = null;
    this.btnSaveCurFth = null;
    this.btnDelCurFth = null;


    this.txtCurEnName = null;
    this.txtCurCnName = null;
}

//初始化方法
ProductCategoryMgr.prototype.init = function (e) {
    var _this = this;
    _d = this.d;
    this.ddlRootProCat = this.$("ddlRootProCat");
    this.ddlSndProCat = this.$("ddlSndProCat");
    this.ddlThdProCat = this.$("ddlThdProCat");
    this.ddlFthProCat = this.$("ddlFthProCat");
    //一
    this.txtRootEnName = this.$("txtRootEnName");
    this.txtRootCnName = this.$("txtRootCnName");
    this.txtFirSort1 = this.$("txtFirSort1");
    this.rdoRoot = this.$("rdoRoot");
    this.rdoRoot1 = this.$("rdoRoot1");
    this.btnAddRoot = this.$("btnAddRoot");
    this.btnSaveCur = this.$("btnSaveCur");
    this.btnDelCur = this.$("btnDelCur");
    //二
    this.txtSndEnName = this.$("txtSndEnName");
    this.txtSndCnName = this.$("txtSndCnName");
    this.rdoSnd = this.$("rdoSnd");
    this.rdoSnd1 = this.$("rdoSnd1");
    this.btnAddSnd = this.$("btnAddSnd");
    this.btnSaveCurSnd = this.$("btnSaveCurSnd");
    this.btnDelCurSnd = this.$("btnDelCurSnd");
    //三
    this.txtThdEnName = this.$("txtThdEnName");
    this.txtThdCnName = this.$("txtThdCnName");
    this.rdoThd = this.$("rdoThd");
    this.rdoThd1 = this.$("rdoThd1");
    this.btnAddThd = this.$("btnAddThd");
    this.btnSaveCurThd = this.$("btnSaveCurThd");
    this.btnDelCurThd = this.$("btnDelCurThd");
    //四
    this.txtFthEnName = this.$("txtFthEnName");
    this.txtFthCnName = this.$("txtFthCnName");
    this.rdoFth = this.$("rdoFth");
    this.rdoFth1 = this.$("rdoFth1");
    this.btnAddFth = this.$("btnAddFth");
    this.btnSaveCurFth = this.$("btnSaveCurFth");
    this.btnDelCurFth = this.$("btnDelCurFth");


    this.txtCurEnName = this.$("txtCurEnName");
    this.txtCurCnName = this.$("txtCurCnName");
    //    this.btnSaveCur = this.$("rdoFth1");
    this.btnDelCur = this.$("btnDelCur");

    this.bindEvent(_d);
}

ProductCategoryMgr.prototype.bindEvent = function (d) {
    var _this = this;
    //选择一级目录加载二级
    _this.ddlRootProCat.change(function (e) {
        _this.ShowProductCategoryMgrSndProCat(e);
    });
    //选择二级加载三级
    _this.ddlSndProCat.change(function (e) {
        _this.ShowProductCategoryMgrThdProCat(e);
    });
    //选择三级加载四级
    _this.ddlThdProCat.change(function (e) {
        _this.ShowProductCategoryMgrddlFthProCat(e);
    });
    //选择四级菜单显示内容
    _this.ddlFthProCat.change(function (e) {
        _this.ShowProductCategoryFthProCat(e);
    });

    //添加一级目录
    _this.btnAddRoot.click(function (e) {
        _this.AddRootProductCategoryMgr(e);
    });
    //添加二级目录
    _this.btnAddSnd.click(function (e) {
        _this.AddSndProductCategoryMgr(e);
    });
    //添加三级目录
    _this.btnAddThd.click(function (e) {
        _this.AddThdProductCategoryMgr(e);
    });
    //添加四级目录
    _this.btnAddFth.click(function (e) {
        _this.AddFthProductCategoryMgr(e);
    });
    //更新一级目录
    _this.btnSaveCur.click(function (e) {
        _this.UpdateRootProductCategoryMgr(e);
    });
    //更新二级目录
    _this.btnSaveCurSnd.click(function (e) {
        _this.UpdateSceProductCategoryMgr(e);
    });
    //更新三级目录
    _this.btnSaveCurThd.click(function (e) {
        _this.UpdateThiProductCategoryMgr(e);
    });
    //更新四级目录
    _this.btnSaveCurFth.click(function (e) {
        _this.UpdateFthProductCategoryMgr(e);
    });
    //删除选中一级目录
    _this.btnDelCur.click(function (e) {
        if (confirm("您确定要删除此类别吗?")) {
            _this.DelRootProductCategoryMgr(e);
        }
    });
    //删除选中二级目录
    _this.btnDelCurSnd.click(function (e) {
        if (confirm("您确定要删除此类别吗?")) {
            _this.DeleteSceProductCategoryMgr(e);
        }
    });
    //删除选中三级目录
    _this.btnDelCurThd.click(function (e) {
        if (confirm("您确定要删除此类别吗?")) {
            _this.DelThiProductCategoryMgr(e);
        }
    });
    //删除选中四级目录
    _this.btnDelCurFth.click(function (e) {
        if (confirm("您确定要删除此类别吗?")) {
            _this.DelFthProductCategoryMgr(e);
        }
    });
}
//金策排序的文本框只能输入数字
$(checkTxtSort("#txtFirSort1"));
$(checkTxtSort("#txtFirSort"));
$(checkTxtSort("#txtSecSort1"));
$(checkTxtSort("#txtSecSort"));
$(checkTxtSort("#txtThirSort1"));
$(checkTxtSort("#txtThirSort"));
$(checkTxtSort("#txtForSort1"));
$(checkTxtSort("#txtForSort"));
function checkTxtSort(name) {
    // 给文本框加个keypress,即键盘按下的时候判断 
    $(name).keypress(function (event) {
        if (!$.browser.mozilla) {
            if (event.keyCode && (event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 46) {
                // ie6,7,8,opera,chrome管用 
                event.preventDefault();
            }
        } else {
            if (event.charCode && (event.charCode < 48 || event.charCode > 57) && event.keyCode != 46) {
                // firefox管用 
                event.preventDefault();
            }
        }
    });
    //屏蔽输入法 
    $(name).css("ime-mode", "disabled");
    //然后用jquery绑定一个paste事件,屏蔽粘贴。 
    $(name).bind("paste", function () {
        $("[name='txtFirSort1']").val(" ");
        //        _this.$("txtFirSort1").attr('value', "");
    });

}
//获取radio中选中项的值
function GetRdo(controlName) {
    var rdio = document.getElementsByName(controlName);
    var rdo;
    for (var i = 0; i < rdio.length; i++) {
        if (rdio[i].checked) {
            rdo = rdio[i].value;
        }
    }
    return rdo;
}

//设置单选按钮自动选中
function SetRdo(name, rdoStatus) {
    var rdio = document.getElementsByName(name);
    for (var i = 0; i < rdio.length; i++) {
        if (rdio[i].value == rdoStatus) {
            rdio[i].checked = true;
        }
    }
}
//方便获得父ID的方法
function GetOptAttr(controlName) {
    var selproId;
    var options = document.getElementById(controlName).options;
    for (var i = 0; i < options.length; i++) {
        if (options[i].selected) {
            selproId = options[i].getAttribute('proId');
        }
    }
    return selproId;
}
//删除一级菜单
ProductCategoryMgr.prototype.DelRootProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["ProductId"] = GetOptAttr("ddlRootProCat");
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/DeleteCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert(x.msg);
                    $("#ddlRootProCat").find("option:selected").remove();
                    _this.$("txtCurEnName").attr('value', "");
                    _this.$("txtCurCnName").attr('value', "");
                    _this.$("txtFirSort").attr('value', "");
                } else {
                    alert(x.msg);
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}

//删除二级菜单
ProductCategoryMgr.prototype.DeleteSceProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["ProductId"] = GetOptAttr("ddlSndProCat");
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/DeleteCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert(x.msg);
                    $("#ddlSndProCat").find("option:selected").remove();
                    _this.$("txtCurSndEnName").attr('value', "");
                    _this.$("txtCurSndCnName").attr('value', "");
                    _this.$("txtSecSort").attr('value', "");
                } else {
                    alert(x.msg);
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//删除三级菜单
ProductCategoryMgr.prototype.DelThiProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["ProductId"] = GetOptAttr("ddlThdProCat");
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/DeleteCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert(x.msg);
                    $("#ddlThdProCat").find("option:selected").remove();
                    _this.$("txtCurThdEnName").attr('value', "");
                    _this.$("txtCurThdCnName").attr('value', "");
                    _this.$("txtThirSort").attr('value', "");
                } else {
                    alert(x.msg);
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//删除四级菜单
ProductCategoryMgr.prototype.DelFthProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["ProductId"] = GetOptAttr("ddlFthProCat");
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/DeleteCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert(x.msg);
                    $("#ddlFthProCat").find("option:selected").remove();
                    _this.$("txtCurFthEnName").attr('value', "");
                    _this.$("txtCurFthCnName").attr('value', "");
                    _this.$("txtForSort").attr('value', "");
                } else {
                    alert(x.msg);
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;


}
//更新一级菜单
ProductCategoryMgr.prototype.UpdateRootProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    //获取选中项的值
    postData["IsShow"] = GetRdo("rdoFirIsShow");
    postData["status"] = GetRdo("rdoRoot1");

    //获取当前文本内容
    postData["txtRootEnName"] = _this.$("txtCurEnName").attr('value');
    postData["txtRootCnName"] = _this.$("txtCurCnName").attr('value');
    postData["txtSortOrder"] = _this.$("txtFirSort").attr('value');
    postData["ProductId"] = GetOptAttr("ddlRootProCat");
    postData["isRecommend"] = GetRdo("rdoFirIsRecommend")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/ModifiedCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert("修改成功!");
                    $("#ddlRootProCat").find("option:selected").remove();
                    var op = $("<option value=" + x.CategoryEnName + " sta=" + x.sta + " isShow=" + x.IsShow + "  proId=" + x.ProductCategoryId + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.CategoryCnName + "</option>");
                    $("#ddlRootProCat").append(op);
                    _this.$("txtCurEnName").attr('value', "");
                    _this.$("txtCurCnName").attr('value', "");
                    _this.$("txtFirSort").attr('value', "");
                } else {
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//更新二级菜单
ProductCategoryMgr.prototype.UpdateSceProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["IsShow"] = GetRdo("rdoSecIsShow");
    postData["status"] = GetRdo("rdoSnd1");
    //获取当前文本内容
    postData["txtRootEnName"] = _this.$("txtCurSndEnName").attr('value');
    postData["txtRootCnName"] = _this.$("txtCurSndCnName").attr('value');
    postData["txtSortOrder"] = _this.$("txtSecSort").attr('value');
    postData["ProductId"] = GetOptAttr("ddlSndProCat");
    postData["isRecommend"] = GetRdo("rdoSecIsRecommend")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/ModifiedCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert("修改成功!");
                    $("#ddlSndProCat").find("option:selected").remove();
                    var op = $("<option value=" + x.CategoryEnName + " sta=" + x.sta + " isShow=" + x.IsShow + "  proId=" + x.ProductCategoryId + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.CategoryCnName + "</option>");
                    $("#ddlSndProCat").append(op);
                    _this.$("txtCurSndCnName").attr('value', "");
                    _this.$("txtCurSndEnName").attr('value', "");
                    _this.$("txtSecSort").attr('value', "");

                } else {
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//更新三级菜单
ProductCategoryMgr.prototype.UpdateThiProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["IsShow"] = GetRdo("rdoThiIsShow");
    postData["status"] = GetRdo("rdoThd1");
    //获取当前文本内容
    postData["txtRootEnName"] = _this.$("txtCurThdEnName").attr('value');
    postData["txtRootCnName"] = _this.$("txtCurThdCnName").attr('value');
    postData["txtSortOrder"] = _this.$("txtThirSort").attr('value');
    postData["ProductId"] = GetOptAttr("ddlThdProCat");
    postData["isRecommend"] = GetRdo("rdoThiIsRecommend")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/ModifiedCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert("修改成功!");
                    $("#ddlThdProCat").find("option:selected").remove();
                    var op = $("<option value=" + x.CategoryEnName + " sta=" + x.sta + " isShow=" + x.IsShow + "  proId=" + x.ProductCategoryId + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.CategoryCnName + "</option>");
                    $("#ddlThdProCat").append(op);
                    _this.$("txtCurThdEnName").attr('value', "");
                    _this.$("txtCurThdCnName").attr('value', "");
                    _this.$("txtThirSort").attr('value', "");
                } else {
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//更新四级菜单
ProductCategoryMgr.prototype.UpdateFthProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["IsShow"] = GetRdo("rdoForIsShow");
    postData["status"] = GetRdo("rdoFth1");
    //获取当前文本内容
    postData["txtRootEnName"] = _this.$("txtCurFthEnName").attr('value');
    postData["txtRootCnName"] = _this.$("txtCurFthCnName").attr('value');
    postData["txtSortOrder"] = _this.$("txtForSort").attr('value');
    postData["ProductId"] = GetOptAttr("ddlFthProCat");
    postData["isRecommend"] = GetRdo("rdoForIsRecommend")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/ModifiedCurProductCategoryMgr",
            data: postData,
            dataType: 'json',
            success: function (x) {
                if ("ok" === x.code || "OK" === x.code) {
                    alert("修改成功!");
                    $("#ddlFthProCat").find("option:selected").remove();
                    var op = $("<option value=" + x.CategoryEnName + " sta=" + x.sta + " isShow=" + x.IsShow + "  proId=" + x.ProductCategoryId + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.CategoryCnName + "</option>");
                    $("#ddlFthProCat").append(op);
                    _this.$("txtCurFthEnName").attr('value', "");
                    _this.$("txtCurFthCnName").attr('value', "");
                    _this.$("txtForSort").attr('value', "");
                } else {
                    $(x.code).tooltip({ html: x.msg, isFocus: 1, isSelect: 1 });
                    return false;
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}

//添加一级菜单
ProductCategoryMgr.prototype.AddRootProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["txtRootEnName"] = this.txtRootEnName.attr('value');
    postData["txtRootCnName"] = this.txtRootCnName.attr('value');
    postData["txtSortOrder"] = _this.$("txtFirSort1").attr('value');
    postData["IsShow"] = GetRdo("rdoFirIsShow1")
    postData["status"] = GetRdo("rdoRoot")
    postData["isRecommend"] = GetRdo("rdoFirIsRecommend1")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/AddRootProductCategoryMgr",
            dataType: 'json',
            data: postData,
            success: function (x) {
                if (x) {
                    if (x.code) {
                        if ("ok" === x.code || "OK" === x.code) {
                            alert("添加成功!!");
                            _this.$("txtRootEnName").attr('value', "");
                            _this.$("txtRootCnName").attr('value', "");
                            _this.$("txtFirSort1").attr('value', "");
                            var op = $("<option value=" + x.enName + " sta=" + x.sta + "  isShow=" + x.IsShow + " proId=" + x.productID + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.cnName + "</option>");
                            $("#ddlRootProCat").append(op);
                            return false;
                        }
                        else {
                            alert(x.msg);
                            return false;
                        }
                    }
                }
            },
            complete: function () { aj = 1; }
        });
        return false;
    }
}
//添加选中项的二级菜单
ProductCategoryMgr.prototype.AddSndProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["txtTitleEnName"] = this.txtSndEnName.attr('value');
    postData["txtTitleCnName"] = this.txtSndCnName.attr('value');
    postData["txtSortOrder"] = _this.$("txtSecSort1").attr('value');
    postData["IsShow"] = GetRdo("rdoSecIsShow1");
    postData["parentID"] = GetOptAttr("ddlRootProCat");
    postData["status"] = GetRdo("rdoSnd");
    postData["isRecommend"] = GetRdo("rdoSecIsRecommend1")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/AddSndProductCategoryMgr",
            dataType: 'json',
            data: postData,
            success: function (x) {

                if (x) {
                    if (x.code) {
                        if ("ok" === x.code || "OK" === x.code) {
                            alert("添加成功!!");
                            _this.$("txtSndEnName").attr('value', "");
                            _this.$("txtSndCnName").attr('value', "");
                            _this.$("txtSecSort1").attr('value', "");
                          var op = $("<option value=" + x.enName + " sta=" + x.sta + "  isShow=" + x.IsShow + " proId=" + x.productID + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.cnName + "</option>");
                            $("#ddlSndProCat").append(op);
                            return false;
                        }
                        else {
                            alert(x.msg);
                            return false;
                        }
                    }
                }
            },
            complete: function () { aj = 1; }
        });
        return false;
    }
}
//添加三级菜单
ProductCategoryMgr.prototype.AddThdProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["txtTitleEnName"] = this.txtThdEnName.attr('value');
    postData["txtTitleCnName"] = this.txtThdCnName.attr('value');
    postData["txtSortOrder"] = _this.$("txtThirSort1").attr('value');
    postData["parentID"] = GetOptAttr("ddlSndProCat");
    postData["status"] = GetRdo("rdoThd");
    postData["IsShow"] = GetRdo("rdoThrIsShow1");
    postData["isRecommend"] = GetRdo("rdoThiIsRecommend1")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/AddSndProductCategoryMgr",
            dataType: 'json',
            data: postData,
            success: function (x) {
                if (x) {
                    if (x.code) {

                        if ("ok" === x.code || "OK" === x.code) {
                            alert("添加成功!!");
                            _this.$("txtThdEnName").attr('value', "");
                            _this.$("txtThdCnName").attr('value', "");
                            _this.$("txtThirSort1").attr('value', "");
                           var op = $("<option value=" + x.enName + " sta=" + x.sta + "  isShow=" + x.IsShow + " proId=" + x.productID + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.cnName + "</option>");
                            $("#ddlThdProCat").append(op);
                            return false;
                        }
                        else {
                            alert(x.msg);
                            return false;
                        }
                    }
                }
            },
            complete: function () { aj = 1; }
        });
        return false;
    }
}
//添加四级菜单
ProductCategoryMgr.prototype.AddFthProductCategoryMgr = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    postData["txtTitleEnName"] = this.txtFthEnName.attr('value');
    postData["txtTitleCnName"] = this.txtFthCnName.attr('value');
    postData["txtSortOrder"] = _this.$("txtForSort1").attr('value');
    postData["parentID"] = GetOptAttr("ddlThdProCat");
    postData["status"] = GetRdo("rdoFth");
    postData["IsShow"] = GetRdo("rdoForIsShow1");
       postData["isRecommend"] = GetRdo("rdoForIsRecommend1")
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/AddSndProductCategoryMgr",
            dataType: 'json',
            data: postData,
            success: function (x) {
                if (x) {
                    if (x.code) {
                        if ("ok" === x.code || "OK" === x.code) {
                            alert("添加成功!!");
                            _this.$("txtFthEnName").attr('value', "");
                            _this.$("txtFthCnName").attr('value', "");
                            _this.$("txtForSort1").attr('value', "");
                            var op = $("<option value=" + x.enName + " sta=" + x.sta + "  isShow=" + x.IsShow + " proId=" + x.productID + " sortOrder=" + x.softOrder + " isRecommend=" + x.isRecommend + ">" + x.cnName + "</option>");
                            $("#ddlFthProCat").append(op);
                            return false;
                        }
                        else {
                            alert(x.msg);
                            return false;
                        }
                    }
                }
            },
            complete: function () { aj = 1; }
        });
        return false;
    }
}


//选中一级目录显示二级目录
ProductCategoryMgr.prototype.ShowProductCategoryMgrSndProCat = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    var selproId;
    var category_en_name;
    var category_cn_name;
    var radStatus;
    var isShow;
    var sortOrder;
    var isRecommend;
    var options = document.getElementById("ddlRootProCat").options;
    for (var i = 0; i < options.length; i++) {
        if (options[i].selected) {
            selproId = options[i].getAttribute('proId');
            isShow = options[i].getAttribute('isShow');
            radStatus = options[i].getAttribute('sta');
            sortOrder = options[i].getAttribute('sortOrder');
            isRecommend = options[i].getAttribute('isRecommend');
            category_en_name = options[i].value;
            category_cn_name = options[i].text;
        }
    }
    _this.$("txtCurEnName").attr('value', "");
    _this.$("txtCurCnName").attr('value', "");
    _this.$("txtFirSort").attr('value', "");
    postData["ProductId"] = selproId;
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/ShowProductCategoryMgrSndProCat",
            data: postData,
            dataType: 'json',
            success: function (x) {
                _this.$("txtCurEnName").attr('value', category_en_name);
                _this.$("txtCurCnName").attr('value', category_cn_name);
                _this.$("txtFirSort").attr('value', sortOrder);
                //读取此种类是否是启用状态
                SetRdo("rdoRoot1", radStatus);
                //读取此种类是否在首页显示
                SetRdo("rdoFirIsShow", isShow);
                //是否推荐
                SetRdo("rdoFirIsRecommend", isRecommend);
                $("#ddlThdProCat").empty();
                $("#ddlFthProCat").empty();
                $("#ddlSndProCat").empty();
                if (x) {
                    for (var i = 0; i < x.length; i++) {

                        var op = $("<option value=" + x[i].CategoryEnName + "  sta=" + x[i].Status + " isShow=" + x[i].IsShow + " proId=" + x[i].ProductCategoryId + " sortOrder=" + x[i].SortOrder + " isRecommend=" + x[i].IsRecommend + ">" + x[i].CategoryCnName + "</option>");
                        $("#ddlSndProCat").append(op);
                    }
                }

            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//选中二级目录显示三级目录
ProductCategoryMgr.prototype.ShowProductCategoryMgrThdProCat = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    var selproId;
    var category_en_name;
    var category_cn_name;
    var radStatus;
    var isShow;
    var sortOrder;
    var isRecommend;
    //循环读取选中项中的参数
    var options = document.getElementById("ddlSndProCat").options;
    for (var i = 0; i < options.length; i++) {
        if (options[i].selected) {
            isShow = options[i].getAttribute('isShow');
            radStatus = options[i].getAttribute('sta');
            selproId = options[i].getAttribute('proId');
             sortOrder = options[i].getAttribute('sortOrder');
             isRecommend = options[i].getAttribute('isRecommend');
            category_en_name = options[i].value;
            category_cn_name = options[i].text;
        }
    }
    postData["ProductId"] = selproId;
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/ShowProductCategoryMgrThdProCat",
            data: postData,
            dataType: 'json',
            success: function (x) {
                _this.$("txtCurSndEnName").attr('value', category_en_name);
                _this.$("txtCurSndCnName").attr('value', category_cn_name);
                _this.$("txtSecSort").attr('value', sortOrder);
                //读取此种类是否是启用状态
                SetRdo("rdoSnd1", radStatus);
                //读取此种类是否在首页显示
                SetRdo("rdoSecIsShow", isShow);
                //是否推荐
                SetRdo("rdoSecIsRecommend", isRecommend);
                $("#ddlFthProCat").empty();
                $("#ddlThdProCat").empty();
                if (x) {
                    for (var i = 0; i < x.length; i++) {
                        var op = $("<option value=" + x[i].CategoryEnName + " sta=" + x[i].Status + " isShow=" + x[i].IsShow + " proId=" + x[i].ProductCategoryId + " sortOrder=" + x[i].SortOrder + " isRecommend=" + x[i].IsRecommend + ">" + x[i].CategoryCnName + "</option>");
                        $("#ddlThdProCat").append(op);
                    }
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//选中三级目录显示四级目录
ProductCategoryMgr.prototype.ShowProductCategoryMgrddlFthProCat = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    var category_en_name;
    var category_cn_name;
    var selproId;
    var radStatus;
    var isShow;
    var sortOrder;
      var isRecommend;
    var options = document.getElementById("ddlThdProCat").options;
    for (var i = 0; i < options.length; i++) {
        if (options[i].selected) {
            isShow = options[i].getAttribute('isShow');
            radStatus = options[i].getAttribute('sta');
            selproId = options[i].getAttribute('proId');
            sortOrder = options[i].getAttribute('sortOrder');
            isRecommend = options[i].getAttribute('isRecommend');
            category_en_name = options[i].value;
            category_cn_name = options[i].text;
        }
    }
    postData["ProductId"] = selproId;
    if (aj == 1) {
        aj = 0;
        $.ajax({
            type: "post",
            url: "/ProductMgr/ShowProductCategoryMgrddlFthProCat",
            data: postData,
            dataType: 'json',
            success: function (x) {
                _this.$("txtCurThdEnName").attr('value', category_en_name);
                _this.$("txtCurThdCnName").attr('value', category_cn_name);
                _this.$("txtThirSort").attr('value', sortOrder);
                 //读取此种类是否是启用状态
                 SetRdo("rdoThd1", radStatus);
                //读取此种类是否在首页显示
                SetRdo("rdoThiIsShow", isShow);
                //是否推荐
                 SetRdo("rdoThiIsRecommend", isRecommend);
                $("#ddlFthProCat").empty();
                if (x) {
                    for (var i = 0; i < x.length; i++) {
                        var op = $("<option value=" + x[i].CategoryEnName + " sta=" + x[i].Status + " isShow=" + x[i].IsShow + " proId=" + x[i].ProductCategoryId + " sortOrder=" + x[i].SortOrder + " isRecommend=" + x[i].IsRecommend + ">" + x[i].CategoryCnName + "</option>");
                        $("#ddlFthProCat").append(op);
                    }
                }
            },
            complete: function () {
                aj = 1;
            }
        });
    }
    return false;
}
//选中四级菜单
ProductCategoryMgr.prototype.ShowProductCategoryFthProCat = function (e) {
    var _this = this;
    var aj = 1;
    var postData = {};
    var category_en_name;
    var category_cn_name;
    var selproId;
    var radStatus;
    var isShow;
    var sortOrder;
          var isRecommend;
    var options = document.getElementById("ddlFthProCat").options;
    for (var i = 0; i < options.length; i++) {
        if (options[i].selected) {
            isShow = options[i].getAttribute('isShow');
            radStatus = options[i].getAttribute('sta');
            selproId = options[i].getAttribute('proId');
            sortOrder = options[i].getAttribute('sortOrder');
            isRecommend = options[i].getAttribute('isRecommend');
            category_en_name = options[i].value;
            category_cn_name = options[i].text;
        }
    }
      //读取此种类是否是启用状态
                 SetRdo("rdoFth1", radStatus);
                //读取此种类是否在首页显示
                SetRdo("rdoForIsShow", isShow);
                //是否推荐
                 SetRdo("rdoForIsRecommend", isRecommend);
    _this.$("txtCurFthEnName").attr('value', category_en_name);
    _this.$("txtCurFthCnName").attr('value', category_cn_name);
    _this.$("txtForSort").attr('value', sortOrder);
}


//获取元素
ProductCategoryMgr.prototype.$ = function (name) {
    return $('[name="' + name + '"]');
}
var Product = new ProductCategoryMgr();
Product.init();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ligengdipan

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值