e729b7fee85067173fc1140feb77fdf81518f021.svn-base 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. /**
  2. * 功能:
  3. * @author ljp
  4. * @date 2016/11/09
  5. */
  6. DutyPlan = function() {
  7. /** 定义变量* */
  8. var _this = this;
  9. _this.listGrid = null;// 数据列表
  10. _this.searchPanel = null; // 查询面板
  11. $queryForm = null;// 查询区域表单
  12. $searchButt = null;// 查询按钮
  13. $more = null; // 更多
  14. _this.loadParams = null;// 列表加载参数
  15. //部门id
  16. var unitId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  17. var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  18. /** *新增信息** */
  19. _this.addForm = function() {
  20. $('#frmright', window.parent.document).attr('src',$.pathname() + "/page/business/em/warningDuty/DutyRecordsAddEdit.jsp?fd_id=");
  21. };
  22. /** *修改信息** */
  23. _this.editForm = function() {
  24. var rows = _this.listGrid.getSelectedRows();
  25. var rowsLength = rows.length;
  26. if (rowsLength == 0) {
  27. top.Dialog.alert("请选中要修改的记录!");
  28. return;
  29. } else if (rowsLength > 1) {
  30. top.Dialog.alert("请选中一条要修改的记录!");
  31. return;
  32. } else {
  33. var row = _this.listGrid.getSelectedRow();
  34. if(row.RELEASE_STATE_311 == "1"){
  35. top.Dialog.alert("该记录已发布,不可再修改!");
  36. return;
  37. }
  38. var fd_id = row.FD_OBJECTID311;
  39. var inputRoleId = row.INPUT_PER_DEPT_ID_311;
  40. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/em/warningDuty/DutyRecordsAddEdit.jsp?fd_id='+fd_id+"&input_role="+inputRoleId);
  41. }
  42. };
  43. /** *发布** */
  44. _this.release = function() {
  45. // 取得选中的Grid行
  46. var rows = _this.listGrid.getSelectedRows();
  47. // 选中的行数
  48. var rowsLength = rows.length;
  49. if (rowsLength == 0) {
  50. top.Dialog.alert("请选中要发布的记录!");
  51. return;
  52. } else if (rowsLength > 1) {
  53. top.Dialog.alert('请选中一条要发布的记录!');
  54. return;
  55. }else {
  56. var row = _this.listGrid.getSelectedRow();
  57. // 判断选中的记录是否已经发布过
  58. if (row.RELEASE_STATE_311 == 1) {
  59. top.Dialog.alert("选中的记录有已经发布过的,请重新选择!");
  60. return;
  61. }
  62. var fd_id = row.FD_OBJECTID311; //
  63. var params = {classid : "311",FD_OBJECTID311:fd_id,RELEASE_STATE_311:"1"};
  64. top.Dialog.confirm("确定要发布吗?|发布", function() {
  65. $.ajax({
  66. url : $.pathname() + '/ws/crud/CRUDService/update/',
  67. type : 'post',
  68. data : params,
  69. async:false,
  70. dataType : 'json',
  71. success : function(data){
  72. top.Dialog.alert("发布成功!");
  73. _this.listGrid.rend();
  74. },
  75. error : function(e){
  76. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  77. }
  78. });
  79. });
  80. }
  81. };
  82. /********收回********/
  83. _this.handOn = function(){
  84. // 取得选中的Grid行
  85. var rows = _this.listGrid.getSelectedRows();
  86. // 选中的行数
  87. var rowsLength = rows.length;
  88. if (rowsLength == 0) {
  89. top.Dialog.alert("请选中要收回的记录!");
  90. return;
  91. } else if (rowsLength > 1) {
  92. top.Dialog.alert('请选中一条要收回的记录!');
  93. return;
  94. }else {
  95. var row = _this.listGrid.getSelectedRow();
  96. var user_id = row.INPUT_PER_ID_311;
  97. if (user_id != userId) {
  98. top.Dialog.alert("须填写人本人才能收回,您没有权限收回该记录!");
  99. return;
  100. }
  101. if (row.RELEASE_STATE_311 == 0) {
  102. top.Dialog.alert("选中的记录未发布,请重新选择!");
  103. return;
  104. }
  105. var alertMsg = "确定要收回该条记录吗?";
  106. var fd_id = row.FD_OBJECTID311; //
  107. var params = {classid : "311",FD_OBJECTID311:fd_id,RELEASE_STATE_311:"0"};
  108. top.Dialog.confirm(alertMsg, function() {
  109. $.ajax({
  110. url : $.pathname() + '/ws/crud/CRUDService/update/',
  111. type : 'post',
  112. timeout : 15000,
  113. data : params,
  114. dataType : 'json',
  115. success : function(data){
  116. top.Dialog.alert('收回记录成功!', null, null, null, -1);
  117. _this.listGrid.rend();
  118. },
  119. error : function(e){
  120. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  121. }
  122. });
  123. });
  124. }
  125. };
  126. /** *删除信息** */
  127. _this.del = function() {
  128. var rows = _this.listGrid.getSelectedRows();
  129. var rowsLength = rows.length;
  130. if (rowsLength == 0) {
  131. top.Dialog.alert("请选中要删除的记录!");
  132. return;
  133. }
  134. var ids = "";
  135. for (var i = 0; i < rowsLength; i++) {
  136. ids += rows[i].FD_OBJECTID311 + ",";
  137. var row = rows[i];
  138. if (row.RELEASE_STATE_311 == 1) {
  139. top.Dialog.alert("选中的记录有已发布,请重新选择!");
  140. return;
  141. }
  142. /*var expirationDate = stringToDate(row.EXPIRATION_DATE_311);
  143. if (expirationDate < curr_date) {
  144. top.Dialog.alert("选中的记录有已结束的填报要求,请重新选择!");
  145. return;
  146. }*/
  147. }
  148. var url = $.pathname() + "/ws/crud/CRUDService/delete/";
  149. var params = {
  150. objectIDs : ids,
  151. classid : 311,
  152. "is_del":"1"
  153. };
  154. top.Dialog.confirm("确定要删除吗?|删除", function() {
  155. $.request.del(url, params, function(result) {
  156. if (result.Msg.sucsess == true) {
  157. top.Dialog.alert("删除成功!");
  158. // 刷新表格数据
  159. _this.listGrid.rend();
  160. } else {
  161. top.Dialog.alert("删除失败!");
  162. }
  163. });
  164. });
  165. };
  166. _this.show = function(fdId) {
  167. if(fdId){
  168. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/em/warningDuty/detailDutyDetail.jsp?fd_id='+fdId);
  169. }else{
  170. var rows = _this.listGrid.getSelectedRows();
  171. var rowsLength = rows.length;
  172. if (rowsLength == 0) {
  173. top.Dialog.alert("请选中要查看的记录!");
  174. return;
  175. } else if (rowsLength > 1) {
  176. top.Dialog.alert("请选中一条要查看的记录!");
  177. return;
  178. } else {
  179. var fd_id = _this.listGrid.getSelectedRow().FD_OBJECTID311;
  180. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/em/warningDuty/detailDutyDetail.jsp?fd_id='+fd_id);
  181. }
  182. }
  183. };
  184. // 查询
  185. function search(obj) {
  186. $queryForm = $("#queryForm");
  187. if($("#DUTY_RECORD_NAME_311").val()=="记录名称"){
  188. $("#DUTY_RECORD_NAME_311").val("");
  189. }
  190. $queryForm.serialize();
  191. //获取选中的值
  192. var searchCondition = getSelectCon(conditionData);
  193. var queryParams = getQueryFormParams($queryForm);
  194. var params=$.extend({},_this.loadParams,queryParams);
  195. //与之前参数条件拼接
  196. params.condition = searchCondition.condition + params.condition;
  197. _this.listGrid.setOptions({"params":params});
  198. //加载数据
  199. // _this.listGrid.setNewPage(1);
  200. _this.listGrid.rend();
  201. }
  202. // 更多
  203. function more() {
  204. $('#moreDiv').toggle(200,function(){
  205. $("#emptyCondition").click();
  206. setHight();
  207. });
  208. }
  209. return {
  210. init : function() {
  211. $queryForm = $("#queryForm");
  212. /** 绑定查询面板的按钮点击事件* */
  213. $searchButt = $("#searchButt");// 更多查询按钮
  214. $searchButt.live('click', function() {
  215. search();
  216. });
  217. $searchOne = $("#searchOne");//查询图标绑定查询事件
  218. $searchOne.bind('click', function() {
  219. search();
  220. });
  221. $("#DUTY_RECORD_NAME_311").keydown(function(event){
  222. if(event.which == "13")
  223. $searchOne.click();
  224. });
  225. /** 绑定更多的按钮点击事件 */
  226. $more = $("#more"); // 更多按钮
  227. $more.bind('click', function() {
  228. more();
  229. });
  230. $(".l-grid-body-table .isPrimaryKey").live("click",function(){
  231. var rowdata = $(this).find("a").data("rowdata");
  232. if(rowdata){
  233. var fdId = rowdata.FD_OBJECTID311;
  234. show(fdId);
  235. }
  236. });
  237. // 获得面板对象
  238. _this.searchPanel = $("#searchPanel");
  239. // 列表加载参数
  240. _this.loadParams = {
  241. listId : '311',
  242. condition : "is_del=0 and INPUT_PER_UNIT_ID='"+unitId+"'",
  243. direction : 'desc', // 排序方式
  244. sort : 'UPDATEDATE'
  245. };
  246. /** grid载入数据* */
  247. var grid_option={
  248. columns : [
  249. {
  250. display : '记录名称',
  251. name : 'DUTY_RECORD_NAME_311',
  252. align : 'center',
  253. width : "20%",
  254. isPrimaryKey:true,
  255. render:function(rowdata, rowindex, value, column){
  256. value = "<a href='javascript:;' data-rowdata='"+JSON.stringify(rowdata)+"' >"+value+"</a>";
  257. return value;
  258. }
  259. }, {
  260. display : '任务名称',
  261. name : 'DUTY_PLAN_ID_311_SHOW',
  262. align : 'center',
  263. width : "20%",
  264. showTitle:true
  265. },{
  266. display : '填写角色',
  267. name : 'INPUT_PER_DEPT_NAME_311',
  268. align : 'center',
  269. width : "20%",
  270. isSort : true
  271. }, {
  272. display : '填写人',
  273. name : 'INPUT_PER_NAME_311',
  274. align : 'center',
  275. width : "20%",
  276. showTitle:true
  277. }, {
  278. display : '状态',
  279. name : 'RELEASE_STATE_311_SHOW',
  280. align : 'center',
  281. width : "20%",
  282. showTitle:true
  283. }],
  284. rownumbers : true,
  285. checkbox : true,
  286. pageSize : 10,
  287. percentWidthMode : true};
  288. var roleCons = roleButtonArr();
  289. var toolBarOpt={
  290. items : [ {
  291. text : '新增',
  292. click : 'addForm',
  293. iconClass : 'add1_tem',
  294. id : '23tj'
  295. }, {
  296. text : '删除',
  297. click : 'del',
  298. iconClass : 'delete_tem',
  299. id : '23sc'
  300. }, {
  301. text : '修改',
  302. click : 'editForm',
  303. iconClass : 'update_tem',
  304. id : '23xg'
  305. }, {
  306. text : '发布',
  307. click :'release',
  308. iconClass : 'release_tem',
  309. id : '23fb'
  310. }, {
  311. text : '收回',
  312. click : 'handOn',
  313. iconClass : 'delete_tem',
  314. id : '23js'
  315. } ],
  316. roleCons:roleCons
  317. };
  318. var options={
  319. url :'/nwyj/ws/crud/CRUDService/queryQui',
  320. params: _this.loadParams,
  321. width:960,
  322. gridOptions:grid_option,
  323. singleRecodeOptions:{a:""},
  324. paperOpration:{showInput:"true"},
  325. toolBarOptions:toolBarOpt
  326. };
  327. /**grid载入数据(定义数据列表)**/
  328. _this.listGrid =gridAndSingleRecode=$("#dataGrid").quickgridAndSingleRecode(options);
  329. }
  330. };
  331. }();
  332. $(function() {
  333. DutyPlan.init();
  334. });
  335. function showPrimaryKey(row,index){//row为整条数据,index为第几字段,index是从0开始的
  336. var fdId = row.FD_OBJECTID311;
  337. show(fdId);
  338. }