tremble преди 4 години
родител
ревизия
d636b851bc
променени са 3 файла, в които са добавени 41 реда и са изтрити 40 реда
  1. 2 2
      index.html
  2. 16 19
      js/lib/sys-calendar.js
  3. 23 19
      js/showHardware.js

+ 2 - 2
index.html

@@ -136,7 +136,7 @@
                 <i class="iconfont iconquxiao"></i>
             </div>
         </div>
-        <div class="m-con">
+        <!-- <div class="m-con">
             <i class="iconfont iconquxiao"></i>
             <div class="monitorbody">
                 <div class="mvideo">
@@ -144,7 +144,7 @@
                 </div>
                 <div id="calendar"></div>
             </div>
-        </div>
+        </div> -->
     </div>
     <div id="popup">
         <div class="popup-content">

+ 16 - 19
js/lib/sys-calendar.js

@@ -55,6 +55,7 @@ Calendar.prototype = {
             "0100": "除夕"  
         },  
         newDate: new Date(),
+        currentDate:'',
         width: null,
         shwoLunar: false,
         showModeBtn: true,
@@ -91,6 +92,9 @@ Calendar.prototype = {
             $(".dropdown-month").removeClass("open");
             $(".dropdown-year").removeClass("open");
 
+            $('.calendar-table td').removeClass("calendar-today");
+            $(e.currentTarget).addClass("calendar-today")
+
             var cellDate = $(this).attr("title");
             var DataArry=[];
             var viewData = me.viewData;
@@ -99,6 +103,11 @@ Calendar.prototype = {
             var datajson=viewData[month];
             var date = parseInt(cellDate.split("年")[1].split("月")[1].split("日")[0]);
 
+            opts.currentDate = {
+                year:year,
+                month:month+1
+            }
+
             if (opts.mode == "year") {
                 if (opts.cellClick) opts.cellClick.call(me, datajson,e,me)
             }
@@ -182,6 +191,7 @@ Calendar.prototype = {
             if (beforeDate != afterDate) {
                 opts.newDate.setDate(opts.newDate.getDate() - 1);
             }
+            opts.mode == "month" ? me._refreshCalendar(opts.newDate,cycleData) : me._refreshYearCalendar(opts.newDate);
             $(parent).find(".calendar-month-text").text(monthText);
 
         })
@@ -842,30 +852,17 @@ Calendar.prototype = {
 }
 $.fn.calendar = function (options) {
 
-    var isSTR = typeof options == "string",
-        args, ret;
-
-    if (isSTR) {
-        args = $.makeArray(arguments)
-        args.splice(0, 1);
-    }
-
     var name = "calendar",
         type = Calendar;
 
-    var jq = this.each(function () {
-        var ui = $.data(this, name);
+    var ui = $.data(this, name);
 
-        if (!ui) {
-            ui = new type(this, options);
-            $.data(this, name, ui);
-        }
-        if (isSTR) {
-            ret = ui[options].apply(ui, args);
-        }
-    });
+    if (!ui) {
+        ui = new type(this, options);
+        $.data(this, name, ui);
+    }
 
-    return isSTR ? ret : jq;
+    return ui;
 };
 (function(w) {
 	/** 

+ 23 - 19
js/showHardware.js

@@ -392,33 +392,36 @@ $(function () {
 
     let { data,cellCb=()=>{},yearSelect=()=>{},monthCb=()=>{} } = params
       //日历方法
-      $("#calendar").calendar({
-      data: data, //记录数据
-      work: [],//上班时间
-      mode: "month",
-      shwoLunar:false,
-      width: 400,
-      cellClick: function (data) {
-        let item = data[0]
-        cellCb(item)
-      },
-      yearSelect: function (yearText) {
-        yearSelect(yearText)
-      },
-      monthClick: function (e, nextMonth, opts, me) {
-        monthCb(nextMonth)
-      }
-    });
+      let ret = $("#calendar").calendar({
+        data: data, //记录数据
+        work: [],//上班时间
+        mode: "month",
+        shwoLunar:false,
+        width: 400,
+        cellClick: function (data) {
+          let item = data[0]
+          cellCb(item)
+        },
+        yearSelect: function (yearText) {
+          yearSelect(yearText)
+        },
+        monthClick: function (e, nextMonth, opts, me) {
+          monthCb(nextMonth)
+        }
+      });
+
+      return ret
   }
 
-  window.loadCalendar({
+  let ret = window.loadCalendar({
     data:[{
-        'startDate': "2021-5-18",//有监控的日期
+        'startDate': "2021-05-18",//有监控的日期
         id:'传对应的id'
     }],
     //点击日期时间
     cellCb: (item)=> {
       console.log(item);
+      console.log(ret.options.currentDate);
     },
     yearSelect: (yearText)=> {
       console.log(yearText);
@@ -429,6 +432,7 @@ $(function () {
     
   })
 
+
   /*loadMonitor({
       id:"monitor",
       url:'http://14.215.216.123:18080/rtp/00A153DF/hls.m3u8'