2d37bde01665a9216634368a176705254ea34174.svn-base 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. $(function(){
  2. //应急制度文件分类FILE_CLASSIFY_230
  3. // $("#FILE_CLASSIFY_230").initCanstSelect('BM_FILE_CLASSIFY');
  4. //$('#fileDiv').getUploadFileContent();
  5. //
  6. // $('#CHANGE_TYPE').data("data",changetype);
  7. // $("#CHANGE_TYPE").render();
  8. var opts = {
  9. //swf: 'baiduUpload/Uploader.swf',
  10. //server: 'Upload',
  11. fileNumLimit: 1,
  12. fileSizeLimit: 200 * 1024 * 1024, // 200 M
  13. fileSingleSizeLimit: 50 * 1024 * 1024, // 50 M
  14. pick: {
  15. id: '#filePicker',
  16. label: '点击选择文件',
  17. name : 'file'
  18. },
  19. dnd: '#dndArea',
  20. paste: '#uploader',
  21. chunked: false,
  22. chunkSize: 512 * 1024,
  23. disableGlobalDnd: true
  24. };
  25. $('#fileDiv').getAsyncUploadFileContent(opts);
  26. });
  27. //单位ID
  28. var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
  29. var getUser_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id()+""; //登录人ID
  30. var parent_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  31. var changetype = {"list":[
  32. {value:"2",key:"更新",suggest:""},
  33. {value:"3",key:"撤销",suggest:""}]
  34. };
  35. var time = "";
  36. var COLUMN_1_232="0";
  37. //修改表单信息,获取记录
  38. if((window.location.href).indexOf('?')>-1){
  39. var fd_id = (window.location.href).split('?')[1];
  40. var url = $.pathname() + '/ws/crud/CRUDService/getDataById/';
  41. var params = {
  42. classid : '232',
  43. objectID : fd_id
  44. };
  45. $.ajax({
  46. url : url,
  47. type : 'post',
  48. timeout : 60000,
  49. data : params,
  50. dataType : 'json',
  51. success : function(data){
  52. COLUMN_1_232 = data.COLUMN_1_232;//版本标志
  53. COLUMN_3_232 = data.COLUMN_3_232;//上传标志
  54. COLUMN_4_232 = data.COLUMN_4_232;//上个文件ID
  55. if(COLUMN_1_232=="0"){
  56. getFileList(fd_id,1);
  57. }
  58. if(COLUMN_3_232=="1"&&COLUMN_4_232!="0"){
  59. getFileList(fd_id,1);
  60. }
  61. //纯修改
  62. if(COLUMN_3_232=="0"&&COLUMN_1_232!="0"){
  63. getFileList(COLUMN_4_232,1);
  64. }
  65. $('#fillForm').ajaxWrite({data:data});
  66. $('#fillForm input[name="classid"]').val('232');
  67. },
  68. error : function(e){
  69. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  70. }
  71. });
  72. }
  73. var file ="";
  74. //取系统时间:年月日时分秒
  75. var date = allGetServerTime();
  76. var seperator1 = "";
  77. var seperator2 = "";
  78. var month = date.getMonth() + 1;
  79. var strDate = date.getDate();
  80. if (month >= 1 && month <= 9) {
  81. month = "0" + month;
  82. }
  83. if (strDate >= 0 && strDate <= 9) {
  84. strDate = "0" + strDate;
  85. }
  86. time = date.getFullYear() + seperator1 + month + seperator1 + strDate
  87. + "" + date.getHours() + seperator2 + date.getMinutes()
  88. + seperator2 + date.getSeconds();
  89. //表单验证
  90. function validateForm(containerId){
  91. var title = $("#NOTICE_TITLE_232").val();
  92. var noticedate = $("#NOTICE_PUBLISH_DATE_232").val();
  93. var valid = $(containerId).validationEngine({returnIsValid: true});
  94. if(valid == true){
  95. //取上传附件容器的值,如果为空,则为单纯修改预案基本信息。如不为空,则为修订预案,重新上传预案。
  96. var file = $("#uploaderFileName").val();
  97. if(file!=null&&file!=undefined&&file!=""){
  98. //先删除原来记录。
  99. del();
  100. $("#fd_id232").val("");
  101. //再新增记录
  102. add();
  103. }else{
  104. edit();
  105. }
  106. }else{
  107. if(title==""){
  108. top.Dialog.alert('标题不能为空!');
  109. return;
  110. }
  111. if(noticedate==""){
  112. top.Dialog.alert('日期不能为空!');
  113. return;
  114. }
  115. }
  116. }
  117. function add(containerId){
  118. var file = $("#uploaderFileName").val();
  119. var ldot = file.lastIndexOf(".");
  120. var type ="."+ file.substring(ldot + 1);
  121. var pos=file.lastIndexOf("\\");
  122. var filename = file.substring(pos+1,ldot);
  123. var valid = $(containerId).validationEngine({returnIsValid: true});
  124. if(valid == true){
  125. $("#COLUMN_3_232").val("1");
  126. $("#COLUMN_4_232").val(fd_id);
  127. if(COLUMN_1_232=="0"){
  128. $("#COLUMN_1_232").val(fd_id);
  129. }else{
  130. $("#COLUMN_1_232").val(COLUMN_1_232);
  131. }
  132. var $form=$("#fillForm");
  133. var formValue = $form.serialize();
  134. var url = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
  135. $.request.add(url,formValue,function(data){
  136. closeProgress();
  137. top.Dialog.alert("修改成功!");
  138. var url = "/nwyj/page/business/am/file/"+"FileList_AM_TZ.jsp";
  139. top.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
  140. });
  141. }else{
  142. top.Dialog.alert('请检查标红输入框!');
  143. }
  144. }
  145. //修改
  146. function edit(){
  147. $("#COLUMN_3_232").val("0");
  148. //上一个版本的预案的ID
  149. $("#COLUMN_4_232").val(fd_id);
  150. var formValue = $('#fillForm').serialize();
  151. var url = $.pathname() + '/ws/crud/CRUDService/update';
  152. $.ajax({
  153. url : url,
  154. type : 'post',
  155. data : formValue,
  156. dataType : 'text',
  157. timeout : 60000,
  158. success : function(data){
  159. top.Dialog.alert('修改成功!',null,null,null,-1);
  160. var url = "/nwyj/page/business/am/file/"+"FileList_AM_TZ.jsp";
  161. top.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
  162. },
  163. error : function(){
  164. $.messager.alert('操作失败');
  165. }
  166. });
  167. }
  168. //删除原来信息
  169. function del(){
  170. // 删除记录
  171. $.post($.pathname() +"/ws/crud/CRUDService/delete/", {
  172. "objectIDs" : fd_id,
  173. classid : 232
  174. }, function(result) {
  175. if (result.Msg.sucsess == true) {
  176. //$.messager.alert("废止上一版本制度文件",null,null,null,-1);
  177. } else {
  178. top.Dialog.alert("废止失败!");
  179. }
  180. }, "json");
  181. }
  182. function goBack() {
  183. var url = "/nwyj/page/business/am/file/"+"FileList_AM_TZ.jsp";
  184. top.document.getElementById("frmright").setAttribute("src", ""+encodeURI(url));
  185. }
  186. //重置
  187. function resetSearch(){
  188. document.location.reload();
  189. }
  190. $.messager=top.Dialog;