5b779b54a6f18b8c7fb818092bc0e7f28aa5dc71.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. /**定义变量**/
  2. var _this = this;
  3. /**私有方法**/
  4. /***新增信息***/
  5. _this.save = function(){
  6. var message='';
  7. var equipmentval;
  8. var equipmenttext;
  9. var safeyval;
  10. var safetext;
  11. var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
  12. if(!checkTime()){
  13. return;
  14. }else if(!decideTime()){
  15. return ;
  16. }else if(pattern.test($("#MISSION_NAME_703").val())){
  17. top.Dialog.alert("填报要求名称不能包含特殊字符");
  18. return;
  19. }
  20. $('#editForm input[name="classid"]').val('703');
  21. //获得填报地区名
  22. var write_area=$("#WRITE_AREA_ID_703_show").val();
  23. $("#WRITE_AREA_703").val(write_area);
  24. //获取表名及部门名称
  25. if($("#EQUIPMENT_DEPT").attr("relText")!="请选择" && $("#EQUIPMENT_DEPT").attr("relText")!=undefined){
  26. var tb1='';
  27. equipmentval = splits($("#EQUIPMENT_DEPT").attr("relValue"));
  28. equipmenttext = $("#EQUIPMENT_DEPT").attr("relText");
  29. var nodes = $("#EQUIPMENT_DEPT").data("selectedNodes");
  30. for(var i=0;i<nodes.length;i++){
  31. if(i==nodes.length-1){
  32. tb1=tb1+nodes[i].report_type+"||";
  33. }else{
  34. tb1=tb1+nodes[i].report_type+",";
  35. }
  36. }
  37. message += "生产设备部:"+equipmenttext+";"+equipmentval.split(";")[0]+":"+tb1;
  38. }
  39. if($("#SAFEY_DEPT").attr("relText")!="请选择" && $("#SAFEY_DEPT").attr("relText")!=undefined){
  40. var tb2='';
  41. safeyval = splits($("#SAFEY_DEPT").attr("relValue"));
  42. safetext = $("#SAFEY_DEPT").attr("relText");
  43. var nodes = $("#SAFEY_DEPT").data("selectedNodes");
  44. for(var i=0;i<nodes.length;i++){
  45. if(i==nodes.length-1){
  46. tb2+=nodes[i].report_type;
  47. }else{
  48. tb2+=nodes[i].report_type+",";
  49. }
  50. }
  51. message += "安全监察部:"+safetext+";"+safeyval.split(";")[0]+":"+tb2;
  52. }
  53. //将报表及部门录入
  54. $("#REPORT_DEPT_703").val(message);
  55. if(message==""){
  56. top.Dialog.alert("请选择至少一张表!");
  57. return;
  58. }
  59. $form = $('#editForm');
  60. var valid = $form.validationEngine({returnIsValid: true});
  61. if(!valid){
  62. top.Dialog.alert(CHECKREDBOX);
  63. return;
  64. }
  65. if(valid){
  66. showProgressBar("正在提交中...");
  67. var formValue = $form.serialize();
  68. var url = $.pathname() + '/ws/crud/CRUDService/create/';
  69. if(fd_id!=undefined&&fd_id!=""&&fd_id!="null"){
  70. url = $.pathname() +"/ws/crud/CRUDService/update/";
  71. }
  72. $.request.add(url,formValue,function(data){
  73. closeProgress();
  74. top.Dialog.alert(data.Msg.info);
  75. $('#frmright', window.parent.document).attr('src','/nwyj/page/business/em/report/SpecialReport.jsp');
  76. });
  77. }
  78. };
  79. _this.saveAndRelease = function(){
  80. var message='';
  81. var equipmentval;
  82. var equipmenttext;
  83. var safeyval;
  84. var safetext;
  85. var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]");
  86. if(!checkTime()){
  87. return;
  88. }else if(!decideTime()){
  89. return ;
  90. }else if(pattern.test($("#MISSION_NAME_703").val())){
  91. top.Dialog.alert("填报要求名称不能包含特殊字符");
  92. return;
  93. }
  94. $('#editForm input[name="classid"]').val('703');
  95. //获得填报地区名
  96. var write_area=$("#WRITE_AREA_ID_703_show").val();
  97. $("#WRITE_AREA_703").val(write_area);
  98. //获取表名及部门名称
  99. if($("#EQUIPMENT_DEPT").attr("relText")!="请选择" && $("#EQUIPMENT_DEPT").attr("relText")!=undefined){
  100. var tb1='';
  101. equipmentval = splits($("#EQUIPMENT_DEPT").attr("relValue"));
  102. equipmenttext = $("#EQUIPMENT_DEPT").attr("relText");
  103. var nodes = $("#EQUIPMENT_DEPT").data("selectedNodes");
  104. for(var i=0;i<nodes.length;i++){
  105. if(i==nodes.length-1){
  106. tb1=tb1+nodes[i].report_type+"||";
  107. }else{
  108. tb1=tb1+nodes[i].report_type+",";
  109. }
  110. }
  111. message += "生产设备部:"+equipmenttext+";"+equipmentval.split(";")[0]+":"+tb1;
  112. }
  113. if($("#SAFEY_DEPT").attr("relText")!="请选择" && $("#SAFEY_DEPT").attr("relText")!=undefined){
  114. var tb2='';
  115. safeyval = splits($("#SAFEY_DEPT").attr("relValue"));
  116. safetext = $("#SAFEY_DEPT").attr("relText");
  117. var nodes = $("#SAFEY_DEPT").data("selectedNodes");
  118. for(var i=0;i<nodes.length;i++){
  119. if(i==nodes.length-1){
  120. tb2+=nodes[i].report_type;
  121. }else{
  122. tb2+=nodes[i].report_type+",";
  123. }
  124. }
  125. message += "安全监察部:"+safetext+";"+safeyval.split(";")[0]+":"+tb2;
  126. }
  127. //将报表及部门录入
  128. $("#REPORT_DEPT_703").val(message);
  129. if(message==""){
  130. top.Dialog.alert("请选择至少一张表!");
  131. return;
  132. }
  133. $form = $('#editForm');
  134. var valid = $form.validationEngine({returnIsValid: true});
  135. if(!valid){
  136. top.Dialog.alert(CHECKREDBOX);
  137. return;
  138. }
  139. if(valid){
  140. showProgressBar("正在提交中...");
  141. var url = $.pathname() + '/ws/crud/CRUDService/create/';
  142. if(fd_id!=undefined&&fd_id!=""&&fd_id!="null"){
  143. url = $.pathname() +"/ws/crud/CRUDService/update/";
  144. }
  145. var start_time_check = $("#START_TIME_703").val();
  146. var affair_type = $("#EARLY_WARNING_NAME_703").val();
  147. $
  148. .ajax({
  149. url : $.pathname()
  150. + '/ws/xianlutingyun/XianlutingyunService/checkSpecialReport/',
  151. type : 'post',
  152. data : {
  153. start_time : start_time_check,
  154. affair_type : affair_type
  155. },
  156. async : false,
  157. dataType : 'text',
  158. success : function(data) {
  159. if (data != "") {
  160. top.Dialog
  161. .confirm(
  162. "当日已经有已发布的同类型的特殊报表任务,是否确认发布?",
  163. function() {
  164. //根据id结束已发布的特殊报表任务
  165. var params = {
  166. classid : "703",
  167. FD_OBJECTID703 : data,
  168. IS_RELEASE_703 : "2"
  169. };
  170. $
  171. .ajax({
  172. url : $.pathname()
  173. + '/ws/crud/CRUDService/update/',
  174. type : 'post',
  175. timeout : 15000,
  176. data : params,
  177. dataType : 'json',
  178. success : function(
  179. data) {
  180. top.Dialog
  181. .alert(
  182. '结束记录成功!',
  183. null,
  184. null,
  185. null,
  186. -1);
  187. //发布时才获取发布时间
  188. $("#SEND_TIME_703").val(getDateTime());
  189. //确定发布时才改变发布状态
  190. $("#IS_RELEASE_703").val("1");
  191. var formValue = $form.serialize();
  192. $
  193. .ajax({
  194. url : url,
  195. type : 'post',
  196. data : formValue,
  197. async : false,
  198. dataType : 'json',
  199. success : function(
  200. data) {
  201. top.Dialog
  202. .alert("新任务发布成功!");
  203. //获取iframe中的元素值
  204. var iframe = parent.document
  205. .getElementsByName("frmright")[0];
  206. iframe.src = "/nwyj/page/business/em/report/SpecialReport.jsp";
  207. },
  208. error : function(
  209. e) {
  210. $.messager
  211. .alert(
  212. '系统提示信息',
  213. '访问服务失败!',
  214. 'error');
  215. }
  216. });
  217. },
  218. error : function(e) {
  219. $.messager
  220. .alert(
  221. '系统提示信息',
  222. '访问服务失败!',
  223. 'error');
  224. }
  225. });
  226. }, function() {
  227. //点击取消取消发布
  228. return;
  229. });
  230. } else {
  231. top.Dialog.confirm("是否确认发布?",function(){
  232. //发布时才获取发布时间
  233. $("#SEND_TIME_703").val(getDateTime());
  234. //确定发布时才改变发布状态
  235. $("#IS_RELEASE_703").val("1");
  236. var formValue = $form.serialize();
  237. $.ajax({
  238. url :url,
  239. type : 'post',
  240. data : formValue,
  241. async : false,
  242. dataType : 'json',
  243. success : function(data) {
  244. top.Dialog.alert("发布成功!");
  245. //获取iframe中的元素值
  246. var iframe = parent.document
  247. .getElementsByName("frmright")[0];
  248. iframe.src = "/nwyj/page/business/em/report/SpecialReport.jsp";
  249. },
  250. error : function(e) {
  251. $.messager.alert('系统提示信息',
  252. '访问服务失败!', 'error');
  253. }
  254. });
  255. },function(){
  256. return;
  257. });
  258. }
  259. },
  260. error : function(e) {
  261. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  262. }
  263. });
  264. }
  265. };
  266. function formReset(){
  267. top.Dialog.confirm("确定要重置?将会清空填写的数据,请慎重选择|重置",
  268. function(){$('#frmright', window.parent.document).attr('src',$.pathname()+ '/scripts/business/em/response/report/addSpecialReportMission.jsp?fd_id='+fd_id);},
  269. function(){return;});
  270. };
  271. //初始化绑定按钮的点击事件
  272. function init() {
  273. $('#save').bind('click',function(){
  274. _this.save();
  275. });
  276. $("#saveAndRelease").bind("click",function(){
  277. _this.saveAndRelease();
  278. });
  279. $('#goback').bind('click',function(){
  280. $('#frmright', window.parent.document).attr('src',$.pathname()+ '/page/business/em/report/SpecialReport.jsp');
  281. });
  282. }
  283. //初始化页面
  284. $(function() {
  285. //加载按钮的点击事件
  286. init();
  287. //加载报表选择的下拉框
  288. initTypeSel();
  289. //获得reportid并赋值(见鬼了不知道为啥写jsp页面里没反应,只能写这里了)
  290. role_id = getReportRole();
  291. $("#ROLE_ID_703").val(role_id);
  292. });
  293. /**
  294. * 报表类型加载
  295. */
  296. function initTypeSel(){
  297. var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getRequireTypeSel";
  298. $.ajax({
  299. url : urls,
  300. type : 'post',
  301. timeout : 15000,
  302. async : false,
  303. data : {
  304. xg:"xg",
  305. "comp_id" : deptId
  306. },
  307. dataType : 'json',
  308. success : function(data) {
  309. for(var i=0;i<data.length;i++){
  310. var data1 = data[i].value;
  311. data1 = eval('('+data1+')');
  312. if(data[i].key=='R002105430211'){
  313. var special = {treeNodes:[]};
  314. for(var j = 0;j<data1.treeNodes.length;j++){
  315. if(data1.treeNodes[j].report_type=="114"||data1.treeNodes[j].report_type=="113"||data1.treeNodes[j].report_type=="115"||data1.treeNodes[j].report_type==""){
  316. special.treeNodes.push(data1.treeNodes[j]);
  317. }
  318. }
  319. debugger;
  320. $("#EQUIPMENT_DEPT").data("data",special);
  321. $("#EQUIPMENT_DEPT").render();
  322. }
  323. if(data[i].key=='R002105430213'){
  324. var special = {treeNodes:[]};
  325. for(var j = 0;j<data1.treeNodes.length;j++){
  326. if(data1.treeNodes[j].report_type=="110"||data1.treeNodes[j].report_type=="111"||data1.treeNodes[j].report_type=="108"||data1.treeNodes[j].report_type==""){
  327. special.treeNodes.push(data1.treeNodes[j]);
  328. }
  329. }
  330. $("#SAFEY_DEPT").data("data",special);
  331. $("#SAFEY_DEPT").render();
  332. }
  333. }
  334. },
  335. error : function(e) {
  336. $.messager.alert('查询报表类型失败', '访问服务失败!', 'error');
  337. }
  338. });
  339. }
  340. //将角色Id劈开
  341. function splits(val){
  342. relval = val.split(",")[0];
  343. return relval;
  344. }