76df4f7bb30bc0e66392ae957df82e3d55d6a8c3.svn-base 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. <%@page language="java" pageEncoding="UTF-8"%>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>组织机构管理</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <!--框架必需start-->
  8. <%@include file="../.././../../include.jsp"%>
  9. <!--引用资源文件,JS CSS-->
  10. <script type="text/javascript"
  11. src="<%=path%>/scripts/jquery/plugins/jquery.extension.util.js"></script>
  12. <script type="text/javascript"
  13. src="<%=path%>/scripts/freamwork/com/sinosoft/common/common.js"></script>
  14. <script type="text/javascript"
  15. src="<%=path%>/scripts/freamwork/com/sinosoft/common/utils/utils.js"></script>
  16. <script type="text/javascript"
  17. src="<%=path%>/scripts/freamwork/com/sinosoft/common/frameWork/frameWork.js"></script>
  18. <script type="text/javascript"
  19. src="<%=path%>/scripts/freamwork/com/sinosoft/common/utils/Request.js"></script>
  20. <script type="text/javascript"
  21. src="<%=path%>/scripts/freamwork/com/sinosoft/common/searchUtil.js"></script>
  22. <link
  23. href="<%=path%>/scripts/freamwork/com/sinosoft/common/searchUtil.css"
  24. rel="stylesheet" type="text/css" />
  25. <style type = "text/css">
  26. .tips {
  27. white-space: nowrap;
  28. width: 100%;
  29. overflow: hidden;
  30. text-overflow: ellipsis;
  31. dispaly:inline-block;
  32. }
  33. .hr3 {
  34. filter: alpha(opacity = 100, finishopacity = 0, style = 1);
  35. noshade: "noshade";
  36. height: 0.5px;
  37. border: none;
  38. /* border-top: 2px ridge #45D6D8; */
  39. border: 1px dotted #45D6D8;
  40. }
  41. #queryContent1 {
  42. position: absolute;
  43. min-height: 0px;
  44. max-height: 273px;
  45. max-width: 100%;
  46. background-color: #B2E0FF;
  47. z-index: 12;
  48. text-overflow: -o-ellipsis-lastline;
  49. overflow: hidden;
  50. text-overflow: ellipsis;
  51. display: -webkit-box;
  52. -webkit-line-clamp: 2;
  53. -webkit-box-orient: vertical;
  54. }
  55. #queryContent1ul li:hover {
  56. cursor: pointer;
  57. background-color:gray;
  58. }
  59. </style>
  60. <script type="text/javascript">
  61. //图标
  62. var imgclass = "<%=request.getParameter("imgclass")%>";
  63. //选项卡界面地址
  64. var jsonaa = [{"src":"/nwyj/page/business/am/org/query/Org_In.jsp","text":"内部机构"},
  65. {"src":"/nwyj/page/business/am/org/query/Org_Out.jsp","text":"外部机构"}]
  66. var getParam = "";//点击选项卡需要传递的参数
  67. var org_type = "<%=request.getParameter("org_type")%>";
  68. org_type = org_type.split('?')[0];
  69. //登陆人的机构id
  70. var loginOrgId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  71. //登陆人单位name
  72. var loginOrgName = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
  73. var role = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
  74. //取得用户真实名字
  75. var realName = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  76. var realName_ID = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  77. var realName_phe = top.com.sinosoft.lz.system.user.LoginInfo.getMobile();
  78. /**************2017-03-17 唐群胜 获取登陆人的单位级别*****************/
  79. //alert("++++"+realName_ID+realName+realName_phe)
  80. function getDeptLevel(dpids){
  81. var dept_level = "";
  82. $.ajax({
  83. url : $.pathname()+ "/ws/planService/PlanService/getDeptLevel",
  84. type : 'post',
  85. timeout : 60000,
  86. data : {id:dpids},
  87. dataType : 'text',
  88. async: false,
  89. success : function(data){
  90. dept_level = data;
  91. }
  92. });
  93. return dept_level;
  94. }
  95. //树的初始化
  96. var setting;
  97. //定义选项卡
  98. var tab;
  99. //新增选项卡的下标
  100. var tabIndex = 0;
  101. //设置机构树的对象
  102. var zTree;
  103. //设置当前选中的机构节点 ,可以取机构所有信息。是否虚拟机构的字段0虚拟,1实体
  104. var selectedTreeNode={
  105. "id":loginOrgId,
  106. "name":loginOrgName
  107. };
  108. //定义初始化的根节点
  109. var rootNode;
  110. var frheight=$(parent.document.body).find("#frmright");
  111. $(function(){
  112. /* $("#tab1_index1").live("click",function(){//“机构人员信息”选项卡的点击事件
  113. //var $tab1 = $("#tab1_index1").children().children().children("td").eq(1).text();//
  114. var $tab1 = $("#tab1_index1").children().children().children(".tab_item2_mouseover").text();
  115. if($tab1 == "机构人员信息"){
  116. //alert($tab1)
  117. //var isParent = getParam.isParent;//应急指挥中心为true,应急办为false
  118. //alert("++++++"+isParent)
  119. parent.avtiveTab('tab1_index1');
  120. }
  121. });
  122. $("#tab1_index12").live("click",function(){//“历史人员信息”选项卡的点击事件
  123. //var $tab2 = $("#tab1_index12").children().children().children("td").eq(1).text();
  124. var $tab2 = $("#tab1_index12").children().children().children(".tab_item2_mouseover").text();
  125. if($tab2 == "历史人员信息"){
  126. //alert($tab2)
  127. //$("#tab1_index12").update();
  128. //location.reload();
  129. }
  130. }); */
  131. $("#zjjg").hide();
  132. $("#xgjg").hide();
  133. $("#scjg").hide();
  134. $("#shangyi").hide();
  135. $("#xiayi").hide();
  136. //判断按钮的显示,只有超级管理员才有权限使用
  137. var corp_roles = role.split(",");
  138. for ( var i = 0; i < corp_roles.length; i++) {
  139. if(corp_roles[i]=="R002105430200"){
  140. $("#zjjg").show();
  141. $("#xgjg").show();
  142. $("#scjg").show();
  143. $("#shangyi").show();
  144. $("#xiayi").show();
  145. }
  146. }
  147. //tabPosition(jsonaa,imgclass);
  148. //初始化布局组件
  149. initLayout();
  150. //初始化右侧的选项卡
  151. initTab();
  152. //树的设置
  153. setting = {
  154. view : {
  155. selectedMulti : false
  156. },
  157. edit: {
  158. enable: true,
  159. showRemoveBtn: false,
  160. showRenameBtn: false,
  161. drag: {
  162. minMoveSize: 5,
  163. prev: true,
  164. next: true,
  165. inner: false
  166. }
  167. },
  168. async : {
  169. enable : true,
  170. dataType : 'JSON',
  171. dataName : 'treeNodes',
  172. aysnc : false,
  173. url : getAsyncUrl,
  174. autoParam : [ "id", "name", "orgLevel" ],
  175. otherParam : ["deptId", loginOrgId,"deptLevel",getDeptLevel(loginOrgId)]
  176. },
  177. callback: {
  178. //响应右键
  179. //onRightClick: OnRightClick,
  180. //树的拖拽
  181. beforeDrag: beforeDrag2,
  182. beforeDrop: beforeDrop2,
  183. //鼠标按键松开后的事件回调函数
  184. onMouseUp: onMouseUp,
  185. onClick: onClick,
  186. onDrop: onDrop2
  187. }
  188. };
  189. //初始化树
  190. initTree();
  191. //绑定查询框事件
  192. $("#queryInput1").focus(function (){
  193. $("#queryInput1").on("keyup", function(event) {
  194. var e = event||window.event;
  195. if(e&&e.keyCode<106&&e.keyCode>64||e.keyCode=="13"){
  196. }
  197. var getValue = $("#queryInput1").val().trim();
  198. if(getValue!=""){
  199. inputTips(getValue);
  200. }
  201. });
  202. })
  203. //绑定点击查询显示框的其他位置隐藏div方法
  204. $("body:eq(0)").bind("click" ,function (event){
  205. var e = event || window.event;
  206. var elem = e.srcElement || e.target;
  207. var inOrgHOS = $("#queryContent1").is(":hidden");
  208. if(!inOrgHOS){
  209. while(elem)
  210. {
  211. if(elem.id == "queryContent1")
  212. {
  213. return;
  214. }
  215. elem = elem.parentNode;
  216. }
  217. //隐藏div的方法
  218. $("#queryContent1").hide();
  219. }
  220. });
  221. //鼠标移入右键菜单效果
  222. $("#rMenu >div").hover(function(){
  223. $(this).addClass("b-m-ifocus");
  224. },function(){
  225. $(this).removeClass("b-m-ifocus");
  226. });
  227. $searchOne = $("#searchOne");//查询图标绑定查询事件
  228. $searchOne.bind('click', function() {
  229. });
  230. });
  231. //初始化右侧选项卡
  232. function initTab(){
  233. //初始化右侧选项卡信息
  234. tab = new TabView( {
  235. containerId :'tab_menu',
  236. pageid :'page',
  237. cid :'tab1',
  238. position :"top"
  239. });
  240. //设置页签id编号
  241. tabIndex = tabIndex +1;
  242. //默认添加机构人员信息的选项卡界面
  243. tab.add({
  244. id :'tab1_index'+1,
  245. title :"应急机构图",
  246. //url :"/nwyj/page/business/am/org/query/Org_Collection.jsp?statisticId=" + loginOrgId+"&statisticName="+loginOrgName,
  247. url :"/nwyj/page/business/am/org/query/Org_AllInformation.jsp",
  248. isClosed :false
  249. });
  250. // 拖拽handle width
  251. $(".l-layout-drophandle-left").get(0).style.width=20 + 'px';
  252. }
  253. function changeTabUrl(flag,treeNode){
  254. var isParent = treeNode.isParent;//应急指挥中心为true,应急办为false
  255. if(flag){
  256. closeTab("tab1_index12")
  257. tab.update({
  258. id :'tab1_index'+1,
  259. title :"应急机构图",//treeNode.name+"统计信息",
  260. //url :"/nwyj/page/business/am/org/query/Org_Collection.jsp?statisticId=" + selectedTreeNode.id+"&statisticName="+selectedTreeNode.name,
  261. url :"/nwyj/page/business/am/org/query/Org_AllInformation.jsp",
  262. isClosed :false
  263. });
  264. }else{
  265. tab.update({
  266. id :'tab1_index1',
  267. title :"机构人员信息",
  268. url :"/nwyj/page/business/am/org/query/AllInformation.jsp?isParent="+isParent,
  269. isClosed :false
  270. });
  271. if(isParent){//应急指挥中心为
  272. tab.add({
  273. id :'tab1_index1'+2,
  274. title :"历史人员信息",
  275. url :"/nwyj/page/business/am/org/query/AllInformation_history.jsp?isParent="+isParent,
  276. isClosed :false
  277. });
  278. }else{//应急办
  279. tab.update({
  280. id :'tab1_index12',
  281. title :"历史人员信息",
  282. url :"/nwyj/page/business/am/org/query/AllInformation_history.jsp?isParent="+isParent,
  283. isClosed :false
  284. });
  285. }
  286. tab.activate("tab1_index1");
  287. /* var frame = document.getElementById("page_tab1_index1");
  288. frame.contentWindow.refreshInformation(treeNode,selectedTreeNode.id); */
  289. }
  290. }
  291. //鼠标按键松开后的事件回调函数 用于返回当前选中的
  292. function onMouseUp(event, treeId, treeNode){
  293. return selectedTreeNode = treeNode==null?selectedTreeNode:treeNode;
  294. }
  295. //新增成功后 调用新增机构的方法(用于显示树)
  296. function addNewVirtualOrg(parentNode,addNode,index){
  297. var newNodes = zTree.addNodes(parentNode,addNode);
  298. //选中新增的节点
  299. zTree.selectNode(newNodes[0]);
  300. selectedTreeNode = newNodes[0];
  301. top.Dialog.alert('新增成功');
  302. //关闭页签
  303. closeTab('tab1_index'+index);
  304. //刷新information界面
  305. var frame = document.getElementById("page_tab1_index1");
  306. frame.contentWindow.refreshInformation(newNodes[0],newNodes[0].id);
  307. }
  308. // 修改成功后 调用修改机构的方法(用于显示树)
  309. function updateVirtualOrg(newNode,oldNode,index){
  310. //更新节点的属性
  311. oldNode.name = newNode.name;
  312. zTree.updateNode(oldNode);
  313. //选中修改的节点
  314. zTree.selectNode(oldNode);
  315. top.Dialog.alert('修改成功');
  316. //关闭页签
  317. closeTab('tab1_index'+index);
  318. //刷新information界面
  319. var frame = document.getElementById("page_tab1_index1");
  320. frame.contentWindow.refreshInformation(oldNode,oldNode.id);
  321. }
  322. //标记点击的机构是实体机构还是应急机构 true=实体机构 false = 应急机构
  323. var orgFlag = true;
  324. //组织机构树的点击事件
  325. function onClick(event, treeId, treeNode, clickFlag){
  326. //记录当前点击的机构为实体机构还是应急机构
  327. var currentFlag = treeNode.isVirtual=="0"?true:false;
  328. //getParam = treeNode;//20180323
  329. //changeTabUrl(currentFlag,treeNode);//20180323
  330. //alert(treeNode.isParent)//true为应急指挥中心;false为应急办
  331. //alert(currentFlag)
  332. if(currentFlag == orgFlag && currentFlag==false){
  333. orgFlag= false
  334. //如果点击的是应急机构并且和之前点击的一样 那么 调用刷新页面的方法
  335. tab.activate("tab1_index1");
  336. var frame = document.getElementById("page_tab1_index1");
  337. frame.contentWindow.refreshInformation(treeNode,selectedTreeNode.id);
  338. changeTabUrl(currentFlag,treeNode);
  339. }else if(currentFlag == orgFlag && currentFlag==true){
  340. orgFlag= true;
  341. //如果点击的是实体机构并且和之前点击的一样 那么 调用刷新页面的方法
  342. tab.activate("tab1_index1");
  343. var frame = document.getElementById("page_tab1_index1");
  344. frame.contentWindow.refreshStatisticInfo(treeNode,selectedTreeNode.id);
  345. }else{
  346. orgFlag= currentFlag;
  347. changeTabUrl(currentFlag,treeNode);
  348. }
  349. /* tab.activate("tab1_index1");
  350. var frame = document.getElementById("page_tab1_index1");
  351. frame.contentWindow.refreshInformation(treeNode,selectedTreeNode.id); */
  352. if(treeNode.id!=gtreeId){
  353. sortNo="";
  354. sortNo1="";
  355. }
  356. /* if(treeNode.id!=gtreeId1){
  357. sortNo1="";
  358. } */
  359. }
  360. //拖拽前的判定 不能拖拽(根节点不能拖拽)返回false
  361. function beforeDrag2(treeId, treeNodes) {
  362. for (var i = 0, l = treeNodes.length; i < l; i++) {
  363. if(treeNodes[i].id ==loginOrgId) {
  364. return false;
  365. }
  366. }
  367. return true;
  368. }
  369. //拖拽放下前的判定 只能在同级拖动 (父id相同) 不能放下返回false
  370. function beforeDrop2(treeId, treeNodes, targetNode, moveType) {
  371. if(targetNode && targetNode.parentId == treeNodes[0].parentId){
  372. return true;
  373. }
  374. return false;
  375. }
  376. //拖拽完成后进行后台交互
  377. function onDrop2(event, treeId, treeNodes, targetNode, moveType, isCopy){
  378. if(targetNode){
  379. //后台交互
  380. $.ajax({
  381. url:$.pathname()+"/ws/InDepartmentService/InDepartmentService/updateSortNo",
  382. type:"post",
  383. dataType:"json",
  384. data:{"dragNodeId":treeNodes[0].id,
  385. "destNodeSortNo":targetNode.sortNo},
  386. success:function(data){
  387. if(data=="1"){
  388. //更新已变更的sortNo
  389. var treeObj = $.fn.zTree.getZTreeObj("myTree");
  390. var node = treeNodes[0];
  391. node.sortNo = (parseFloat(targetNode.sortNo) + 0.123401)+"";
  392. treeObj.updateNode(node);
  393. }
  394. }
  395. })
  396. }
  397. }
  398. //加载搜索框的提示信息
  399. function inputTips(inputValue) {
  400. var params = {
  401. "name":inputValue,
  402. "permissionId":loginOrgId
  403. }
  404. //清空ul
  405. $("#queryContent1").find("ul").empty();
  406. //查询字段
  407. $.ajax({
  408. url : $.pathname()
  409. + '/ws/InDepartmentService/InDepartmentService/queryOrgByName',
  410. data : params,
  411. dataType : 'json',
  412. type : 'post',
  413. success : function(result) {
  414. /* if (result.length > 0) {
  415. $("#queryContent1").show();
  416. } */
  417. $("#queryContent1").show();
  418. $("#queryContent1ul").empty();
  419. for (var i = 0; i < result.length; i++) {
  420. var item = result[i];
  421. if (i < 3) {
  422. //遍历加载字段
  423. $("#queryContent1")
  424. .find("ul")
  425. .append(
  426. "<li><div >"
  427. + item.name
  428. + "</div><div style='text-align:right;margin : 0px 0px 0px 5px;' title='"+item.path+"'>"
  429. + item.spath
  430. + "</div><hr class='hr3'/></li>");
  431. $("#queryContent1").find("ul").find("li")
  432. .last().data("id", item.id)
  433. .on("click", function() {
  434. findById($(this).data("id"));
  435. });
  436. continue;
  437. }
  438. if (i == 3) {
  439. $("#queryContent1")
  440. .find("ul").append(
  441. "<li><div id='gengduo'>查看更多</div></li>");
  442. //设置控件节点高度
  443. $("#gengduo").css({
  444. "font-size" : "12px",
  445. "line-height" : "1.4em",
  446. "text-align" : "center"
  447. });
  448. //绑定点击事件,
  449. $("#gengduo").on("click", function() {
  450. $("#gengduo").hide();
  451. moreOptions(result);
  452. });
  453. break;
  454. }
  455. }
  456. }
  457. });
  458. //绑定键盘上下键
  459. $("#queryContent1").on("keyup",function(event){
  460. var e = event||window.event;
  461. if(e&&e.keyCode=="40"){
  462. $("#queryContent1ul").find("li").focus();
  463. $("#queryContent1ul").find("li").focus(function(event){
  464. var e = event||window.event;
  465. if(e&&e.keyCode=="13"){
  466. findById($(this).data("id"));
  467. }
  468. });
  469. }
  470. })
  471. }
  472. //加载更多搜索选项
  473. function moreOptions(moreresult) {
  474. for (var i = 3; i < moreresult.length; i++) {
  475. var item = moreresult[i];
  476. $("#queryContent1").find("ul").append(
  477. "<li><div>" + item.name
  478. + "</div><div style='text-align:right;margin : 0px 0px 0px 5px;' title='"+item.path+"'>"
  479. + item.spath
  480. + "</div><hr class='hr3'/></li>");
  481. $("#queryContent1").find("ul").find("li").last()
  482. .data("id", item.id).on("click", function() {
  483. findById($(this).data("id"));
  484. });
  485. }
  486. }
  487. //根据id精准搜索
  488. function findById(id) {
  489. $
  490. .ajax({
  491. url : $.pathname()
  492. + '/ws/InDepartmentService/InDepartmentService/getHigherOrgIds',
  493. data : {
  494. 'id' : id,
  495. 'permissionId':loginOrgId
  496. },
  497. type : 'post',
  498. dataType : 'json',
  499. success : function(data) {
  500. doSome(data, id);
  501. }
  502. })
  503. $("#queryContent1").hide();
  504. }
  505. //找到给定id的机构信息
  506. function doSome(data, mid) {
  507. var zTree =$.fn.zTree.getZTreeObj("myTree") ;
  508. //判定是否能直接在前台找到想要搜寻的机构
  509. if (canFind(mid)) {
  510. zTree.selectNode(zTree.getNodesByParam("id", mid, null)[0]);
  511. return;
  512. }
  513. //不能搜寻到就找出已经加载的节点信息 然后异步加载树
  514. isAdd = true;
  515. for (var i = 0; i < data.length; i++) {
  516. var treeNodes = zTree.getNodesByParam("id", data[i], null)[0];
  517. //var p = i - 1;
  518. if (treeNodes != null) {
  519. var pnode = zTree.getNodesByParam("id", data[i], null)[0];
  520. targetOrg = mid;
  521. zTree.reAsyncChildNodes(pnode, "refresh", true);
  522. break;
  523. }
  524. }
  525. setTimeout(function() {
  526. zTree.selectNode(zTree.getNodesByParam("id", mid, null)[0]);
  527. }, 300);
  528. isAdd = false;
  529. }
  530. //是否能直接在已加载的机构中找寻到
  531. function canFind(mid) {
  532. var treeObj = $.fn.zTree.getZTreeObj("myTree");
  533. var treeNodes = treeObj.getNodesByParam("id", mid, null)[0];
  534. return treeNodes != null;
  535. }
  536. //初始化树
  537. function initTree(){
  538. if(org_type=="yj"){
  539. $.fn.zTree.init($("#myTree"), setting1);
  540. }else{
  541. $.fn.zTree.init($("#myTree"), setting);
  542. }
  543. zTree = $.fn.zTree.getZTreeObj("myTree");
  544. setTimeout(function(){
  545. //初始化后选中根节点(默认)
  546. var treeObj = $.fn.zTree.getZTreeObj("myTree");
  547. selectedTreeNode = treeObj.getNodeByParam("id",loginOrgId,null);
  548. rootNode = treeObj.getNodeByParam("id",loginOrgId,null);
  549. },600);
  550. }
  551. function getSelectTreeNode(){
  552. var treeObj = $.fn.zTree.getZTreeObj("myTree");
  553. selectedTreeNode = treeObj.getNodeByParam("id",loginOrgId,null);
  554. }
  555. //点击右键处理
  556. function OnRightClick(event, treeId, treeNode) {
  557. //在节点之外显示一种菜单
  558. if (!treeNode && event.target.tagName.toLowerCase() != "button" && $(event.target).parents("a").length == 0) {
  559. //在节点里面显示另一种菜单
  560. } else if(treeNode&&treeNode.isVirtual=="0") {
  561. zTree.selectNode(treeNode);
  562. showRMenu("entityNode", event.clientX, event.clientY);
  563. }else if(treeNode&&treeNode.isVirtual=="1"){
  564. zTree.selectNode(treeNode);
  565. showRMenu("virtualNode", event.clientX, event.clientY);
  566. }
  567. }
  568. //根据设置弹出不同的右键菜单
  569. function showRMenu(type, x, y) {
  570. $("#rMenu ul").show();
  571. if(type == "virtualNode") {//树节点外只保留添加和恢复
  572. $("#m_add").show();
  573. $("#m_edit").show();
  574. $("#m_delete").show();
  575. }else if(type == "entityNode") {//父节点保留添加和删除
  576. $("#m_add").show();
  577. $("#m_edit").hide();
  578. $("#m_delete").hide();
  579. }
  580. $("#rMenu").css({"top":y+"px", "left":x+"px", "visibility":"visible"});
  581. //点击菜单外时隐藏菜单
  582. $("body").bind("mousedown", onBodyMouseDown);
  583. }
  584. //点击菜单项时隐藏菜单
  585. function hideRMenu() {
  586. if ($("#rMenu")) $("#rMenu").css({"visibility": "hidden"});
  587. $("body").unbind("mousedown", onBodyMouseDown);
  588. }
  589. //点击菜单外时隐藏菜单
  590. function onBodyMouseDown(event){
  591. if (!(event.target.id == "rMenu" || $(event.target).parents("#rMenu").length > 0)) {
  592. $("#rMenu").css({"visibility" : "hidden"});
  593. }
  594. }
  595. //右键的新增 虚拟机构的方法(打开新的界面)
  596. function addVirtualOrg(){
  597. //获得点击的机构节点
  598. var pNode = selectedTreeNode==null?rootNode:selectedTreeNode;
  599. //if(pNode.corpId!=undefined){//应急处理,新添加的机构在树没刷新前在树内没有corpId
  600. var co_id = pNode.corpId;
  601. if(co_id!=loginOrgId){
  602. top.Dialog.alert("只能维护本级单位的信息");
  603. return;
  604. }
  605. //}
  606. var url="Add_VirtualOrg.jsp";
  607. var name ="新增应急机构【"+pNode.name+"】";
  608. addTab(url,name);
  609. hideRMenu();
  610. };
  611. //右键修改机构信息学
  612. function editOrgInfo(){
  613. //获得点击的机构节点
  614. var pNode = selectedTreeNode;
  615. var co_id = pNode.corpId;
  616. if(pNode.isVirtual=="0"){
  617. top.Dialog.alert("只能维护应急机构的信息");
  618. return;
  619. }
  620. //if(pNode.corpId!=undefined){
  621. if(co_id!=loginOrgId){
  622. top.Dialog.alert("只能维护本级单位的信息");
  623. return;
  624. }
  625. //}
  626. var url="Update_VirtualOrg.jsp?";
  627. var name ="修改【"+pNode.name+"】";
  628. addTab(url,name);
  629. hideRMenu();
  630. }
  631. //右键产出机构信息
  632. function deleteOrg(){
  633. top.Dialog.confirm("确定要删除吗?|删除", function() {
  634. //获得点击的机构节点
  635. var pNode = selectedTreeNode;
  636. if(pNode.isVirtual=="0"){
  637. top.Dialog.alert("只能删除应急机构的信息");
  638. return;
  639. }
  640. //if(pNode.corpId!=undefined){
  641. var co_id = pNode.corpId;
  642. if(co_id!=loginOrgId){
  643. top.Dialog.alert("只能删除本级单位的信息");
  644. return;
  645. }
  646. //}
  647. hideRMenu();
  648. $.ajax({
  649. url:$.pathname() + "/ws/InDepartmentService/InDepartmentService/deleteOrgById",
  650. data:{
  651. "id":pNode.id
  652. },
  653. dataType :"json",
  654. type :"post",
  655. success : function(data){
  656. //如果删除成功那么在树上删除该节点
  657. if(data==pNode.id){
  658. top.Dialog.alert("删除成功");
  659. zTree.removeNode(pNode);
  660. //选中根节点
  661. fNode = zTree.getNodeByParam("id",loginOrgId,null);
  662. selectedTreeNode = fNode;
  663. orgFlag = true;
  664. //getParam = selectedTreeNode;
  665. changeTabUrl(orgFlag,selectedTreeNode);
  666. //zTree.getNodeByParam("id",rootNode.id,null);
  667. //刷新information界面
  668. /* var frame = document.getElementById("page_tab1_index1");
  669. frame.contentWindow.refreshInformation(fNode,fNode.id); */
  670. }else{
  671. top.Dialog.alert("该机构下存在联系人或子机构");
  672. }
  673. }
  674. });
  675. });
  676. }
  677. //判定是否为搜索的变量
  678. var isAdd = false;
  679. //定义需要搜索的机构id
  680. var targetOrg;
  681. // 异步加载树时的请求url变更
  682. function getAsyncUrl(treeId, treeNode) {
  683. return isAdd ? $.pathname()
  684. + "/ws/InDepartmentService/InDepartmentService/newOrgInfoById?targetOrg="
  685. + targetOrg
  686. : $.pathname()
  687. + "/ws/InDepartmentService/InDepartmentService/getOrgInfoById";
  688. };
  689. //新增页签的方法
  690. function addTab(url,name){
  691. tabIndex = tabIndex +1;
  692. tab.add( {
  693. id :'tab1_index'+tabIndex,
  694. title :name,
  695. url :url,
  696. isClosed :true
  697. });
  698. return 'tab1_index'+tabIndex;
  699. }
  700. //刷新页签的方法
  701. function updateTab(url,name){
  702. //tabIndex = tabIndex +1;
  703. tab.update( {
  704. id :'tab1_index'+tabIndex,
  705. title :name,
  706. url :url,
  707. isClosed :true
  708. });
  709. return 'tab1_index'+tabIndex;
  710. }
  711. //关闭页签的方法
  712. function closeTab(id){
  713. tab.close(id);
  714. }
  715. //切换页签的方法
  716. function avtiveTab(id){
  717. tab.activate(id);
  718. if(id=="tab1_index1"){
  719. var frame = document.getElementById("page_tab1_index1");
  720. frame.contentWindow.refreshInformation(selectedTreeNode,selectedTreeNode.id);
  721. }
  722. }
  723. // 布局组件初始化
  724. function initLayout() {
  725. var layout = $("#layout1").layout({
  726. leftWidth : 320,
  727. centerWidth : 760,
  728. height: 850,
  729. space:15
  730. });
  731. layout.setRightCollapse(true);
  732. };
  733. // 重置页面高度
  734. function resetWindowSize(){
  735. $(parent.document.body).find("#frmright").height(950);
  736. $(window).resize(function(){
  737. $(parent.document.body).find("#frmright").height(950);
  738. });
  739. }
  740. //点击表格双视图,增加页面高度
  741. function resetWindowSize1200(){
  742. /* setTimeout(function(){
  743. $(parent.document.body).find("#frmright").height(1200);
  744. $(".l-layout-center").get(0).style.height=1200 + 'px';
  745. },2000) ; */
  746. $(parent.document.body).find("#frmright").height(1200);
  747. $(".l-layout-center").get(0).style.height=1200 + 'px';
  748. $(window).resize(function(){
  749. $(parent.document.body).find("#frmright").height(1200);
  750. });
  751. }
  752. var sortNo = "";
  753. var gtreeId = "";
  754. function moveup(){
  755. var pNode = selectedTreeNode==null?rootNode:selectedTreeNode;
  756. if(sortNo==""){
  757. sortNo = pNode.sortNo;
  758. }else{
  759. sortNo = parseInt(sortNo)-1;
  760. }
  761. gtreeId = pNode.id;
  762. $.ajax({
  763. url:$.pathname() + "/ws/InDepartmentService/InDepartmentService/getMoveUp",
  764. data:{
  765. "sortNo": sortNo,
  766. "id":pNode.id,
  767. "parent_id":pNode.parentId
  768. },
  769. dataType :"json",
  770. type :"post",
  771. success : function(data){
  772. if(data==pNode.id){
  773. $.fn.zTree.init($("#myTree"), setting);
  774. setTimeout(function(){
  775. zTree.selectNode(zTree.getNodesByParam("id", data, null)[0]);
  776. },200);
  777. }else{
  778. top.Dialog.alert("该机构没有排序字段");
  779. }
  780. }
  781. });
  782. }
  783. var sortNo1 = "";
  784. function movedown(){
  785. var pNode = selectedTreeNode==null?rootNode:selectedTreeNode;
  786. if(sortNo1==""){
  787. sortNo1 = pNode.sortNo;
  788. }else{
  789. sortNo1 = parseInt(sortNo1)+1;
  790. }
  791. gtreeId = pNode.id;
  792. $.ajax({
  793. url:$.pathname() + "/ws/InDepartmentService/InDepartmentService/getMoveDowndown",
  794. data:{
  795. "sortNo": sortNo1,
  796. "id":pNode.id,
  797. "parent_id":pNode.parentId
  798. },
  799. dataType :"json",
  800. type :"post",
  801. success : function(data){
  802. if(data==pNode.id){
  803. $.fn.zTree.init($("#myTree"), setting);
  804. setTimeout(function(){
  805. zTree.selectNode(zTree.getNodesByParam("id", data, null)[0]);
  806. },600);
  807. }else{
  808. top.Dialog.alert("该机构没有排序字段");
  809. }
  810. }
  811. });
  812. }
  813. var setting1 = {
  814. view : {
  815. selectedMulti : false
  816. },
  817. edit: {
  818. enable: true,
  819. showRemoveBtn: false,
  820. showRenameBtn: false,
  821. drag: {
  822. minMoveSize: 5,
  823. prev: true,
  824. next: true,
  825. inner: false
  826. }
  827. },
  828. async : {
  829. enable : true,
  830. dataType : 'JSON',
  831. dataName : 'treeNodes',
  832. aysnc : false,
  833. url : $.pathname() + "/ws/InDepartmentService/InDepartmentService/getOnlyOrgInfoById",
  834. autoParam : [ "id", "name", "orgLevel" ],
  835. otherParam : ["deptId", loginOrgId,"deptLevel",getDeptLevel(loginOrgId)]
  836. },
  837. callback: {
  838. //响应右键
  839. //onRightClick: OnRightClick,
  840. //树的拖拽
  841. beforeDrag: beforeDrag2,
  842. beforeDrop: beforeDrop2,
  843. //鼠标按键松开后的事件回调函数
  844. onMouseUp: onMouseUp,
  845. onClick: onClick,
  846. onDrop: onDrop2
  847. }
  848. };
  849. function qiehuan1(){
  850. $.fn.zTree.init($("#myTree"), setting1);
  851. }
  852. function qiehuan2(){
  853. $.fn.zTree.init($("#myTree"), setting);
  854. }
  855. </script>
  856. </head>
  857. <body>
  858. <div class="b-m-mpanel" style="width: 150px;visibility:hidden;" id="rMenu">
  859. <div class="b-m-item" id="m_add" onclick="addVirtualOrg();">
  860. <img align="middle" src="<%=path%>/scripts/qui/libs/icons/add.png"/><span>增加应急机构</span>
  861. </div>
  862. <div class="b-m-item" id="m_edit" onclick="editOrgInfo();">
  863. <img align="middle" src="<%=path%>/scripts/qui/libs/icons/edit.png"/><span>修改机构</span>
  864. </div>
  865. <div class="b-m-item" id="m_delete" onclick="deleteOrg();">
  866. <img align="middle" src="<%=path%>/scripts/qui/libs/icons/delete.png"/><span>删除机构</span>
  867. </div>
  868. </div>
  869. <div style="margin: 10px 0px 0px 0px">
  870. <div id="layout1" >
  871. <div position="left" >
  872. <div class="layout_content">
  873. <div name="组织结构" id="myBox1" >
  874. <fieldset style="max-height:690px;overflow : auto;border-color: #cdcaca;border-top: 1px;border-left: 1px;border-right: 1px">
  875. <table cellspacing="0">
  876. <tr>
  877. <td colspan="2"><span style="font-size: 14px;fontfont-family: 微软雅黑微软雅黑微软雅黑微软雅黑微软雅黑;font-weight: bold;">组织结构</span></td>
  878. </tr>
  879. <tr>
  880. <td><input type="text" id="queryInput1"
  881. maxlength="15" watermark="请输入单位名称查询"
  882. style="width:245px;margin:4px 0px 0px 0px;display:'';">
  883. <div id="queryContent1"
  884. style="width:245px; overflow : auto;display:none;">
  885. <ul id="queryContent1ul"></ul>
  886. </div>
  887. </td>
  888. <td><a id="searchOne"><img src="/nwyj/scripts/qui/libs/icons/toolbar_icons/zzjg_find.png" alt="" style="height: 29px;padding: 3px 0px 0px 0px"/></a></td>
  889. </tr>
  890. </table>
  891. <table>
  892. <tr>
  893. <td>
  894. <input type="button" id="zjjg" onclick="addVirtualOrg()" value="增加机构" style="color: white;background-color: #009999"/>
  895. <input type="button" id="xgjg" onclick="editOrgInfo()" value="修改机构" style="color: white;background-color: #5bba3c"/>
  896. <input type="button" id="scjg" onclick="deleteOrg()" value="删除机构" style="color: white;background-color: #f65050"/></br>
  897. <input type="button" id="shangyi" onclick="moveup()" value="上移机构" style="color: white;background-color: #679cbb"/>
  898. <input type="button" id="xiayi" onclick="movedown()" value="下移机构" style="color: white;background-color: #679cbb"/>
  899. <!-- <input type="button" id="qiehuan1" onclick="qiehuan1()" value="应急机构" style="color: white;background-color: #679cbb"/>
  900. <input type="button" id="qiehuan2" onclick="qiehuan2()" value="实体机构" style="color: white;background-color: #679cbb"/> -->
  901. </td>
  902. </tr>
  903. </table>
  904. </fieldset>
  905. <div style="overflow:auto;height:95%;border-color: #cdcaca;margin-top: 15px">
  906. <div style="max-height:450px;overflow : auto;">
  907. <ul id="myTree" class="ztree"></ul>
  908. </div>
  909. </div>
  910. </div>
  911. </div>
  912. <!-- /***************************图例**************************/ -->
  913. <div>
  914. <fieldset style="background-color:#f4f4f4;max-height:990px;overflow : auto;border-style:solid;border-width:0px;border-color: #cdcaca;margin: 20px 20px 0px 20px">
  915. <table>
  916. <tr>
  917. <td><span style="font-size:14px;font-family:微软雅黑;font-weight: bold;color:#424242">图例:</span>&nbsp;&nbsp;<img src="/nwyj/scripts/qui/libs/icons/home.gif" />&nbsp;&nbsp;应急机构&nbsp;&nbsp;<img src="/nwyj/scripts/qui/libs/icons/home.png" />&nbsp;&nbsp;实体机构 </td>
  918. </tr>
  919. <tr>
  920. <td><span style="font-size:14px;font-family:微软雅黑;font-weight: bold;color:#424242">同步数据时间:</span><span style="font-size:12px;font-family:微软雅黑;color:#54994a">2016-07-21 15:08:31</span></td>
  921. </tr>
  922. </table>
  923. </fieldset>
  924. </div>
  925. </div>
  926. <div position="center">
  927. <div id="tab_menu"></div>
  928. <div id="page"
  929. style="height:800px"></div>
  930. </div>
  931. <!-- /***************************图例**************************/ -->
  932. <!-- <div>
  933. <div style="height:100px;width:300px;border:2px solid red;position:absolute;bottom:0px; z-index:9;">
  934. <fieldset style="background-color:#EDEDED;max-height:990px;overflow : auto;">
  935. <table>
  936. <tr>
  937. <td>图例:<img class="back" align="left" src="/nwyj/images/temp/yingji.png" /> 应急机构<img class="back" align="left" src="/nwyj/images/temp/shiti.png" />实体机构</td>
  938. <td></td>
  939. </tr>
  940. 放图例用
  941. </table>
  942. </fieldset>
  943. </div> -->
  944. </div>
  945. </div>
  946. </body>
  947. </html>