3107ec0d5d0382bdd2e0a14d7123dbba7d67b596.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  1. /**
  2. * 功能:附件更多页面列表及其操作
  3. *
  4. * @author KANG
  5. * @date 2016/07/19
  6. */
  7. ReportInput = function() {
  8. /** 定义变量* */
  9. var _this = this;
  10. _this.listGrid = null;// 数据列表
  11. $queryForm = null;// 查询区域表单
  12. $searchButt = null;// 查询按钮
  13. $more = null; // 更多
  14. _this.loadParams = null;// 列表加载参数
  15. //部门id
  16. var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  17. var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  18. var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
  19. /** 私有方法* */
  20. /** *新增信息** */
  21. _this.addForm = function() {
  22. //$('#frmright', window.parent.document).attr('src',$.pathname()+"/page/business/gps/programManagement/programManagementAddEdit.jsp?fd_id=");
  23. //$("#fileselect").trigger("click");
  24. var diag = new top.Dialog();
  25. diag.Title = '选择上传文件';
  26. diag.URL = $.pathname() + '/page/system/accessory/accessoryEdit.jsp'; //修改对应的路径的编辑界面
  27. //diag.URL = '';
  28. diag.OkButtonText = '提交';
  29. diag.OKEvent = function(){
  30. var inputValue = diag.innerFrame.contentWindow.getDateFromChild();
  31. var urlfile = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
  32. $.request.add(urlfile,inputValue,function(data){
  33. inputValue = null;
  34. diag.close();
  35. top.Dialog.alert("添加成功!");
  36. // 刷新表格数据
  37. _this.listGrid.rend();
  38. setHt();
  39. });
  40. };
  41. diag.Width = 600; //宽度
  42. diag.Height = 300; //高度
  43. diag.ButtonAlign = 'center';//发送和取消按钮的位置
  44. diag.show();
  45. };
  46. /** *删除信息** */
  47. _this.del = function() {
  48. var rows = _this.listGrid.getSelectedRows();
  49. var rowsLength = rows.length;
  50. if (rowsLength == 0) {
  51. top.Dialog.alert("请选中要删除的记录!");
  52. return;
  53. }
  54. var ids = "";
  55. for (var i = 0; i < rowsLength; i++) {
  56. //console.log(rows[i].FD_OBJECTID110);
  57. ids += rows[i].FD_OBJECTID110 + ",";
  58. var row = rows[i];
  59. if (row.PROGRAM_STATE_110 == 1) {
  60. top.Dialog.alert("选中的记录正在执行,请重新选择!");
  61. return;
  62. }
  63. }
  64. var url = $.pathname() + "/ws/crud/CRUDService/delete/";
  65. var params = {
  66. objectIDs : ids,
  67. classid : 110
  68. };
  69. top.Dialog.confirm("确定要删除吗?|删除", function() {
  70. $.request.del(url, params, function(result) {
  71. if (result.Msg.sucsess == true) {
  72. top.Dialog.alert("删除成功!");
  73. // 刷新表格数据
  74. _this.listGrid.rend();
  75. setHt();
  76. } else {
  77. top.Dialog.alert("删除失败!");
  78. }
  79. });
  80. });
  81. };
  82. //下载
  83. _this.download = function(){
  84. var rows = _this.listGrid.getSelectedRows();
  85. if(rows.length != 0){
  86. //只选中一个文件时直接下载,选中多个时打包下载
  87. if (rows.length==1) {
  88. var url = $.pathname() + '/page/common/getFileExc.jsp?objectID=' + rows[0].FD_OBJECTID110+
  89. "&filename=" + encodeURI(encodeURI( rows[0].SAVENAME_110)
  90. + "." + rows[0].FILEEXT_110) +
  91. "&downfilename=" + encodeURI(encodeURI( rows[0].NAME_110)+ "." +
  92. rows[0].FILEEXT_110);
  93. window.open(url);
  94. }else{
  95. var downfilename = "";
  96. var filenames = "";
  97. //将选中的文件存入arr
  98. for (var i = 0; i < rows.length; i++) {
  99. downfilename += rows[i].SAVENAME_110+ "." + rows[i].FILEEXT_110+";";
  100. filenames += rows[i].NAME_110+ "." + rows[i].FILEEXT_110+";";
  101. }
  102. var url = "/nwyj/page/business/am/org/query/downZipFile.jsp?downfilename="+encodeURI(encodeURI(downfilename))+"&filenames="+encodeURI(encodeURI(filenames));
  103. window.open(url);
  104. }
  105. }else{
  106. top.Dialog.alert("请选中要下载的文件");
  107. }
  108. };
  109. /** **查看详细信息*** */
  110. _this.show = function() {
  111. var rows = _this.listGrid.getSelectedRows();
  112. var rowsLength = rows.length;
  113. if (rowsLength == 0) {
  114. top.Dialog.alert("请选中要查看的记录!");
  115. return;
  116. } else if (rowsLength > 1) {
  117. top.Dialog.alert("请选中一条要查看的记录!");
  118. return;
  119. } else {
  120. var fd_id = _this.listGrid.getSelectedRow().FD_OBJECTID110;
  121. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/gps/programManagement/detailProgramManagement.jsp?fd_id='+fd_id);
  122. }
  123. };
  124. // 查询
  125. function searchfile() {
  126. //alert(111);
  127. $queryForm = $("#queryForm");
  128. if($("#NAME_110").val()=="请输入附件文件名称"){
  129. $("#NAME_110").val("");
  130. }
  131. $queryForm.serialize();
  132. //获取选中的值
  133. var searchCondition = getSelectCon(conditionData);
  134. var queryParams = getQueryFormParams($queryForm);
  135. var params=$.extend({},_this.loadParams,queryParams);
  136. //与之前参数条件拼接
  137. params.condition = searchCondition.condition + params.condition;
  138. //alert(JSON.stringify(params));
  139. _this.listGrid.setOptions({"params":params});
  140. //加载数据
  141. // _this.listGrid.setNewPage(1);
  142. _this.listGrid.rend();
  143. setHt();
  144. }
  145. // 更多
  146. function more() {
  147. $('#moreDiv').toggle(200,function(){
  148. document.getElementById("queryForm").reset(); //重置一下表单
  149. setHt();
  150. //$(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  151. });
  152. }
  153. function getOfficeOnlinePath1(ext){
  154. var path ="";
  155. //扩展名转为小写
  156. ext = ext.toLowerCase();
  157. if(ext=="pdf"){
  158. path = "/nwyj/page/webOffice/pdfOnline.jsp";
  159. }
  160. //word和excel
  161. if(ext=="doc"||ext=="docx"||ext=="xls"||ext=="xlsx"||ext=="pptx"||ext=="vsd"||ext=="mpp"){
  162. path = "/nwyj/page/webOffice/officeOnline.jsp";
  163. }
  164. //图片
  165. if(ext=="png"||ext=="jpg"||ext=="gif"||ext=="jpeg"||ext=="bmp"){
  166. path = "/nwyj/page/webOffice/img.jsp";
  167. }
  168. //txt文本文件
  169. if(ext == "txt"){
  170. path = "/nwyj/page/webOffice/txt.jsp";
  171. }
  172. return path;
  173. }
  174. //点击主键跳转详细信息页面
  175. _this.openDetail = function(rowindex) {
  176. var row = _this.listGrid.getRow(rowindex);
  177. var id = row.FD_OBJECTID110;
  178. var ext = row.FILEEXT_110;
  179. //预览页面路径
  180. var url =getOfficeOnlinePath1(ext);
  181. if(url){
  182. window.open(url + "?filePath="+encodeURI(encodeURI(row.SAVENAME_110))+"."+ext);
  183. }else{
  184. top.Dialog.alert("暂不支持该类型文件预览");
  185. }
  186. };
  187. return {
  188. init : function() {
  189. //开始加载右边框
  190. $queryForm = $("#queryForm");
  191. /** 绑定查询面板的按钮点击事件* */
  192. $searchButt = $("#searchButt");// 查询按钮
  193. $searchButt.live('click', function() {
  194. searchfile();
  195. });
  196. $("#NAME_110").bind('keydown', function(event) {
  197. if(event.keyCode==13){
  198. searchfile();
  199. };
  200. });
  201. /** 绑定更多的按钮点击事件 */
  202. $more = $("#more"); // 更多按钮
  203. $more.bind('click', function() {
  204. more();
  205. });
  206. // 列表加载参数
  207. _this.loadParams = {
  208. listId : '110',
  209. //condition : "IS_DEL=0 and (((INPUT_UNIT_ID='"+deptId+"' or GPS_AREA_ID like '%,"+deptId+"%' or GPS_AREA_ID like '%"+deptId+",%' or GPS_AREA_ID = '"+deptId+"') AND TASK_STATE=1) OR (INPUT_NAME_ID='"+userId+"'))",
  210. condition : "IS_DEL=0 and MAINID = '00000123456' ",
  211. direction : 'desc', // 排序方式
  212. sort : 'UPDATEDATE'
  213. };
  214. var grid_option={
  215. columns :[ {
  216. display : '文件名称',
  217. name : 'NAME_110',
  218. showTitle:true,
  219. width : "30%",
  220. isSort : false,
  221. isPrimaryKey:true,
  222. render : function(rowdata, rowindex, value, column) {
  223. return "<a href='javascript:;' style='width:100%;height:100%;display:block' title='" + value + "' onclick='openDetail(" + rowindex + ")'>" + value + "</a>";
  224. }
  225. },{
  226. display : '文件下载名称',
  227. name : 'SAVENAME_110',
  228. showTitle:true,
  229. width : "26%"
  230. },{
  231. display : '上传时间',
  232. name : 'UPLOADTIME_110',
  233. showTitle:true,
  234. width : "12%"
  235. },{
  236. display : '文件类型',
  237. name : 'FILEEXT_110',
  238. showTitle:true,
  239. width : "10%"
  240. },{
  241. display : '文件大小',
  242. name : 'FILESIZE_110',
  243. showTitle:true,
  244. width : "10%",
  245. render: function (rowdata, rowindex, value, column){
  246. //console.log(rowdata);
  247. var filesize = rowdata.FILESIZE_110;
  248. var resultnumb = "0B";
  249. if(filesize&&filesize!=null){
  250. var numb= parseInt(filesize);
  251. if(numb<1024){
  252. resultnumb = filesize+"B";
  253. }else if(numb<1024*1024){
  254. resultnumb = (numb/1024).toFixed(2)+"KB";
  255. }else if(numb<1024*1024*1024){
  256. resultnumb = (numb/1024/1024).toFixed(2)+"MB";
  257. }else if(numb<1024*1024*1024*1024){
  258. resultnumb = (numb/1024/1024/1024).toFixed(2)+"GB";
  259. }
  260. }
  261. return resultnumb;
  262. }
  263. },{
  264. display: '操作',
  265. isAllowHide: false,
  266. width:"12%",
  267. render: function (rowdata, rowindex, value, column){
  268. var fd_id = rowdata.FD_OBJECTID110;
  269. var filename = rowdata.NAME_110;
  270. var downloadname = rowdata.SAVENAME_110;
  271. var fileext = rowdata.FILEEXT_110;
  272. /*console.log(rowdata);
  273. console.log(fd_id);*/
  274. return '<div class="loadClass">'
  275. + '<span title="下载" onclick="downloadFile(\''+fd_id+'\',\''+filename+'\',\''+downloadname+'\',\''+fileext+'\');">下载</span>'
  276. + '</div>';
  277. }
  278. } ],
  279. usePager:true,
  280. rownumbers : true,
  281. checkbox : true,
  282. pageSize : 10,
  283. percentWidthMode:true};
  284. var toolBarOpt = {};
  285. //console.log(role_id);
  286. if(role_id.indexOf("R002105430200")>-1){
  287. toolBarOpt={
  288. items : [ {
  289. text : '添加',
  290. click : 'addForm',
  291. iconClass : 'add1_tem',
  292. disabled: false,
  293. id:"bgdxz"
  294. },{
  295. text : '删除',
  296. click : 'del',
  297. iconClass : 'delete_tem',
  298. disabled: false,
  299. id:"bgdsc"
  300. },{
  301. text : '下载',
  302. click : 'download',
  303. iconClass : 'export_tem',
  304. disabled: false,
  305. id:"fdsfs"
  306. }],
  307. };
  308. }else{
  309. toolBarOpt={
  310. items : [{
  311. text : '下载',
  312. click : 'download',
  313. iconClass : 'export_tem',
  314. disabled: false,
  315. id:"fdsfs"
  316. }],
  317. };
  318. }
  319. var options={
  320. url :'/nwyj/ws/crud/CRUDService/queryQui',
  321. params: _this.loadParams,
  322. width:"100%",
  323. gridOptions:grid_option,
  324. toolBarOptions:toolBarOpt,
  325. singleRecodeOptions:{a:"aa"},
  326. paperOpration:{showInput:"true"}
  327. };
  328. /**grid载入数据(定义数据列表)**/
  329. _this.listGrid = gridAndSingleRecode=$("#maingrid").quickgridAndSingleRecode(options);
  330. /*$("#toolBar_singleRecode").bind("click",function(){
  331. setHt();
  332. });
  333. $("#toolBar_grid").bind("click",function(){
  334. setTimeout("setHt();", 2000);
  335. //setHt();
  336. });*/
  337. /*_this.listGrid = $("#maingrid").quiGrid({
  338. columns:[ {
  339. display : '文件名称',
  340. name : 'NAME_110',
  341. showTitle:true,
  342. width : "40%",
  343. isSort : false,
  344. isPrimaryKey:true,
  345. render : function(rowdata, rowindex, value, column) {
  346. return "<a href='javascript:;' style='width:100%;height:100%;display:block' title='" + value + "' onclick='openDetail(" + rowindex + ")'>" + value + "</a>";
  347. }
  348. },{
  349. display : '上传时间',
  350. name : 'UPLOADTIME_110',
  351. showTitle:true,
  352. width : "20%"
  353. },{
  354. display : '描述',
  355. name : 'DESCRIPTION_110',
  356. showTitle:true,
  357. width : "20%"
  358. },{
  359. display : '文件类型',
  360. name : 'FILEEXT_110',
  361. showTitle:true,
  362. width : "10%"
  363. },{
  364. display : '文件大小',
  365. name : 'FILESIZE_110',
  366. showTitle:true,
  367. width : "10%"
  368. } ],
  369. url :'/nwyj/ws/crud/CRUDService/queryQui',
  370. params: _this.loadParams,
  371. rownumbers:true,checkbox:true,
  372. width:"100%",pageSize:10,percentWidthMode:true,
  373. alternatingRow:false,
  374. toolbar:{
  375. items : [ {
  376. text : '查看',
  377. click : 'show',
  378. iconClass : 'view_tem',
  379. disabled: false,
  380. id:'bgdck'
  381. }],
  382. }
  383. });*/
  384. //****布局
  385. /*var layout = $("#layout1").layout({
  386. leftWidth : 220,
  387. space : 10
  388. });
  389. function customHeightSet(contentHeight) {
  390. $(".layout_content").height(contentHeight - 30);
  391. }
  392. function customHeightSet(contentHeight) {
  393. $(".cusBoxContent").height(contentHeight - 20);
  394. }
  395. $(".l-layout-left").css("overflow", "auto");
  396. $("#toolBar_singleRecode").bind("click",function(){
  397. setHt();
  398. });
  399. $("#toolBar_grid").bind("click",function(){
  400. setTimeout("setHt();", 2000);
  401. //setHt();
  402. });
  403. $(".leftnav").bind("click",function(){
  404. $(this).addClass("rc_yuan_hover").siblings().removeClass("rc_yuan_hover");
  405. _this.listGrid.setOptions({//重置加载列表的参数
  406. params : {
  407. listId : '110',
  408. //condition : "IS_DEL=0 and (((INPUT_UNIT_ID='"+deptId+"' or GPS_AREA_ID like '%,"+deptId+"%' or GPS_AREA_ID like '%"+deptId+",%' or GPS_AREA_ID = '"+deptId+"') AND TASK_STATE=1) OR (INPUT_NAME_ID='"+userId+"'))",
  409. condition : "IS_DEL=0 ",
  410. direction : 'desc', // 排序方式
  411. sort : 'UPDATEDATE'
  412. }
  413. });
  414. _this.listGrid.rend();//刷新列表
  415. });*/
  416. //setHt();
  417. }
  418. };
  419. }();
  420. function downloadFile(fd_id,filename,downloadname,fileext){
  421. var url = $.pathname() + '/page/common/getFileExc.jsp?objectID=' + fd_id+
  422. "&downfilename=" + encodeURI(encodeURI(filename)+ "." +fileext) +
  423. "&filename=" + encodeURI(encodeURI(downloadname)+ "." +fileext);
  424. window.open(url);
  425. }
  426. $(function() {
  427. ReportInput.init();
  428. });
  429. function setHt(){
  430. //$(window.document.body).height($(".padding_right5").height()+30);
  431. $(parent.document.body).find("iframe").height($(window.document.body).height()+30);
  432. }
  433. /* 获取 文件的路径 ,用于测试*/
  434. function getFilePath(){
  435. //alert($("#fileselect").attr("value"));
  436. }