alarmMan.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. var _this, dataObj = [],nowDate = null, nowEnna = "";
  2. new Vue({
  3. el: '#app',
  4. filters: {
  5. setTime(_key){
  6. let _sf = getDTime(new Date((_key+"").length>10?parseInt(_key):parseInt(_key)*1000));
  7. return _sf[0] + _sf[1];
  8. },
  9. setImg(_key,num){
  10. let _sfj = "";
  11. if(_key != undefined){
  12. let _safd = _key.split(";");
  13. let _arr = [];
  14. _safd.forEach(item =>{
  15. item = "https://www.enstation.vip:9443" + item.split(":8170")[1];
  16. if(item.indexOf("Waring") == -1){
  17. item = item.replace(/faceImg\/businessFile/g,"alarm_folder/display_image");
  18. }
  19. _arr.push(item);
  20. });
  21. _sfj = (num == 0?_arr[0]:_arr);
  22. }
  23. return _sfj
  24. }
  25. },
  26. data: function() {
  27. return {
  28. warmLi: [],
  29. ajaxType: 'alljc',
  30. curPage: 1,
  31. allTotal: 0,
  32. starDay: "",
  33. endDay: "",
  34. dataLi: [],
  35. vidSrc: "",
  36. dialogVisible: false,
  37. mapVisible: false
  38. }
  39. },
  40. created() {
  41. _this = this;
  42. nowDate = getDTime(new Date());
  43. nowEnna = JSON.parse(localStorage.getItem("nowShip"));
  44. _this.getWarmType();
  45. _this.initAjax();
  46. },
  47. mounted(){
  48. window.addEventListener('message',(data)=>{
  49. nowEnna = JSON.parse(localStorage.getItem("nowShip"));
  50. _this.initAjax();
  51. })
  52. },
  53. methods: {
  54. getWarmType(){
  55. let _ocjh = JSON.parse(getCookie("Admin-User"));
  56. let _show = (_ocjh.userId == 380);
  57. let _obj = [{
  58. label: '告警总览',
  59. show: true,
  60. children: [{
  61. label: '告警总览',
  62. type: 'alljc',
  63. show: true
  64. }]
  65. }, {
  66. label: '行为告警',
  67. show: false,
  68. children: [{
  69. label: '离岗检测',
  70. type: 'lgjc',
  71. show: true
  72. }, {
  73. label: '区域闯入',
  74. type: 'jjjc',
  75. show: !_show
  76. },{
  77. label: '打电话检测',
  78. type: 'ddhjc',
  79. show: true
  80. }, {
  81. label: '玩手机检测',
  82. type: 'wsjjc',
  83. show: true
  84. }, {
  85. label: '抽烟检测',
  86. type: 'xyjc',
  87. show: true
  88. },{
  89. label: '打瞌睡检测',
  90. type: 'dksjc',
  91. show: _show
  92. }, {
  93. label: '睡觉检测',
  94. type: 'sjjc',
  95. show: _show
  96. },{
  97. label: '瞭望检测',
  98. type: 'lwjc',
  99. show: _show
  100. }, {
  101. label: '巡检检测',
  102. type: 'xjjc',
  103. show: _show
  104. }, {
  105. label: '遮挡摄像头检测',
  106. type: 'zdjc',
  107. show: _show
  108. }]
  109. }, {
  110. label: '物品识别',
  111. show: false,
  112. children: [{
  113. label: '安全帽检测',
  114. type: 'tkjc',
  115. show: true
  116. }, {
  117. label: '工作服检测',
  118. type: 'gzfjc',
  119. show: true
  120. }, {
  121. label: '口罩检测',
  122. type: 'kzjc',
  123. show: !_show
  124. }, {
  125. label: '烟火识别',
  126. type: 'yhjc',
  127. show: !_show
  128. }]
  129. }];
  130. _this.warmLi = _obj;
  131. },
  132. initAjax(){
  133. if(nowEnna !=null && nowEnna != "null"&&nowEnna.en_name != ""&&nowEnna.en_name != null){
  134. const loading = this.$loading({
  135. background: 'rgba(0, 0, 0, 0.4)'
  136. })
  137. setTimeout(()=>{
  138. let _opts = {
  139. url: vipUrl + "/receive",
  140. type:"GET"
  141. };
  142. let _data = {
  143. // user: "ruigaozhuoyue",
  144. user: nowEnna.en_name,
  145. msgType: _this.ajaxType == "alljc"?"":_this.ajaxType,
  146. enddate: _this.endDay,
  147. startdate: _this.starDay,
  148. pageNum: (_this.curPage - 1),
  149. pageSize: 12,
  150. };
  151. let _hea = {
  152. "Authorization": "ZDhlNjhjOTAwM2EyJWd6eXolaWUldXNlciV6aF9DTg==",
  153. "Content-Type": "application/json;charset=UTF-8"
  154. };
  155. getAxios(_opts, _data, _hea).then((res) => {
  156. if(res.success&&res.data.length){
  157. _this.allTotal = res.total;
  158. _this.dataLi = res.data;
  159. }else{
  160. _this.allTotal = 0;
  161. _this.dataLi = [];
  162. }
  163. loading.close();
  164. })
  165. },200)
  166. }else{
  167. _this.allTotal = 0;
  168. _this.dataLi = [];
  169. }
  170. },
  171. changeShow(ind){
  172. _this.warmLi[ind].show = !_this.warmLi[ind].show
  173. },
  174. changType(e){
  175. let val = e.target.dataset.type;
  176. if(val != _this.ajaxType){
  177. _this.ajaxType = val;
  178. _this.curPage = 1;
  179. _this.initAjax();
  180. }
  181. },
  182. handleCurrentChange(val) {
  183. if(val != _this.curPage){
  184. _this.curPage = val;
  185. _this.checkQuery();
  186. }
  187. },
  188. seeVid(_src){
  189. _this.dialogVisible = true;
  190. if(_src.indexOf(":8170/") != -1){
  191. _this.vidSrc = `<video width="100%" controls autobuffer autoplay>
  192. <source src="https://www.enstation.vip:9443${_src.split(":8170")[1]}" type="video/mp4"></source>
  193. </video>`
  194. }else{
  195. _this.vidSrc = "";
  196. }
  197. },
  198. handleClose(done) {
  199. _this.vidSrc = "";
  200. _this.dialogVisible = false;
  201. _this.mapVisible = false;
  202. },
  203. seachLi(){
  204. _this.curPage = 1;
  205. _this.checkQuery();
  206. },
  207. checkQuery(){
  208. if((isNaN(_this.endDay)&&!isNaN(Date.parse(_this.endDay)))&&(!isNaN(_this.starDay)||isNaN(Date.parse(_this.starDay)))){
  209. _this.$message({
  210. message: '请选择开始时间!',
  211. type: 'warning'
  212. });
  213. return;
  214. }
  215. if((isNaN(_this.endDay)&&!isNaN(Date.parse(_this.endDay)))&&(isNaN(_this.starDay)&&!isNaN(Date.parse(_this.starDay)))){
  216. if(new Date(_this.endDay).getTime()<new Date(_this.starDay).getTime()){
  217. let a = _this.endDay;
  218. _this.endDay = _this.starDay;
  219. _this.starDay = a;
  220. }
  221. }else if((!isNaN(_this.endDay)||!isNaN(Date.parse(_this.endDay)))&&(isNaN(_this.starDay)&&!isNaN(Date.parse(_this.starDay)))){
  222. _this.endDay = nowDate[0];
  223. }
  224. _this.initAjax();
  225. },
  226. }
  227. })