function jsCallInputSheetManage(){

};

jsCallInputSheetManage.typeEndFlagChk=null;//查看停用
jsCallInputSheetManage.CurrentCallInputTypeNode=null;//当前树选中的表单类型节点


/*删除分类及相关明细*/
jsCallInputSheetManage.DeleteData=function(currTypeID){
//         var txtSql="exec eOA_Sys_Delete 'eOA_fip_CallInputSheetType', ' and ID="+currTypeID+"'";
//         DBReader.execSql(txtSql);
         var EntityObj = jsEntity.CreateEntityByTableName_access("eOA_fip_CallInputSheetType", "", "", "", "ID");
         EntityObj.Fields.ID = currTypeID;
         EntityObj.Delete(EntityObj);
         txtSql=null;
         return true;
};

/*删除当前节点*/
jsCallInputSheetManage.DeleteCurrCallInputType = function() {
    if (jsCallInputSheetManage.CurrentCallInputTypeNode != null) {
        if (confirm("您确定要删除吗！")) {
            var currSelTypeID = jsCallInputSheetManage.CurrentCallInputTypeNode.id;
            if (jsCommonLogic.selExistData("count(*)", "eOA_fip_CallInputSheetType", "where ParentID=" + currSelTypeID) == 0) {
                if (jsCommonLogic.selExistData("count(*)", "eOA_fip_CallInputSheet", "where TypeID=" + currSelTypeID) == 0) {
                    var result = jsCallInputSheetManage.DeleteData(currSelTypeID);
                    if (result) {
                        alert("删除成功！");
                        jsCallInputSheetManage.CurrentCallInputTypeNode = null;
                        jsCallInputSheetManage.LoadData("");
                    }
                    else {
                        alert("删除失败！");
                    }
                    result = null;
                    CollectGarbage();
                } else {
                    alert("该分组已被使用，不能删除！");
                }
            }
            else {
                alert("该类型有子集，不能删除！");
            }
        }
    }
    else {
        alert(" 请选择要删除的项！");
    }
};

/*弹出添加或修改快速录入类型信息框*/
jsCallInputSheetManage.OpenCallInputTypeWin=function(isEdit){
          try
            {
                var FormIndex=ShowWindow.getFormIdx();
                if(isEdit!="" && isEdit!=undefined)
                {
                          if(jsCallInputSheetManage.CurrentCallInputTypeNode!=null)
                           {
                               ShowWindow.ShowMoledDialog("Application/TeleSecretary/CallInputSheetDesign/frmCallInputSheetTypeDetail.htm?FormIndex=" + FormIndex + "&LoadAction=jsIndexPage.freshItemPage('tab-systemMan','jsSystemSettings.sheetManageLoadData()')&PageState=Edit&TypeID=" + jsCallInputSheetManage.CurrentCallInputTypeNode.id + "", "修改模板类型", 800, 600);
                          }
                          else
                          {
                                    alert("请选择要修改的模板类型！");
                          }
                }
                else
                {
                    var pageUrl = "Application/TeleSecretary/CallInputSheetDesign/frmCallInputSheetTypeDetail.htm?FormIndex=" + FormIndex + "&LoadAction=jsIndexPage.freshItemPage('tab-systemMan','jsSystemSettings.sheetManageLoadData()')&PageState=Add";
                         if(jsCallInputSheetManage.CurrentCallInputTypeNode!=null)
                         {
                                pageUrl=pageUrl +"&TypeID="+jsCallInputSheetManage.CurrentCallInputTypeNode.id+"&TypeName="+jsCallInputSheetManage.CurrentCallInputTypeNode.text;
                         }
                         ShowWindow.ShowMoledDialog(pageUrl,"添加模板类型",800,600);             
                }
                FormIndex=null;
                CollectGarbage();
            }
            catch(e)
            {
                 alert(e.message);
            }   
};

/*加载树*/
jsCallInputSheetManage.LoadData = function() {
    try {
        var treeString = "";
        if (jsCallInputSheetManage.typeEndFlagChk != "" && jsCallInputSheetManage.typeEndFlagChk != undefined) {
            treeString = GetTree("select ID,CNName as Name,ParentID,EndFlag from eOA_fip_CallInputSheetType", "eOA_fip_CallInputSheetType", "1");
        }
        else {
            treeString = GetTree("select ID,CNName as Name,ParentID,EndFlag from eOA_fip_CallInputSheetType where EndFlag=false", "eOA_fip_CallInputSheetType", "1");
        }
        var menudata = $.parseJSON(treeString);
        var op = { data: menudata, onnodeclick: jsCallInputSheetManage.ReloadCallInputList, foldtheme: "leaf", theme: "bbit-tree-no-lines", spacepic: "../../AppFrame/APICss/Shared/images/s.gif" };
        if (document.getElementById("div-left-menu-content")) {
            $("#div-left-menu-content").treeview(op);
        }

        treeString = null;
        menudata = null;
        CollectGarbage();
    }
    catch (e) {
        alert(e.message);
    }
};
/*单击节点动作*/
jsCallInputSheetManage.ReloadCallInputList=function(item){
        jsCallInputSheetManage.CurrentCallInputTypeNode=item; 
        window.frames["ifrMainContent"].jsCallInputSheetList.searchString(item.id);
        window.frames["ifrMainContent"].jsCallInputSheetList.AddCallInputSheet();
};

//frmBillDetail添加，修改表单后刷新页面
jsCallInputSheetManage.ReloadList=function(){
       window.frames["ifrMainContent"].jsCallInputSheetList.searchString(window.frames["ifrMainContent"].jsCallInputSheetList.CurrentBillTypeID);
}

/*停用*/
jsCallInputSheetManage.changChkEndFlag=function(){
          $("#chkIsEndFlag,#pauseIsEndFlag").click(function(){
             $("#chkIsEndFlag").attr("checked")==true?$("#chkIsEndFlag").attr("checked",false):$("#chkIsEndFlag").attr("checked",true);
             var checked = $("#chkIsEndFlag").attr("checked");
              jsCallInputSheetManage.typeEndFlagChk = (checked == true ? 1 : 0);
              jsCallInputSheetManage.LoadData();
        });
};

$(function(){
     App.SetNullHref(0);
     jsCallInputSheetManage.LoadData();/*生成流程类型的树*/
     App.SetNullHref(1);
     
     jsCallInputSheetManage.changChkEndFlag();/*选择查看停用*/
 });

 /*传递设计控件字符串*/
 jsCallInputSheetManage.getMessage = function(str) {
     window.frames['ifrMainContent'].execScript('jsCallInputSheetList.getSource("' + str + '")');
 }

 /*传递选择所属类型*/
 jsCallInputSheetManage.SetValue = function(str, str2) {
     window.frames['ifrMainContent'].execScript('jsCallInputSheetList.SetValue("' + str + '","' + str2 + '")');
 }