04eaadee3171d75f91b7e25f3770a4700fc91f35.svn-base 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. //取得用户真实名字
  2. var realName = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  3. //部门id
  4. var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
  5. //部门名称
  6. var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
  7. //父部门id
  8. var parentId = top.com.sinosoft.lz.system.user.LoginInfo.getParent_ids();
  9. var resetValue={};
  10. var flagAdd_Edit;
  11. //属性树的初始值
  12. var Dname;
  13. var DnameShow;
  14. function initComplete(){
  15. /**************************************录入人信息***************************************/
  16. //取登录用户信息
  17. //登录用户姓名
  18. var userName = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  19. $("#REAL_NAME_880").html(userName);
  20. //用户手机号
  21. var getMobile = top.com.sinosoft.lz.system.user.LoginInfo.getMobile();
  22. if(getMobile==undefined){
  23. $("#MOBILE_880").html("暂无手机号码");
  24. }else{
  25. $("#MOBILE_880").html(getMobile);
  26. }
  27. var getCorp_names = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
  28. $("#COMPANY_ID_880").html(getCorp_names);
  29. //用户所属部门
  30. var getDeptnames = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
  31. $("#ORG_ID_880").html(getDeptnames);
  32. /**************************************end***************************************/
  33. //绑定表单提交按钮和重置按钮
  34. $("#save").bind("click",function(){
  35. submitInfo();
  36. });
  37. $("#cancel").bind("click",function(){
  38. reset_input();
  39. });
  40. $("#goback").bind("click",function(){
  41. goBack();
  42. });
  43. var iframe = parent.document.getElementById("frmright");
  44. var iframeUrl = iframe.src;
  45. if (iframeUrl.indexOf('?') > -1) {
  46. flagAdd_Edit="edit";
  47. /***
  48. 单位部门树形结构
  49. */
  50. // var deptUrl = $.pathname() + '/ws/dept/DeptService/getDepartTree';
  51. // $.post(deptUrl,{id:parentId,name:''},function(data){
  52. // $("#SUP_UNIT_220").data("data",data);
  53. // $("#SUP_UNIT_220").render();
  54. // }, "json");
  55. //判定修改--》更新界面显示的信息
  56. document.getElementById("basetitle").innerHTML = "修改应急基地信息";
  57. var fd_id = (iframeUrl).split('?')[1];
  58. var url = $.pathname() + "/ws/crud/CRUDService/getDataById/";
  59. var params = {
  60. classid : '220',
  61. objectID : fd_id
  62. };
  63. $('#fileDiv').newAsyncFileUpload("",fd_id,1);
  64. /* ajax请求 */
  65. $.ajax({
  66. url : url,
  67. type : 'post',
  68. timeout : 60000,
  69. data : params,
  70. dataType : 'json',
  71. success : function(data) {
  72. $("#shijian").attr("style","show");
  73. resetValue=data;
  74. $('#baseFillForm').ajaxWrite({
  75. data : data
  76. });
  77. //设定联动部门树形下拉框的值
  78. // Dname = data.SUP_UNIT_220;
  79. // DnameShow = data.SUP_UNIT_220_SHOW;
  80. //加载树的赋值
  81. // $("#SUP_UNIT_220").attr("relValue",Dname);
  82. // $("#SUP_UNIT_220").attr("relText",DnameShow);
  83. // $("#SUP_UNIT_220").find("input:text").val(DnameShow);
  84. $("#SUP_UNIT").val(data.SUP_UNIT_220_SHOW);
  85. $('#baseFillForm input[name="classid"]').val('220');
  86. $("#UPDATEDATE").html(data.UPDATEDATE_220);
  87. },
  88. error : function(e) {
  89. top.Dialog.alert('系统提示信息', '访问服务失败!', 'error');
  90. }
  91. });
  92. } else {
  93. flagAdd_Edit="add";
  94. /***
  95. 单位部门树形结构
  96. */
  97. // var deptUrl = $.pathname() + '/ws/dept/DeptService/getDepartTree';
  98. // $.post(deptUrl,{id:parentId,name:''},function(data){
  99. // $("#SUP_UNIT_220").data("data",data);
  100. // $("#SUP_UNIT_220").render();
  101. // }, "json");
  102. $("#SUP_UNIT").val(getCorp_names);
  103. var compid = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  104. $("#SUP_UNIT_220").val(compid);
  105. //附件
  106. $('#fileDiv').newAsyncFileUpload("",null,1);
  107. document.getElementById("basetitle").innerHTML = "新增应急基地信息";
  108. }
  109. /*//给附件重命名
  110. document.getElementByTagName("legend")[0].innerHTML="上传培训资料附件";*/
  111. $("#goback").hover(function(){
  112. $(this).attr("src","/nwyj/images/temp/back_hover.png");
  113. },function(){
  114. $(this).attr("src","/nwyj/images/temp/back.png");
  115. });
  116. }
  117. // 设定新增与修改的界面和方法 --点击保存按钮后触发事件
  118. function submitInfo() {
  119. if (flagAdd_Edit=="edit") {
  120. editValidate();
  121. }
  122. if (flagAdd_Edit=="add") {
  123. addValidate();
  124. }
  125. };
  126. //新增表单验证
  127. function addValidate() {
  128. // function exValid(){
  129. // if($("#BASE_NAME_220").val().trim()!=""||null==$("#BASE_NAME_220").val().trim()){
  130. // return true;
  131. // }else{
  132. // return false;
  133. // }
  134. // }
  135. var valid = $("#baseFillForm").validationEngine({
  136. returnIsValid : true,
  137. });
  138. if (valid == true) {
  139. if(hasFile()==false){
  140. top.Dialog.alert("请选择上传的文件!");
  141. return;
  142. }
  143. addfn();
  144. } else {
  145. top.Dialog.alert('表单填写不正确,请按要求填写!');
  146. }
  147. }
  148. //修改表单验证
  149. function editValidate() {
  150. var valid = $("#baseFillForm").validationEngine({
  151. returnIsValid : true,
  152. });
  153. if (valid == true) {
  154. if(hasFile()==false){
  155. top.Dialog.alert("请选择上传的文件!");
  156. return;
  157. }
  158. editfn();
  159. } else {
  160. top.Dialog.alert('表单填写不正确,请按要求填写!');
  161. }
  162. }
  163. //系统方法重写--文件上传
  164. function fileToSave($form,listGrid,msg){
  165. showProgressBar("正在提交中...");
  166. //表单异步提交处理
  167. $form.ajaxSubmit({
  168. url:$.pathname() +"/ws/uploadForm/FileUpDownService/fileUpLoad",
  169. //表单提交成功后的回调
  170. success: function(responseText, statusText, xhr, $form){
  171. responseText = eval('('+responseText+')');
  172. top.Dialog.close();//关闭窗口
  173. closeProgress();
  174. if(msg!=undefined){
  175. if(responseText.info == 'success'){
  176. top.Dialog.alert(msg+'成功!');//弹出提示
  177. var iframe = parent.document.getElementById("frmright");
  178. iframe.src = "business/am/base/am-base.html";
  179. }else{
  180. top.Dialog.alert(msg+'失败!');//弹出提示
  181. }
  182. }else{
  183. if(responseText.info == 'success'){
  184. top.Dialog.alert('保存成功!');//弹出提示
  185. var iframe = parent.document.getElementById("frmright");
  186. iframe.src = "business/am/base/am-base.html";
  187. }else{
  188. top.Dialog.alert('保存失败!');//弹出提示
  189. }
  190. }
  191. //listGrid.setNewPage(1);//页号设置为第一页
  192. //listGrid.loadData();//刷新列表
  193. }
  194. });
  195. }
  196. //系统方法重写修改
  197. function fileToupdate($form,listGrid,msg){
  198. showProgressBar("正在提交中...");
  199. // 表单异步提交处理
  200. $form.ajaxSubmit({
  201. url:$.pathname() +"/ws/uploadForm/FileUpDownService/editlocation",
  202. // 表单提交成功后的回调
  203. success: function(responseText, statusText, xhr, $form){
  204. responseText = eval('('+responseText+')');
  205. top.Dialog.close();// 关闭窗口
  206. closeProgress();
  207. if(msg!=undefined){
  208. if(responseText.info == 'success'){
  209. top.Dialog.alert(msg+'成功!');//弹出提示
  210. var iframe = parent.document.getElementById("frmright");
  211. iframe.src = "business/am/base/am-base.html";
  212. }else{
  213. top.Dialog.alert(msg+'失败!');//弹出提示
  214. }
  215. }else{
  216. if(responseText.info == 'success'){
  217. top.Dialog.alert('保存成功!');//弹出提示
  218. var iframe = parent.document.getElementById("frmright");
  219. iframe.src = "business/am/base/am-base.html";
  220. }else{
  221. top.Dialog.alert('保存失败!');//弹出提示
  222. }
  223. }
  224. listGrid.setNewPage(1);// 页号设置为第一页
  225. listGrid.loadData();// 刷新列表
  226. }
  227. });
  228. }
  229. //修改事件
  230. function editfn() {
  231. $("body").eq(0).showLoading();
  232. var $form=$("#baseFillForm");
  233. //var url = $.pathname() +"/ws/uploadForm/FileUpDownService/editlocation";
  234. // fileToupdate($form,null,null);
  235. var formValue = $form.serialize();
  236. var url = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
  237. $.request.add(url,formValue,function(data){
  238. $("body").eq(0).hideLoading();
  239. $.messager.alert("修改成功",null,null,null,-1);
  240. var iframe = parent.document.getElementById("frmright");
  241. iframe.src = "business/am/base/am-base.jsp";
  242. });
  243. };
  244. //新增事件
  245. function addfn() {
  246. var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  247. $('#RESERVE_ONE_220').val(userId);
  248. $("body").eq(0).showLoading();
  249. var $form=$("#baseFillForm");
  250. //var url = $.pathname() +"/ws/uploadForm/FileUpDownService/fileUpLoad";
  251. // fileToSave($form,null,null);
  252. var formValue = $form.serialize();
  253. var url = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
  254. $.request.add(url,formValue,function(data){
  255. $("body").eq(0).hideLoading();
  256. $.messager.alert("新增成功",null,null,null,-1);
  257. var iframe = parent.document.getElementById("frmright");
  258. iframe.src = "business/am/base/am-base.jsp";
  259. });
  260. };
  261. //返回按钮 返回到外部机构列表
  262. function goBack() {
  263. var iframe = parent.document.getElementById("frmright");
  264. iframe.src = "business/am/base/am-base.jsp";
  265. }
  266. function reset_input(){
  267. document.location.reload();
  268. // $("#BASE_NAME_220").val(resetValue.BASE_NAME_220);
  269. // $("#BASE_ADDRESS_220").val(resetValue.BASE_ADDRESS_220);
  270. // $("#TEAM_NUMBER_220").val(resetValue.TEAM_NUMBER_220);
  271. // $("#LONGITUDE_220").val(resetValue.LONGITUDE_220);
  272. // $("#LATITUDE_220").val(resetValue.LATITUDE_220);
  273. // $("#EQUIPMENT_TYPE_220").val(resetValue.EQUIPMENT_TYPE_220);
  274. // $("#EQUIPMENT_NUM_220").val(resetValue.EQUIPMENT_NUM_220);
  275. // //重置联动部门
  276. // $("#SUP_UNIT_220").attr("relValue",Dname);
  277. // $("#SUP_UNIT_220").attr("relText",DnameShow);
  278. // $("#SUP_UNIT_220").find("input:text").val(DnameShow);
  279. }
  280. $.messager=top.Dialog;