//设置全局的AJAX为同步
$.ajaxSetup( {
async : false
});
function undis(){
var c = document.getElementById("chunpan");
c.disabled="";
}
function topClick() {
var manageType = document.getElementById("manageType");
manageType.value = "zero";
var manageType = document.getElementById("manageType2");
manageType.value = "zx";
}
function onClick(note) {
var tableSpan = document.getElementById("contentTable");
var tempArr = note.data.id.split("-");
var manageType = document.getElementById("manageType");
var manageTypeCode = document.getElementById("manageTypeCode");
manageType.value = tempArr[1];
if(tempArr[1].indexOf('zero',0)<0){
var inser = document.getElementById("inser");
if(inser != null){
//del.parentNode.removeChild(del);
inser.disabled="";
}
var dels = document.getElementById("dels");
dels.innerHTML = "<input class='but' type='button' onclick='saveDelete();' value='删除' id='del'/>";
manageTypeCode.value = tempArr[0];
var areaCheck = new $.get(
"LoadKnowledgeManageListByCode.action?classifyFirstCode="
+ tempArr[0] + "&manageType=" + tempArr[1],
null,
function(data) {
var Obj = eval("(" + data + ")");
var thickStr = "";
if (Obj != null) {
$(Obj)
.each(
function() {
thickStr = thickStr
+ "<table style='height: 30px;line-height: 30px;margin:10px;font-size: 14px;width:680px;'><tr><td class='td1'>一级分类代码:</td><td><input type='text' class='ba' readonly='readonly' name='classifyFirstCode' id='classifyFirstCode'";
if (tempArr[1] == "one") {
thickStr = thickStr
+ " class='ba' readonly='readonly'";
}
thickStr = thickStr + " value='"
+ this.classifyFirstCode
+ "'/></td><td class='td1'>一级分类名称:</td><td id='select1'>";
thickStr = thickStr
+ "<input type='text' name='classifyFirstName' id='classifyFirstName' value='"
+ this.classifyFirstName
+ "'";
if (tempArr[1] != "one") {
thickStr = thickStr
+ " class='ba' readonly='readonly'";
}else{
thickStr = thickStr+" onkeyup='undis();'";
}
var classifyFirstCode = document.getElementById("classifyFirstCode");
var classifyFirstName = document.getElementById("classifyFirstName");
var classifySecondCode = document.getElementById("classifySecondCode");
var classifySecondName = document.getElementById("classifySecondName");
thickStr = thickStr + "/></td></tr>";
if (tempArr[1] == "two"||tempArr[1] == "three") {
thickStr = thickStr
+ "<tr><td class='td1'>二级分类代码:</td><td><input type='text' name='classifySecondCode' class='ba' readonly='readonly' id='classifySecondCode' value='"
+ this.classifySecondCode
+ "'/></td><td class='td1'>二级分类名称:</td><td><input type='text' name='classifySecondName' id='classifySecondName' value='"
+ this.classifySecondName
+"'";
classifyFirstCode.value=this.classifyFirstCode;
classifyFirstName.value=this.classifyFirstName;
classifySecondCode.value=this.classifySecondCode;
classifySecondName.value=this.classifySecondName;
if (tempArr[1] == "three") {
thickStr = thickStr
+ " class='ba' readonly='readonly'";
}else{
thickStr = thickStr+" onkeyup='undis();'";
}
thickStr = thickStr + "/></td></tr>";
}
if (tempArr[1] == "three") {
thickStr = thickStr
+ "<tr><td class='td1'>三级分类代码:</td><td><input type='text' name='classifyThirdCode' id='classifyThirdCode' class='ba' readonly='readonly'";
thickStr = thickStr + " value='"
+ this.classifyThirdCode
+ "'/></td>";
thickStr = thickStr
+ "<td class='td1'>三级分类名称:</td><td><input type='text' name='classifyThirdName' id='classifyThirdName' onkeyup='undis();' value='"
+ this.classifyThirdName
+ "'/></td></tr>";
}
var not = this.notes=="null"?'':this.notes;
var ei = this.createEId=="null"?'':this.createEId;
var en = this.createEName=="null"?'':this.createEName;
var ed = this.createDate=="null"?'':this.createDate;
var un = this.updateEName=="null"?'':this.updateEName;
var ud = this.updateDate=="null"?'':this.updateDate;
thickStr = thickStr
+ "<tr><td style='text-align: right;vertical-align: top;'>备注:</td><td colspan='3'><textarea id='notes' onkeyup='undis();' name='notes' rows='5' cols='75'>"
+ not
+ "</textarea> </td></tr>";
thickStr = thickStr
+ "<tr><td class='td1'>创建人:</td><td><input type='text' class='ba' readonly='readonly' value='"
+ en
+ "'/></td>";
thickStr = thickStr
+ "<td class='td1'>创建时间:</td><td><input type='text' class='ba' readonly='readonly' value='"
+ ed
+ "'/></td><td></td><td></td></tr>";
thickStr = thickStr
+ "<tr><td class='td1'>修改人:</td><td><input type='text' class='ba' readonly='readonly' value='"
+ un
+ "'/></td>";
thickStr = thickStr
+ "<td class='td1'>修改时间:</td><td><input type='text' class='ba' readonly='readonly' value='"
+ ud
+ "'/></td><td></td><td></td></tr></table>";
});
}
tableSpan.innerHTML = thickStr;
});
}else{
insertKinds(tempArr[1]);
}
}
function saveDelete(){
var manageType = document.getElementById("manageType");
var manageTypeCode = document.getElementById("manageTypeCode");
var flag = "no";
if(manageType.value=="one"||manageType.value=="zero"){
if(confirm("确定删除一级分类代码为 ["+manageTypeCode.value+"] 的菜单及其所有子菜单吗?")){
var flag = "yes";
}
}
if(manageType.value=="two"){
if(confirm("确定删除二级分类代码为 ["+manageTypeCode.value+"] 的菜单及其所有子菜单吗?")){
var flag = "yes";
}
}
if(manageType.value=="three"){
if(confirm("确定删除三级分类代码为 ["+manageTypeCode.value+"] 的菜单吗?")){
var flag = "yes";
}
}
if(flag == "yes"){
var areaCheck = new $.get("saveKnowledgeManageListByDelete.action?manageType="+ manageType.value + "&manageTypeCode=" + manageTypeCode.value,null,function(data) {
if(data=="yes"){
alert("删除成功!");
window.location.reload();
}else{
alert("删除失败!");
}
});
}
}
function saveInsert(){
var manageType = document.getElementById("manageType");
var manageTypeCode = document.getElementById("manageTypeCode");
var manageTypeName = document.getElementById("manageTypeName");
var classifyFirstCode = document.getElementById("classifyFirstCode");
var classifyFirstName = document.getElementById("classifyFirstName");
var notes = document.getElementById("notes");
var thickStr = "";
var str = manageType.value;
thickStr = thickStr + "manageType="+ manageType.value + "¬es=" + encodeURI(notes.value)+ "&classifyFirstName=" + encodeURI(classifyFirstName.value);
if(str.indexOf('two',0)>=0||str.indexOf('three',0)>=0){
var classifySecondCode = document.getElementById("classifySecondCode");
var classifySecondName = document.getElementById("classifySecondName");
if(classifySecondName.value==""){
alert("请输入菜单名称");
return false;
}
if(classifyFirstCode.value==""){
alert("请先创建一级菜单!");
return false;
}
if(classifyFirstNam