/* * 20180228 LJY 娣诲姞鏃ュ織 娣诲姞鏂规硶锛氬湪鍘熸湁鐨勬柟娉曚笂娣诲姞obj锛屽鍔犱竴涓紶鍏ュ弬鏁帮紝渚夸簬鍦ㄥ悓涓€椤甸潰涓嶅悓input浣跨敤瀛楀吀鏃跺彲浠ョ伒娲昏祴鍊 selectListDictAssigned(typeCode, callback, obj) 鈥 selectDict(typeCode, callback) getListDictAssignedForList(url, callback, obj) 鈥 showList(url, callback) getListDictAssignedForTree(code, callback, obj) 鈥 showDictTree(code, callback) */ var code; var cfunction; var callbackDictTargets; var dictThisObj; // 琛ㄥ崟涓撶敤閫夋嫨瀛楀吀 function dictSelect(_this) { var type = _this.getAttribute("dictcode");// 瀛楀吀缂栫爜 by lfj 20180830 // var type = _this.getAttribute("orgtype"); var title = _this.getAttribute("title"); if (title != null) $("#dictionaryModal .modal-title").html(title); callbackDictTargets = _this.getAttribute("targets");// 2:name;3:b selectDict(type, callbackDict); dictThisObj = _this; } // 琛ㄥ崟涓撶敤閫夋嫨瀛楀吀鍥炶皟鏂规硶 function callbackDict(obj) { if (callbackDictTargets != null && callbackDictTargets != "") { var list = callbackDictTargets.split(";"); for ( var i = 0; i < list.length; i++) { var arr = list[i].split(":"); $("[id='_" + arr[1] + "']:eq(0)").val(obj["col" + (parseInt(arr[0]))]); $("[name='_" + arr[1] + "']:eq(0)").val(obj["col" + (parseInt(arr[0]) + 1)]); } } } function callbackDict(id, value, code) { if (callbackDictTargets != null && callbackDictTargets != "") { var list = callbackDictTargets.split(";"); for ( var i = 0; i < list.length; i++) { /*var arr = list[i].split(":"); $("[id='_" + arr[1] + "']:eq(0)").val(value); $("[name='_" + arr[1] + "']:eq(0)").val(code);*/ $(dictThisObj).val(value); $(dictThisObj).prev().val(code); } } } // 閫氱敤鐨勯€夋嫨瀛楀吀鏂规硶 function selectDict(typeCode, callback) { code = typeCode; cfunction = callback; $.ajax({ url : '../dictionary/getCountByCode.do?typeCode=' + typeCode, type : 'POST', dataType : 'JSON', success : function(data) { var url = '../dictionary/list.do?type=' + typeCode + "&name=" + $("#dictionaryModal #dictSearch input[name=name]").val(); if (data > 300) { $("#dictionaryModal #myTab").hide(); $("#dictionaryModal #dictTreeDiv").removeClass("active in"); $("#dictionaryModal #dictList").addClass("active in"); // 鍙樉绀哄瓧鍏稿垪琛 showList(url, callback); } else { $("#dictionaryModal #myTab").show(); // $("#dictionaryModal #listActive").removeClass("active"); // $("#dictionaryModal #treeActive").addClass("active"); // $("#dictionaryModal #dictList").removeClass("active in"); // $("#dictionaryModal #dictTreeDiv").addClass("active in"); // if(typeCode=="dict_tree") showDictTree(typeCode, callback);// 鏄剧ず瀛楀吀鏍 // else showList(url, callback);// 鏄剧ず瀛楀吀鍒楄〃 } }, error : function(data) { toastr.warning("缃戠粶寮傚父锛岃鍒锋柊椤甸潰锛屾垨閲嶆柊鐧诲綍锛? + data.responseText); } }); $('#dictionaryModal').modal('show'); } // 鍒楄〃鏄剧ず瀛楀吀鏁版嵁 function showList(url, callback) { $("#dictionaryModal #dictTable").bootstrapTable("destroy").bootstrapTable({ url : url, pagination : true, sidePagination : "server", onClickRow : function(row) { if (callback.length == 3) callback(row.id, row.col2, row.col3); else callback(row); $("#dictionaryModal").modal("hide"); }, queryParams : function queryParams(params) { // 璁剧疆鏌ヨ鍙傛暟 var o = typeof (params) == "undefined" ? {} : params; return o; }, columns : [{ "field" : "col3", "title" : "缂栫爜" }, { "field" : "col2", "title" : "鍚嶇О" } ] }); $("#dictionaryModal .fixed-table-toolbar").css("position","unset").show(); } // 鍒楄〃鏌ヨ鏂规硶 function dictSearch() { selectDict(code, cfunction); } // 鏄剧ず瀛楀吀鏍 function showDictTree(code, callback) { $.ajax({ type : "post", url : "../dictionary/getTrees.do", data : { code : code }, dataType : 'json', cache : false, success : function(data, state) { $('#dictionaryModal #dictTree').data('jstree', false).empty();// 娓呯┖鍘熸潵鐨勬爲 $('#dictionaryModal #dictTree').unbind(); $('#dictionaryModal #dictTree').jstree({ 'plugins' : [ 'contextmenu', 'themes', 'ui', 'dnd', 'types' ], 'core' : { 'data' : data, 'animation' : 0 }, 'types' : { // 杩欓噷灏辨槸鍥剧墖鐨勬樉绀烘牸寮 "default" : { "icon" : "../images/treeIcon/flowDictionary.png" } } }).bind('changed.jstree', function(e, data) { var selected = data.instance.get_node(data.selected[0]).original; callback(selected.id, selected.text, selected.key); $("#dictionaryModal").modal("hide"); }); }, error : function(data, state) { toastr.error("鎿嶄綔澶辫触锛岃繑鍥炵姸鎬?" + state); } }); } var tableTreeTypes = { "0" : { "icon" : "../images/treeIcon/metadata.png" }, "1" : { "icon" : "../images/treeIcon/table.png" }, "2" : { "icon" : "../images/treeIcon/table.png" } }; // 鍔ㄦ€乽rl鐢熸垚鏍 function treesDlg(treeurl, types, callbackFunc) { // var code = $("#dictionaryModal #dictCode").val(); $('#dictionaryModal #dictTree').data('jstree', false).empty();// 娓呯┖鍘熸潵鐨勬爲 $("#dictionaryModal #dictTreeDiv").addClass("active in"); $('#dictionaryModal #dictTree').unbind(); $('#dictionaryModal #dictTree').html(""); $("#dictionaryModal #myTab").hide(); $("#dictionaryModal #dictList").hide(); $("#dictionaryModal #dictTree").show(); $('#dictionaryModal').modal('show'); if (treeurl == null || treeurl == "") return false; $.ajax({ type : "post", url : treeurl, data : {}, dataType : 'json', cache : false, success : function(data, state) { if (data != null && data.length > 0) { // 濡傛灉鍙湁涓€涓紝鍒欐墦寮€ if (data.length == 1) data[0].state = { "opened" : true }; var menu = {}; $('#dictionaryModal #dictTree').jstree({ 'plugins' : [ 'themes', 'ui', 'dnd', 'types' ], 'core' : { 'data' : data, 'animation' : 0 }, 'types' : types == null ? tableTreeTypes : types, 'contextmenu' : { 'items' : menu } }).bind('changed.jstree', function(e, data) { var sData = data.instance.get_node(data.selected[0]); var selectedData = sData.original; if (callbackFunc != null) callbackFunc(selectedData); $("#dictionaryModal").modal("hide"); }); } }, error : function(data, state) { toastr.error("鎿嶄綔澶辫触锛岃繑鍥炵姸鎬?" + state); } }); } // 鍔ㄦ€乽rl鐢熸垚鏍 function treesDlgByData(data, types, callbackFunc) { if (data == null || data.length <= 0) return false; // var code = $("#dictionaryModal #dictCode").val(); $('#dictionaryModal #dictTree').data('jstree', false).empty();// 娓呯┖鍘熸潵鐨勬爲 $("#dictionaryModal #dictTreeDiv").addClass("active in"); $('#dictionaryModal #dictTree').unbind(); $('#dictionaryModal #dictTree').html(""); $("#dictionaryModal #myTab").hide(); $("#dictionaryModal #dictList").hide(); $("#dictionaryModal #dictTree").show(); // 濡傛灉鍙湁涓€涓紝鍒欐墦寮€ if (data.length == 1) data[0].state = { "opened" : true }; var menu = {}; $('#dictionaryModal #dictTree').jstree({ 'plugins' : [ 'themes', 'ui', 'dnd', 'types' ], 'core' : { 'data' : data, 'animation' : 0 }, 'types' : types == null ? tableTreeTypes : types, 'contextmenu' : { 'items' : menu } }).bind('changed.jstree', function(e, data) { var sData = data.instance.get_node(data.selected[0]); var selectedData = sData.original; if (callbackFunc != null) callbackFunc(selectedData); $("#dictionaryModal").modal("hide"); }); } // 閫氱敤鐨勯€夋嫨瀛楀吀鏂规硶 -- 鍙璧嬪€ function selectListDictAssigned(typeCode, callback, obj) { code = typeCode; cfunction = callback; $.ajax({ url : '../dictionary/getCountByCode.do?typeCode=' + typeCode, type : 'POST', dataType : 'JSON', success : function(data) { var url = '../dictionary/list.do?type=' + typeCode + "&name=" + $("#dictionaryModal #dictSearch input[name=name]").val(); if (data > 300) { $("#dictionaryModal #myTab").hide(); // 鍙樉绀哄瓧鍏稿垪琛 getListDictAssignedForList(url, callback, obj); } else { // 鏄剧ず瀛楀吀鍒楄〃 getListDictAssignedForList(url, callback, obj); // 鏄剧ず瀛楀吀鏍 getListDictAssignedForTree(typeCode, callback, obj); } }, error : function(data) { toastr.warning("缃戠粶寮傚父锛岃鍒锋柊椤甸潰锛屾垨閲嶆柊鐧诲綍锛? + data.responseText); } }); $('#dictionaryModal').modal('show'); } // 鍒楄〃鏄剧ず瀛楀吀鏁版嵁 function getListDictAssignedForList(url, callback, obj) { $("#dictionaryModal #dictTable").bootstrapTable("destroy").bootstrapTable({ url : url, pagination : true, sidePagination : "server", onClickRow : function(row) { callback(row.id, row.col2, row.col3, obj); $("#dictionaryModal").modal("hide"); }, queryParams : function queryParams(params) { // 璁剧疆鏌ヨ鍙傛暟 var o = typeof (params) == "undefined" ? {} : params; return o; }, columns : [{ "field" : "col3", "title" : "缂栫爜" }, { "field" : "col2", "title" : "鍚嶇О" } ] }); } // 鏄剧ず瀛楀吀鏍 function getListDictAssignedForTree(code, callback, obj) { $.ajax({ type : "post", url : "../dictionary/getTrees.do", data : { code : code }, dataType : 'json', cache : false, success : function(data, state) { $('#dictionaryModal #dictTree').data('jstree', false).empty();// 娓呯┖鍘熸潵鐨勬爲 $('#dictionaryModal #dictTree').unbind(); $('#dictionaryModal #dictTree').jstree({ 'plugins' : [ 'contextmenu', 'themes', 'ui', 'dnd', 'types' ], 'core' : { 'data' : data, 'animation' : 0 }, 'types' : { // 杩欓噷灏辨槸鍥剧墖鐨勬樉绀烘牸寮 "default" : { "icon" : "../images/treeIcon/flowDictionary.png" } } }).bind('changed.jstree', function(e, data) { var selected = data.instance.get_node(data.selected[0]).original; callback(selected.id, selected.text, selected.key, obj); $("#dictionaryModal").modal("hide"); }); }, error : function(data, state) { toastr.error("鎿嶄綔澶辫触锛岃繑鍥炵姸鎬?" + state); } }); } var selectTreeId ;//鏍慽d鏁扮粍 var selectTreeName ;//鏍戝悕绉版暟缁 var selectedTreeNode; //鏌ヨ澶氶€夊瓧鍏告爲锛坣ame瀛樺偍鏍煎紡鍙瓨缂栫爜锛夛紙search鎼滅储鏉′欢鍙傛暟锛 function selectedTreeCode(_this,code,name,search){ selectDictAjax(code,name,_this,"0",search); $(document).mouseup(function (e) { var con = $(".search-box .muiltree"); // 璁剧疆鐩爣鍖哄煙 if (!con.is(e.target) && con.has(e.target).length === 0) { $(".search-box .muiltree").hide(); } }); } //鏌ヨ澶氶€夊瓧鍏告爲锛坣ame瀛樺偍鏍煎紡,缂栫爜鍔犱腑鏂囧悕绉 濡傦細 1鐢?0濂筹級 function selectedTreeName(_this,code,name){ selectDictAjax(code,name,_this,"1"); $(document).mouseup(function (e) { var con = $(".search-box .muiltree"); // 璁剧疆鐩爣鍖哄煙 if (!con.is(e.target) && con.has(e.target).length === 0) { $(".search-box .muiltree").hide(); } }); } //鏌ヨ鍗曢€夊瓧鍏告爲 function selectedTreeCodeRadio(_this,code,name,id){ selectDictRadio(code,name,_this,"0",id); $(document).mouseup(function (e) { var con = $(".search-box .muiltree"); // 璁剧疆鐩爣鍖哄煙 if (!con.is(e.target) && con.has(e.target).length === 0) { $(".search-box .muiltree").hide(); } }); } //鏌ヨ鍗曢€夊瓧鍏告爲锛坣ame瀛樺偍鏍煎紡,缂栫爜鍔犱腑鏂囧悕绉 濡傦細 1鐢凤級 function selectedTreeNameRadio(_this,code,name){ selectDictRadio(code,name,_this,"1"); $(document).mouseup(function (e) { var con = $(".search-box .muiltree"); // 璁剧疆鐩爣鍖哄煙 if (!con.is(e.target) && con.has(e.target).length === 0) { $(".search-box .muiltree").hide(); } }); } function selectAllDict(_this){ selectedTreeCode(_this,$(_this).attr("code")); } //鏍规嵁鏍戣妭鐐筽id澶氶€夋煡璇㈡爲 //鏍规嵁鏍戣妭鐐筽id鏌ヨ锛堝閫夊瓧鍏告爲锛夛紙pid涓虹┖鏌ヨ鐖秈d涓虹┖鐨勫閫夊瓧鍏告爲锛夛紙childObj绗簩绾ц仈鍔╥d,鍙傛暟鏍煎紡:#id锛 //root:鏄惁鏄剧ず鏍硅妭鐐 function selectDictPidCheckbox(_this,pid,root,childObj) { if(childObj == null) { childObj = ""; } var code=$(_this).attr("code"); var name="";//鏃犵敤 if(pid != null && pid != '') { selectedTreeCode(_this,code,name,{pid:pid,root:root}); }else { selectedTreeCode(_this,code,name,{state:0,child:childObj}); } } //鏍规嵁鏍戣妭鐐筽id鍗曢€夋煡璇㈡爲 function selectDictPidRadio(_this,pids){ var code=$(_this).attr("code"); $(".search-box .muiltree").css({"top":($(_this).offset().top+30),"left":$(_this).offset().left,"width":$(_this).outerWidth()}); $(".search-box .muiltree").show(); var treeHtml = $(".search-box .muiltree").html(); $(".search-box .muiltree").data('jstree', false).empty(); //娓呯┖鍘熸潵鐨勬爲 $(".search-box .muiltree").unbind(); // 绉婚櫎鎵€鏈夌粦瀹 $(".search-box .muiltree").html("鍔犺浇涓?.."); $.ajax({ type : 'POST', url : "../teacherInfo/getTrees.do", data : {ids : pids,code : code}, dataType : 'json', success : function(data) { if(data !=null && data !=""){ $(".search-box .muiltree").jstree({ 'plugins' : ['types' ], 'types' : {}, 'core' : { 'data' : data }, 'types' : { // 杩欓噷灏辨槸鍥剧墖鐨勬樉绀烘牸寮 "default" : { "icon" : "../images/treeIcon/flowDictionary.png" } } }).on("ready.jstree", function(e, data) { var inst = data.instance; selectedTreeNode = inst.get_node(e.target.firstChild.firstChild.lastChild); inst.open_node(selectedTreeNode);//榛樿鎵撳紑绗竴鑺傜偣 }).bind('changed.jstree', function(e, data) { var selected = data.instance.get_node(data.selected[0]).original; var key = selected.key; var textname = selected.text; var childNodes = data.instance.get_node(data.selected[0]).children; var code = $(_this).attr("dictcode"); var fruits=["deptTree","HR_STF_TYPE"]; // 涓嶉檺鍒跺瓨鍦ㄥ瓙鐩綍閫夋嫨 if(childNodes == null || childNodes.length <= 0 || fruits.indexOf(code) != -1) { if((key == null || key == '') && textname == '璇烽€夋嫨') { $(_this).siblings().val(''); $(_this).val(''); }else { $(_this).siblings().val(key); $(_this).val(textname); } }else { toastr.warning("涓嶈兘閫夋嫨瀛樺湪瀛愮洰褰曠殑閫夐」锛?"); } $(".search-box .muiltree").hide(); }); } }, error : function(data, status) { toastr.error("缃戠粶寮傚父锛岃鍒锋柊椤甸潰锛屾垨閲嶆柊鐧诲綍銆?); } }); $(document).mouseup(function (e) { var con = $(".search-box .muiltree"); // 璁剧疆鐩爣鍖哄煙 if (!con.is(e.target) && con.has(e.target).length === 0) { $(".search-box .muiltree").hide(); } }); } //鍔犺浇瀛楀吀鏍 function selectDictRadio(code,name,_this,type,id,searchName){ $(".search-box .muiltree").css({"top":($(_this).offset().top+30),"left":$(_this).offset().left,"width":$(_this).outerWidth()}); $(".search-box .muiltree").show(); var treeHtml = $(".search-box .muiltree").html(); $(".search-box .muiltree").data('jstree', false).empty(); //娓呯┖鍘熸潵鐨勬爲 $(".search-box .muiltree").unbind(); // 绉婚櫎鎵€鏈夌粦瀹 $(".search-box .muiltree").html("鍔犺浇涓?.."); $.ajax({ type : 'POST', url : "../dictionary/getTrees.do", data : { code : code, type:type, id:id, searchName:searchName }, dataType : 'json', success : function(data) { if(data !=null && data !=""){ $(".search-box .muiltree").jstree({ 'plugins' : ['types' ], 'types' : {}, 'core' : { 'data' : data }, 'types' : { // 杩欓噷灏辨槸鍥剧墖鐨勬樉绀烘牸寮 "default" : { "icon" : "../images/treeIcon/flowDictionary.png" } } }).on("ready.jstree", function(e, data) { var inst = data.instance; selectedTreeNode = inst.get_node(e.target.firstChild.firstChild.lastChild); inst.open_node(selectedTreeNode);//榛樿鎵撳紑绗竴鑺傜偣 }).bind('changed.jstree', function(e, data) { var selected = data.instance.get_node(data.selected[0]).original; var key = selected.key; var textname = selected.text; var childNodes = data.instance.get_node(data.selected[0]).children; if(type =='1'){ key = key+""+textname; } var fruits=["1","2","3","4","5","6","10131680"];//铏氭嫙閮ㄩ棬ID if(code !="deptTree" || fruits.indexOf(key) ==-1 ){//绉婚櫎铏氭嫙閮ㄩ棬 if(childNodes == null || childNodes.length <= 0 || code !="deptTree") { if((key == null || key == '') && textname == '璇烽€夋嫨') { $(_this).siblings().val(''); $(_this).val(''); }else { $(_this).siblings("[name='"+$(_this).attr("id")+"']").val(key); $(_this).val(textname); } //change浜嬩欢瑙﹀彂 $(_this).siblings().change(); }else { toastr.warning("涓嶈兘閫夋嫨瀛樺湪瀛愮洰褰曠殑閫夐」锛?); } } if(code =="deptTree" && fruits.indexOf(key) > 0){ toastr.warning("涓嶈兘閫夋嫨铏氭嫙閮ㄩ棬锛?); } $(".search-box .muiltree").hide(); }); if(code =="deptTree") { dictRadio_code = code; dictRadio_name = name; dictRadio_this = _this; dictRadio_type = type; dictRadio_id = id; if(searchName == null) { searchName = ''; } $(".search-box .muiltree").prepend('