c70257cbeb34589d0110997fd19e0f4e60dcb7df.svn-base 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. var pm = null;
  2. var su = null;
  3. var mid = null;
  4. var role_ids=null;
  5. var mfdStr = "";
  6. var isVisiblePage = "0";
  7. $(function(){
  8. pm = new ResourceMenu();
  9. su = new SearchUtil();
  10. role_ids=su.resolveUrl().role_id;
  11. });
  12. $(function(){
  13. mid = su.resolveUrl().mid;
  14. var fids = su.resolveUrl().fid;
  15. if(su.isLegitimate(fids)){
  16. fridArr = fids.split(",");
  17. for(var i = 0; i < fridArr.length; i++){
  18. pm.setMfdStr(fridArr[i]);
  19. };
  20. }
  21. });
  22. $(document).ready(function() {
  23. if(su.isLegitimate(mid)){
  24. pm.initPageByMarkerId();
  25. }else{
  26. pm.initPage();
  27. };
  28. // var a = pm.addParamsByTime(hms,"CORRESPONDING_DATE");
  29. // alert(JSON.stringify(a))
  30. // var b = pm.sortParams(a,"sortTime");
  31. // alert(JSON.stringify(b))
  32. });
  33. function setMfd(fid){
  34. window.parent.window.setResourceIdBymid(mid, fid);
  35. pm.setMfdStr(fid);
  36. mfdStr = pm.getMfdStr();
  37. pm.initPageByMarkerId();
  38. $(".first").click();
  39. };
  40. /**
  41. * 分页回调函数
  42. * @param page
  43. */
  44. function callBackChangePage(page){
  45. var url = '/nwyj/ws/icingZmap/IcingZmapService/getRescueSchedule';
  46. var param = {list_num:5, page_num:page, visible:isVisiblePage};
  47. if(su.isLegitimate(mid)){
  48. url = '/nwyj/ws/icingZmap/IcingZmapService/getRescueScheduleBymid';
  49. param = {list_num:5, page_num:page, mid:mid, fd_ids:pm.getMfdStr(), visible:isVisiblePage};
  50. };
  51. $.post(url, param, function(data){
  52. if(data.state=="success"){
  53. var params = pm.sortParams(data.rows,"SORT");
  54. pm.infoLeft(params);
  55. };
  56. }, "json");
  57. };
  58. /**
  59. * 刷新
  60. */
  61. function loadRefresh(){
  62. if(su.isLegitimate(mid)){
  63. pm.initPageByMarkerId();
  64. }else{
  65. pm.initPage();
  66. };
  67. $(".first").click();
  68. };
  69. var ResourceMenu = function(){
  70. var _this = this;
  71. var mfdStrr = "";
  72. this.setMfdStr = function(mfd){ mfdStrr += "'"+mfd+"',"; };
  73. this.getMfdStr = function(){
  74. if(mfdStrr==""||mfdStrr==undefined||mfdStrr==null){ return ""; }
  75. else{ return mfdStrr.substring(0, mfdStrr.length-1); }
  76. };
  77. this.initPage = function(){
  78. $.post('/nwyj/ws/icingZmap/IcingZmapService/getRescueScheduleCountPage', {list_num:5, visible:isVisiblePage}, function(data){
  79. if(data.state=="success"){
  80. $('.pagination').jqPagination({
  81. link_string : '/?page={page_number}',
  82. max_page : data.count_page,
  83. paged : function(page) {
  84. /* $('.log').prepend('<li>' + page + '</li>'); */
  85. }
  86. });
  87. };
  88. }, "json");
  89. };
  90. this.initPageByMarkerId = function(){
  91. $.post('/nwyj/ws/icingZmap/IcingZmapService/getRescueScheduleCountPageBymid', {list_num:5, visible:isVisiblePage, mid:mid, fd_ids:_this.getMfdStr()}, function(data){
  92. if(data.state=="success"){
  93. if(data.count_list=="0"){
  94. $("#left_grid").empty().append(_this.getAddBtn());
  95. };
  96. $("#left_grid").empty().append(_this.getAddBtn());
  97. $('.pagination').jqPagination({
  98. link_string : '/?page={page_number}',
  99. max_page : data.count_page,
  100. paged : function(page) {
  101. /* $('.log').prepend('<li>' + page + '</li>'); */
  102. }
  103. });
  104. };
  105. }, "json");
  106. };
  107. /**
  108. * 初始化左边
  109. */
  110. this.infoLeft = function(params){
  111. var $left_table = document.createElement("table");
  112. $($left_table).addClass("table-title").attr("cellpadding",0).attr("cellspacing","0");
  113. var $ct_tr = document.createElement("tr");
  114. var $ct_cz_td = document.createElement("td");
  115. $($ct_cz_td).attr("width","30").html("操作");
  116. var $ct_dw_td = document.createElement("td");
  117. $($ct_dw_td).attr("width","40").html("单位");
  118. var $ct_sn_td = document.createElement("td");
  119. $($ct_sn_td).attr("width","40").html("施工名称");
  120. var $ct_sd_td = document.createElement("td");
  121. $($ct_sd_td).attr("width","40").html("施工单位");
  122. var $ct_em_td = document.createElement("td");
  123. $($ct_em_td).attr("width","20");
  124. $($ct_tr).append($ct_cz_td).append($ct_dw_td).append($ct_sn_td).append($ct_sd_td).append($ct_em_td);
  125. $($left_table).append($ct_tr);
  126. for(var i=0; i<params.length; i++){
  127. var $con_tr = document.createElement("tr");
  128. var $edit_td = document.createElement("td");
  129. $($edit_td).attr("rowspan","2").append(_this.getOperationDom(params[i]));
  130. var $comp_td = document.createElement("td");
  131. $($comp_td).attr("rowspan","2").attr("title",params[i].RESCUE_COMP_ID_SHOW).html(params[i].RESCUE_COMP_ID_SHOW);
  132. var $sgn_td = document.createElement("td");
  133. $($sgn_td).attr("rowspan","2").attr("title",params[i].CONSTRUCTION_NAME).html(params[i].CONSTRUCTION_NAME);
  134. var $sgc_td = document.createElement("td");
  135. $($sgc_td).attr("rowspan","2").attr("title",params[i].CONSTRUCTION_COMP).html(params[i].CONSTRUCTION_COMP);
  136. var $plan_td = document.createElement("td");
  137. $($plan_td).html("计划").css("background","#fdd5b5");
  138. $($con_tr).append($edit_td).append($comp_td).append($sgn_td).append($sgc_td).append($plan_td).data("data",params[i]);
  139. var $reality_tr = document.createElement("tr");
  140. var $reality_td = document.createElement("td");
  141. $($reality_td).html("实际").css("background","#93cddd");
  142. $($reality_tr).append($reality_td);
  143. $($left_table).append($con_tr).append($reality_tr);
  144. };
  145. $("#left_grid").empty().append(_this.getAddBtn()).append($left_table);
  146. // _this.infoRight(params);//一个月
  147. _this.infoRightMuti(params);//多个月
  148. $(".plan_con").on("dblclick", function(){
  149. var param = $(this).parent().data("data");
  150. var cd = $(this).attr("parallelism-date");
  151. var pd = {RESCUE_ID:param.FD_OBJECTID, IS_PLAN:0, CORRESPONDING_DATE:cd};
  152. var fid = "";
  153. if($(this).find("div").hasClass("has_characters_describe")){
  154. var param = $(this).find("div").eq(0).data("data");
  155. fid = param.FD_OBJECTID;
  156. };
  157. window.parent.window.openResourceInfoEdit(fid, pd);
  158. });
  159. $(".reality_con").on("dblclick", function(){
  160. var param = $(this).parent().data("data");
  161. var cd = $(this).attr("parallelism-date");
  162. var pd = {RESCUE_ID:param.FD_OBJECTID, IS_PLAN:1, CORRESPONDING_DATE:cd};
  163. var fid = "";
  164. if($(this).find("div").hasClass("has_characters_describe")){
  165. var param = $(this).find("div").eq(0).data("data");
  166. fid = param.FD_OBJECTID;
  167. };
  168. window.parent.window.openResourceInfoEdit(fid, pd);
  169. });
  170. };
  171. /**
  172. * 新增按钮
  173. */
  174. this.getAddBtn = function(){
  175. var $tool_btn_div = document.createElement("div");
  176. var $add_btn = document.createElement("div");
  177. $($add_btn).addClass("add_btn").html("新增&nbsp;").on("click",function(){
  178. window.parent.window.openResourceEdit("", mid);
  179. });
  180. var $visible_btn = document.createElement("div");
  181. $($visible_btn).attr("id", "visible_btn").addClass("add_btn visible_btn_active").html("可见&nbsp;").on("click",function(){
  182. $("#hidden_btn").removeClass("isvisible_btn_active");
  183. $(this).addClass("isvisible_btn_active");
  184. isVisiblePage = "0";
  185. if(su.isLegitimate(mid)){
  186. _this.initPageByMarkerId();
  187. }else{
  188. _this.initPage();
  189. };
  190. });
  191. var $hidden_btn = document.createElement("div");
  192. $($hidden_btn).attr("id", "hidden_btn").addClass("add_btn").html("隐藏&nbsp;").on("click",function(){
  193. $("#visible_btn").removeClass("isvisible_btn_active");
  194. $(this).addClass("isvisible_btn_active");
  195. isVisiblePage = "1";
  196. if(su.isLegitimate(mid)){
  197. _this.initPageByMarkerId();
  198. }else{
  199. _this.initPage();
  200. };
  201. });
  202. if(role_ids.indexOf("R002105430335")>-1){//指挥看板操作员权限控制
  203. $($tool_btn_div).addClass("tool_btn_box").append($add_btn).append($visible_btn).append($hidden_btn);
  204. }
  205. //$($tool_btn_div).addClass("tool_btn_box").append($add_btn).append($visible_btn).append($hidden_btn);
  206. return $tool_btn_div;
  207. };
  208. /**
  209. * 动态创建分页工具栏/暂时废弃
  210. */
  211. this.getPageTool = function(){
  212. var $page_box = document.createElement("div");
  213. var $first_page_a = document.createElement("a");
  214. var $prev_page_a = document.createElement("a");
  215. var $next_page_a = document.createElement("a");
  216. var $last_page_a = document.createElement("a");
  217. var $show_page_input = document.createElement("input");
  218. $($first_page_a).addClass("first").attr("data-action","first").html("&laquo;");
  219. $($prev_page_a).addClass("previous").attr("data-action","previous").html("&lsaquo;");
  220. $($next_page_a).addClass("next").attr("data-action","next").html("&rsaquo;");
  221. $($last_page_a).addClass("last").attr("data-action","last").html("&raquo;");
  222. $($show_page_input).attr("type","text").attr("readonly","readonly");
  223. $($page_box).addClass("gigantic pagination").append($first_page_a).append($prev_page_a).append($show_page_input).append($next_page_a).append($last_page_a);
  224. return $page_box;
  225. };
  226. /**
  227. * 得到操作dom内容
  228. */
  229. this.getOperationDom = function(param){
  230. var $oper_div = document.createElement("div");
  231. var $edit = document.createElement("span");
  232. $($edit).addClass("img_edit hand").attr("title","修改").on("click",function(){
  233. var param = $(this).parent().data("data");
  234. window.parent.window.openResourceEdit(param.FD_OBJECTID);
  235. });
  236. var $del = document.createElement("span");
  237. $($del).addClass("img_delete hand").attr("title","删除").on("click",function(){
  238. var param = $(this).parent().data("data");
  239. var url = "/nwyj/ws/crud/CRUDService/delete/";
  240. var dp = { classid:"314", objectIDs:param.FD_OBJECTID };
  241. $.post(url, dp, function(data){
  242. if(data.Msg.sucsess){
  243. _this.initPage();
  244. $(".first").click();
  245. };
  246. }, "json");
  247. });
  248. var $hidden = document.createElement("span");
  249. $($hidden).addClass("img_delete hand").attr("title","隐藏").on("click",function(){
  250. var param = $(this).parent().data("data");
  251. var url = "/nwyj/ws/crud/CRUDService/delete/";
  252. var dp = { classid:"314", objectIDs:param.FD_OBJECTID };
  253. $.post(url, dp, function(data){
  254. if(data.Msg.sucsess){
  255. _this.initPage();
  256. $(".first").click();
  257. };
  258. }, "json");
  259. });
  260. $($oper_div).append($edit).append($hidden).append($del).data("data",param);
  261. return $oper_div;
  262. };
  263. /**
  264. * 排序
  265. */
  266. this.sortParams = function(params, sc){
  267. var resSort = params.sort(function(a,b){
  268. return a[sc] - b[sc];
  269. });
  270. return resSort;
  271. };
  272. /**
  273. * 时间转换
  274. */
  275. this.addParamsByTime = function(params, sc){
  276. for(var i=0; i < params.length; i++){
  277. var t = params[i][sc].replace(/-/g,"/");
  278. params[i]["sortTime"] = new Date(t).getTime() ;
  279. // params[i] = $(params[i]).attr("sortTime",new Date(params[i][sc]).getTime());
  280. };
  281. return params;
  282. };
  283. // /**
  284. // * 时间排序
  285. // */
  286. // this.sortParamsByTime = function(params, sc){
  287. // var resSort = params.sort(function(a,b){
  288. //
  289. // var o = new Date(a[sc]).getTime();
  290. // var t = new Date(a[sc]).getTime();
  291. // alert(o)1483452132000/1484316132000
  292. // if(o>t){
  293. // return a[sc];
  294. // }
  295. // return b[sc];
  296. // });
  297. // return resSort;
  298. // };
  299. /**
  300. * 得到显示的月份数组
  301. * @returns ["yyyy-MM"]
  302. */
  303. this.getDateArr = function(params){
  304. var dateArr = [];
  305. for(var i = 0; i < params.length; i++){
  306. dateArr.push(params[i].PLAY_START_TIME.substr(0,7));
  307. dateArr.push(params[i].PLAY_END_TIME.substr(0,7));
  308. dateArr.push(params[i].REALITY_START_TIME.substr(0,7));
  309. dateArr.push(params[i].REALITY_END_TIME.substr(0,7));
  310. };
  311. for(var i = 0 ;i<dateArr.length;i++){
  312. if(dateArr[i] == "" || typeof(dateArr[i]) == "undefined"){
  313. dateArr.splice(i,1);
  314. i= i-1;
  315. };
  316. };
  317. Array.prototype.clearRepeat = function(){
  318. var res = [];
  319. var json = {};
  320. for(var i = 0; i < this.length; i++){
  321. if(!json[this[i]]){
  322. res.push(this[i]);
  323. json[this[i]] = 1;
  324. };
  325. };
  326. return res;
  327. };
  328. return dateArr.clearRepeat();
  329. };
  330. /**
  331. * 初始化右边多个月
  332. */
  333. this.infoRightMuti = function(params){
  334. // var date = _this.allGetServerTime();
  335. var dates = _this.getDateArr(params);
  336. var $right_table = document.createElement("table");
  337. $($right_table).addClass("resource_crossing_chart");
  338. var $month_tr = document.createElement("tr");
  339. for(var i = 0; i < dates.length; i++){
  340. var dateJson = _this.getYearMonthByTest(dates[i]);
  341. var days = _this.getDaysOfMonth(dateJson.year,dateJson.month);
  342. var $month_td = document.createElement("td");
  343. $($month_td).addClass("crochar_title_month").html(dateJson.year+"年"+dateJson.month+"月");
  344. $($month_tr).append($month_td);
  345. };
  346. var $week_tr = document.createElement("tr");
  347. for(var j = 0; j < dates.length; j++){
  348. var dateJson = _this.getYearMonthByTest(dates[j]);
  349. var days = _this.getDaysOfMonth(dateJson.year,dateJson.month);
  350. for(var i = 1; i <= days; i++){
  351. var $week_td = document.createElement("td");
  352. var week = _this.getWeekShow(_this.getWeek(dateJson.year, dateJson.month, i));
  353. $($week_td).addClass("title_col").html(week);
  354. $($week_tr).append($week_td);
  355. };
  356. };
  357. var $day_tr = document.createElement("tr");
  358. for(var j = 0; j < dates.length; j++){
  359. var dateJson = _this.getYearMonthByTest(dates[j]);
  360. var days = _this.getDaysOfMonth(dateJson.year,dateJson.month);
  361. for(var i = 1; i <= days; i++){
  362. var $day_td = document.createElement("td");
  363. $($day_td).addClass("title_col").html(i);
  364. $($day_tr).append($day_td);
  365. };
  366. };
  367. $($right_table).append($month_tr).append($week_tr).append($day_tr);
  368. var fd_id_arr = [];
  369. for(var i = 0; i < params.length; i++){
  370. fd_id_arr.push(params[i].FD_OBJECTID);
  371. var $week_tr = document.createElement("tr");
  372. for(var j = 0; j < dates.length; j++){
  373. var dateJson = _this.getYearMonthByTest(dates[j]);
  374. var days = _this.getDaysOfMonth(dateJson.year,dateJson.month);
  375. for(var k = 1; k <= days; k++){
  376. var $week_td = document.createElement("td");
  377. var d = k < 10 ? "0"+k : k;
  378. $($week_td).addClass("title_col_con "+dateJson.year+"-"+dateJson.month+"-"+d+"_plan_con").attr("parallelism-date",dateJson.year+"-"+dateJson.month+"-"+d);
  379. if(_this.isLegitimate(params[i].PLAY_START_TIME) || _this.isLegitimate(params[i].PLAY_END_TIME)){
  380. var beginTime = params[i].PLAY_START_TIME;
  381. var endTime = params[i].PLAY_END_TIME;
  382. var nowTime = dateJson.year+"-"+dateJson.month+"-"+k;
  383. if(_this.date_range(beginTime, endTime, nowTime)){ $($week_td).addClass("plan_con"); };
  384. };
  385. $($week_tr).append($week_td).attr("FD_ID",params[i].FD_OBJECTID).addClass("plan_cell").data("data",params[i]);
  386. };
  387. };
  388. // $($week_tr).attr("FD_ID",params[i].FD_OBJECTID).addClass("plan_cell").data("data",params[i]);
  389. var $r_week_tr = document.createElement("tr");
  390. for(var j = 0; j < dates.length; j++){
  391. var dateJson = _this.getYearMonthByTest(dates[j]);
  392. var days = _this.getDaysOfMonth(dateJson.year,dateJson.month);
  393. for(var k = 1; k <= days; k++){
  394. var $week_td = document.createElement("td");
  395. var d = k < 10 ? "0"+k : k;
  396. $($week_td).addClass("title_col_con "+dateJson.year+"-"+dateJson.month+"-"+d+"_reality_con").attr("parallelism-date",dateJson.year+"-"+dateJson.month+"-"+d);
  397. if(_this.isLegitimate(params[i].REALITY_START_TIME) || _this.isLegitimate(params[i].REALITY_END_TIME)){
  398. var beginTime = params[i].REALITY_START_TIME;
  399. var endTime = params[i].REALITY_END_TIME;
  400. var nowTime = dateJson.year+"-"+dateJson.month+"-"+k;
  401. if(_this.date_range(beginTime, endTime, nowTime)){ $($week_td).addClass("reality_con"); };
  402. };
  403. $($r_week_tr).append($week_td).attr("FD_ID",params[i].FD_OBJECTID).addClass("reality_cell").data("data",params[i]);
  404. };
  405. $($right_table).append($week_tr).append($r_week_tr);
  406. };
  407. };
  408. $("#crossing_chart").empty().append($right_table);
  409. if(fd_id_arr.length>0){
  410. var fd_ids = "'"+fd_id_arr.join("','")+"'";
  411. var url = '/nwyj/ws/icingZmap/IcingZmapService/getRescueScheduleMessage' ;
  412. $.post(url, {fd_ids:fd_ids}, function(data){
  413. if(data.state=="success"){
  414. _this.appendMsg(data.rows);
  415. };
  416. },"json");
  417. };
  418. };
  419. /**
  420. * 添加日期备注
  421. */
  422. this.appendMsg = function(params){
  423. for(var i = 0; i < params.length; i++){
  424. var $char_desc_div = document.createElement("div");
  425. $($char_desc_div).addClass("has_characters_describe").data("data",params[i]);
  426. // var corr_date = param[i].CORRESPONDING_DATE.split(" ")[0];
  427. var corr_date = params[i].CORRESPONDING_DATE;
  428. var isp = params[i].IS_PLAN == "0" ? "plan_con":"reality_con";
  429. $("tr[fd_id='"+params[i].RESCUE_ID+"']").find("."+corr_date+"_"+isp).empty().eq(0).attr("title",params[i].RESCUE_MESSAGE).append($char_desc_div);
  430. };
  431. };
  432. /**
  433. * 初始化右边一个月
  434. */
  435. this.infoRight = function(params){
  436. var date = _this.allGetServerTime();
  437. var dateJson = _this.formatDateTimeByTest(date);
  438. var days = _this.getDaysOfMonth(dateJson.year,dateJson.month);
  439. var $right_table = document.createElement("table");
  440. $($right_table).addClass("resource_crossing_chart");
  441. var $month_tr = document.createElement("tr");
  442. var $month_td = document.createElement("td");
  443. $($month_td).addClass("crochar_title_month").html(dateJson.year+"年"+dateJson.month+"月");
  444. $($month_tr).append($month_td);
  445. $($right_table).append($month_tr).append(_this.getWeekColumns(days, dateJson)).append(_this.getDayColumns(days));
  446. for(var i = 0; i < params.length; i++){
  447. $($right_table).append(_this.getContentPlanCell(dateJson, days, params[i])).append(_this.getContentRealityCell(dateJson, days, params[i]));
  448. };
  449. $("#crossing_chart").empty().append($right_table);
  450. for(var i = 0; i < hms.length; i++){
  451. var $char_desc_div = document.createElement("div");
  452. $($char_desc_div).addClass("has_characters_describe");
  453. var corr_date = hms[i].CORRESPONDING_DATE.split(" ")[0];
  454. var isp = hms[i].IS_PLAN == "0" ? "plan_con":"reality_con";
  455. // alert(isp)
  456. $("tr[fd_id='"+hms[i].RESCUE_ID+"']").find("."+corr_date+"_"+isp).eq(0).attr("title",hms[i].RESCUE_MESSAGE).append($char_desc_div);
  457. };
  458. };
  459. /**
  460. * 得到星期表头
  461. * @param days 当月天数
  462. * @param dateJson 时间信息
  463. * @returns 星期表头$tr
  464. */
  465. this.getWeekColumns = function(days, dateJson){
  466. var $week_tr = document.createElement("tr");
  467. for(var i = 1; i <= days; i++){
  468. var $week_td = document.createElement("td");
  469. var week = _this.getWeekShow(_this.getWeek(dateJson.year, dateJson.month, i));
  470. $($week_td).addClass("title_col").html(week);
  471. $($week_tr).append($week_td);
  472. };
  473. return $week_tr;
  474. };
  475. /**
  476. * 得到日期表头
  477. * @param days 当月天数
  478. * @param dateJson 时间信息
  479. * @returns 日期表头$tr
  480. */
  481. this.getDayColumns = function(days, dateJson){
  482. var $week_tr = document.createElement("tr");
  483. for(var i = 1; i <= days; i++){
  484. var $week_td = document.createElement("td");
  485. $($week_td).addClass("title_col").html(i);
  486. $($week_tr).append($week_td);
  487. };
  488. return $week_tr;
  489. };
  490. /**
  491. * 得到计划详细表格
  492. * @param days 当月天数
  493. */
  494. this.getContentPlanCell = function(dateJson, days, params){
  495. var $week_tr = document.createElement("tr");
  496. for(var i = 1; i <= days; i++){
  497. var $week_td = document.createElement("td");
  498. var d = i < 10 ? "0"+i : i;
  499. $($week_td).addClass("title_col_con "+dateJson.year+"-"+dateJson.month+"-"+d+"_plan_con");
  500. if(_this.isLegitimate(params.PLAY_START_TIME) || _this.isLegitimate(params.PLAY_END_TIME)){
  501. var beginTime = params.PLAY_START_TIME.split(" ")[0];
  502. var endTime = params.PLAY_END_TIME.split(" ")[0];
  503. var nowTime = dateJson.year+"-"+dateJson.month+"-"+i;
  504. if(_this.date_range(beginTime, endTime, nowTime)){ $($week_td).addClass("plan_con"); };
  505. };
  506. $($week_tr).append($week_td).attr("FD_ID",params.FD_OBJECTID).addClass("plan_cell");
  507. };
  508. return $week_tr;
  509. };
  510. /**
  511. * 得到实际详细表格
  512. * @param days 当月天数
  513. */
  514. this.getContentRealityCell = function(dateJson, days, params){
  515. var $week_tr = document.createElement("tr");
  516. for(var i = 1; i <= days; i++){
  517. var $week_td = document.createElement("td");
  518. var d = i < 10 ? "0"+i : i;
  519. $($week_td).addClass("title_col_con "+dateJson.year+"-"+dateJson.month+"-"+d+"_reality_con");
  520. if(_this.isLegitimate(params.REALITY_START_TIME) || _this.isLegitimate(params.REALITY_END_TIME)){
  521. var beginTime = params.REALITY_START_TIME.split(" ")[0];
  522. var endTime = params.REALITY_END_TIME.split(" ")[0];
  523. var nowTime = dateJson.year+"-"+dateJson.month+"-"+i;
  524. if(_this.date_range(beginTime, endTime, nowTime)){ $($week_td).addClass("reality_con"); };
  525. };
  526. $($week_tr).append($week_td).attr("FD_ID",params.FD_OBJECTID).addClass("reality_cell");
  527. };
  528. return $week_tr;
  529. };
  530. /**
  531. * 判断参数是否合法
  532. * 如果是null/undefined/""/"null"/"undefined"返回false
  533. */
  534. this.isLegitimate = function(param){
  535. if(param==null || param==undefined || param=="" || param=="null" || param=="undefined"){
  536. return false;
  537. }else{
  538. return true;
  539. };
  540. };
  541. /**
  542. * 判断时间是否在某一时间区
  543. * @param beginTime 开始时间 yyyy-MM-dd
  544. * @param endTime 结束时间 yyyy-MM-dd
  545. * @param nowTime 要判断的时间 yyyy-MM-dd
  546. *
  547. */
  548. this.date_range = function (beginTime, endTime, nowTime) {
  549. var strb = beginTime.split ("-");
  550. if (strb.length != 3) { return false; };
  551. var stre = endTime.split ("-");
  552. if (stre.length != 3) { return false; };
  553. var strn = nowTime.split ("-");
  554. if (strn.length != 3) { return false; };
  555. var b = new Date ();
  556. var e = new Date ();
  557. var n = new Date ();
  558. b.setFullYear(strb[0]);
  559. b.setMonth (strb[1]);
  560. b.setDate (strb[2]);
  561. e.setFullYear (stre[0]);
  562. e.setMonth (stre[1]);
  563. e.setDate (stre[2]);
  564. n.setFullYear (strn[0]);
  565. n.setMonth (strn[1]);
  566. n.setDate (strn[2]);
  567. if (n.getTime () - b.getTime () >= 0 && n.getTime () - e.getTime () <= 0) {
  568. return true;
  569. } else {
  570. return false;
  571. };
  572. };
  573. // date_range ("2016-11-23", "2017-01-11", "2016-11-24");
  574. /**
  575. * 判断时间是否在某一时间区
  576. * @param beginTime 开始时间 hh:mm
  577. * @param endTime 结束时间 hh:mm
  578. * @param nowTime 要判断的时间 hh:mm
  579. *
  580. */
  581. this.time_range = function (beginTime, endTime, nowTime) {
  582. var strb = beginTime.split (":");
  583. if (strb.length != 2) {
  584. return false;
  585. }
  586. var stre = endTime.split (":");
  587. if (stre.length != 2) {
  588. return false;
  589. }
  590. var strn = nowTime.split (":");
  591. if (stre.length != 2) {
  592. return false;
  593. }
  594. var b = new Date ();
  595. var e = new Date ();
  596. var n = new Date ();
  597. b.setHours (strb[0]);
  598. b.setMinutes (strb[1]);
  599. e.setHours (stre[0]);
  600. e.setMinutes (stre[1]);
  601. n.setHours (strn[0]);
  602. n.setMinutes (strn[1]);
  603. if (n.getTime () - b.getTime () >= 0 && n.getTime () - e.getTime () <= 0) {
  604. return true;
  605. } else {
  606. return false;
  607. }
  608. };
  609. /**
  610. * 获取系统时间
  611. */
  612. this.allGetServerTime = function(){
  613. var nowTime = "";
  614. $.ajax({//后台获取系统当前时间
  615. url :'/nwyj/ws/response/responseService/getNowTime',
  616. type : 'post',
  617. dataType : 'text',
  618. async : false,
  619. timeout : 6000,
  620. success : function(result){
  621. nowTime=result;
  622. },error : function(e){
  623. //top.Dialog.alert("获取后台时间失败!");
  624. return new Date();
  625. }
  626. });
  627. // return nowTime.stringToDate();
  628. return nowTime;
  629. };
  630. /**
  631. * 得到日期类型时间{year:yyyy, md:mm/dd, hm:hh:mm, alltime:yyyy-mm-dd hh:mm:ss}
  632. * @param date 日期date
  633. * @returns {String}
  634. */
  635. this.getFormatDateTimeByMess = function(data){
  636. var month = data.getMonth() + 1 ;
  637. if(month<10)
  638. month = "0" + month ;
  639. var day = data.getDate() ;
  640. if(day<10)
  641. day = "0" + day ;
  642. var hour = data.getHours() ;
  643. if(hour<10)
  644. hour = "0" + hour ;
  645. var minute = data.getMinutes() ;
  646. if(minute<10)
  647. minute = "0" + minute ;
  648. var second = data.getSeconds() ;
  649. if(second<10)
  650. second = "0" + second ;
  651. return {year:data.getFullYear(), md: month + "/" + day, hm: hour + ":" + minute, alltime:data.getFullYear() + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second };
  652. };
  653. /**
  654. * 得到日期类型时间{year:yyyy, month:MM }
  655. * @param date 日期str
  656. * @returns {String}
  657. */
  658. this.getYearMonthByTest = function(data){
  659. // 2016-12
  660. var year = data.split("-")[0];
  661. var month = data.split("-")[1];
  662. return {year:year, month:month};
  663. };
  664. /**
  665. * 得到日期类型时间{year:yyyy, month:MM, day:dd, hh:hh, mm:mm, ss:ss, alltime:yyyy-mm-dd hh:mm:ss}
  666. * @param date 日期str
  667. * @returns {String}
  668. */
  669. this.formatDateTimeByTest = function(data){
  670. // 2016/12/19 13:44:05
  671. var a = data.split(" ");
  672. var year = a[0].split("-")[0];
  673. var month = a[0].split("-")[1];
  674. var day = a[0].split("-")[2];
  675. var hour = a[1].split(":")[0] ;
  676. var minute = a[1].split(":")[1] ;
  677. var second = a[1].split(":")[2] ;
  678. return {year:year, month:month, day:day, hour:hour, minute:minute, second:second, alltime:year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second };
  679. };
  680. /**
  681. * 获取当月天数
  682. * @param year 年str
  683. * @param month 月str
  684. * @returns {String}
  685. */
  686. this.getDaysOfMonth = function(year, month) {
  687. var d = new Date(year, month, 0);
  688. return d.getDate();
  689. };
  690. /**
  691. * 获取当天星期数
  692. * @param year 年str
  693. * @param month 月str
  694. * @param day 日str
  695. * @returns {String}
  696. */
  697. this.getWeek = function(year, month, day) {
  698. var d = new Date(year, month - 1, day);
  699. return d.getDay();
  700. };
  701. /**
  702. * 星期转换
  703. */
  704. this.getWeekShow = function(i) {
  705. switch (i) {
  706. case 0:
  707. return "日";
  708. case 1:
  709. return "一";
  710. case 2:
  711. return "二";
  712. case 3:
  713. return "三";
  714. case 4:
  715. return "四";
  716. case 5:
  717. return "五";
  718. case 6:
  719. return "六";
  720. }
  721. return "error";
  722. };
  723. };