/** * 功能: * @author ljp * @date 2016/11/09 */ DutyPlan = function() { /** 定义变量* */ var _this = this; _this.listGrid = null;// 数据列表 _this.searchPanel = null; // 查询面板 $queryForm = null;// 查询区域表单 $searchButt = null;// 查询按钮 $more = null; // 更多 _this.loadParams = null;// 列表加载参数 //部门id var unitId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids(); var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id(); /** *新增信息** */ _this.addForm = function() { $('#frmright', window.parent.document).attr('src',$.pathname() + "/page/business/em/warningDuty/DutyRecordsAddEdit.jsp?fd_id="); }; /** *修改信息** */ _this.editForm = 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 row = _this.listGrid.getSelectedRow(); if(row.RELEASE_STATE_311 == "1"){ top.Dialog.alert("该记录已发布,不可再修改!"); return; } var fd_id = row.FD_OBJECTID311; var inputRoleId = row.INPUT_PER_DEPT_ID_311; $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/em/warningDuty/DutyRecordsAddEdit.jsp?fd_id='+fd_id+"&input_role="+inputRoleId); } }; /** *发布** */ _this.release = function() { // 取得选中的Grid行 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 row = _this.listGrid.getSelectedRow(); // 判断选中的记录是否已经发布过 if (row.RELEASE_STATE_311 == 1) { top.Dialog.alert("选中的记录有已经发布过的,请重新选择!"); return; } var fd_id = row.FD_OBJECTID311; // var params = {classid : "311",FD_OBJECTID311:fd_id,RELEASE_STATE_311:"1"}; top.Dialog.confirm("确定要发布吗?|发布", function() { $.ajax({ url : $.pathname() + '/ws/crud/CRUDService/update/', type : 'post', data : params, async:false, dataType : 'json', success : function(data){ top.Dialog.alert("发布成功!"); _this.listGrid.rend(); }, error : function(e){ $.messager.alert('系统提示信息', '访问服务失败!', 'error'); } }); }); } }; /********收回********/ _this.handOn = function(){ // 取得选中的Grid行 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 row = _this.listGrid.getSelectedRow(); var user_id = row.INPUT_PER_ID_311; if (user_id != userId) { top.Dialog.alert("须填写人本人才能收回,您没有权限收回该记录!"); return; } if (row.RELEASE_STATE_311 == 0) { top.Dialog.alert("选中的记录未发布,请重新选择!"); return; } var alertMsg = "确定要收回该条记录吗?"; var fd_id = row.FD_OBJECTID311; // var params = {classid : "311",FD_OBJECTID311:fd_id,RELEASE_STATE_311:"0"}; top.Dialog.confirm(alertMsg, function() { $.ajax({ url : $.pathname() + '/ws/crud/CRUDService/update/', type : 'post', timeout : 15000, data : params, dataType : 'json', success : function(data){ top.Dialog.alert('收回记录成功!', null, null, null, -1); _this.listGrid.rend(); }, error : function(e){ $.messager.alert('系统提示信息', '访问服务失败!', 'error'); } }); }); } }; /** *删除信息** */ _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++) { ids += rows[i].FD_OBJECTID311 + ","; var row = rows[i]; if (row.RELEASE_STATE_311 == 1) { top.Dialog.alert("选中的记录有已发布,请重新选择!"); return; } /*var expirationDate = stringToDate(row.EXPIRATION_DATE_311); if (expirationDate < curr_date) { top.Dialog.alert("选中的记录有已结束的填报要求,请重新选择!"); return; }*/ } var url = $.pathname() + "/ws/crud/CRUDService/delete/"; var params = { objectIDs : ids, classid : 311, "is_del":"1" }; top.Dialog.confirm("确定要删除吗?|删除", function() { $.request.del(url, params, function(result) { if (result.Msg.sucsess == true) { top.Dialog.alert("删除成功!"); // 刷新表格数据 _this.listGrid.rend(); } else { top.Dialog.alert("删除失败!"); } }); }); }; _this.show = function(fdId) { if(fdId){ $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/em/warningDuty/detailDutyDetail.jsp?fd_id='+fdId); }else{ 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_OBJECTID311; $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/em/warningDuty/detailDutyDetail.jsp?fd_id='+fd_id); } } }; // 查询 function search(obj) { $queryForm = $("#queryForm"); if($("#DUTY_RECORD_NAME_311").val()=="记录名称"){ $("#DUTY_RECORD_NAME_311").val(""); } $queryForm.serialize(); //获取选中的值 var searchCondition = getSelectCon(conditionData); var queryParams = getQueryFormParams($queryForm); var params=$.extend({},_this.loadParams,queryParams); //与之前参数条件拼接 params.condition = searchCondition.condition + params.condition; _this.listGrid.setOptions({"params":params}); //加载数据 // _this.listGrid.setNewPage(1); _this.listGrid.rend(); } // 更多 function more() { $('#moreDiv').toggle(200,function(){ $("#emptyCondition").click(); setHight(); }); } return { init : function() { $queryForm = $("#queryForm"); /** 绑定查询面板的按钮点击事件* */ $searchButt = $("#searchButt");// 更多查询按钮 $searchButt.live('click', function() { search(); }); $searchOne = $("#searchOne");//查询图标绑定查询事件 $searchOne.bind('click', function() { search(); }); $("#DUTY_RECORD_NAME_311").keydown(function(event){ if(event.which == "13") $searchOne.click(); }); /** 绑定更多的按钮点击事件 */ $more = $("#more"); // 更多按钮 $more.bind('click', function() { more(); }); $(".l-grid-body-table .isPrimaryKey").live("click",function(){ var rowdata = $(this).find("a").data("rowdata"); if(rowdata){ var fdId = rowdata.FD_OBJECTID311; show(fdId); } }); // 获得面板对象 _this.searchPanel = $("#searchPanel"); // 列表加载参数 _this.loadParams = { listId : '311', condition : "is_del=0 and INPUT_PER_UNIT_ID='"+unitId+"'", direction : 'desc', // 排序方式 sort : 'UPDATEDATE' }; /** grid载入数据* */ var grid_option={ columns : [ { display : '记录名称', name : 'DUTY_RECORD_NAME_311', align : 'center', width : "20%", isPrimaryKey:true, render:function(rowdata, rowindex, value, column){ value = ""+value+""; return value; } }, { display : '任务名称', name : 'DUTY_PLAN_ID_311_SHOW', align : 'center', width : "20%", showTitle:true },{ display : '填写角色', name : 'INPUT_PER_DEPT_NAME_311', align : 'center', width : "20%", isSort : true }, { display : '填写人', name : 'INPUT_PER_NAME_311', align : 'center', width : "20%", showTitle:true }, { display : '状态', name : 'RELEASE_STATE_311_SHOW', align : 'center', width : "20%", showTitle:true }], rownumbers : true, checkbox : true, pageSize : 10, percentWidthMode : true}; var roleCons = roleButtonArr(); var toolBarOpt={ items : [ { text : '新增', click : 'addForm', iconClass : 'add1_tem', id : '23tj' }, { text : '删除', click : 'del', iconClass : 'delete_tem', id : '23sc' }, { text : '修改', click : 'editForm', iconClass : 'update_tem', id : '23xg' }, { text : '发布', click :'release', iconClass : 'release_tem', id : '23fb' }, { text : '收回', click : 'handOn', iconClass : 'delete_tem', id : '23js' } ], roleCons:roleCons }; var options={ url :'/nwyj/ws/crud/CRUDService/queryQui', params: _this.loadParams, width:960, gridOptions:grid_option, singleRecodeOptions:{a:""}, paperOpration:{showInput:"true"}, toolBarOptions:toolBarOpt }; /**grid载入数据(定义数据列表)**/ _this.listGrid =gridAndSingleRecode=$("#dataGrid").quickgridAndSingleRecode(options); } }; }(); $(function() { DutyPlan.init(); }); function showPrimaryKey(row,index){//row为整条数据,index为第几字段,index是从0开始的 var fdId = row.FD_OBJECTID311; show(fdId); }