53089de4f8c5255a6542ee17c19becdd21e13523.svn-base 7.9 KB

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