78f0b914e2527b528527b1bbf8720648c87fa5dc.svn-base 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /**
  2. * 功能:
  3. *
  4. *
  5. * @author HXB
  6. * @date 2015/09/18
  7. */
  8. /** 定义变量* */
  9. var _this = this;
  10. var g = null;// 数据列表
  11. var g1 = null;
  12. _this.loadParams = null;// 列表加载参数
  13. /** 私有方法* */
  14. /** 上传附件 **/
  15. _this.save = function($form){
  16. showProgressBar("正在提交中...");
  17. /*var formValue = $form.serialize();
  18. var url = $.pathname() +"/ws/uploadForm/FileUpDownService/fileUpLoad";
  19. fileToSave($form,null,null,url);*/
  20. var formValue = $form.serialize();
  21. var url = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
  22. $.request.add(url,formValue,function(data){
  23. closeProgress();
  24. top.Dialog.alert(data.Msg.info);
  25. });
  26. };
  27. function fileToSave($form,listGrid,msg,url){
  28. showProgressBar("正在提交中...");
  29. //表单异步提交处理
  30. $form.ajaxSubmit({
  31. type: 'post',
  32. url:url,
  33. //表单提交成功后的回调
  34. success: function(responseText, statusText, xhr, $form){
  35. responseText = eval('('+responseText+')');
  36. closeProgress();
  37. readLoad();
  38. if(msg!=undefined){
  39. if(responseText.info == 'success')
  40. top.Dialog.alert(msg+'成功!');//弹出提示
  41. else
  42. top.Dialog.alert(msg+'失败!');//弹出提示
  43. }else{
  44. if(responseText.info == 'success')
  45. top.Dialog.alert('保存成功!');//弹出提示
  46. else
  47. top.Dialog.alert('保存失败!');//弹出提示
  48. }
  49. }
  50. });
  51. }
  52. /**初始化表格**/
  53. function initgrid(taskJson){
  54. /** grid载入数据* */
  55. g = $("#dataGrid").quiGrid({
  56. columns : [{
  57. display : '填报部门',
  58. name : 'INPUT_DEPT_614',
  59. align : 'center',
  60. width : "15%",
  61. showTitle:true
  62. }, {
  63. display : "保供电风险评估指标",
  64. name : 'FILE_SUOSHU_614',
  65. align : 'center',
  66. width : "35%",
  67. showTitle:true,
  68. render:function(rowdata,rowindex,value){
  69. return "<a onclick='_loadFile(&quot;" + rowdata.fileUrl + "&quot;)' style='color:blue'>"+value+"</a>";
  70. }
  71. }, {
  72. display : '填报时间',
  73. name : 'INPUT_TIME_614',
  74. align : 'center',
  75. width : "15%",
  76. isSort : true
  77. }, {
  78. display : '填报人',
  79. name : 'INPUT_NAME_614',
  80. align : 'center',
  81. width : "10%",
  82. showTitle:true
  83. }, {
  84. display : '操作',
  85. align : 'center',
  86. width : "10%",
  87. showTitle:true,
  88. render:function(rowdata,rowindex,value){
  89. return "<a><input type='button' class='delete_btn' value='删除' onclick='_deleteRow("+rowindex+")'/></a>";
  90. }
  91. }],
  92. /*url : $.pathname() + '/ws/crud/CRUDService/queryQui',
  93. params :_this.loadParams,*/
  94. data:taskJson,
  95. rownumbers : true,
  96. checkbox : true,
  97. width : '100%',
  98. height:"485px",
  99. pageSize : 10,
  100. percentWidthMode : true
  101. });
  102. };
  103. /**初始化表格**/
  104. function initgrid1(taskJson){
  105. /** grid载入数据* */
  106. g1 = $("#dataGrid1").quiGrid({
  107. columns : [{
  108. display : '单位',
  109. name : 'INPUT_DEPT_614',
  110. align : 'center',
  111. width : "15%",
  112. showTitle:true
  113. }, {
  114. display : "保供电风险评估报告",
  115. name : 'FILE_SUOSHU_614',
  116. align : 'center',
  117. width : "35%",
  118. showTitle:true,
  119. render:function(rowdata,rowindex,value){
  120. return "<a onclick='_loadFile(&quot;" + rowdata.fileUrl + "&quot;)' style='color:blue'>"+value+"</a>";
  121. }
  122. }, {
  123. display : '填报时间',
  124. name : 'INPUT_TIME_614',
  125. align : 'center',
  126. width : "15%",
  127. isSort : true
  128. }, {
  129. display : '填报人',
  130. name : 'INPUT_NAME_614',
  131. align : 'center',
  132. width : "10%",
  133. showTitle:true
  134. }, {
  135. display : '操作',
  136. align : 'center',
  137. width : "10%",
  138. showTitle:true,
  139. render:function(rowdata,rowindex,value){
  140. return "<a><input type='button' class='delete_btn' value='删除' onclick='_deleteRow1("+rowindex+")'/></a>";
  141. }
  142. }],
  143. data:taskJson,
  144. rownumbers : true,
  145. checkbox : true,
  146. width : '100%',
  147. height:"485px",
  148. pageSize : 10,
  149. percentWidthMode : true
  150. });
  151. };
  152. //批量删除
  153. function _deleteRow(rowidx) {
  154. var rows = g.getSelectedRows(rowidx);
  155. var rowsLength = rows.length;
  156. if (rowsLength == 0) {//请选中要删除的记录!
  157. top.Dialog.alert("请选中要删除的记录!");
  158. return;
  159. }
  160. var ids = "";
  161. for ( var i = 0; i < rowsLength; i++) {
  162. ids += rows[i].FD_OBJECTID614+ ",";
  163. }
  164. var url = $.pathname() +"/ws/crud/CRUDService/delete/";
  165. var params = {
  166. objectIDs : ids,
  167. classid : 614
  168. };
  169. top.Dialog.confirm("确定要删除吗?|删除", function() {
  170. $.request.del(url,params,function(result){
  171. if (result.Msg.sucsess == true) {
  172. top.Dialog.alert("删除成功!");
  173. // 刷新表格数据
  174. //loadData();
  175. readLoad();
  176. //g.rend();
  177. } else {
  178. top.Dialog.alert("删除失败!");
  179. }
  180. });
  181. });
  182. }
  183. /*****删除********/
  184. /*function _deleteRow(rowindex){
  185. var row = g.getRow(rowindex);
  186. var fd_iddd = row.file_id;
  187. var url = $.pathname() + "/ws/crud/CRUDService/delete/";
  188. var params = {
  189. objectIDs : fd_iddd,
  190. classid : 110
  191. };
  192. top.Dialog.confirm("确定要删除吗?|删除", function() {
  193. $.request.del(url, params, function(result) {
  194. if (result.Msg.sucsess == true) {
  195. top.Dialog.alert("删除成功!");
  196. // 刷新表格数据
  197. readLoad();
  198. //g.render();
  199. } else {
  200. top.Dialog.alert("删除失败!");
  201. }
  202. });
  203. });
  204. }*/
  205. /*****删除********/
  206. function _deleteRow1(rowindex){
  207. var row = g1.getRow(rowindex);
  208. var fd_iddd = row.file_id;
  209. var url = $.pathname() + "/ws/crud/CRUDService/delete/";
  210. var params = {
  211. objectIDs : fd_iddd,
  212. classid : 110
  213. };
  214. top.Dialog.confirm("确定要删除吗?|删除", function() {
  215. $.request.del(url, params, function(result) {
  216. if (result.Msg.sucsess == true) {
  217. top.Dialog.alert("删除成功!");
  218. // 刷新表格数据
  219. readLoad();
  220. //g.render();
  221. } else {
  222. top.Dialog.alert("删除失败!");
  223. }
  224. });
  225. });
  226. }
  227. //判断是否上传附件,需要传递组件id
  228. function hasFile(divId){
  229. var o = $("#"+divId).find("[name='fileData']").val();
  230. if(o){
  231. return true;
  232. }
  233. return false;
  234. }
  235. _this.daoru = function(){
  236. /*var fileaaa = $(".textinput").eq(0).val();
  237. alert(fileaaa);
  238. return;*/
  239. /*var isFile = hasFile("fileDiv");
  240. if(!isFile){
  241. top.Dialog.alert("附件不能为空!");
  242. return;
  243. }*/
  244. $form = $('#editForm');
  245. //保存附件
  246. save($form);
  247. var fengxian_type = "1";
  248. loadGridData(fengxian_type);
  249. var taskJson33 = loadGridData(fengxian_type);
  250. initgrid(taskJson33);
  251. };
  252. _this.daoru1 = function(){
  253. /*var isFile = hasFile("fileDiv1");
  254. if(!isFile){
  255. top.Dialog.alert("附件不能为空!");
  256. return;
  257. }*/
  258. $form = $('#editForm1');
  259. //保存附件
  260. save($form);
  261. var fengxian_type2 = "2";
  262. loadGridData(fengxian_type2);
  263. var taskJson44 = loadGridData(fengxian_type2);
  264. initgrid1(taskJson44);
  265. };
  266. //点击文件下载
  267. function _loadFile(fileUrl){
  268. window.open(fileUrl);
  269. }
  270. /***通过判断页面类型(方案,风险,工作简报...)和任务id,获取该任务下所属类型的数据***/
  271. function gettaskJson(fileSuoShu,taskId,fengxian_type){
  272. var taskJson;
  273. var dataparams = {
  274. listId : '614',
  275. condition : "is_del=0 and FILE_SUOSHU='"+fileSuoShu+"' and FD_TASK='"+taskId+"' " +
  276. "and FENGXIAN_TYPE='"+fengxian_type+"' ORDER BY UPDATEDATE DESC"
  277. };
  278. $.ajax({
  279. url : $.pathname() + '/ws/crud/CRUDService/queryQui',
  280. type : 'post',
  281. async : false,
  282. data : dataparams,
  283. success : function(data) {
  284. taskJson = data;
  285. },error : function(e) {
  286. $.messager.alert('保存失败!', '访问服务失败!', 'error');
  287. }
  288. });
  289. return taskJson;
  290. }
  291. /***通过业务id获取附件数据,返回附件名称和url的json**/
  292. function getFileJson(mainid){
  293. var dataparams = {
  294. listId : '110',
  295. condition : "IS_DEL=0 AND MAINID='"+mainid+"'"
  296. };
  297. var filename = "";
  298. var jsondds = [];
  299. $.ajax({
  300. url : $.pathname() + '/ws/crud/CRUDService/queryQui',
  301. type : 'post',
  302. async : false,
  303. data : dataparams,
  304. success : function(data) {
  305. for(var i=0;i<data.rows.length;i++){
  306. filename = data.rows[i].NAME_110 + "."+ data.rows[i].FILEEXT_110;
  307. var url = $.pathname() + '/page/common/getFileExc.jsp?objectID=' + data.rows[i].FD_OBJECTID110
  308. + "&filename=" + encodeURI(data.rows[i].SAVENAME_110)
  309. + "." + data.rows[i].FILEEXT_110 + "&downfilename=" + encodeURI(encodeURI(data.rows[i].NAME_110)
  310. + "." + data.rows[i].FILEEXT_110);
  311. var file_id = data.rows[i].FD_OBJECTID110;
  312. var jsondd = {"FILE_SUOSHU_614":filename,"fileUrl":url,"file_id":file_id};
  313. jsondds.push(jsondd);
  314. }
  315. },error : function(e) {
  316. $.messager.alert('保存失败!', '访问服务失败!', 'error');
  317. }
  318. });
  319. return jsondds;
  320. }
  321. //加载表格数据
  322. function loadGridData(fengxian_type){
  323. //获取该类型当前任务的数据
  324. var taskJson = gettaskJson(file_suoshu,fd_id,fengxian_type);
  325. //通过fd_objectid去附件表中获取相应的附件信息
  326. var taskJson22 = {"rows":[]};
  327. if(taskJson.rows.length>0){
  328. for(var i=0;i<taskJson.rows.length;i++){
  329. var mainiddd = taskJson.rows[i].FD_OBJECTID614;
  330. var FileJson = getFileJson(mainiddd);
  331. for(var j=0;j<FileJson.length;j++){
  332. var json1 = $.extend({},taskJson.rows[i],FileJson[j]);
  333. taskJson22.rows.push(json1);
  334. }
  335. }
  336. }
  337. return taskJson22;
  338. }
  339. function readLoad(){
  340. var fengxian_type = "1";
  341. var taskJson33 = loadGridData(fengxian_type);
  342. initgrid(taskJson33);
  343. var fengxian_type2 = "2";
  344. var taskJson44 = loadGridData(fengxian_type2);
  345. initgrid1(taskJson44);
  346. }
  347. $(function() {
  348. readLoad();
  349. $("#addFile").live("click",daoru);
  350. $("#addFile1").live("click",daoru1);
  351. });