| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- //'/service?wdApplication=env&wdService=env.getAllNz&wdToken=2&now=s'
- var nzinterval
- var data = {};
- var h6;
- var nzdatas;
- var errorTimes = 0;
- var maxErrorTimes = 3;
- initNz();
- function initData() {
- $.ajax({
- /* 改。Lin
- url: "/service?wdApplication=zzfb_&wdService=getAllNz&wdToken=2&now=" + new Date().Format("yyyy-MM-dd hh:mm:ss"),
- */ url: "/service?ssServ=selAllSched&ssToken=2&now="+ new Date().Format("yyyy-MM-dd hh:mm:ss"),
- // dataType:"json",
- success: function(dat) {
- data = eval("(" + dat + ")");
- nzdatas = document.getElementById("nzdatas");
- if (!nzdatas) {
- console.log("append");
- $("body").append("<div style='display:none' id='nzdatas'></div>");
- }
- console.log($("#nzdatas")[0]);
- document.getElementById("nzdatas").innerHTML = dat;
- if (data.length > 0 && h6) {
- var lis = '';
- var now = new Date();
- $.each(data, function(i) {
- var kssj = new Date(this.start);
- var sjstr;
- if (now.Format("yyyy-MM-dd") == kssj.Format("yyyy-MM-dd")) {
- sjstr = kssj.Format("hh:mm:ss");
- } else {
- sjstr = this.start;
- }
- lis += '<li id="' + this.id + "_" + this.rclbm + '">' + sjstr + ': ' + this.title + '</li>'
- if (i >= 10) {
- return false;
- }
- });
- var f = window.top.data[0];
- var fsj = new Date(f.start);
- var sj;
- if (now.Format("yyyy-MM-dd") == fsj.Format("yyyy-MM-dd")) {
- sj = fsj.Format("hh:mm:ss");
- } else {
- if(now.getFullYear() == fsj.getFullYear())
- sj = fsj.Format("MM-dd hh:mm:ss");
- else
- sj = f.start;
- }
- console.log("sj"+ sj);
- $.each(h6, function(index) {
- var s = "";
- if (data.length > 1) {
- s = "<span class='sho' onmouseover=\"$(this).parent().find('ul').show('fast','swing')\" onmouseleave=\"$(this).parent().find('ul').hide('fast','swing')\">▲<ul>" + lis + "</ul></span>";
- }
- $(this).html("<div><span id=\"" + f.id + "_" + f.rclbm + "\" >" + sj + ":" + f.title + "</span>" + s + "</div>");
- });
- } else if (data.length == 0) {
- $.each(h6, function(index) {
- $(this).html(new Date().Format("yyyy-MM-dd E"));
- });
- }
- $(h6).find("span").on("click", function(e) {
- var t = $(this);
- var id = t.attr("id");
- if (!id) {
- return;
- }
- window.top.rcapid = id;
- var jj = $(h6).parent().find(".showcal").eq(0).val();
- console.log(jj);
- eval(jj);
- return false;
- });
- $(h6).find("li").on('click', function(e) {
- var t = $(this);
- var id = t.attr("id");
- window.top.rcapid = id;
- var jj = $(h6).parent().find(".showcal").eq(0).val();
- console.log(jj);
- eval(jj);
- return false;
- });
- $(h6).find("div").on("click", function() {
- eval($(h6).parent().find(".showcal").eq(0).val());
- });
- },
- //请求出现错误
- error: function(dat){
- errorTimes++;
- //超过三次 删除定时器
- if(maxErrorTimes > errorTimes){
- ;
- }else{
- if(undefined != nzinterval)
- clearInterval(nzinterval);
- }
- },
- async: false
- });
- }
- function initNz() {
- if(!nzinterval) {
- nzinterval = setInterval(
- function() {
- var now = new Date();
- $.each(
- data,
- function(a) {
- var b = this
- var nowStr = now
- .Format("yyyy-MM-dd hh:mm:ss");
- var dataTime = new Date(b.start);
- var dataTimeStr = dataTime
- .Format("yyyy-MM-dd hh:mm:ss")
- if(nowStr == dataTimeStr) {
- // wd.display
- // .showComponent({
- // show: ["wdDialog"],
- // hide: [],
- // url: "/service?wdApplication=env&wdService=env.xgNz&wdOutputComponent=440122853&wdtest=false&wdComponentWebsite=4461&rcapid=" + b.id,
- // dest: "env.grsydialog.tip",
- // title: "闹钟提醒",
- // width: 650,
- // high: 450,
- // wdDialogId: 440122853,
- // form: ""
- // });
- //shownzjs = shownzjs.replace("ID=ID", "rcapid=" + b.id);
- var json = JSON.parse('{"ID":"'+b.id+'"}');
- shownzjs = wd.display.replaceDynamicParam(shownzjs, json);
- eval(shownzjs);
- //console.log(shownzjs);
- data.splice(a, 1);
- return false;
- }
- if(now > dataTime) { // 如果存在小于现在的时间,重新获取闹钟时间
- initData();
- return false;
- }
- });
- }, 1000);
- } else {
- initData();
- }
- }
|