0615ada43c755ad6d3ae38d60100ac5088048c1e.svn-base 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  1. var corpId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
  2. //部门名称
  3. var deptName = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
  4. var deptId = top.com.sinosoft.lz.system.user.LoginInfo.getDeptids();
  5. //获取用户Id
  6. var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
  7. var _thisUrl = window.location.href;
  8. //获取role_id
  9. var role_id = getUrlParams("role_Id=",_thisUrl);//top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
  10. var real_name = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
  11. var addmessage =""; var relval;
  12. var sysval; var equipmentval; var markval;var safeyval;
  13. var systext;var equipmenttext;var marktext;var safetext;
  14. var temp;var roundtime;
  15. var flag = true;
  16. var roleSel = "";
  17. var roleObj = {"R002105430210":"系统运行部",
  18. "R002105430211":"生产设备部",
  19. "R002105430213":"安全监管部",
  20. "R002105430212":"市场营销部"};
  21. function initComplete(){
  22. var pepRole = role_id;
  23. if(pepRole=="R002105430200"){
  24. $(".tipsDiv").text("超级管理员没有固定模版");
  25. $(".tipsDiv").show();
  26. }
  27. $("#COMP_ID_337").val(corpId);
  28. $("#USER_ID_337").val(userId);
  29. $("#ROLE_ID_337").val( pepRole);
  30. $("#DEPT_337").val(deptName);
  31. $("#REAL_NAME_337").val(real_name);
  32. var deptUrl = $.pathname() + '/ws/xianlutingyun/XianlutingyunService/getChildComp';
  33. $.post(deptUrl,{role_id: pepRole,comp_id:corpId},function(data){
  34. if(data.treeNodes.length>0){
  35. for(var i=0;i<data.treeNodes.length;i++){
  36. if(data.treeNodes[i].id!=corpId){
  37. var $li = ("<li id='"+data.treeNodes[i].id+"'>"+data.treeNodes[i].name+"</li>");
  38. $("#WRITE_DEPT_SHOW").append($li);
  39. }
  40. }
  41. /*$("#WRITE_DEPT").data("data",data);
  42. $("#WRITE_DEPT").render();*/
  43. }else{
  44. top.Dialog.alert("您所在的公司没有下级单位,不能填报");
  45. }
  46. setBbContentHeight();
  47. }, "json");
  48. $("#WRITE_DEPT_SHOW").on("mouseenter","li",function(){
  49. $(this).addClass("hoverli");
  50. });
  51. $("#WRITE_DEPT_SHOW").on("mouseleave","li",function(){
  52. $(this).removeClass("hoverli");
  53. });
  54. $("#WRITE_DEPT_SHOW").on("click","li",function(){
  55. $("#inverse").removeClass("backcolor");
  56. $("#addAll").removeClass("backcolor");
  57. var _this = $(this);
  58. var id = _this.attr("id");
  59. if(_this.hasClass("selectedli")){
  60. _this.removeClass("selectedli");
  61. $("#WRITE_DEPT li").each(function(){
  62. if($(this).data("id")==id){
  63. $(this).remove();
  64. }
  65. });
  66. }else{
  67. _this.addClass("selectedli");
  68. var $li = $("<li class='selectCondi'>"+_this.text()+"</li>");
  69. $li.data("id",_this.attr("id"));
  70. $("#WRITE_DEPT").append($li);
  71. }
  72. $("#selectNum").text("已选择"+$("#WRITE_DEPT li").length+"个填报单位");
  73. // $(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  74. setBbContentHeight();
  75. });
  76. $("#WRITE_DEPT").on("click","li",function(){
  77. $("#inverse").removeClass("backcolor");
  78. $("#addAll").removeClass("backcolor");
  79. var _this = $(this);
  80. var id = _this.data("id");
  81. _this.remove();
  82. $("#WRITE_DEPT_SHOW li").each(function(){
  83. if(id==$(this).attr("id")){
  84. $(this).removeClass("selectedli");
  85. }
  86. });
  87. $("#selectNum").text("已选择"+$("#WRITE_DEPT li").length+"个填报单位");
  88. // $(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  89. setBbContentHeight();
  90. });
  91. $("#addAll").bind("click",function(){
  92. $("#inverse").removeClass("backcolor");
  93. $("#addAll").addClass("backcolor");
  94. $("#WRITE_DEPT").empty();
  95. $("#WRITE_DEPT_SHOW li").each(function(){
  96. var $li = $("<li class='selectCondi'>"+$(this).text()+"</li>");
  97. $li.data("id",$(this).attr("id"));
  98. $("#WRITE_DEPT").append($li);
  99. });
  100. $("#WRITE_DEPT_SHOW li").addClass("selectedli");
  101. $("#selectNum").text("已选择"+$("#WRITE_DEPT li").length+"个填报单位");
  102. // $(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  103. setBbContentHeight();
  104. });
  105. $("#inverse").bind("click",function(){
  106. if($("#WRITE_DEPT li").length<=0){
  107. return;
  108. }
  109. $("#inverse").addClass("backcolor");
  110. $("#addAll").removeClass("backcolor");
  111. $("#WRITE_DEPT").empty();
  112. $("#WRITE_DEPT_SHOW li").each(function(){
  113. var _this = $(this);
  114. //var id = _this.attr("id");
  115. if(_this.hasClass("selectedli")){
  116. _this.removeClass("selectedli");
  117. /*$("WRITE_DEPT li").each(function(){
  118. if(id==$(this).data("id")){
  119. $(this).remove();
  120. }
  121. });*/
  122. }else{
  123. _this.addClass("selectedli");
  124. var $li = $("<li class='selectCondi'>"+_this.text()+"</li>");
  125. $li.data("id",_this.attr("id"));
  126. $("#WRITE_DEPT").append($li);
  127. }
  128. });
  129. $("#selectNum").text("已选择"+$("#WRITE_DEPT li").length+"个填报单位");
  130. // $(parent.document.body).find("#frmright").height($(window.document.body).height()+30);
  131. setBbContentHeight();
  132. });
  133. //显示下拉框
  134. showData(pepRole);
  135. if(_thisUrl.indexOf('fd_id=')>-1){//代办进入页面
  136. $("#multiple").show();
  137. $("#single").hide();
  138. $("#save").hide();
  139. var fd_id = _thisUrl.split("?")[1].split("&")[0].split("=")[1];//获取记录id
  140. var proUrl = $.pathname() + '/ws/xianlutingyun/XianlutingyunService/getReportSchedule/';
  141. $.ajax({
  142. url:proUrl,
  143. type:'post',
  144. data:{"fd_id":fd_id,"role_id":role_id},
  145. ascyn:false,
  146. dataType:'json',
  147. success:function(data){
  148. $("#PROJECT_NAME").data("data",data);
  149. $("#PROJECT_NAME").render();
  150. getProjectName();
  151. },
  152. error:function(){
  153. $.messager.alert('系统提示信息', '查询填报计划名称失败', 'error');
  154. }
  155. });
  156. }else{
  157. $("#multiple").hide();
  158. $("#single").show();
  159. change('round');
  160. }
  161. checkScreenWidth();
  162. $("#back").hover(function(){
  163. $(this).attr("src","/nwyj/images/temp/back_hover.png");
  164. },function(){
  165. $(this).attr("src","/nwyj/images/temp/back.png");
  166. });
  167. }
  168. function getProjectName(){
  169. //要拆分的任务
  170. var fd_id = $("#PROJECT_NAME").attr("relValue");
  171. var cfRole = $("#PROJECT_NAME").data("selectedNode").cfRole;
  172. //判断cfRole中是否有拆分给下级已发布的任务
  173. var chFlag = "true";
  174. if(cfRole!=null && cfRole!="" && cfRole.indexOf(corpId)>-1){
  175. var cfRoleArr = cfRole.split("&");
  176. for(var i=0;i<cfRoleArr.length;i++){
  177. if(cfRoleArr[i].indexOf(corpId)>-1){
  178. var ch_fd_id = cfRoleArr[i].split(";")[2];
  179. chFlag = getThing($.pathname() + '/ws/xianlutingyun/XianlutingyunService/queryNextReportSchedule/', {"fd_id" : ch_fd_id}, "text");
  180. break;
  181. }
  182. }
  183. if(chFlag=="false"){
  184. getDataById(fd_id);
  185. return;
  186. }
  187. top.Dialog.confirm("该计划已拆分,是否继续拆分?|继续拆分",function(){
  188. getDataById(fd_id);
  189. },function(){
  190. goback();
  191. /*return;*/
  192. });
  193. }else{
  194. getDataById(fd_id);
  195. }
  196. }
  197. /**
  198. * 根据任务id获取信息
  199. * @param fd_id
  200. */
  201. function getDataById(fd_id){
  202. var url = $.pathname() + "/ws/crud/CRUDService/getDataById/";
  203. var params = {
  204. classid : '337',
  205. objectID : fd_id
  206. };
  207. $.ajax({
  208. url : url,
  209. type : 'post',
  210. timeout : 15000,
  211. data : params,
  212. dataType : 'json',
  213. success : function(data){
  214. if(data.PROJECT_NAME_337.indexOf("应急办")>=-1){
  215. data.PROJECT_NAME_337 = data.PROJECT_NAME_337.replace("应急办",roleObj[role_id]);
  216. }
  217. $("#PROJECT_NAME_337").val(data.PROJECT_NAME_337);
  218. $("#START_TIME_337").val(data.START_TIME_337);
  219. $("#END_TIME_337").val(data.END_TIME_337);
  220. $("#CF_ROLE_337").val(data.CF_ROLE_337);
  221. if(data.FILL_IN_SCHEDULE_337=="临时性"){
  222. temp = data.TEMPORARY_TIME_337;
  223. $("input:radio[name=FILL_IN_SCHEDULE_337]").eq(1).attr("checked",true);
  224. change('temporary');
  225. }else{
  226. temp = data.ROUND_TIME_337;
  227. $("input:radio[name=FILL_IN_SCHEDULE_337]").eq(0).attr("checked",true);
  228. change('round');
  229. }
  230. var timeArr = temp.split(";");
  231. for(var i=0;i<timeArr.length;i++){
  232. if(i!=0){
  233. $("#addBtn").click();
  234. }
  235. $("#time"+i).val(timeArr[i]);
  236. }
  237. var cfType = data.REPORT_DEPT_337.split(":")[0];
  238. showCfRequire(cfType,data.REPORT_DEPT_337,role_id);
  239. setBbContentHeight();
  240. },
  241. error : function(e){
  242. $.messager.alert('系统提示信息', '访问服务失败!', 'error');
  243. }
  244. });
  245. }
  246. function checkScreenWidth(){
  247. var W = window.screen.width;
  248. var H = window.screen.height;
  249. if(W=="1024"&&H=="768"){
  250. $("#buttonDiv").css("left","74.5%");
  251. }
  252. }
  253. function clear_msg(){
  254. top.Dialog.confirm("确定要重置?将会清空填写的数据,请慎重选择|重置", function() {
  255. $("#START_TIME_337").val("");
  256. $("#END_TIME_337").val("");
  257. //$(".selectTree").render();
  258. $("#PROJECT_NAME_337").val("");
  259. $("#round").attr("checked","checked");
  260. //$("#WRITE_DEPT").render();
  261. $("#WRITE_DEPT").empty();
  262. change("round");
  263. if((window.location.href).indexOf('?')>-1){
  264. document.location.reload();
  265. }
  266. });
  267. }
  268. //置换周期性、临时性
  269. function change(obj){
  270. timeindex = 0;
  271. if(obj=="round"){
  272. $("#tbsj").html("");
  273. var $td=$('<td class="circle_type" colspan="3" fixedCellHeight="true"></td>');
  274. var $date = $('<input type="text" class="date validate[required] round" id="time0" style="width:28%;" dateFmt="HH:mm" readOnly="readOnly"/>');
  275. var $add = $('<input type="button" id="addBtn" value="增加"/>');
  276. var $delete = $('<input type="button" id="addBtn" onclick="deleteTimeInput()" value="删除"/>');
  277. $add.bind("click",addTimeInput);
  278. $td.append($date);
  279. $td.append($add);
  280. $td.append($delete);
  281. $("#tbsj").append('<td width="15%" align="right" class="circle_type"><span class="star">*</span><span class="odd">每日:</span></td>');
  282. $("#tbsj").append($td);
  283. $add.render();
  284. $delete.render();
  285. $date.render();
  286. }
  287. if(obj=="temporary"){
  288. $("#tbsj").html("");
  289. var $td=$('<td class="temporary_type" colspan="3" fixedCellHeight="true"></td>');
  290. var $date = $('<input type="text" class="date validate[required] temporary" id="time0" style="width:28%;" dateFmt="yyyy-MM-dd HH:mm" readOnly="readOnly"/>');
  291. var $add = $('<input type="button" id="addBtn" value="增加"/>');
  292. var $delete = $('<input type="button" id="addBtn" onclick="deleteTimeInput()" value="删除"/>');
  293. $add.bind("click",addTimeInput);
  294. $td.append($date);
  295. $td.append($add);
  296. $td.append($delete);
  297. $("#tbsj").append('<td width="15%" align="right" class="temporary_type"><span class="star">*</span><span class="odd">填报时间:</span></td>');
  298. $("#tbsj").append($td);
  299. $add.render();
  300. $delete.render();
  301. $date.render();
  302. }
  303. }
  304. var timeindex = 0;
  305. //点击新增,增加一个时间选择框
  306. function addTimeInput(){
  307. var obj = getTimeId();
  308. /*if(checkTimeAdd("tbsj",obj,timeindex)){*/
  309. var addTime = $("#tbsj");
  310. var lastVal = addTime.find("."+obj).last().val();
  311. if(lastVal==""){
  312. top.Dialog.alert("请输入时间再进行添加");
  313. return false;
  314. }
  315. timeindex++;
  316. var $date ;
  317. if(obj=="round"){
  318. $date = $('<input type="text" id="time'+timeindex+'" class="date validate[required] round" style="width:28%;" dateFmt=" HH:mm" readOnly="readOnly"/>');
  319. }else{
  320. $date = $('<input type="text" id="time'+timeindex+'" class="date validate[required] temporary" style="width:28%;" dateFmt="yyyy-MM-dd HH:mm" readOnly="readOnly"/>');
  321. }
  322. $("#addBtn").before($date);
  323. $date.render();
  324. $("#addBtn").render();
  325. addTime.render();
  326. /*}*/
  327. }
  328. //点击删除,删除最后一个时间选择框
  329. function deleteTimeInput(){
  330. var $date = $("#tbsj").find(".date");
  331. if($date.length==1){
  332. return;
  333. }else{
  334. $date.last().remove();
  335. timeindex--;
  336. }
  337. }
  338. function sure(role,cfRole){
  339. var pattern = new RegExp("[`~!@#$^&*=|{}':;',\\[\\].<>/?~!@#¥……&*|{}【】‘;:”“'。,、?]");
  340. //var obj = getTimeId();
  341. if(!checkTime()){
  342. return;
  343. }else if(!decideTime()){
  344. return ;
  345. } else if(!checkTimes()){
  346. return;
  347. }/*else if(!checkTimeAdd("tbsj",obj,timeindex)){
  348. return;
  349. }*/else if(pattern.test($("#PROJECT_NAME_337").val())){
  350. top.Dialog.alert("计划名称不能包含特殊字符");
  351. return;
  352. }
  353. else{
  354. if($("#SYSTEM_DEPT").attr("relText")!="请选择"&&role=="R002105430210"){
  355. sysval = $("#SYSTEM_DEPT").attr("relValue");
  356. systext = $("#SYSTEM_DEPT").attr("relText");
  357. //addmessage = sysval+";"+$("#WRITE_DEPT").attr("relValue")+";"+systext;
  358. addmessage = sysval+";"+getCorpInfo('id')+";"+systext;
  359. }
  360. if($("#EQUIPMENT_DEPT").attr("relText")!="请选择"&&role=="R002105430211"){
  361. equipmentval = $("#EQUIPMENT_DEPT").attr("relValue");
  362. equipmenttext = $("#EQUIPMENT_DEPT").attr("relText");
  363. //addmessage = equipmentval+";"+$("#WRITE_DEPT").attr("relValue")+";"+equipmenttext;
  364. addmessage = equipmentval+";"+getCorpInfo('id')+";"+equipmenttext;
  365. }
  366. if($("#MARKETING_DEPT").attr("relText")!="请选择"&&role=="R002105430212"){
  367. //alert($("#MARKETING_DEPT").attr("relText"));
  368. markval = $("#MARKETING_DEPT").attr("relValue");
  369. marktext = $("#MARKETING_DEPT").attr("relText");
  370. //addmessage = markval+";"+$("#WRITE_DEPT").attr("relValue")+";"+marktext;
  371. addmessage = markval+";"+getCorpInfo('id')+";"+marktext;
  372. }
  373. if($("#SAFEY_DEPT").attr("relText")!="请选择"&&role=="R002105430213"){
  374. safeyval = $("#SAFEY_DEPT").attr("relValue");
  375. safetext = $("#SAFEY_DEPT").attr("relText");
  376. //addmessage = safeyval+";"+$("#WRITE_DEPT").attr("relValue")+";"+safetext;
  377. addmessage = safeyval+";"+getCorpInfo('id')+";"+safetext;
  378. }
  379. var messages = "专业管理部门:"+addmessage;
  380. $form = $("#requireForm");
  381. $("#REPORT_DEPT_337").val(messages.trim());
  382. //$("#DEPT_NAME_337").val($("#WRITE_DEPT").attr("relText"));
  383. $("#DEPT_NAME_337").val(getCorpInfo('name'));
  384. //判断本单位是否对上级任务已拆分,若已拆分则删除上次拆分给下级的任务(不区分是否已发布)
  385. var old_fdId = "";
  386. if(cfRole!=null && cfRole!="" && cfRole.indexOf(corpId)>-1){
  387. var fd_ids = cfRole.split("&");
  388. for(var i=0;i<fd_ids.length;i++){
  389. if(fd_ids[i].indexOf(corpId)>-1){
  390. old_fdId = fd_ids[i].split(";")[2];
  391. }
  392. }
  393. var is_del = getThing($.pathname() +"/ws/xianlutingyun/XianlutingyunService/deleteReportSchedule",{fd_id:old_fdId},'text');
  394. if(is_del=="false"){
  395. top.Dialog.alert("更新报表计划失败");
  396. }
  397. }
  398. //给下级生成任务
  399. var url = $.pathname() + '/ws/crud/CRUDService/create';
  400. $.ajax({
  401. url : url,
  402. type : 'post',
  403. data : $form.serialize(),
  404. dataType : 'json',
  405. timeout : 60000,
  406. success : function(data){
  407. //拆分给下级的任务id
  408. var new_fdId = data.Msg.objectID;
  409. if(_thisUrl.indexOf('fd_id=')>-1){//代办 进入
  410. var fd_id = $("#PROJECT_NAME").attr("relValue");//获取记录id
  411. //更新任务的拆分字段
  412. getThing($.pathname() +"/ws/xianlutingyun/XianlutingyunService/updateCfRole",{roleId:role_id,fd_id:fd_id,cf_role:cfRole,old_fdId:old_fdId,new_fdId:new_fdId,comp_id:corpId},'text');
  413. }
  414. top.Dialog.alert("保存成功",null,null,null,null);
  415. goback();
  416. },
  417. error : function(){
  418. top.Dialog.alert('操作失败');
  419. }
  420. });
  421. }
  422. }
  423. function save1(role,cfRole){
  424. var pattern = new RegExp("[`~!@#$^&*=|{}':;',\\[\\].<>/?~!@#¥……&*|{}【】‘;:”“'。,、?]");
  425. //var obj = getTimeId();
  426. if(!checkTime()){
  427. return;
  428. }else if(!decideTime()){
  429. return ;
  430. } else if(!checkTimes()){
  431. return;
  432. }/*else if(!checkTimeAdd("tbsj",obj,timeindex)){
  433. return;
  434. } */
  435. else if(pattern.test($("#PROJECT_NAME_337").val())){
  436. top.Dialog.alert("计划名称不能包含特殊字符");
  437. return;
  438. }
  439. else{
  440. if($("#SYSTEM_DEPT").attr("relText")!="请选择"&&role=='R002105430210'){
  441. sysval = $("#SYSTEM_DEPT").attr("relValue");
  442. systext = $("#SYSTEM_DEPT").attr("relText");
  443. //message = sysval+";"+$("#WRITE_DEPT").attr("relValue")+";"+systext;
  444. message = sysval+";"+getCorpInfo('id')+";"+systext;
  445. }
  446. if($("#EQUIPMENT_DEPT").attr("relText")!="请选择"&&role=="R002105430211"){
  447. equipmentval = $("#EQUIPMENT_DEPT").attr("relValue");
  448. equipmenttext = $("#EQUIPMENT_DEPT").attr("relText");
  449. //message = equipmentval+";"+$("#WRITE_DEPT").attr("relValue")+";"+equipmenttext;
  450. message = equipmentval+";"+getCorpInfo('id')+";"+equipmenttext;
  451. }
  452. if($("#MARKETING_DEPT").attr("relText")!="请选择"&&role=="R002105430212"){
  453. markval = $("#MARKETING_DEPT").attr("relValue");
  454. marktext = $("#MARKETING_DEPT").attr("relText");
  455. //message = markval+";"+$("#WRITE_DEPT").attr("relValue")+";"+marktext;
  456. message = markval+";"+getCorpInfo('id')+";"+marktext;
  457. }
  458. if($("#SAFEY_DEPT").attr("relText")!="请选择"&&role=="R002105430213"){
  459. safeyval = $("#SAFEY_DEPT").attr("relValue");
  460. safetext = $("#SAFEY_DEPT").attr("relText");
  461. //message = safeyval+";"+$("#WRITE_DEPT").attr("relValue")+";"+safetext;
  462. message = safeyval+";"+getCorpInfo('id')+";"+safetext;
  463. }
  464. var messages = "专业管理部门:"+message;
  465. $("#REPORT_DEPT_337").val(messages.trim());
  466. //$("#DEPT_NAME_337").val($("#WRITE_DEPT").attr("relText"));
  467. $("#DEPT_NAME_337").val(getCorpInfo('name'));
  468. var json=[{
  469. "ROLE_ID":$("#ROLE_ID_337").val(),
  470. "DEPT":$("#DEPT_337").val(),
  471. "REAL_NAME":$("#REAL_NAME_337").val(),
  472. "REPORT_DEPT":$("#REPORT_DEPT_337").val(),
  473. "DEPT_NAME":$("#DEPT_NAME_337").val(),
  474. "ROUND_TIME":$("#ROUND_TIME_337").val(),
  475. "TEMPORARY_TIME":$("#TEMPORARY_TIME_337").val(),
  476. "PROJECT":$("#PROJECT_NAME_337").val(),
  477. "START_TIME":$("#START_TIME_337").val(),
  478. "END_TIME":$("#END_TIME_337").val(),
  479. "FILL_IN_SCHEDULE": getVal()
  480. }];
  481. var jsons = JSON.stringify(json);
  482. $("body").eq(0).showLoading();
  483. var old_fdId = "";
  484. //判断本单位是否对上级任务已拆分,若已拆分则删除上次拆分给下级的任务(不区分是否已发布)
  485. if(cfRole!=null && cfRole!="" && cfRole.indexOf(corpId)>-1){
  486. var fd_ids = cfRole.split("&");
  487. for(var i=0;i<fd_ids.length;i++){
  488. if(fd_ids[i].indexOf(corpId)>-1){
  489. old_fdId = fd_ids[i].split(";")[2];
  490. }
  491. }
  492. var is_del = getThing($.pathname() +"/ws/xianlutingyun/XianlutingyunService/deleteReportSchedule",{fd_id:old_fdId},'text');
  493. if(is_del=="false"){
  494. top.Dialog.alert("更新报表计划失败");
  495. }
  496. }
  497. $.ajax({
  498. url : $.pathname()+ "/ws/xianlutingyun/XianlutingyunService/saveAndSend",
  499. type : 'post',
  500. data : {
  501. json:jsons,
  502. compId:corpId,
  503. userId:userId
  504. },
  505. dataType : 'json',
  506. timeout : 60000,
  507. success : function(data){
  508. $("body").eq(0).hideLoading();
  509. if(data[0].succ=="true"){
  510. var name=data[0].name;
  511. var tel=data[0].tel;
  512. //拆分给下级的任务id
  513. var new_fdId = data[0].fd_id;
  514. if(_thisUrl.indexOf('fd_id=')>-1){//代办 进入
  515. var fd_id = $("#PROJECT_NAME").attr("relValue");//获取记录id
  516. //更新任务的拆分字段
  517. getThing($.pathname() +"/ws/xianlutingyun/XianlutingyunService/updateCfRole",{roleId:role_id,fd_id:fd_id,cf_role:cfRole,old_fdId:old_fdId,new_fdId:new_fdId,comp_id:corpId},'text');
  518. }
  519. top.Dialog.confirm("保存并发布成功,是否发送短信?|发送短信",function(){
  520. addMsg(name,tel,"","1");
  521. },function(){
  522. goback();
  523. });
  524. }else{
  525. top.Dialog.alert("保存并发布失败");
  526. }
  527. },
  528. error : function(){
  529. top.Dialog.alert('操作失败');
  530. }
  531. });
  532. }
  533. }
  534. //获取填报单位
  535. function getCorpInfo(type){
  536. var corpIds = "";
  537. var corpNames = "";
  538. var len = $("#WRITE_DEPT li").length;
  539. for(var i=0;i<len;i++){
  540. if(i==len-1){
  541. corpIds += $("#WRITE_DEPT li").eq(i).data("id");
  542. corpNames += $("#WRITE_DEPT li").eq(i).text();
  543. }else{
  544. corpIds += $("#WRITE_DEPT li").eq(i).data("id")+",";
  545. corpNames += $("#WRITE_DEPT li").eq(i).text()+",";
  546. }
  547. }
  548. if(type=='id'){
  549. return corpIds;
  550. }
  551. if(type=='name'){
  552. return corpNames;
  553. }
  554. }
  555. function save(num) {
  556. var valid = $("#requireForm").validationEngine({
  557. returnIsValid : true
  558. });
  559. var rr=role_id;
  560. var obj = getTimeId();
  561. var cfRole = $("#CF_ROLE_337").val();
  562. if(_thisUrl.indexOf('fd_id=')>-1){
  563. if($("#PROJECT_NAME").attr("relText").trim()==""){
  564. top.Dialog.alert("请输入计划名称");
  565. return;
  566. }
  567. }else{
  568. if($("#PROJECT_NAME_337").val().trim()==""){
  569. top.Dialog.alert("请输入计划名称");
  570. return;
  571. }
  572. }
  573. if($("input[name=WRITE_DEPT]").val()==""){
  574. top.Dialog.alert("请选择填报单位");
  575. return;
  576. }
  577. if($("#START_TIME_337").val().trim()==""){
  578. top.Dialog.alert("请输入起始日期");
  579. return;
  580. }
  581. if(obj=="round"){
  582. var $inputs = $("#tbsj").find("input");
  583. for(var i=0;i<$inputs.length;i++){
  584. if($inputs.eq(i).val()==""){
  585. top.Dialog.alert("请输入第"+(i+1)+"个周期性时间");
  586. return;
  587. }
  588. }
  589. }
  590. if(obj=="temporary"){
  591. var $inputs = $("#tbsj").find("input");
  592. for(var i=0;i<$inputs.length;i++){
  593. if($inputs.eq(i).val()==""){
  594. top.Dialog.alert("请输入第"+(i+1)+"个临时性时间");
  595. return;
  596. }
  597. }
  598. }
  599. if(!$(".system").is(":hidden")&&$("#SYSTEM_DEPT").attr("relvalue")==""){
  600. top.Dialog.alert("请选择要填报的报表模版");
  601. return;
  602. }
  603. if(!$(".equipment").is(":hidden")&&$("#EQUIPMENT_DEPT").attr("relvalue")==""){
  604. top.Dialog.alert("请选择要填报的报表模版");
  605. return;
  606. }
  607. if(!$(".marking").is(":hidden")&&$("#MARKETING_DEPT").attr("relvalue")==""){
  608. top.Dialog.alert("请选择要填报的报表模版");
  609. return;
  610. }
  611. if(!$(".safe").is(":hidden")&&$("#SAFEY_DEPT").attr("relvalue")==""){
  612. top.Dialog.alert("请选择要填报的报表模版");
  613. return;
  614. }
  615. if($("#WRITE_DEPT").text()==""){
  616. top.Dialog.alert("请选择填报单位!");
  617. return;
  618. }
  619. if(valid==true&&num=="0"){
  620. save1(rr,cfRole);
  621. }else if(valid==true&&num=="1"){
  622. sure(rr,cfRole);
  623. }
  624. }
  625. //判断起始时间和截止时间不能小于当前日期
  626. function decideTime(){
  627. var star = $("#START_TIME_337").val();
  628. var end = $("#END_TIME_337").val();
  629. /*if(star==""||star==null||star==undefined||end==""||end==null||end==undefined){
  630. return;
  631. }*/
  632. if(star&&end&&(getTime()>star||getTime()>end)){
  633. top.Dialog.alert("起始日期和截止日期不能小于当前日期");
  634. return false;
  635. }else if(star&&(getTime()>star)){
  636. top.Dialog.alert("起始日期不能小于当前日期");
  637. return false;
  638. }
  639. else{
  640. return true;
  641. }
  642. }
  643. //获取当前日期
  644. function getTime(){
  645. var now=allGetServerTime();
  646. var year = now.getFullYear();
  647. var month=now.getMonth()+1;
  648. if(month>=1&&month<=9){
  649. month = "0"+month;
  650. }
  651. //获取日期
  652. var day=now.getDate();
  653. if(day>=1&&day<=9){
  654. day = "0"+day;
  655. }
  656. var currenttime = year+"-"+month+"-"+day;
  657. return currenttime;
  658. };
  659. //判定时间
  660. function checkTime(){
  661. var star = $("#START_TIME_337").val();
  662. var end = $("#END_TIME_337").val();
  663. star = star.substring(0,10);
  664. if(star&&end&&(star>end)){
  665. top.Dialog.alert("截止日期不能小于起始日期");
  666. return false;
  667. }else{
  668. return true;
  669. }
  670. }
  671. function goback(){
  672. var url = "";
  673. var len =_thisUrl.split("?")[1].split("&").length;
  674. if(len==1 || len==2){
  675. url = "/nwyj/page/business/em/report/Report_Require.jsp";
  676. }else{
  677. url ="/nwyj/page/business/em/waitdo/waitDo.html";
  678. }
  679. window.parent.document.getElementById("frmright").setAttribute("src",url);
  680. }
  681. //根据role_id 显示出不同的下拉框
  682. function showData(role,data){
  683. roleSel = getSelectedData(role);
  684. if(role=="R002105430210"){
  685. $("#mubang").text("系统运行部报表模版:");
  686. $(".system").show();
  687. $("#SYSTEM_DEPT").data("data",roleSel);
  688. $("#SYSTEM_DEPT").render();
  689. $("#SYSTEM_DEPT").addClass("validate[required]");
  690. }else
  691. if(role=="R002105430211"){
  692. $("#mubang").text("生产设备部报表模版:");
  693. $(".equipment").show();
  694. $("#EQUIPMENT_DEPT").data("data",roleSel);
  695. $("#EQUIPMENT_DEPT").render();
  696. $("#EQUIPMENT_DEPT").addClass("validate[required]");
  697. }else
  698. if(role=="R002105430213"){
  699. $("#mubang").text("安全监管部报表模版:");
  700. $(".safe").show();
  701. $("#SAFEY_DEPT").data("data",roleSel);
  702. $("#SAFEY_DEPT").render();
  703. $("#SAFEY_DEPT").addClass("validate[required]");
  704. }else
  705. if(role=="R002105430212"){
  706. $("#mubang").text("市场营销部报表模版:");
  707. $(".marking").show();
  708. $("#MARKETING_DEPT").data("data",roleSel);
  709. $("#MARKETING_DEPT").render();
  710. $("#MARKETING_DEPT").addClass("validate[required]");
  711. }
  712. else if(role=="R002105430200"){
  713. $("#mubang").text("超级管理员没有固定模板");
  714. $(".marking").show();
  715. //$("#MARKETING_DEPT").data("data",roleSel);
  716. //$("#MARKETING_DEPT").render();
  717. //$("#MARKETING_DEPT").addClass("validate[required]");
  718. }
  719. }
  720. function checkTimes(){
  721. var obj = getTimeId();
  722. var timeStr = "";
  723. var startTime = $("#START_TIME_337").val().substring(0,10);
  724. var endTime = $("#END_TIME_337").val();
  725. var $date = $("#tbsj").find(".date");
  726. for(var i=0;i<$date.length;i++){
  727. var time = $date.eq(i).val().trim();
  728. if(obj=="temporary"){
  729. var time1 = time.substring(0,10);
  730. if(startTime&&endTime&&(time1<startTime||time1>endTime)){
  731. top.Dialog.alert("填报时间要在起始日期和截止日期之间");
  732. return false;
  733. }else if(startTime&&(time1<startTime)){
  734. top.Dialog.alert("填报时间不能小于起始日期");
  735. return false;
  736. }
  737. }
  738. timeStr +=time+';';
  739. }
  740. timeStr = timeStr.substring(0, timeStr.lastIndexOf(";"));
  741. if(obj=="temporary"){
  742. $("#TEMPORARY_TIME_337").val(timeStr);
  743. }else{
  744. $("#ROUND_TIME_337").val(timeStr);
  745. }
  746. return true;
  747. }
  748. function getTimes(){
  749. var now=allGetServerTime();
  750. //获取年份
  751. var year=now.getFullYear();
  752. //获取月份
  753. var month=now.getMonth()+1;
  754. if(month>=1&&month<=9){
  755. month = "0"+month;
  756. }
  757. //获取日期
  758. var day=now.getDate();
  759. if(day>=1&&day<=9){
  760. day = "0"+day;
  761. }
  762. //获取小时
  763. var hours=now.getHours();
  764. if(hours>=1&&hours<=9){
  765. hours = "0"+hours;
  766. }
  767. //获取分钟
  768. var minutes=now.getMinutes();
  769. if(minutes>=1&&minutes<=9){
  770. minutes = "0"+minutes;
  771. }
  772. //获取秒
  773. var seconds=now.getSeconds();
  774. if(seconds>=1&&seconds<=9){
  775. seconds = "0"+seconds;
  776. }
  777. var currentTime =year+"-"+month+"-"+day+" "+hours+":"+minutes+":"+seconds;
  778. return currentTime;
  779. }
  780. function getVal(){
  781. $int=$("#int").find("input");
  782. for(var i=0;i<$int.length;i++){
  783. if($int.eq(i).attr("checked")=="checked"){
  784. return $int.eq(i).val();
  785. }
  786. }
  787. }
  788. function getTimeId(){
  789. var $radio = $("#int :radio");
  790. var obj = "";
  791. for(var i=0;i<$radio.length;i++){
  792. if($radio.eq(i).attr("checked")=="checked"){
  793. obj = $radio.eq(i).attr("id");
  794. }
  795. }
  796. return obj;
  797. }
  798. function getSelectedData(r){
  799. var roleSelect="";
  800. var url = $.pathname() + '/ws/xianlutingyun/XianlutingyunService/getZYGLBMTypeSel';
  801. $.ajax({
  802. url : url,
  803. type : 'post',
  804. data : {role_id:r},
  805. dataType : 'json',
  806. timeout : 60000,
  807. async:false,
  808. success : function(data){
  809. roleSelect=data;
  810. },
  811. error : function(){
  812. top.Dialog.alert('操作失败');
  813. }
  814. });
  815. return roleSelect;
  816. }
  817. function checkName(arr,str){
  818. var val = "" ;
  819. for(var i=0;i<arr.length;i++){
  820. for(var j=0;j<str.length;j++){
  821. if(arr[i].name==str[j]){
  822. val += arr[i].id+",";
  823. }
  824. }
  825. }
  826. val = val.substring(0, val.lastIndexOf(","));
  827. return val;
  828. }
  829. function getUrlParams(msg,url){
  830. if(msg!=""&&url.indexOf(msg)>-1&&url.indexOf("&")==-1){
  831. return url.split("?")[1].split("=")[1];
  832. }else{
  833. return url.split("?")[1].split("&")[1].split("=")[1];
  834. }
  835. }
  836. function showCfRequire(dept,deptMessage,pepRole){
  837. if(dept=="应急办"){
  838. var message = deptMessage.split(":")[1].split("|");
  839. var depts = "";
  840. var tables = "";
  841. var tableArr = roleSel.treeNodes;
  842. var setVal="";
  843. if( pepRole=="R002105430210"){
  844. for(var i=0;i<message.length;i++){
  845. depts = message[i].split(";")[0];
  846. if(depts=="R002105430210"){
  847. tables = message[i].split(";")[1].split(",");
  848. setVal = checkName(tableArr,tables);
  849. }
  850. }
  851. $("#SYSTEM_DEPT").setValue(setVal);
  852. }
  853. if( pepRole=="R002105430211"){
  854. for(var i=0;i<message.length;i++){
  855. depts = message[i].split(";")[0];
  856. if(depts=="R002105430211"){
  857. tables = message[i].split(";")[1].split(",");
  858. setVal =checkName(tableArr,tables);
  859. }
  860. }
  861. $("#EQUIPMENT_DEPT").setValue(setVal);
  862. }
  863. if( pepRole=="R002105430212"){
  864. for(var i=0;i<message.length;i++){
  865. depts = message[i].split(";")[0];
  866. if(depts=="R002105430212"){
  867. tables = message[i].split(";")[1].split(",");
  868. setVal =checkName(tableArr,tables);
  869. }
  870. }
  871. $("#MARKETING_DEPT").setValue(setVal);
  872. }
  873. if( pepRole=="R002105430213"){
  874. for(var i=0;i<message.length;i++){
  875. depts = message[i].split(";")[0];
  876. if(depts=="R002105430213"){
  877. tables = message[i].split(";")[1].split(",");
  878. setVal =checkName(tableArr,tables);
  879. }
  880. }
  881. $("#SAFEY_DEPT").setValue(setVal);
  882. }
  883. }else{
  884. var message = deptMessage.split(":")[1].split(";")[0];
  885. if(pepRole=="R002105430210"){
  886. $("#SYSTEM_DEPT").setValue(message);
  887. }else if(pepRole=="R002105430211"){
  888. $("#EQUIPMENT_DEPT").setValue(message);
  889. }else if(pepRole=="R002105430212"){
  890. $("#MARKETING_DEPT").setValue(message);
  891. }else if(pepRole=="R002105430213"){
  892. $("#SAFEY_DEPT").setValue(message);
  893. }
  894. }
  895. }
  896. function setBbContentHeight(){
  897. var content = $(".box1").height();
  898. $(window.document.body).height(content+20);
  899. $(parent.document.body).find("#frmright").height($(window.document.body).height());
  900. }