南昌市物联网技防平台-前端
shuishen
2021-01-29 c0cba2f33dd6b1329b94d7ec4e4606fd46c28151
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
layui.use('laydate', function () {
  var laydate = layui.laydate;
 
  //执行一个laydate实例 开始
  laydate.render({
    elem: '#analysis_select_time_start', //指定元素
    type: "datetime",
    format: 'yyyy-MM-dd HH:mm:ss',
    btns: ['confirm'],
    trigger: 'click',
    max: getNowFormatDate(),
    change: function () {
      $('.laydate-btns-time').trigger('click');
    },
    done: function done(value) {
      $($(this)[0].elem[0]).val(value);
    },
    ready: function (date) {
      this.max = gerCurrentTime();
    }
  });
  // 结束
  laydate.render({
    elem: '#analysis_select_time_end', //指定元素
    type: "datetime",
    format: 'yyyy-MM-dd HH:mm:ss',
    btns: ['confirm'],
    trigger: 'click',
    max: getNowFormatDate(),
    min: getStartTime(),
    change: function () {
      $('.laydate-btns-time').trigger('click');
    },
    done: function done(value) {
      $($(this)[0].elem[0]).val(value);
    },
    ready: function (date) {
      this.max = gerCurrentTime();
      this.min = gerStarrtClickTime();
    }
  });
});
 
// 日期时间选择,做的一些限制,最大最小范围
function gerCurrentTime() {
  var timestamp = Date.parse(new Date());
  // 当前时间
  var currentTime = new Date(timestamp);
  // 年
  var currentY = currentTime.getFullYear();
  // 月
  var currentM = currentTime.getMonth();
  // 日
  var currentD = currentTime.getDate();
  // 时
  var currentH = currentTime.getHours();
  // 分
  var currentDd = currentTime.getMinutes();
  var currentS = currentTime.getSeconds();
  return {
    date: currentD,
    hours: currentH,
    minutes: currentDd,
    month: currentM,
    seconds: currentS,
    year: currentY
  }
}
 
function getNowFormatDate() {
  var date = new Date();
  var seperator1 = "-";
  var seperator2 = ":";
  var month = date.getMonth() + 1;
  var strDate = date.getDate();
  if (month >= 1 && month <= 9) {
    month = "0" + month;
  }
  if (strDate >= 0 && strDate <= 9) {
    strDate = "0" + strDate;
  }
  var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
    + " " + date.getHours() + seperator2 + date.getMinutes()
    + seperator2 + date.getSeconds();
  return currentdate;
}
 
function gerStarrtClickTime() {
  var time = $('#analysis_select_time_start').val();
  // 年
  var currentY = Number(time.substr(0, 4));
  // 月
  var currentM = Number(time.substr(5, 2)) - 1;
  // 日
  var currentD = Number(time.substr(8, 2));
  // 时
  var currentH = Number(time.substr(11, 2));
  // 分
  var currentDd = Number(time.substr(14, 2));
  var currentS = Number(time.substr(17, 2));
  return {
    date: currentD,
    hours: currentH,
    minutes: currentDd,
    month: currentM,
    seconds: currentS,
    year: currentY
  }
}
 
function getStartTime() {
  var time = $('#analysis_select_time_start').val();
  return time
}
 
$('.analysis-and-judgment-tab li').click(function () {
  $(this).addClass('on').siblings().removeClass('on');
  var ind = $(this).index();
  $($('.analysis-container > div')[ind]).stop().show().siblings().stop().hide();
})
 
// 警情信息中类别选择的点击事件
$('#policeCategory').mouseenter(function () {
  if ($('#policeCategory .select-list').is(':hidden')) {
    $('#policeCategory .select-list').stop().slideDown(0);
  }
})
 
$('#policeCategory').mouseleave(function () {
  if (!$('#policeCategory .select-list').is(':hidden')) {
    $('#policeCategory .select-list').stop().slideUp(0);
  }
})
 
// 警情信息类别,具体项的点击事件
$('.analysis-category .select-list').on('click', 'li', function () {
  var text = $(this).text();
  console.log($(this).parent().parent().prev());
  $(this).parent().parent().prev().html(text + '<i></i>');
  $(this).parent().parent().stop().slideUp(0);
})
 
// 时间查询
$('#policeSelectTime').click(function () {
  var times = $(this).prevAll();
  // 开始时间
  var startTime = $(times[1]).val();
  // 结束时间
  var endTime = $(times[0]).val();
})
 
var layerOpen = null;
 
 
$('.analysis-container-police .analysis-table-content .tbody tr').click(function () {
 
  if ($('.police-details')) {
    $('.police-details .layui-layer-setwin .layui-layer-close1').trigger('click');
  }
 
  // var obj = $(this).attr('details');
 
  var obj = { a: 1, b: 2, c: 'sdf' };
  var str = '';
  for (var i in obj) {
    str += i;
    str += ':';
    str += obj[i];
    str += ';';
  }
 
 
  var url = '../popup/html/police-details.html?obj=' + str;
 
  layui.use('layer', function () {
    var layer = layui.layer;
    layer.config({
      extend: 'myskin/police-details.css'
    });
 
    layer.open({
      title: '警情详情',
      type: 2,
      shadeClose: true,
      shade: false,
      maxmin: false, //开启最大化最小化按钮
      area: ['500px', '400px'],
      offset: 'auto',
      skin: 'police-details',
      content: url,
      closeBtn: 1,
    });
  })
})