123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- /**
- * 功能:附件更多页面列表及其操作
- *
- * @author KANG
- * @date 2016/07/19
- */
- ReportInput = function() {
- /** 定义变量* */
- var _this = this;
- _this.listGrid = null;// 数据列表
- $queryForm = null;// 查询区域表单
- $searchButt = null;// 查询按钮
- $more = null; // 更多
- _this.loadParams = null;// 列表加载参数
- //部门id
- var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
- /** 私有方法* */
-
- /** *新增信息** */
- _this.addForm = function() {
- //$('#frmright', window.parent.document).attr('src',$.pathname()+"/page/business/gps/programManagement/programManagementAddEdit.jsp?fd_id=");
- //$("#fileselect").trigger("click");
- var diag = new top.Dialog();
- diag.Title = '选择上传文件';
- diag.URL = $.pathname() + '/page/system/accessory/accessoryEdit.jsp'; //修改对应的路径的编辑界面
- //diag.URL = '';
- diag.OkButtonText = '提交';
- diag.OKEvent = function(){
- var inputValue = diag.innerFrame.contentWindow.getDateFromChild();
- var urlfile = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
- $.request.add(urlfile,inputValue,function(data){
- inputValue = null;
- diag.close();
- top.Dialog.alert("添加成功!");
- // 刷新表格数据
- _this.listGrid.rend();
- setHt();
- });
-
- };
- diag.Width = 600; //宽度
- diag.Height = 300; //高度
- diag.ButtonAlign = 'center';//发送和取消按钮的位置
- diag.show();
- };
-
-
- /** *删除信息** */
- _this.del = function() {
- var rows = _this.listGrid.getSelectedRows();
- var rowsLength = rows.length;
- if (rowsLength == 0) {
- top.Dialog.alert("请选中要删除的记录!");
- return;
- }
- var ids = "";
- for (var i = 0; i < rowsLength; i++) {
- //console.log(rows[i].FD_OBJECTID110);
- ids += rows[i].FD_OBJECTID110 + ",";
- var row = rows[i];
- if (row.PROGRAM_STATE_110 == 1) {
- top.Dialog.alert("选中的记录正在执行,请重新选择!");
- return;
-
- }
- }
- var url = $.pathname() + "/ws/crud/CRUDService/delete/";
- var params = {
- objectIDs : ids,
- classid : 110
- };
- top.Dialog.confirm("确定要删除吗?|删除", function() {
- $.request.del(url, params, function(result) {
- if (result.Msg.sucsess == true) {
- top.Dialog.alert("删除成功!");
- // 刷新表格数据
- _this.listGrid.rend();
- setHt();
- } else {
- top.Dialog.alert("删除失败!");
- }
- });
- });
- };
- //下载
- _this.download = function(){
- var rows = _this.listGrid.getSelectedRows();
- if(rows.length != 0){
- //只选中一个文件时直接下载,选中多个时打包下载
- if (rows.length==1) {
- var url = $.pathname() + '/page/common/getFileExc.jsp?objectID=' + rows[0].FD_OBJECTID110+
- "&filename=" + encodeURI(encodeURI( rows[0].SAVENAME_110)
- + "." + rows[0].FILEEXT_110) +
- "&downfilename=" + encodeURI(encodeURI( rows[0].NAME_110)+ "." +
- rows[0].FILEEXT_110);
- window.open(url);
- }else{
- var downfilename = "";
- var filenames = "";
- //将选中的文件存入arr
- for (var i = 0; i < rows.length; i++) {
- downfilename += rows[i].SAVENAME_110+ "." + rows[i].FILEEXT_110+";";
- filenames += rows[i].NAME_110+ "." + rows[i].FILEEXT_110+";";
- }
- var url = "/nwyj/page/business/am/org/query/downZipFile.jsp?downfilename="+encodeURI(encodeURI(downfilename))+"&filenames="+encodeURI(encodeURI(filenames));
- window.open(url);
- }
- }else{
- top.Dialog.alert("请选中要下载的文件");
- }
- };
- /** **查看详细信息*** */
- _this.show = function() {
- var rows = _this.listGrid.getSelectedRows();
- var rowsLength = rows.length;
- if (rowsLength == 0) {
- top.Dialog.alert("请选中要查看的记录!");
- return;
- } else if (rowsLength > 1) {
- top.Dialog.alert("请选中一条要查看的记录!");
- return;
- } else {
- var fd_id = _this.listGrid.getSelectedRow().FD_OBJECTID110;
- $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/gps/programManagement/detailProgramManagement.jsp?fd_id='+fd_id);
- }
- };
- // 查询
- function searchfile() {
- //alert(111);
- $queryForm = $("#queryForm");
- if($("#NAME_110").val()=="请输入附件文件名称"){
- $("#NAME_110").val("");
- }
- $queryForm.serialize();
- //获取选中的值
- var searchCondition = getSelectCon(conditionData);
- var queryParams = getQueryFormParams($queryForm);
- var params=$.extend({},_this.loadParams,queryParams);
- //与之前参数条件拼接
- params.condition = searchCondition.condition + params.condition;
- //alert(JSON.stringify(params));
- _this.listGrid.setOptions({"params":params});
- //加载数据
- // _this.listGrid.setNewPage(1);
- _this.listGrid.rend();
- setHt();
- }
- // 更多
- function more() {
- $('#moreDiv').toggle(200,function(){
- document.getElementById("queryForm").reset(); //重置一下表单
- setHt();
- //$(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
- });
- }
-
- function getOfficeOnlinePath1(ext){
- var path ="";
- //扩展名转为小写
- ext = ext.toLowerCase();
- if(ext=="pdf"){
- path = "/nwyj/page/webOffice/pdfOnline.jsp";
- }
- //word和excel
- if(ext=="doc"||ext=="docx"||ext=="xls"||ext=="xlsx"||ext=="pptx"||ext=="vsd"||ext=="mpp"){
- path = "/nwyj/page/webOffice/officeOnline.jsp";
- }
- //图片
- if(ext=="png"||ext=="jpg"||ext=="gif"||ext=="jpeg"||ext=="bmp"){
- path = "/nwyj/page/webOffice/img.jsp";
- }
- //txt文本文件
- if(ext == "txt"){
- path = "/nwyj/page/webOffice/txt.jsp";
- }
- return path;
- }
-
- //点击主键跳转详细信息页面
- _this.openDetail = function(rowindex) {
- var row = _this.listGrid.getRow(rowindex);
- var id = row.FD_OBJECTID110;
- var ext = row.FILEEXT_110;
- //预览页面路径
- var url =getOfficeOnlinePath1(ext);
- if(url){
- window.open(url + "?filePath="+encodeURI(encodeURI(row.SAVENAME_110))+"."+ext);
- }else{
- top.Dialog.alert("暂不支持该类型文件预览");
- }
- };
- return {
- init : function() {
- //开始加载右边框
- $queryForm = $("#queryForm");
- /** 绑定查询面板的按钮点击事件* */
- $searchButt = $("#searchButt");// 查询按钮
- $searchButt.live('click', function() {
- searchfile();
- });
- $("#NAME_110").bind('keydown', function(event) {
- if(event.keyCode==13){
- searchfile();
- };
- });
- /** 绑定更多的按钮点击事件 */
- $more = $("#more"); // 更多按钮
- $more.bind('click', function() {
- more();
- });
-
- // 列表加载参数
- _this.loadParams = {
- listId : '110',
- //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+"'))",
- condition : "IS_DEL=0 and MAINID = '00000123456' ",
- direction : 'desc', // 排序方式
- sort : 'UPDATEDATE'
- };
-
- var grid_option={
- columns :[ {
- display : '文件名称',
- name : 'NAME_110',
- showTitle:true,
- width : "30%",
- isSort : false,
- isPrimaryKey:true,
- render : function(rowdata, rowindex, value, column) {
- return "<a href='javascript:;' style='width:100%;height:100%;display:block' title='" + value + "' onclick='openDetail(" + rowindex + ")'>" + value + "</a>";
- }
- },{
- display : '文件下载名称',
- name : 'SAVENAME_110',
- showTitle:true,
- width : "26%"
- },{
- display : '上传时间',
- name : 'UPLOADTIME_110',
- showTitle:true,
- width : "12%"
- },{
- display : '文件类型',
- name : 'FILEEXT_110',
- showTitle:true,
- width : "10%"
- },{
- display : '文件大小',
- name : 'FILESIZE_110',
- showTitle:true,
- width : "10%",
- render: function (rowdata, rowindex, value, column){
- //console.log(rowdata);
- var filesize = rowdata.FILESIZE_110;
- var resultnumb = "0B";
- if(filesize&&filesize!=null){
- var numb= parseInt(filesize);
- if(numb<1024){
- resultnumb = filesize+"B";
- }else if(numb<1024*1024){
- resultnumb = (numb/1024).toFixed(2)+"KB";
- }else if(numb<1024*1024*1024){
- resultnumb = (numb/1024/1024).toFixed(2)+"MB";
- }else if(numb<1024*1024*1024*1024){
- resultnumb = (numb/1024/1024/1024).toFixed(2)+"GB";
- }
- }
- return resultnumb;
- }
- },{
- display: '操作',
- isAllowHide: false,
- width:"12%",
- render: function (rowdata, rowindex, value, column){
- var fd_id = rowdata.FD_OBJECTID110;
- var filename = rowdata.NAME_110;
- var downloadname = rowdata.SAVENAME_110;
- var fileext = rowdata.FILEEXT_110;
- /*console.log(rowdata);
- console.log(fd_id);*/
- return '<div class="loadClass">'
- + '<span title="下载" onclick="downloadFile(\''+fd_id+'\',\''+filename+'\',\''+downloadname+'\',\''+fileext+'\');">下载</span>'
- + '</div>';
- }
- } ],
-
- usePager:true,
- rownumbers : true,
- checkbox : true,
- pageSize : 10,
- percentWidthMode:true};
- var toolBarOpt = {};
- //console.log(role_id);
- if(role_id.indexOf("R002105430200")>-1){
- toolBarOpt={
- items : [ {
- text : '添加',
- click : 'addForm',
- iconClass : 'add1_tem',
- disabled: false,
- id:"bgdxz"
- },{
- text : '删除',
- click : 'del',
- iconClass : 'delete_tem',
- disabled: false,
- id:"bgdsc"
- },{
- text : '下载',
- click : 'download',
- iconClass : 'export_tem',
- disabled: false,
- id:"fdsfs"
- }],
- };
- }else{
- toolBarOpt={
- items : [{
- text : '下载',
- click : 'download',
- iconClass : 'export_tem',
- disabled: false,
- id:"fdsfs"
- }],
- };
- }
- var options={
- url :'/nwyj/ws/crud/CRUDService/queryQui',
- params: _this.loadParams,
- width:"100%",
- gridOptions:grid_option,
- toolBarOptions:toolBarOpt,
- singleRecodeOptions:{a:"aa"},
- paperOpration:{showInput:"true"}
-
-
- };
- /**grid载入数据(定义数据列表)**/
- _this.listGrid = gridAndSingleRecode=$("#maingrid").quickgridAndSingleRecode(options);
- /*$("#toolBar_singleRecode").bind("click",function(){
- setHt();
- });
-
- $("#toolBar_grid").bind("click",function(){
- setTimeout("setHt();", 2000);
- //setHt();
- });*/
-
- /*_this.listGrid = $("#maingrid").quiGrid({
- columns:[ {
- display : '文件名称',
- name : 'NAME_110',
- showTitle:true,
- width : "40%",
- isSort : false,
- isPrimaryKey:true,
- render : function(rowdata, rowindex, value, column) {
- return "<a href='javascript:;' style='width:100%;height:100%;display:block' title='" + value + "' onclick='openDetail(" + rowindex + ")'>" + value + "</a>";
- }
- },{
- display : '上传时间',
- name : 'UPLOADTIME_110',
- showTitle:true,
- width : "20%"
- },{
- display : '描述',
- name : 'DESCRIPTION_110',
- showTitle:true,
- width : "20%"
- },{
- display : '文件类型',
- name : 'FILEEXT_110',
- showTitle:true,
- width : "10%"
- },{
- display : '文件大小',
- name : 'FILESIZE_110',
- showTitle:true,
- width : "10%"
- } ],
- url :'/nwyj/ws/crud/CRUDService/queryQui',
- params: _this.loadParams,
- rownumbers:true,checkbox:true,
- width:"100%",pageSize:10,percentWidthMode:true,
- alternatingRow:false,
- toolbar:{
- items : [ {
- text : '查看',
- click : 'show',
- iconClass : 'view_tem',
- disabled: false,
- id:'bgdck'
- }],
- }
- });*/
-
- //****布局
- /*var layout = $("#layout1").layout({
- leftWidth : 220,
- space : 10
- });
-
- function customHeightSet(contentHeight) {
- $(".layout_content").height(contentHeight - 30);
- }
- function customHeightSet(contentHeight) {
- $(".cusBoxContent").height(contentHeight - 20);
- }
- $(".l-layout-left").css("overflow", "auto");
-
- $("#toolBar_singleRecode").bind("click",function(){
- setHt();
- });
-
- $("#toolBar_grid").bind("click",function(){
- setTimeout("setHt();", 2000);
- //setHt();
- });
-
- $(".leftnav").bind("click",function(){
- $(this).addClass("rc_yuan_hover").siblings().removeClass("rc_yuan_hover");
- _this.listGrid.setOptions({//重置加载列表的参数
- params : {
- listId : '110',
- //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+"'))",
- condition : "IS_DEL=0 ",
- direction : 'desc', // 排序方式
- sort : 'UPDATEDATE'
- }
- });
-
- _this.listGrid.rend();//刷新列表
- });*/
- //setHt();
- }
- };
- }();
- function downloadFile(fd_id,filename,downloadname,fileext){
- var url = $.pathname() + '/page/common/getFileExc.jsp?objectID=' + fd_id+
- "&downfilename=" + encodeURI(encodeURI(filename)+ "." +fileext) +
- "&filename=" + encodeURI(encodeURI(downloadname)+ "." +fileext);
- window.open(url);
- }
- $(function() {
- ReportInput.init();
- });
- function setHt(){
- //$(window.document.body).height($(".padding_right5").height()+30);
- $(parent.document.body).find("iframe").height($(window.document.body).height()+30);
- }
- /* 获取 文件的路径 ,用于测试*/
- function getFilePath(){
- //alert($("#fileselect").attr("value"));
- }
|