detail.js 19 KB

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