main.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. $.namespace("grsw.gggl.main");
  2. grsw.gggl.main.$popWin = null;
  3. /** 页面初始化 */
  4. grsw.gggl.main.init = function() {
  5. grsw.gggl.main.$popWin = $("#popWin");
  6. grsw.gggl.main.initpage();
  7. };
  8. /** 页面初始化*/
  9. grsw.gggl.main.initpage = function() {
  10. $("#pagetools").hide();
  11. //把form传入,构造翻页控件
  12. pageinfo($("#ggglform"));//见common.js
  13. }
  14. /**新增页面*/
  15. grsw.gggl.main.add=function(backurl){
  16. location.href=$.ctx+"/dbgg/add?backurl="+backurl;
  17. }
  18. /**
  19. * 记录编辑处理
  20. */
  21. grsw.gggl.main.doEdit = function(id) {
  22. window.location=$.ctx + '/dbgg/view?flag=0&rflag=0&id='+id+'&backurl='+$.ctx+'/dbgg/main';
  23. }
  24. /**
  25. * 记录查看处理
  26. */
  27. grsw.gggl.main.doView = function(id) {
  28. window.location=$.ctx + '/dbgg/view?flag=1&rflag=3&id='+id+'&backurl='+$.ctx+'/dbgg/main';
  29. }
  30. /**
  31. * 记录置顶处理
  32. */
  33. grsw.gggl.main.doTop = function() {
  34. var ids = grsw.gggl.main.getSelectedRecords();
  35. var id = $("#"+ids).val();
  36. var status = $("#"+ids).next().next().next().next().val();
  37. var istop = $("#"+ids).next().next().next().next().next().val();
  38. //alert("id:"+id+";istop:"+istop+";status:"+status);
  39. if (ids.length == 1) {
  40. if("完成"!=status){
  41. $.messager.alert("提示", "流程未结束不可置顶!");
  42. return false;
  43. }else if("1"==istop){
  44. $.messager.alert("提示", "该公告已被置顶!");
  45. return false;
  46. }else{
  47. $.post($.ctx + "/ybgg/top", {
  48. ids : id
  49. }, function(data, status) {
  50. if (data.success) {
  51. location.href=$.ctx+"/ybgg/main";
  52. }
  53. else {
  54. $.messager.showError(data.message);
  55. }
  56. }, "json");
  57. }
  58. }else if(ids.length<=0){
  59. $.messager.alert("提示", "请选择要置顶的记录!");
  60. }else{
  61. $.messager.alert("提示", "只能选择一条要置顶的记录!");
  62. }
  63. }
  64. /** 删除处理 */
  65. grsw.gggl.main.doDel = function() {
  66. var ids = grsw.gggl.main.getSelectedRecords();
  67. if (ids.length > 0) {
  68. $.messager.confirm("确认", "确定要删除吗?", function(msg) {
  69. if (msg) {
  70. // 确认删除
  71. $.post($.ctx + "/dbgg/delete", {
  72. ids : ids.join(",")
  73. }, function(data, status) {
  74. if (data.success) {
  75. location.href=$.ctx+"/dbgg/main";
  76. }
  77. else {
  78. $.messager.showError(data.message);
  79. }
  80. }, "json");
  81. }
  82. ;
  83. });
  84. }
  85. else {
  86. $.messager.alert("提示", "请选择记录!");
  87. }
  88. }
  89. /**
  90. * 全选/全不选
  91. */
  92. grsw.gggl.main.all = function(){
  93. if($("#all").prop("checked")){
  94. $(".gggl_table_checkbox").each(function(){
  95. $(this).prop("checked",true);
  96. });
  97. }else{
  98. $(".gggl_table_checkbox").each(function(){
  99. $(this).prop("checked",false);
  100. });
  101. }
  102. }
  103. /**
  104. * 获取选中的数据
  105. * 返回选中数据的id数组
  106. */
  107. grsw.gggl.main.getSelectedRecords = function(){
  108. var ids = new Array();
  109. $(".gggl_table_checkbox").each(function(){
  110. if($(this).prop("checked")){
  111. ids.push($(this).val());
  112. }
  113. });
  114. return ids;
  115. }
  116. grsw.gggl.main.query=function(sortname,order){
  117. $("#ggglform").submit();
  118. }
  119. grsw.gggl.main.doShow = function(a,backurl) {
  120. window.location=$.ctx + '/dbgg/view?id='+a+'&backurl='+backurl;
  121. }
  122. grsw.gggl.main.showWin = function(id){
  123. $dialog = grsw.gggl.main.$popWin.dialog({
  124. href : $.ctx + '/wf/task/hisWf?id='+id,
  125. title : "历史流程",
  126. width : 800,
  127. height :400,
  128. top:$(document).scrollTop() + ($(window).height()-400) * 0.5,
  129. left:$(document).scrollLeft() + ($(window).width()-600) * 0.5,
  130. onClose : function() {
  131. $dialog.dialog('destroy');
  132. },
  133. buttons : [ {
  134. text : '关闭',
  135. iconCls : 'icon-cancel',
  136. handler : function() {
  137. $dialog.dialog('close');
  138. }
  139. } ]
  140. });
  141. $dialog.dialog('open');
  142. }
  143. /**
  144. * 判断是否为空
  145. * @param str
  146. * @returns {Boolean}
  147. */
  148. function isEmpty(str){
  149. if(str!=null&&str!=""&&str.length!=0){
  150. return false;
  151. }else{
  152. return true;
  153. }
  154. }
  155. $(document).ready(function() {
  156. $("#sendgg").click(function(){
  157. var ids = grsw.gggl.main.getSelectedRecords();
  158. if (ids.length == 1) {
  159. var id = $("#"+ids).val();
  160. var ggr = $("#"+ids).next().val();
  161. var ggrname = $("#"+ids).next().next().val();
  162. var sendStatus = $("#"+ids).next().next().next().val();
  163. var status = $("#"+ids).next().next().next().next().val();
  164. //alert("ggr:"+ggr+";ggrname:"+ggrname+";id:"+id+";sendStatus:"+sendStatus+";status:"+status);
  165. if("完成"!=status){
  166. $.messager.alert("提示", "流程未结束不可发布!");
  167. return false;
  168. }
  169. if("1"==sendStatus){
  170. $.messager.confirm("确认", "确定要重新发布该公告吗?", function(msg) {
  171. if (msg) {
  172. $('#userto').tree({
  173. url : '/gkoa/fyj/showUserTree',
  174. onExpand: function (node) {
  175. var ggrs = new Array();
  176. ggrs = ggr.split(",");
  177. for(var i=0;i<ggrs.length;i++){
  178. var ggrnode = $('#userto').tree('find', ggrs[i]);
  179. $('#userto').tree('check',ggrnode.target);
  180. }
  181. }
  182. });
  183. $("#dialogDiv").show();
  184. $("#dialogDiv").dialog({
  185. hide:true,
  186. autoOpen:false,
  187. title : "发布公告",
  188. width : 450,
  189. height : 380,
  190. modal:true,
  191. overlay: {opacity: 0.5, background: "black" ,overflow:'auto'},
  192. onLoad : function() {
  193. },
  194. onClose : function() {
  195. },
  196. buttons : [ {
  197. text : '确定',
  198. iconCls : 'icon-xt-ok',
  199. handler : function() {
  200. var usertos = $("#userto").tree('getChecked');
  201. var userto = "";
  202. for(var i=0;i<usertos.length;i++){
  203. userto+=usertos[i].id+",";
  204. }
  205. userto = userto.substring(0,userto.length-1);
  206. if(isEmpty(userto)){
  207. $.messager.alert("提示", "请选择发布范围!");
  208. return false;
  209. }else{
  210. var mes = "";
  211. if(sendStatus==1){
  212. mes="确定要重新发布该公告吗?";
  213. }else{
  214. mes="确定要发布该公告吗?";
  215. }
  216. $.messager.confirm("确认", mes, function(msg) {
  217. if (msg) {
  218. //确认修改
  219. $.post($.ctx + "/ybgg/send?userto="+userto, {
  220. id : id
  221. }, function(data, status) {
  222. if (data.success) {
  223. $("#dialogDiv").dialog('close');
  224. $.messager.alert("提示", "发布成功!");
  225. window.location.href=window.location.href;
  226. } else {
  227. $.messager.alert("发布失败", data.message);
  228. }
  229. }, "json");
  230. }
  231. });
  232. }
  233. }
  234. }, {
  235. text : '取消',
  236. iconCls : 'icon-cancel',
  237. handler : function() {
  238. $("#dialogDiv").dialog('close');
  239. $("#dialogDiv").hide();
  240. }
  241. }]
  242. });
  243. }else{
  244. return false;
  245. }
  246. });
  247. }else{
  248. $("#dialogDiv").show();
  249. $("#dialogDiv").dialog({
  250. hide:true,
  251. autoOpen:false,
  252. title : "发布公告",
  253. width : 450,
  254. height : 380,
  255. modal:true,
  256. overlay: {opacity: 0.5, background: "black" ,overflow:'auto'},
  257. onLoad : function() {
  258. },
  259. onClose : function() {
  260. },
  261. buttons : [ {
  262. text : '确定',
  263. iconCls : 'icon-xt-ok',
  264. handler : function() {
  265. var usertos = $("#userto").tree('getChecked');
  266. var userto = "";
  267. for(var i=0;i<usertos.length;i++){
  268. userto+=usertos[i].id+",";
  269. }
  270. userto = userto.substring(0,userto.length-1);
  271. if(isEmpty(userto)){
  272. $.messager.alert("提示", "请选择发布范围!");
  273. return false;
  274. }else{
  275. var mes = "";
  276. if(sendStatus==1){
  277. mes="确定要重新发布该公告吗?";
  278. }else{
  279. mes="确定要发布该公告吗?";
  280. }
  281. $.messager.confirm("确认", mes, function(msg) {
  282. if (msg) {
  283. //确认修改
  284. $.post($.ctx + "/ybgg/send?userto="+userto, {
  285. id : id
  286. }, function(data, status) {
  287. if (data.success) {
  288. $("#dialogDiv").dialog('close');
  289. $.messager.alert("提示", "发布成功!");
  290. window.location.href=window.location.href;
  291. } else {
  292. $.messager.alert("发布失败", data.message);
  293. }
  294. }, "json");
  295. }
  296. });
  297. }
  298. }
  299. }, {
  300. text : '取消',
  301. iconCls : 'icon-cancel',
  302. handler : function() {
  303. $("#dialogDiv").dialog('close');
  304. $("#dialogDiv").hide();
  305. }
  306. } ]
  307. });
  308. }
  309. } else if(ids.length<1) {
  310. $.messager.alert("提示", "请选择要发布的记录!");
  311. }else{
  312. $.messager.alert("提示", "只能选择一条记录发布!");
  313. }
  314. });
  315. });