2efc302a090cd4c07016b00215e8311efd0f9c98.svn-base 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //IE屏蔽退格键
  2. document.onkeydown =function (e) {
  3. var bancode,bantype;
  4. if (!e){ var e = window.event;}
  5. if (e.keyCode){ bancode = e.keyCode;}
  6. else if (e.which){ bancode = e.which;}
  7. bantype = event.srcElement.bantype;
  8. if ((bancode == 8)
  9. && ((bantype == "text" && bantype == "textarea" ) || event.srcElement.readOnly == true)) {
  10. event.keyCode = 0;
  11. event.returnValue = false;
  12. }
  13. return true;
  14. };
  15. $(function() {
  16. //获得树节点的objectId用于加载机构信息
  17. fd_id_org = parent.sup_fd_objectId;
  18. //获得机构名称 用于查询筛选条件
  19. org_name_org = parent.sup_org_name;
  20. if(fd_id_org == "objectid"||null==fd_id_org){
  21. //更新界面显示--界面title(机构名称)
  22. document.getElementById("org_info_span").innerHTML = org_name_org;
  23. //隐藏按钮
  24. document.getElementById("am_org_img").style.display = "none";
  25. document.getElementById("option_tr").style.display = "none";
  26. //隐藏 “修改”按钮
  27. document.getElementById("update_orgInfo").style.display = "none";
  28. }else{
  29. //初始化界面
  30. init_orgInfo();
  31. }
  32. });
  33. //初始化机构的详细信息
  34. function init_orgInfo() {
  35. //更新界面显示--界面title(机构名称)
  36. document.getElementById("org_info_span").innerHTML = org_name_org;
  37. //隐藏按钮
  38. document.getElementById("am_org_img").style.display = "none";
  39. document.getElementById("option_tr").style.display = "none";
  40. //加载机构信息显示
  41. var url = $.pathname() + '/ws/crud/CRUDService/getDataById/';
  42. var params = {
  43. classid : '212',
  44. objectID : fd_id_org
  45. };
  46. $.ajax({
  47. url : url,
  48. type : 'post',
  49. timeout : 60000,
  50. data : params,
  51. dataType : 'json',
  52. success : function(data) {
  53. $("#fillForm").ajaxWrite({
  54. data : data
  55. });
  56. $("#fillForm input[name='classid']").val("212");
  57. },
  58. error : function(e) {
  59. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  60. }
  61. });
  62. }
  63. //修改按钮操作
  64. function update_operator() {
  65. //显示 “返回”图标 “保存” “重置”按钮
  66. document.getElementById("am_org_img").style.display = "";
  67. document.getElementById("option_tr").style.display = "";
  68. //隐藏 “修改” “删除”按钮
  69. document.getElementById("update_orgInfo").style.display = "none";
  70. /*document.getElementById("delete_orgInfo").style.display = "none";*/
  71. //将只读样式去掉
  72. var readOnly_input = document.getElementsByTagName("input");
  73. for (var i = 0; i < readOnly_input.length; i++) {
  74. readOnly_input[i].readOnly = false;
  75. }
  76. }
  77. //删除机构事件
  78. function delete_operator() {
  79. top.Dialog.confirm("确定要删除吗?|删除", function() {
  80. // 删除记录
  81. $.post($.pathname() + "/ws/crud/CRUDService/delete/", {
  82. "objectIDs" : fd_id_org,
  83. classid : 212
  84. }, function(result) {
  85. if (result.Msg.sucsess == true) {
  86. $.messager.alert("删除成功", null, null, null, 1);
  87. //清空界面
  88. document.getElementById("fillForm").setAttribute("style",
  89. "none");
  90. } else {
  91. top.Dialog.alert("删除失败!");
  92. }
  93. }, "json");
  94. });
  95. document.getElementById("fillForm").setAttribute("style", "none");
  96. }
  97. //修改事件--表单提交时触发
  98. function save_orgInfo() {
  99. //验证表单
  100. editValidate();
  101. }
  102. //表单验证
  103. function editValidate() {
  104. var valid = $("#fillForm").validationEngine({
  105. returnIsValid : true,
  106. });
  107. if (valid == true) {
  108. editfn();
  109. } else {
  110. top.Dialog.alert('表单填写不正确,请按要求填写!');
  111. }
  112. }
  113. //修改机构信息--发送请求后台交互
  114. function editfn() {
  115. $form = $("#fillForm");
  116. var formValue = $form.serialize();
  117. $("#classid").val("212");
  118. var url = $.pathname() + "/ws/crud/CRUDService/update/";
  119. //先修改机构名称
  120. updateOrgName();
  121. //再修改全部内容
  122. $.ajax({
  123. url : url,
  124. type : "post",
  125. timeout : 60000,
  126. data : formValue,
  127. dataType : "json",
  128. success : function(data) {
  129. //刷新树的名称
  130. var newOutTreeName=$("#ORG_DEPT_NAME_212").val();
  131. parent.refreshMytree2Node(newOutTreeName);
  132. top.Dialog.alert("修改成功,返回列表");
  133. goBack();
  134. },
  135. error : function() {
  136. top.Dialog.alert("修改失败,稍后再试...");
  137. }
  138. });
  139. }
  140. //返回图标单击事件 --重新加载界面
  141. function goBack() {
  142. location.reload();
  143. }
  144. //修改机构名称
  145. function updateOrgName(){
  146. var params={"deptId":fd_id_org,
  147. "deptName":$("#ORG_DEPT_NAME_212").val()
  148. };
  149. $.ajax({
  150. url:$.pathname() + "/ws/orgOutDeptService/OrgOutDeptService/editOrgOutDept/",
  151. type:"post",
  152. data:params,
  153. dataType:"json",
  154. success:function(data){
  155. if(data.msg=="success"){
  156. return true;
  157. };
  158. if(data.msg=="fail"){
  159. return false;
  160. };
  161. },
  162. error:function(){
  163. return false;
  164. }
  165. });
  166. }