detail.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /**
  2. * 菜单详细画面用js
  3. *
  4. * @author 袁晓冬
  5. */
  6. $.namespace("qbgl.dbqb.detail");
  7. qbgl.dbqb.detail.$popWin2 =null;
  8. qbgl.dbqb.detail.$opflag = null;
  9. qbgl.dbqb.detail.$qm=null;
  10. /** 页面初始化 */
  11. qbgl.dbqb.detail.init = function() {
  12. qbgl.dbqb.detail.$popWin=$('#popWin');
  13. // 转换数据字符串为对象
  14. qbgl.dbqb.detail.initpage();
  15. };
  16. /** 页面初始化*/
  17. qbgl.dbqb.detail.initpage = function() {
  18. $("#pagetools button").click(function(){
  19. qbgl.dbqb.detail.doDel();
  20. });
  21. //把form传入,构造翻页控件
  22. pageinfo($("#fjform"));//见common.js
  23. }
  24. qbgl.dbqb.detail.setSort=function(sortname,order){
  25. $("#pagesort").val(sortname);
  26. $("#pageorder").val(order);
  27. $("#fjform").submit();
  28. }
  29. /**
  30. * 选择单位
  31. */
  32. qbgl.dbqb.detail.dw=function(dw){
  33. qbgl.dbqb.detail.dwchoose({
  34. callback : function(status, rows) {
  35. if (!status) { return; }
  36. var str = $('#'+dw).val();
  37. $.each(rows,function(n,value){
  38. if(str!=""){
  39. if(str.indexOf(value)!=-1){
  40. }else{
  41. str+=","+value;
  42. }
  43. }else{
  44. str+=value;
  45. }
  46. });
  47. $('#'+dw).val(str);
  48. }
  49. });
  50. }
  51. /***
  52. * 弹出单位选择框
  53. */
  54. qbgl.dbqb.detail.dwchoose=function(config){
  55. config = config || {};
  56. $dialog = qbgl.dbqb.detail.$popWin.dialog({
  57. href : $.ctx + '/dbfw/dw',
  58. title : "选择单位",
  59. width : 300,
  60. height : 200,
  61. onClose : function() {
  62. $dialog.dialog('destroy');
  63. },
  64. buttons : [ {
  65. text : '完成',
  66. iconCls : 'icon-xt-ok',
  67. handler : function() {
  68. var rows =[];
  69. $("#stepTable2 tr").each(function(trindex,tritem){
  70. var checked = $(tritem).find("input[type='checkbox']:checked");
  71. if(checked.length>0){
  72. var row =$(tritem).find("input[type='checkbox']:checked").val();
  73. rows.push(row);
  74. }
  75. });
  76. if (config.callback && typeof config.callback == 'function') {
  77. config.callback(true,rows);
  78. }
  79. $dialog.dialog('close');
  80. }
  81. }, {
  82. text : '取消',
  83. iconCls : 'icon-cancel',
  84. handler : function() {
  85. if (config.callback && typeof config.callback == 'function') {
  86. config.callback(false);
  87. }
  88. $dialog.dialog('close');
  89. }
  90. } ]
  91. });
  92. $dialog.dialog('open');
  93. }
  94. var isCommitted = false;//表单是否已经提交标识,默认为false
  95. /**
  96. * 保存
  97. */
  98. qbgl.dbqb.detail.save=function(){
  99. if(isEmpty($("#title").val())){
  100. $.messager.alert("提示","文件标题不能为空");
  101. return false;
  102. }else if(isEmpty($("#company").val())){
  103. $.messager.alert("提示","承办部门不能为空");
  104. return false;
  105. }
  106. if(isCommitted==false){
  107. isCommitted = true;//提交表单后,将表单是否已经提交标识设置为true
  108. $('#dbqbform').form('submit', {
  109. url : $.ctx + '/dbqb/save',
  110. onSubmit : function() {
  111. },
  112. success : function(data, status) {
  113. if (data) {
  114. data = $.parseJSON(data);
  115. }
  116. if (data.success) {
  117. location.href=$.ctx+"/dbqb/view?id="+data.attrs.id+"&flag=0";
  118. }
  119. else {
  120. $.messager.alert("提示",data.message);
  121. }
  122. }
  123. });
  124. return true;//返回true让表单正常提交
  125. }else{
  126. setTimeout(function() { isCommitted = false; }, 5000);
  127. return false;//返回false那么表单将不提交
  128. }
  129. }
  130. /**
  131. * 返回
  132. */
  133. qbgl.dbqb.detail.back=function(){
  134. var a = $('#rflag').val();
  135. if(a==0){
  136. window.location= $.ctx + '/dbqb/main';
  137. }else if(a==1){
  138. window.location= $.ctx + '/ybqb/main';
  139. }else {
  140. window.location= $.ctx + '/allqb/main';
  141. }
  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. /**
  156. * 保存菜单
  157. */
  158. qbgl.dbqb.detail.showWin = function(flag) {
  159. var opinion= $("#opinion").val();
  160. if(!isEmpty(opinion)){
  161. opinion = opinion.replace(/&/g, "&");
  162. opinion = opinion.replace(/&lt;/g, "<");
  163. opinion = opinion.replace(/&gt;/g, ">");
  164. opinion = opinion.replace(/&quot;/g, "\"");
  165. opinion = opinion.replace(/&#x27;/g, "//");
  166. opinion = opinion.replace(/&#x2F;/g, "\\\\");
  167. }
  168. if(flag == "th"){
  169. $.post($.ctx + "/wf/task/isEnd", {
  170. bussKey:$("#id").val()
  171. }, function(data, status) {
  172. if (data.success) {
  173. Xt.showChooseUserBackDialog({
  174. wfid : 'qb',
  175. taskId:$("#taskId").val(),
  176. flag:flag,
  177. callback : function(status, rows) {
  178. if (!status) { return; }
  179. $.post($.ctx + "/dbqb/back", {
  180. step:rows[0].step,
  181. usersStr:encodeURI(rows[0].users),
  182. opStr:opinion,
  183. id:$("#id").val(),
  184. days:rows[0].days
  185. }, function(data, status) {
  186. if (data.success) {
  187. window.location=$.ctx+"/dbqb/main";
  188. } else {
  189. $.messager.alert("提示", data.message);
  190. }
  191. }, "json");
  192. }
  193. });
  194. } else {
  195. if(isEmpty(data.message)){
  196. window.location=$.ctx+"/dbqb/main";
  197. }else{
  198. $.messager.alert("提示", data.message, "info", function () {
  199. window.location=$.ctx+"/dbqb/main";
  200. });
  201. }
  202. }
  203. }, "json");
  204. }else{
  205. $.post($.ctx + "/dbqb/isLastStep", {
  206. wfid : 'qb',
  207. taskId:$("#taskId").val(),
  208. opStr:opinion,
  209. sfjs : flag,
  210. id:$("#id").val()
  211. }, function(data, status) {
  212. if (data.success) {
  213. //var flag = data.attrs.flag
  214. Xt.showChooseUserDialog({
  215. wfid : 'qb',
  216. taskId:$("#taskId").val(),
  217. id:$("#id").val(),
  218. flag:flag,
  219. callback : function(status, rows) {
  220. if (!status) { return; }
  221. $.post($.ctx + "/dbqb/submit", {
  222. step:rows[0].step,
  223. usersStr:encodeURI(rows[0].users),
  224. id:$("#id").val(),
  225. taskId:$("#taskId").val(),
  226. days:rows[0].days,
  227. opStr:opinion
  228. }, function(data, status) {
  229. if (data.success) {
  230. window.location=$.ctx+"/dbqb/main";
  231. } else {
  232. $.messager.alert("提示", data.message);
  233. }
  234. }, "json");
  235. }
  236. });
  237. } else {
  238. if(isEmpty(data.message)){
  239. window.location=$.ctx+"/dbqb/main";
  240. }else{
  241. $.messager.alert("提示", data.message, "info", function () {
  242. window.location=$.ctx+"/dbqb/main";
  243. });
  244. }
  245. }
  246. }, "json");
  247. }
  248. }
  249. /**
  250. * 跳转编辑页面
  251. */
  252. qbgl.dbqb.detail.goDetailUrl=function(a){
  253. window.location=$.ctx + '/dbqb/edit?id='+a+"&flag="+$('#flag').val()+"&rflag="+$('#rflag').val();
  254. }
  255. /**
  256. * 跳转查看页面
  257. */
  258. qbgl.dbqb.detail.goViewUrl=function(a){
  259. window.location=$.ctx + '/dbqb/view?id='+a+"&flag="+$('#flag').val()+"&rflag="+$('#rflag').val();
  260. }
  261. /**
  262. * 跳转原文页面
  263. */
  264. qbgl.dbqb.detail.goYuanwenUrl=function(a){
  265. window.location=$.ctx + '/dbqb/yedit?id='+a+"&flag="+$('#flag').val()+"&rflag="+$('#rflag').val();
  266. }
  267. /**
  268. *原文上传附件
  269. */
  270. qbgl.dbqb.detail.submitFile=function(){
  271. $('#uploadform').form('submit', {
  272. url : $.ctx + '/dbqb/saveFile',
  273. onSubmit : function() {
  274. },
  275. success : function(data, status) {
  276. if (data) {
  277. data = $.parseJSON(data);
  278. }
  279. if (data.success) {
  280. window.location=$.ctx + '/dbqb/yedit?id='+data.attrs.ssid+"&flag=0&rflag=0";
  281. }else {
  282. $.messager.alert("提示",data.message);
  283. }
  284. }
  285. });
  286. }
  287. /**
  288. * 意见弹出框
  289. */
  290. qbgl.dbqb.detail.opWin=function(){
  291. if(qbgl.dbqb.detail.$opflag!=null){
  292. if(qbgl.dbqb.detail.$opflag=="部门核稿"){
  293. $("#opflag").val("bm");
  294. }else if(qbgl.dbqb.detail.$opflag=="会签"){
  295. $("#opflag").val("hq");
  296. }else if(qbgl.dbqb.detail.$opflag=="领导批示"){
  297. $("#opflag").val("ld");
  298. }else if(qbgl.dbqb.detail.$opflag=="办理"){
  299. $("#opflag").val("bl");
  300. }else if(qbgl.dbqb.detail.$opflag=="清稿校对"){
  301. $("#opflag").val("qgjd");
  302. }else if(qbgl.dbqb.detail.$opflag=="文书处理"){
  303. $("#opflag").val("wscl");
  304. }else if(qbgl.dbqb.detail.$opflag=="传阅"){
  305. $("#opflag").val("cy");
  306. }else if(qbgl.dbqb.detail.$opflag=="归档"){
  307. $("#opflag").val("gd");
  308. }
  309. }
  310. Xt.showGryjDialog({
  311. yj:$("#opinion").val(),
  312. callback : function(status) {
  313. if (!status) { return; }
  314. var flag = $("#opflag").val();
  315. var opinion = $('#opinion1').val();
  316. opinion = opinion.replace(/&/g, "&amp");
  317. opinion = opinion.replace(/</g, "&lt");
  318. opinion = opinion.replace(/>/g, "&gt");
  319. opinion = opinion.replace(/"/g, "&quot");
  320. //opinion = opinion.replace(/(^\s*)|(\s*$)/g, "");
  321. $("#opinion").val(opinion);
  322. var str = "<span style='color:blue;cursor: pointer;' onclick='qbgl.dbqb.detail.opWin()'>修改</span>&nbsp;"
  323. + "<span style='color:blue;cursor: pointer;' onclick='qbgl.dbqb.detail.delop()'>删除</span>";
  324. $('#'+flag).html(opinion+"<br/>"+qbgl.dbqb.detail.$qm+"<br/>"+str);
  325. }
  326. });
  327. }
  328. /**
  329. * 保存意见
  330. */
  331. /*qbgl.dbqb.detail.saveOp=function(){
  332. var opinion = $('#opinion').val();
  333. if(opinion&&opinion.length>20){
  334. $.messager.alert("提示", "意见请小于20字。");
  335. }else{
  336. $('#op').hide();
  337. $('#bg').hide();
  338. $('body').css('overflow', 'auto');
  339. var flag = $("#opflag").val();
  340. var str = "<span style='color:blue;cursor: pointer;' onclick='qbgl.dbqb.detail.opWin()'>修改</span>&nbsp;"+
  341. "<span style='color:blue;cursor: pointer;' onclick='qbgl.dbqb.detail.delop()'>删除</span>";
  342. $('#'+flag).html(opinion+"<br/>"+qbgl.dbqb.detail.$qm+"<br/>"+str);
  343. }
  344. }*/
  345. qbgl.dbqb.detail.delop=function(){
  346. var flag = $("#opflag").val();
  347. $('#'+flag).html("");
  348. $('#opinion').val("");
  349. }
  350. /**
  351. * 保存意见
  352. */
  353. /*qbgl.dbqb.detail.selOp=function(data){
  354. $('#opinion').val("");
  355. $('#opinion').val(data);
  356. }
  357. *//**
  358. * 关闭意见框
  359. *//*
  360. qbgl.dbqb.detail.closeOp=function(){
  361. $('#op').hide();
  362. $('#bg').hide();
  363. $('body').css('overflow', 'auto');
  364. }*/
  365. /**
  366. * 金格打开
  367. */
  368. qbgl.dbqb.detail.openWin=function(name,type,id){
  369. if(type=="docx" || type=="doc"||type=="DOCX"||type=="DOC"){
  370. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='+name+"&FileType="+type+"&EditType=2&FileID="+id);
  371. }else if(type=="pdf"||type=="PDF"){
  372. $.post($.ctx + "/accessory/viewpdf", {
  373. id : id,
  374. }, function(data, status) {
  375. if (data.success) {
  376. window.open($.ctx + "/static/temppdf/viewpdf.jsp?filename="+data.attrs.filename+"&width="+(window.screen.width-30)+"&height="+(window.screen.height-65),"newwindow", "height="+window.screen.height+", width="+window.screen.width+", top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no");
  377. } else {
  378. location.href=$.ctx+"/accessory/download?id="+id;
  379. }
  380. }, "json");
  381. }else{
  382. window.location=$.ctx+"/accessory/download?id="+id;
  383. }
  384. }
  385. /**
  386. * 全选/全不选
  387. */
  388. qbgl.dbqb.detail.all = function(){
  389. if($("#all").prop("checked")){
  390. $(".fwgl_table_checkbox").each(function(){
  391. $(this).prop("checked",true);
  392. });
  393. }else{
  394. $(".fwgl_table_checkbox").each(function(){
  395. $(this).prop("checked",false);
  396. });
  397. }
  398. }
  399. /**
  400. * 获取选中的数据
  401. * 返回选中数据的id数组
  402. */
  403. qbgl.dbqb.detail.getSelectedRecords = function(){
  404. var ids = new Array();
  405. $(".fwgl_table_checkbox").each(function(){
  406. if($(this).prop("checked")){
  407. ids.push($(this).val());
  408. }
  409. });
  410. return ids;
  411. }
  412. /** 删除处理 */
  413. qbgl.dbqb.detail.doDel = function() {
  414. var ids = qbgl.dbqb.detail.getSelectedRecords();
  415. if (ids.length > 0) {
  416. $.messager.confirm("确认", "确定要删除吗?", function(msg) {
  417. if (msg) {
  418. // 确认删除
  419. $.post($.ctx + "/accessory/delete", {
  420. ids : ids.join(",")
  421. }, function(data, status) {
  422. if (data.success) {
  423. location.href=$.ctx + '/dbqb/yedit?id='+$('#ssid').val()+"&flag="+$('#flag').val()+"&rflag="+$('#rflag').val();
  424. } else {
  425. $.messager.alert("提示", data.message);
  426. }
  427. }, "json");
  428. }
  429. ;
  430. });
  431. } else {
  432. $.messager.alert("提示", "请选择要删除的记录!");
  433. }
  434. }
  435. /**
  436. * 打印
  437. */
  438. qbgl.dbqb.detail.print=function(id){
  439. var newwin=window.open($.ctx+"/dbqb/print?id="+id,"","top=0,left=0,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+(window.screen.availWidth-10)+",height="+(window.screen.availHeight-30));//修改宽度和高度可控制窗口的大小
  440. newwin.focus();
  441. /*bdhtml=window.document.body.innerHTML;//获取当前页的html代码
  442. sprnstr="<!--startprint-->";//设置打印开始区域
  443. eprnstr="<!--endprint-->";//设置打印结束区域
  444. prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
  445. prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
  446. window.document.body.innerHTML=prnhtml;
  447. window.print();
  448. window.document.body.innerHTML=bdhtml;*/
  449. }
  450. /**
  451. * 模板弹出框
  452. */
  453. qbgl.dbqb.detail.zw=function(data){
  454. $.post($.ctx + "/dbqb/iszwexist", {
  455. id : data,
  456. }, function(data, status) {
  457. if (data.success) {
  458. if("拟稿"==$("#stepname").val()){
  459. $.messager.confirm("确认", "是否重新选择发文模板?", function(msg) {
  460. if (msg) {
  461. $('#mb').show();
  462. }else{
  463. if(data.attrs.ismark=='1'&&data.attrs.isdone=='1'){
  464. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='+data.attrs.filename
  465. +"&FileType="+data.attrs.suc+"&EditType=2&FileID="+data.attrs.fid
  466. + "&iszw=1&zwtitle="+data.attrs.title+"&copyto="+data.attrs.copyto+"&zwbh="+data.attrs.bh+"&zsdw="+data.attrs.zsdw);
  467. }else if(data.attrs.isdone=='2'){
  468. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='+data.attrs.filename
  469. +"&FileType="+data.attrs.suc+"&EditType=1&FileID="+data.attrs.fid
  470. + "&iszw=1&zwtitle="+data.attrs.title+"&copyto="+data.attrs.copyto+"&zwbh="+data.attrs.bh+"&zsdw="+data.attrs.zsdw);
  471. }else{
  472. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='+data.attrs.filename
  473. +"&FileType="+data.attrs.suc+"&EditType=3&FileID="+data.attrs.fid
  474. + "&iszw=1&zwtitle="+data.attrs.title+"&copyto="+data.attrs.copyto+"&zwbh="+data.attrs.bh+"&zsdw="+data.attrs.zsdw);
  475. }
  476. }
  477. });
  478. }else{
  479. if(data.attrs.ismark=='1'&&data.attrs.isdone=='1'){
  480. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='+data.attrs.filename
  481. +"&FileType="+data.attrs.suc+"&EditType=2&FileID="+data.attrs.fid
  482. + "&iszw=1&zwtitle="+data.attrs.title+"&copyto="+data.attrs.copyto+"&zwbh="+data.attrs.bh+"&zsdw="+data.attrs.zsdw);
  483. }else if(data.attrs.isdone=='2'){
  484. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='+data.attrs.filename
  485. +"&FileType="+data.attrs.suc+"&EditType=1&FileID="+data.attrs.fid
  486. + "&iszw=1&zwtitle="+data.attrs.title+"&copyto="+data.attrs.copyto+"&zwbh="+data.attrs.bh+"&zsdw="+data.attrs.zsdw);
  487. }else{
  488. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='+data.attrs.filename
  489. +"&FileType="+data.attrs.suc+"&EditType=3&FileID="+data.attrs.fid
  490. + "&iszw=1&zwtitle="+data.attrs.title+"&copyto="+data.attrs.copyto+"&zwbh="+data.attrs.bh+"&zsdw="+data.attrs.zsdw);
  491. }
  492. }
  493. } else {
  494. $('#mb').show();
  495. }
  496. }, "json");
  497. }
  498. /**
  499. * 模板选择事件
  500. */
  501. qbgl.dbqb.detail.choosezw=function(data,tag){
  502. $.post($.ctx + "/dbqb/zw", {
  503. id : data,
  504. tag:tag
  505. }, function(data, status) {
  506. if (data.success) {
  507. $('#mb').hide();
  508. window.open($.ctx + '/static/iWebOffice/DocumentEdit.jsp?FileName='
  509. +data.attrs.filename+"&FileType="+data.attrs.suc+"&EditType=3&FileID="+data.attrs.fid
  510. + "&iszw=1&zwtitle="+data.attrs.title+"&copyto="+data.attrs.copyto+"&zwbh="+data.attrs.bh+"&zsdw="+data.attrs.zsdw);
  511. } else {
  512. $.messager.alert("提示", data.message);
  513. }
  514. }, "json");
  515. }
  516. qbgl.dbqb.detail.closeMb=function(){
  517. $('#mb').hide();
  518. }