alarmManage.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. var _this, dataObj = [],nowDate = null, nowYsy = "";
  2. var snData = { 412373470: "226940", 413871376: "226941" }
  3. new Vue({
  4. el: '#app',
  5. filters: {
  6. setTime(_key){
  7. let _sf = getDTime(new Date((_key+"").length>10?parseInt(_key):parseInt(_key)*1000));
  8. return _sf[0] + _sf[1];
  9. },
  10. setImg(_key,num){
  11. let _sfj = "";
  12. if(_key != undefined){
  13. let _safd = _key.split(";");
  14. let _arr = [];
  15. _safd.forEach(item =>{
  16. item = "https://www.enstation.vip:9443" + item.split(":8170")[1];
  17. if(item.indexOf("Waring") == -1){
  18. item = item.replace(/faceImg\/businessFile/g,"alarm_folder/display_image");
  19. }
  20. _arr.push(item);
  21. });
  22. _sfj = (num == 0?_arr[0]:_arr);
  23. }
  24. return _sfj
  25. },
  26. getType(_key){
  27. let _sf = "";
  28. switch(_key){
  29. case 'fd':
  30. _sf = "疲劳驾驶";
  31. break;
  32. case 'ya':
  33. _sf = "打哈欠";
  34. break;
  35. case 'cey':
  36. _sf = "闭眼";
  37. break;
  38. case 'am':
  39. _sf = "分神驾驶";
  40. break;
  41. case 't3d':
  42. _sf = "遮挡摄像头";
  43. break;
  44. case 'td':
  45. _sf = "超时驾驶";
  46. break;
  47. }
  48. return _sf;
  49. },
  50. },
  51. data: function() {
  52. return {
  53. warmLi: [],
  54. ajaxType: 'alljc',
  55. curPage: 1,
  56. allTotal: 0,
  57. starDay: "",
  58. endDay: "",
  59. dataLi: [],
  60. vidSrc: "",
  61. dialogVisible: false,
  62. dialogVisibleImg: false,
  63. queryRame: {
  64. "typestr": "",
  65. "startTime":"",
  66. "endTime":""
  67. },
  68. tableData: [],
  69. isGen: false,
  70. nowDetItem: {},
  71. imgSrc: ""
  72. }
  73. },
  74. created() {
  75. _this = this;
  76. nowDate = getDTime(new Date());
  77. _this.queryRame.startTime = nowDate[0];
  78. _this.queryRame.endTime = nowDate[0];
  79. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  80. _this.initAjax();
  81. _this.getWarmType();
  82. },
  83. mounted(){
  84. window.addEventListener('message',(data)=>{
  85. nowYsy = JSON.parse(localStorage.getItem("nowShip"));
  86. if(_this.isGen){
  87. _this.getAlarms();
  88. }else{
  89. _this.initAjax();
  90. }
  91. })
  92. },
  93. methods: {
  94. getWarmType(){
  95. let _ocjh = JSON.parse(getCookie("Admin-User"));
  96. let _show = (_ocjh.userId == 354);
  97. let _obj = [{
  98. label: '告警总览',
  99. show: true,
  100. children: [{
  101. label: '告警总览',
  102. type: 'alljc',
  103. show: true
  104. }]
  105. }, {
  106. label: '行为告警',
  107. show: false,
  108. children: [{
  109. label: '离岗检测',
  110. type: 'lgjc',
  111. show: true
  112. }, {
  113. label: '区域闯入',
  114. type: 'qycr',
  115. show: true
  116. },{
  117. label: '打电话检测',
  118. type: 'ddhjc',
  119. show: true
  120. }, {
  121. label: '玩手机检测',
  122. type: 'wsjjc',
  123. show: true
  124. }, {
  125. label: '抽烟检测',
  126. type: 'cyjc',
  127. show: true
  128. }, {
  129. label: '生理疲劳',
  130. type: 'gen,fd,ya,cey',
  131. show: _show
  132. },{
  133. label: '分神驾驶',
  134. type: 'gen,am',
  135. show: _show
  136. }, {
  137. label: '遮挡摄像头',
  138. type: 'gen,t3d',
  139. show: _show
  140. }, {
  141. label: '超时驾驶',
  142. type: 'gen,td',
  143. show: _show
  144. }]
  145. }, {
  146. label: '物品识别',
  147. show: false,
  148. children: [{
  149. label: '安全帽检测',
  150. type: 'aqmjc',
  151. show: true
  152. }, {
  153. label: '工作服检测',
  154. type: 'gzfjc',
  155. show: true
  156. }, {
  157. label: '口罩检测',
  158. type: 'kzjc',
  159. show: true
  160. }, {
  161. label: '烟火识别',
  162. type: 'yhjc',
  163. show: true
  164. }, {
  165. label: '船只识别',
  166. type: 'czsb',
  167. show: _show
  168. }]
  169. }];
  170. _this.warmLi = _obj;
  171. },
  172. initAjax(){
  173. if(nowYsy !=null && nowYsy != "null"&&nowYsy.en_name != ""&&nowYsy.en_name != null){
  174. const loading = this.$loading({
  175. background: 'rgba(0, 0, 0, 0.4)'
  176. })
  177. setTimeout(()=>{
  178. let _opts = {
  179. url: vipUrl + "/receive",
  180. type:"GET"
  181. };
  182. let _data = {
  183. // user: "ruigaozhuoyue",
  184. user: nowYsy.en_name,
  185. msgType: _this.ajaxType == "alljc"?"":_this.ajaxType,
  186. enddate: _this.endDay,
  187. startdate: _this.starDay,
  188. pageNum: (_this.curPage - 1),
  189. pageSize: 12,
  190. };
  191. let _hea = {
  192. "Authorization": "ZDhlNjhjOTAwM2EyJWd6eXolaWUldXNlciV6aF9DTg==",
  193. "Content-Type": "application/json;charset=UTF-8"
  194. };
  195. getAxios(_opts, _data, _hea).then((res) => {
  196. if(res.success&&res.data.length){
  197. _this.allTotal = res.total;
  198. _this.dataLi = res.data;
  199. }else{
  200. _this.allTotal = 0;
  201. _this.dataLi = [];
  202. }
  203. loading.close();
  204. })
  205. },200)
  206. }else{
  207. _this.allTotal = 0;
  208. _this.dataLi = [];
  209. }
  210. },
  211. getAlarms(){
  212. const loading = this.$loading({
  213. background: 'rgba(0, 0, 0, 0.4)'
  214. })
  215. setTimeout(()=>{
  216. let _opts = {
  217. "types": _this.queryRame.typestr.split(",").slice(1),
  218. "startTime": _this.queryRame.startTime+" 00:00:00",
  219. "endTime": _this.queryRame.endTime+" 23:59:59",
  220. "speedMin":null,
  221. "duration":null,
  222. "alarmSrcs":null,
  223. "states":null,
  224. "alarmLevels":[],
  225. "carId": snData[nowYsy.mmsi]
  226. }
  227. getAlarmById(_opts).then(res => {
  228. _this.tableData = res.result
  229. loading.close();
  230. })
  231. },200)
  232. },
  233. changeShow(ind){
  234. _this.warmLi[ind].show = !_this.warmLi[ind].show
  235. },
  236. changType(e){
  237. let val = e.target.dataset.type;
  238. if(val.indexOf("gen") == -1){
  239. _this.isGen = false;
  240. _this.queryRame.typestr = "";
  241. if(val != _this.ajaxType){
  242. _this.ajaxType = val;
  243. _this.curPage = 1;
  244. _this.initAjax();
  245. }
  246. }else{
  247. _this.isGen = true;
  248. _this.ajaxType = "";
  249. if(val != _this.queryRame.typestr){
  250. _this.queryRame.typestr = val;
  251. _this.getAlarms();
  252. }
  253. }
  254. },
  255. handleCurrentChange(val) {
  256. if(val != _this.curPage){
  257. _this.curPage = val;
  258. _this.checkQuery();
  259. }
  260. },
  261. seeVid(_src){
  262. _this.dialogVisible = true;
  263. if(_src.indexOf(":8170/") != -1){
  264. _this.vidSrc = `<video width="100%" controls autobuffer autoplay>
  265. <source src="https://www.enstation.vip:9443${_src.split(":8170")[1]}" type="video/mp4"></source>
  266. </video>`
  267. }else{
  268. _this.vidSrc = "";
  269. }
  270. },
  271. handleClose(done) {
  272. _this.vidSrc = "";
  273. _this.dialogVisible = false;
  274. },
  275. seeDetail(val, num){
  276. if(val.markx != _this.nowDetItem.markx){
  277. _this.nowDetItem = val;
  278. const loading = this.$loading({
  279. background: 'rgba(0, 0, 0, 0.4)'
  280. })
  281. setTimeout(()=>{
  282. let data = {
  283. "carId": val.carId,
  284. "endTime": val.endTime,
  285. "seq": "",
  286. "startTime": val.startTime,
  287. "types": [val.typeId]
  288. };
  289. getAlarmDetail(data).then(res => {
  290. if(res.result.length){
  291. let _obj = res.result[0];
  292. let _time = _obj["time"].split(' ');
  293. let _str = res.result.filter(item => item.type == 2);
  294. _this.imgSrc = `${nGenUrl}/gps-web/photos?refPath=${_time[0]}/${_obj.carId}/${_time[1].replace(/:/g,"")}_${_obj.mediaId}.jpg`;
  295. if(_str.length){
  296. let videoUrl = `${nGenUrl}/gps-web/photos?refPath=${_time[0]}/${_obj.carId}/${_time[1].replace(/:/g,"")}_${_str[0].mediaId}.mp4`;
  297. _this.vidSrc = `<video width="100%" controls autobuffer autoplay>
  298. <source src="${videoUrl}" type="video/mp4"></source>
  299. </video>`;
  300. }else{
  301. _this.vidSrc = "";
  302. }
  303. }else{
  304. _this.vidSrc = "";
  305. _this.imgSrc = "";
  306. }
  307. loading.close();
  308. if(num == 0){
  309. _this.dialogVisibleImg = true;
  310. }else{
  311. _this.dialogVisible = true;
  312. }
  313. })
  314. },200);
  315. }else{
  316. if(num == 0){
  317. _this.dialogVisibleImg = true;
  318. }else{
  319. _this.dialogVisible = true;
  320. }
  321. }
  322. },
  323. seachGenLi(){
  324. _this.getAlarms();
  325. },
  326. seachLi(){
  327. _this.curPage = 1;
  328. _this.checkQuery();
  329. },
  330. checkQuery(){
  331. if((isNaN(_this.endDay)&&!isNaN(Date.parse(_this.endDay)))&&(!isNaN(_this.starDay)||isNaN(Date.parse(_this.starDay)))){
  332. _this.$message({
  333. message: '请选择开始时间!',
  334. type: 'warning'
  335. });
  336. return;
  337. }
  338. if((isNaN(_this.endDay)&&!isNaN(Date.parse(_this.endDay)))&&(isNaN(_this.starDay)&&!isNaN(Date.parse(_this.starDay)))){
  339. if(new Date(_this.endDay).getTime()<new Date(_this.starDay).getTime()){
  340. let a = _this.endDay;
  341. _this.endDay = _this.starDay;
  342. _this.starDay = a;
  343. }
  344. }else if((!isNaN(_this.endDay)||!isNaN(Date.parse(_this.endDay)))&&(isNaN(_this.starDay)&&!isNaN(Date.parse(_this.starDay)))){
  345. _this.endDay = nowDate[0];
  346. }
  347. _this.initAjax();
  348. },
  349. }
  350. })