123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366 |
- /**
- * 功能:
- *
- *
- * @author HXB
- * @date 2015/09/18
- */
- /** 定义变量* */
- var _this = this;
- var g = null;// 数据列表
- var g1 = null;
- _this.loadParams = null;// 列表加载参数
-
- /** 私有方法* */
- /** 上传附件 **/
- _this.save = function($form){
- showProgressBar("正在提交中...");
- /*var formValue = $form.serialize();
- var url = $.pathname() +"/ws/uploadForm/FileUpDownService/fileUpLoad";
-
- fileToSave($form,null,null,url);*/
- var formValue = $form.serialize();
- var url = $.pathname() +"/ws/uploadForm/FileUpDownService/asyncFileUpLoad";
- $.request.add(url,formValue,function(data){
- closeProgress();
- top.Dialog.alert(data.Msg.info);
- });
- };
- function fileToSave($form,listGrid,msg,url){
- showProgressBar("正在提交中...");
- //表单异步提交处理
- $form.ajaxSubmit({
- type: 'post',
- url:url,
- //表单提交成功后的回调
- success: function(responseText, statusText, xhr, $form){
- responseText = eval('('+responseText+')');
- closeProgress();
- readLoad();
- if(msg!=undefined){
- if(responseText.info == 'success')
- top.Dialog.alert(msg+'成功!');//弹出提示
- else
- top.Dialog.alert(msg+'失败!');//弹出提示
- }else{
- if(responseText.info == 'success')
- top.Dialog.alert('保存成功!');//弹出提示
- else
- top.Dialog.alert('保存失败!');//弹出提示
- }
- }
- });
- }
- /**初始化表格**/
- function initgrid(taskJson){
- /** grid载入数据* */
- g = $("#dataGrid").quiGrid({
- columns : [{
- display : '填报部门',
- name : 'INPUT_DEPT_614',
- align : 'center',
- width : "15%",
- showTitle:true
- }, {
- display : "保供电风险评估指标",
- name : 'FILE_SUOSHU_614',
- align : 'center',
- width : "35%",
- showTitle:true,
- render:function(rowdata,rowindex,value){
- return "<a onclick='_loadFile("" + rowdata.fileUrl + "")' style='color:blue'>"+value+"</a>";
- }
- }, {
- display : '填报时间',
- name : 'INPUT_TIME_614',
- align : 'center',
- width : "15%",
- isSort : true
- }, {
- display : '填报人',
- name : 'INPUT_NAME_614',
- align : 'center',
- width : "10%",
- showTitle:true
- }, {
- display : '操作',
- align : 'center',
- width : "10%",
- showTitle:true,
- render:function(rowdata,rowindex,value){
- return "<a><input type='button' class='delete_btn' value='删除' onclick='_deleteRow("+rowindex+")'/></a>";
- }
- }],
- /*url : $.pathname() + '/ws/crud/CRUDService/queryQui',
- params :_this.loadParams,*/
- data:taskJson,
- rownumbers : true,
- checkbox : true,
- width : '100%',
- height:"485px",
- pageSize : 10,
- percentWidthMode : true
- });
- };
- /**初始化表格**/
- function initgrid1(taskJson){
-
- /** grid载入数据* */
- g1 = $("#dataGrid1").quiGrid({
- columns : [{
- display : '单位',
- name : 'INPUT_DEPT_614',
- align : 'center',
- width : "15%",
- showTitle:true
- }, {
- display : "保供电风险评估报告",
- name : 'FILE_SUOSHU_614',
- align : 'center',
- width : "35%",
- showTitle:true,
- render:function(rowdata,rowindex,value){
- return "<a onclick='_loadFile("" + rowdata.fileUrl + "")' style='color:blue'>"+value+"</a>";
- }
- }, {
- display : '填报时间',
- name : 'INPUT_TIME_614',
- align : 'center',
- width : "15%",
- isSort : true
- }, {
- display : '填报人',
- name : 'INPUT_NAME_614',
- align : 'center',
- width : "10%",
- showTitle:true
- }, {
- display : '操作',
- align : 'center',
- width : "10%",
- showTitle:true,
- render:function(rowdata,rowindex,value){
- return "<a><input type='button' class='delete_btn' value='删除' onclick='_deleteRow1("+rowindex+")'/></a>";
- }
- }],
- data:taskJson,
- rownumbers : true,
- checkbox : true,
- width : '100%',
- height:"485px",
- pageSize : 10,
- percentWidthMode : true
- });
- };
- //批量删除
- function _deleteRow(rowidx) {
- var rows = g.getSelectedRows(rowidx);
- var rowsLength = rows.length;
- if (rowsLength == 0) {//请选中要删除的记录!
- top.Dialog.alert("请选中要删除的记录!");
- return;
- }
- var ids = "";
- for ( var i = 0; i < rowsLength; i++) {
- ids += rows[i].FD_OBJECTID614+ ",";
- }
- var url = $.pathname() +"/ws/crud/CRUDService/delete/";
- var params = {
- objectIDs : ids,
- classid : 614
- };
- top.Dialog.confirm("确定要删除吗?|删除", function() {
- $.request.del(url,params,function(result){
- if (result.Msg.sucsess == true) {
- top.Dialog.alert("删除成功!");
- // 刷新表格数据
- //loadData();
- readLoad();
- //g.rend();
- } else {
- top.Dialog.alert("删除失败!");
- }
- });
- });
- }
- /*****删除********/
- /*function _deleteRow(rowindex){
- var row = g.getRow(rowindex);
- var fd_iddd = row.file_id;
- var url = $.pathname() + "/ws/crud/CRUDService/delete/";
- var params = {
- objectIDs : fd_iddd,
- classid : 110
- };
- top.Dialog.confirm("确定要删除吗?|删除", function() {
- $.request.del(url, params, function(result) {
- if (result.Msg.sucsess == true) {
- top.Dialog.alert("删除成功!");
- // 刷新表格数据
- readLoad();
- //g.render();
- } else {
- top.Dialog.alert("删除失败!");
- }
- });
- });
- }*/
- /*****删除********/
- function _deleteRow1(rowindex){
- var row = g1.getRow(rowindex);
- var fd_iddd = row.file_id;
- var url = $.pathname() + "/ws/crud/CRUDService/delete/";
- var params = {
- objectIDs : fd_iddd,
- classid : 110
- };
- top.Dialog.confirm("确定要删除吗?|删除", function() {
- $.request.del(url, params, function(result) {
- if (result.Msg.sucsess == true) {
- top.Dialog.alert("删除成功!");
- // 刷新表格数据
- readLoad();
- //g.render();
- } else {
- top.Dialog.alert("删除失败!");
- }
- });
- });
- }
- //判断是否上传附件,需要传递组件id
- function hasFile(divId){
- var o = $("#"+divId).find("[name='fileData']").val();
- if(o){
- return true;
- }
- return false;
- }
- _this.daoru = function(){
- /*var fileaaa = $(".textinput").eq(0).val();
- alert(fileaaa);
- return;*/
- /*var isFile = hasFile("fileDiv");
- if(!isFile){
- top.Dialog.alert("附件不能为空!");
- return;
- }*/
- $form = $('#editForm');
- //保存附件
- save($form);
- var fengxian_type = "1";
- loadGridData(fengxian_type);
- var taskJson33 = loadGridData(fengxian_type);
- initgrid(taskJson33);
-
- };
- _this.daoru1 = function(){
-
- /*var isFile = hasFile("fileDiv1");
- if(!isFile){
- top.Dialog.alert("附件不能为空!");
- return;
- }*/
- $form = $('#editForm1');
- //保存附件
- save($form);
- var fengxian_type2 = "2";
- loadGridData(fengxian_type2);
- var taskJson44 = loadGridData(fengxian_type2);
- initgrid1(taskJson44);
- };
- //点击文件下载
- function _loadFile(fileUrl){
- window.open(fileUrl);
- }
- /***通过判断页面类型(方案,风险,工作简报...)和任务id,获取该任务下所属类型的数据***/
- function gettaskJson(fileSuoShu,taskId,fengxian_type){
- var taskJson;
- var dataparams = {
- listId : '614',
- condition : "is_del=0 and FILE_SUOSHU='"+fileSuoShu+"' and FD_TASK='"+taskId+"' " +
- "and FENGXIAN_TYPE='"+fengxian_type+"' ORDER BY UPDATEDATE DESC"
- };
- $.ajax({
- url : $.pathname() + '/ws/crud/CRUDService/queryQui',
- type : 'post',
- async : false,
- data : dataparams,
- success : function(data) {
- taskJson = data;
- },error : function(e) {
- $.messager.alert('保存失败!', '访问服务失败!', 'error');
- }
- });
- return taskJson;
- }
- /***通过业务id获取附件数据,返回附件名称和url的json**/
- function getFileJson(mainid){
- var dataparams = {
- listId : '110',
- condition : "IS_DEL=0 AND MAINID='"+mainid+"'"
- };
- var filename = "";
- var jsondds = [];
- $.ajax({
- url : $.pathname() + '/ws/crud/CRUDService/queryQui',
- type : 'post',
- async : false,
- data : dataparams,
- success : function(data) {
- for(var i=0;i<data.rows.length;i++){
-
- filename = data.rows[i].NAME_110 + "."+ data.rows[i].FILEEXT_110;
- var url = $.pathname() + '/page/common/getFileExc.jsp?objectID=' + data.rows[i].FD_OBJECTID110
- + "&filename=" + encodeURI(data.rows[i].SAVENAME_110)
- + "." + data.rows[i].FILEEXT_110 + "&downfilename=" + encodeURI(encodeURI(data.rows[i].NAME_110)
- + "." + data.rows[i].FILEEXT_110);
- var file_id = data.rows[i].FD_OBJECTID110;
- var jsondd = {"FILE_SUOSHU_614":filename,"fileUrl":url,"file_id":file_id};
- jsondds.push(jsondd);
- }
- },error : function(e) {
- $.messager.alert('保存失败!', '访问服务失败!', 'error');
- }
- });
- return jsondds;
- }
- //加载表格数据
- function loadGridData(fengxian_type){
- //获取该类型当前任务的数据
- var taskJson = gettaskJson(file_suoshu,fd_id,fengxian_type);
- //通过fd_objectid去附件表中获取相应的附件信息
- var taskJson22 = {"rows":[]};
- if(taskJson.rows.length>0){
- for(var i=0;i<taskJson.rows.length;i++){
- var mainiddd = taskJson.rows[i].FD_OBJECTID614;
- var FileJson = getFileJson(mainiddd);
- for(var j=0;j<FileJson.length;j++){
- var json1 = $.extend({},taskJson.rows[i],FileJson[j]);
- taskJson22.rows.push(json1);
- }
- }
- }
- return taskJson22;
- }
- function readLoad(){
- var fengxian_type = "1";
- var taskJson33 = loadGridData(fengxian_type);
- initgrid(taskJson33);
-
- var fengxian_type2 = "2";
- var taskJson44 = loadGridData(fengxian_type2);
- initgrid1(taskJson44);
- }
- $(function() {
- readLoad();
- $("#addFile").live("click",daoru);
- $("#addFile1").live("click",daoru1);
-
- });
|