detail.js 19 KB

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