f70a3bc449298adf30408edbeed697979e7705c0.svn-base 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*//IE屏蔽退格键
  2. document.onkeydown =function (e) {
  3. var code,type;
  4. if (!e){ var e = window.event;}
  5. if (e.keyCode){ code = e.keyCode;}
  6. else if (e.which){ code = e.which;}
  7. type = event.srcElement.type;
  8. if ((code == 8)
  9. && ((type == "text" && type == "textarea" ) || event.srcElement.readOnly == true)) {
  10. event.keyCode = 0;
  11. event.returnValue = false;
  12. }
  13. return true;
  14. };*/
  15. var resetValue;
  16. var treeDeptId = parent.sup_fd_objectId;
  17. var user_id;
  18. $(function() {
  19. //绑定表单提交按钮和重置按钮
  20. $("#save").bind("click",function(){
  21. submitInfo();
  22. });
  23. $("#cancel").bind("click",function(){
  24. reset_input();
  25. });
  26. $("#goback").bind("click",function(){
  27. goBack();
  28. });
  29. //设置标题信息
  30. //设置重置存储对象
  31. //获取当前的iframe框的地址信息
  32. var iframe = parent.document.getElementsByName("frmrightChild")[0];
  33. var iframeUrl = iframe.src;
  34. var tree_fd_id = parent.sup_fd_objectId;
  35. var tree_pfd_id;
  36. var tree_pname;
  37. var fd_id = iframeUrl.split('?')[1];
  38. //user_id = iframeUrl.split('?')[2];
  39. if(parent.sup_fd_objectId==""||fd_id==parent.sup_fd_objectId||undefined==parent.sup_fd_objectId
  40. ||null==parent.sup_fd_objectId ){
  41. tree_pfd_id = parent.inTreeNode.parentId;
  42. tree_pname=parent.inTreeNode.parentName;
  43. }else{
  44. tree_pfd_id = parent.inParentNote.id;
  45. tree_pname = parent.inParentNote.name;
  46. }
  47. var url = $.pathname() + "/ws/crud/CRUDService/getDataById/";
  48. //显示当前机构信息
  49. var currentOrgName = parent.sup_org_name==""?"修改内部联系人":"修改"+parent.sup_org_name+"内部联系人";
  50. $("#inlinktitle").html(currentOrgName);
  51. var params = {
  52. classid : '211',
  53. objectID : fd_id
  54. };
  55. //给下拉框赋值--常量表中的
  56. $("#EMC_TYPE_211").initCanstSelect('BM_EMC_TYPE');
  57. $("#EMC_ROLE_211").initCanstSelect('BM_EMC_ROLE');
  58. /* ajax请求 */
  59. $.ajax({
  60. url : url,
  61. type : 'post',
  62. timeout : 60000,
  63. data : params,
  64. dataType : 'json',
  65. success : function(data) {
  66. //给resetValue赋值
  67. resetValue = data;
  68. $('#fillForm').ajaxWrite({
  69. data : data
  70. })
  71. ;
  72. //给不能修改的字段赋值
  73. $("#INLINK_INDEX_211").html(data.INLINK_INDEX_211);
  74. $("#PARENT_ORG").html(data.PARENT_ORG_ID_211_SHOW);
  75. $("#PARENT_DEPT").html(data.PARENT_DEPT_ID_211_SHOW);
  76. treeDeptId=data.VIRTUAL_ORG_ID_211;
  77. user_id =data.INLINK_INDEX_211;
  78. $('#fillForm input[name="classid"]').val('211');
  79. /*$('#fillForm input[name="PARENT_DEPT_ID_211"]').val(tree_fd_id);
  80. $('#fillForm input[name="PARENT_ORG_ID_211"]').val(tree_pfd_id);*/
  81. /*if($('#fillForm input[name="PARENT_ORG_211"]').val()==""||
  82. null==$('#fillForm input[name="PARENT_ORG_211"]').val()){
  83. $('#fillForm input[name="PARENT_ORG_211"]').val(tree_pname);
  84. }*/
  85. /*$('#fillForm input[name="PARENT_ORG_ID_211"]').val(tree_fd_id);*/
  86. /*//给下拉框赋值
  87. $("#EMC_TYPE_211").attr("selectedValue",data.EMC_TYPE_211);
  88. $("#EMC_ROLE_211").attr("selectedValue", data.EMC_ROLE_211);*/
  89. //设定上级部门和上级单位不可更改
  90. document.getElementById("PARENT_DEPT_211").readOnly = true;
  91. document.getElementById("PARENT_ORG_211").readOnly = true;
  92. //document.getElementById("ORG_NAME_211").readOnly = true;
  93. },
  94. error : function(e) {
  95. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  96. }
  97. });
  98. });
  99. //点击保存按钮后触发的事件
  100. function submitInfo() {
  101. editValidate();
  102. };
  103. // 表单验证
  104. function editValidate() {
  105. var valid = $("#fillForm").validationEngine({
  106. returnIsValid : true,
  107. });
  108. if (valid == true) {
  109. editfn();
  110. } else {
  111. top.Dialog.alert('表单填写不正确,请按要求填写!');
  112. }
  113. }
  114. //修改事件ajax请求
  115. function editfn() {
  116. /*alert("电话号码"+$("#MYPHONE_211").val());*/
  117. $form = $("#fillForm");
  118. var formValue = $form.serialize();
  119. $("#classid").val("211");
  120. var url = $.pathname() + "/ws/crud/CRUDService/update/";
  121. $.ajax({
  122. url : url,
  123. type : "post",
  124. timeout : 60000,
  125. data : formValue,
  126. dataType : "json",
  127. success : function(data) {
  128. //更新角色数据
  129. updateRole();
  130. /*top.Dialog.alert("修改成功");
  131. goBack();*/
  132. },
  133. error : function() {
  134. top.Dialog.alert("修改失败,请稍后");
  135. }
  136. });
  137. };
  138. //更新角色
  139. function updateRole(){
  140. var url=$.pathname()+"/ws/OrganizationsService/OrganizationsService/updateInlinkRole";
  141. var roleId = $("#EMC_ROLE_211").val();
  142. var params={
  143. "deptId":treeDeptId,
  144. "userId":user_id,
  145. "roleId":transform(roleId)
  146. };
  147. $.ajax({
  148. url : url,
  149. type : "post",
  150. timeout : 60000,
  151. data : params,
  152. dataType : "json",
  153. success : function(data) {
  154. top.Dialog.alert("修改成功");
  155. goBack();
  156. },
  157. error : function() {
  158. top.Dialog.alert("修改失败,请稍后");
  159. }
  160. });
  161. }
  162. function transform(role){
  163. return "R00210543020"+role;
  164. }
  165. //点击返回图标事件返--》返回到内部联系人列表
  166. function goBack() {
  167. var iframe = parent.document.getElementsByName("frmrightChild")[0];
  168. iframe.src = "inlinklist.html";
  169. }
  170. //重置按钮
  171. function reset_input(){
  172. $("#INLINK_NAME_211").val(resetValue.INLINK_NAME_211);
  173. $("#EMC_ROLE_211").resetValue();
  174. $("#EMC_TYPE_211").resetValue();
  175. $("#JOB_211").val(resetValue.JOB_211);
  176. $("#MANAGER_DEPT_211").resetValue();
  177. $("#PHONE_211").val(resetValue.PHONE_211);
  178. $("#LANDLINE_211").val(resetValue.LANDLINE_211);
  179. $("#EMAIL_211").val(resetValue.EMAIL_211);
  180. }