星火管控前端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

index.js 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. // 东八区时间差
  2. let _timezone = 8; //目标时区时间,东八区 东时区正数 西时区负数
  3. let _offset_GMT = new Date().getTimezoneOffset(); // 本地时间和格林威治的时间差,单位为分钟
  4. let diffTime = _offset_GMT * 60 * 1000 + _timezone * 60 * 60 * 1000; //0
  5. /**
  6. * 字符串是6-16位的大小写英文字母、数字组合。
  7. */
  8. export const reg = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{6,16}$/;
  9. /**
  10. * 字符串是6-16位的大小写英文字母、数字组合。
  11. */
  12. export const pwdCheck = (rule, value, callback) => {
  13. if (!reg.test(value)) {
  14. return callback(new Error("密码格式不正确!"));
  15. } else {
  16. callback();
  17. }
  18. };
  19. export const codeCheck = (rule, value, callback) => {
  20. if ((value && value.length !== 6) || !value) {
  21. return callback(new Error("请输入6位区域码!"));
  22. } else {
  23. callback();
  24. }
  25. };
  26. export const padDevices = [
  27. {
  28. pdorder: 1,
  29. pdtype: "摄像头",
  30. enabled: 1,
  31. icon: "ivu-icon iconfont icon-ball-camera"
  32. },
  33. {
  34. pdorder: 2,
  35. pdtype: "GPS",
  36. enabled: 1,
  37. icon: "ivu-icon iconfont icon-GPSxinxi"
  38. },
  39. {
  40. pdorder: 3,
  41. pdtype: "蓝牙",
  42. enabled: 2,
  43. icon: "ivu-icon iconfont icon-lanya"
  44. },
  45. {
  46. pdorder: 4,
  47. pdtype: "USB连接",
  48. enabled: 2,
  49. icon: "ivu-icon iconfont icon-USB"
  50. },
  51. {
  52. pdorder: 5,
  53. pdtype: "电话短信",
  54. enabled: 2,
  55. icon: "ivu-icon iconfont icon-dianhuaduanxin_line"
  56. },
  57. {
  58. pdorder: 6,
  59. pdtype: "数据流量",
  60. enabled: 2,
  61. icon: "ivu-icon iconfont icon-liuliang"
  62. },
  63. {
  64. pdorder: 7,
  65. pdtype: "Wi-Fi高级选项",
  66. enabled: 2,
  67. icon: "ivu-icon iconfont icon-wifiguanbi"
  68. },
  69. {
  70. pdorder: 8,
  71. pdtype: "SD卡",
  72. enabled: 2,
  73. icon: "ivu-icon iconfont icon-sdka-09"
  74. },
  75. {
  76. pdorder: 9,
  77. pdtype: "OTG",
  78. enabled: 2,
  79. icon: "ivu-icon iconfont icon-icon-OTG"
  80. }
  81. ];
  82. export const padViolates = [
  83. {
  84. title: "已ROOT",
  85. violateType: 1,
  86. checked: false,
  87. noticed: false,
  88. handleMethod: ""
  89. },
  90. {
  91. title: "安装非商店应用",
  92. violateType: 2,
  93. checked: false,
  94. noticed: false,
  95. handleMethod: ""
  96. },
  97. {
  98. title: "更换SIM卡",
  99. violateType: 3,
  100. checked: false,
  101. noticed: false,
  102. handleMethod: ""
  103. },
  104. {
  105. title: "USB连接电脑",
  106. violateType: 4,
  107. checked: false,
  108. noticed: false,
  109. handleMethod: ""
  110. }
  111. ];
  112. export const weekDay = [
  113. {
  114. label: "周日",
  115. alias: "星期日",
  116. value: 7
  117. },
  118. {
  119. label: "周一",
  120. alias: "星期一",
  121. value: 1
  122. },
  123. {
  124. label: "周二",
  125. alias: "星期二",
  126. value: 2
  127. },
  128. {
  129. label: "周三",
  130. alias: "星期三",
  131. value: 3
  132. },
  133. {
  134. label: "周四",
  135. alias: "星期四",
  136. value: 4
  137. },
  138. {
  139. label: "周五",
  140. alias: "星期五",
  141. value: 5
  142. },
  143. {
  144. label: "周六",
  145. alias: "星期六",
  146. value: 6
  147. }
  148. ];
  149. export const getWeekNameFromVal = (val, useAlias = false) => {
  150. const week = weekDay.filter((v) => {
  151. return v.value === val;
  152. });
  153. if (week.length > 0) {
  154. return useAlias ? week[0].alias : week[0].label;
  155. }
  156. return "";
  157. };
  158. export const getWeekDateName = (date, useAlias = false) => {
  159. const week = weekDay.map((v) => {
  160. return useAlias ? v.alias : v.label;
  161. });
  162. const index = new Date(date).getDay();
  163. return useAlias ? week[index].alias : week[index].label;
  164. };
  165. export const toChinesNum = (num) => {
  166. let changeNum = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九"];
  167. let unit = ["", "十", "百", "千", "万"];
  168. num = parseInt(num);
  169. let getWan = (temp) => {
  170. let strArr = temp.toString().split("").reverse();
  171. let newNum = "";
  172. for (var i = 0; i < strArr.length; i++) {
  173. newNum =
  174. (i == 0 && strArr[i] == 0
  175. ? ""
  176. : i > 0 && strArr[i] == 0 && strArr[i - 1] == 0
  177. ? ""
  178. : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i])) +
  179. newNum;
  180. }
  181. return newNum;
  182. };
  183. let overWan = Math.floor(num / 10000);
  184. let noWan = num % 10000;
  185. if (noWan.toString().length < 4) {
  186. noWan = "0" + noWan;
  187. }
  188. return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
  189. };
  190. // 保留小数(四舍五入)
  191. export const fomatFloat = (src, pos) => {
  192. return Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos);
  193. };
  194. export const setStringToDate = (timeStr) => {
  195. // IE不能识别字符串日期
  196. let splitArray = timeStr.split(" ");
  197. let dateArray = splitArray[0].split("-");
  198. let d = new Date();
  199. d.setFullYear(dateArray[0], dateArray[1] - 1, dateArray[2]);
  200. d.setHours(0);
  201. d.setMinutes(0);
  202. d.setSeconds(0);
  203. return d;
  204. };
  205. // 获取当前时间
  206. export const getNow = () => {
  207. var date = new Date();
  208. var year = date.getFullYear();
  209. var month = date.getMonth() + 1;
  210. var day = date.getDate();
  211. if (month < 10) {
  212. month = "0" + month;
  213. }
  214. if (day < 10) {
  215. day = "0" + day;
  216. }
  217. return year + month + day;
  218. };
  219. /**
  220. * 格式化秒
  221. * @param int value 总秒数
  222. * @return string result 格式化后的字符串
  223. */
  224. export const formatSeconds = (value) => {
  225. var theTime = parseInt(value); // 需要转换的时间秒
  226. var theTime1 = 0; // 分
  227. var theTime2 = 0; // 小时
  228. if (theTime > 60) {
  229. theTime1 = parseInt(theTime / 60);
  230. theTime = parseInt(theTime % 60);
  231. if (theTime1 > 60) {
  232. theTime2 = parseInt(theTime1 / 60);
  233. theTime1 = parseInt(theTime1 % 60);
  234. }
  235. }
  236. var result = "";
  237. if (theTime === 0 && theTime1 === 0 && theTime2 === 0) {
  238. result = "0秒";
  239. }
  240. if (theTime > 0) {
  241. result = "" + parseInt(theTime) + "秒";
  242. }
  243. if (theTime1 > 0) {
  244. result = "" + parseInt(theTime1) + "分" + result;
  245. }
  246. if (theTime2 > 0) {
  247. result = "" + parseInt(theTime2) + "小时" + result;
  248. }
  249. return result;
  250. };
  251. /**
  252. * 格式化秒
  253. * @param int value 总秒数
  254. * @return string result 格式化后的字符串 HH:mm:ss
  255. */
  256. export const format_seconds = (value) => {
  257. let theTime = parseInt(value); // 需要转换的时间秒
  258. let theTime1 = 0; // 分
  259. let theTime2 = 0; // 小时
  260. if (theTime > 60) {
  261. theTime1 = parseInt(theTime / 60);
  262. theTime = parseInt(theTime % 60);
  263. if (theTime1 > 60) {
  264. theTime2 = parseInt(theTime1 / 60);
  265. theTime1 = parseInt(theTime1 % 60);
  266. }
  267. }
  268. let t_hour = 0;
  269. let t_min = 0;
  270. let t_sec = 0;
  271. if (theTime > 0) {
  272. t_sec = parseInt(theTime);
  273. }
  274. if (theTime1 > 0) {
  275. t_min = parseInt(theTime1);
  276. }
  277. if (theTime2 > 0) {
  278. t_hour = parseInt(theTime2);
  279. }
  280. return t_hour > 0
  281. ? `${t_hour > 9 ? "" : 0}${t_hour}:${t_min > 9 ? "" : 0}${t_min}:${
  282. t_sec > 9 ? "" : 0
  283. }${t_sec}`
  284. : `${t_min > 9 ? "" : 0}${t_min}:${t_sec > 9 ? "" : 0}${t_sec}`;
  285. };
  286. /**
  287. * 获取对象类型
  288. */
  289. export const getObjType = (obj) => {
  290. var toString = Object.prototype.toString;
  291. var map = {
  292. "[object Boolean]": "boolean",
  293. "[object Number]": "number",
  294. "[object String]": "string",
  295. "[object Function]": "function",
  296. "[object Array]": "array",
  297. "[object Date]": "date",
  298. "[object RegExp]": "regExp",
  299. "[object Undefined]": "undefined",
  300. "[object Null]": "null",
  301. "[object Object]": "object"
  302. };
  303. if (obj instanceof Element) {
  304. return "element";
  305. }
  306. return map[toString.call(obj)];
  307. };
  308. //时间戳转时间
  309. export const date_format = (unixtimestamp, type) => {
  310. if (!unixtimestamp) {
  311. return "";
  312. }
  313. unixtimestamp = new Date(unixtimestamp * 1000 + diffTime);
  314. var year = 1900 + unixtimestamp.getYear();
  315. var month = "0" + (unixtimestamp.getMonth() + 1);
  316. var date = "0" + unixtimestamp.getDate();
  317. var hour = "0" + unixtimestamp.getHours();
  318. var minute = "0" + unixtimestamp.getMinutes();
  319. var second = "0" + unixtimestamp.getSeconds();
  320. return (
  321. year +
  322. "-" +
  323. month.substring(month.length - 2, month.length) +
  324. "-" +
  325. date.substring(date.length - 2, date.length) +
  326. " " +
  327. hour.substring(hour.length - 2, hour.length) +
  328. ":" +
  329. minute.substring(minute.length - 2, minute.length) +
  330. (type ? "" : ":" + second.substring(second.length - 2, second.length))
  331. );
  332. };
  333. //时间转化为时间戳
  334. export const date_time = (datestring) => {
  335. let time = new Date(datestring).getTime() / 1000;
  336. if (!time && datestring) {
  337. //兼容火狐浏览器
  338. datestring = datestring.replace(new RegExp(/-/gm), "/");
  339. time = new Date(datestring).getTime() / 1000;
  340. }
  341. return parseInt(time);
  342. };
  343. /**
  344. * 对象深拷贝
  345. */
  346. export const deepClone = (data) => {
  347. var type = getObjType(data);
  348. var obj;
  349. if (type === "array") {
  350. obj = [];
  351. } else if (type === "object") {
  352. obj = {};
  353. } else {
  354. // 不再具有下一层次
  355. return data;
  356. }
  357. if (type === "array") {
  358. for (var i = 0, len = data.length; i < len; i++) {
  359. obj.push(deepClone(data[i]));
  360. }
  361. } else if (type === "object") {
  362. for (var key in data) {
  363. obj[key] = deepClone(data[key]);
  364. }
  365. }
  366. return obj;
  367. };
  368. /**
  369. * 日期格式化,时间戳
  370. */
  371. export function format_date(time, format = "yyyy-MM-dd hh:mm:ss") {
  372. let date = new Date(time * 1000 + diffTime);
  373. if (date !== "Invalid Date") {
  374. let o = {
  375. "M+": date.getMonth() + 1, // month
  376. "d+": date.getDate(), // day
  377. "h+": date.getHours(), // hour
  378. "m+": date.getMinutes(), // minute
  379. "s+": date.getSeconds(), // second
  380. "q+": Math.floor((date.getMonth() + 3) / 3), // quarter
  381. S: date.getMilliseconds() // millisecond
  382. };
  383. if (/(y+)/.test(format)) {
  384. format = format.replace(
  385. RegExp.$1,
  386. (date.getFullYear() + "").substr(4 - RegExp.$1.length)
  387. );
  388. }
  389. for (let k in o) {
  390. if (new RegExp("(" + k + ")").test(format)) {
  391. format = format.replace(
  392. RegExp.$1,
  393. RegExp.$1.length === 1
  394. ? o[k]
  395. : ("00" + o[k]).substr(("" + o[k]).length)
  396. );
  397. }
  398. }
  399. return format;
  400. }
  401. return "";
  402. }
  403. /**
  404. * 日期格式化
  405. */
  406. export function dateFormat(dateDemo, format = "yyyy-MM-dd hh:mm:ss") {
  407. let date = new Date(dateDemo);
  408. if (date !== "Invalid Date") {
  409. var o = {
  410. "M+": date.getMonth() + 1, // month
  411. "d+": date.getDate(), // day
  412. "h+": date.getHours(), // hour
  413. "m+": date.getMinutes(), // minute
  414. "s+": date.getSeconds(), // second
  415. "q+": Math.floor((date.getMonth() + 3) / 3), // quarter
  416. S: date.getMilliseconds() // millisecond
  417. };
  418. if (/(y+)/.test(format)) {
  419. format = format.replace(
  420. RegExp.$1,
  421. (date.getFullYear() + "").substr(4 - RegExp.$1.length)
  422. );
  423. }
  424. for (var k in o) {
  425. if (new RegExp("(" + k + ")").test(format)) {
  426. format = format.replace(
  427. RegExp.$1,
  428. RegExp.$1.length === 1
  429. ? o[k]
  430. : ("00" + o[k]).substr(("" + o[k]).length)
  431. );
  432. }
  433. }
  434. return format;
  435. }
  436. return "";
  437. }
  438. // 颜色渐变函数
  439. export function hexToRgba(hex, opacity) {
  440. let rgbaColor = "";
  441. let reg = /^#[\da-f]{6}$/i;
  442. if (reg.test(hex)) {
  443. rgbaColor = `rgba(${parseInt("0x" + hex.slice(1, 3))},${parseInt(
  444. "0x" + hex.slice(3, 5)
  445. )},${parseInt("0x" + hex.slice(5, 7))},${opacity})`;
  446. }
  447. return rgbaColor;
  448. }
  449. // 包含大小写字母和数字的随机组合
  450. export const generateRandomString = (n = 6) => {
  451. let chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  452. let result = "";
  453. let hasUpperCase = false;
  454. let hasLowerCase = false;
  455. let hasDigit = false;
  456. // 当n<3时,只需随机选择字符即可
  457. if (n < 3) {
  458. for (let i = 0; i < n; i++) {
  459. result += chars.charAt(Math.floor(Math.random() * chars.length));
  460. }
  461. return result;
  462. }
  463. // 当n>=3时,需要确保包含大写字母、小写字母和数字
  464. while (result.length < n) {
  465. let randomIndex = Math.floor(Math.random() * chars.length);
  466. let randomChar = chars.charAt(randomIndex);
  467. // 确保每种类型的字符至少被选中一次
  468. if (hasUpperCase && hasLowerCase && hasDigit) {
  469. result += randomChar;
  470. } else {
  471. // 如果还没包含大写字母,并且当前字符是大写字母,则添加
  472. if (!hasUpperCase && /[A-Z]/.test(randomChar)) {
  473. result += randomChar;
  474. hasUpperCase = true;
  475. }
  476. // 如果还没包含小写字母,并且当前字符是小写字母,则添加
  477. else if (!hasLowerCase && /[a-z]/.test(randomChar)) {
  478. result += randomChar;
  479. hasLowerCase = true;
  480. }
  481. // 如果还没包含数字,并且当前字符是数字,则添加
  482. else if (!hasDigit && /\d/.test(randomChar)) {
  483. result += randomChar;
  484. hasDigit = true;
  485. }
  486. // 否则跳过这个字符,重新选择
  487. }
  488. }
  489. // 如果字符串长度仍然小于n,则随机添加字符直到满足长度
  490. while (result.length < n) {
  491. result += chars.charAt(Math.floor(Math.random() * chars.length));
  492. }
  493. // 打乱结果字符串的顺序以确保随机性
  494. result = result
  495. .split("")
  496. .sort(function () {
  497. return 0.5 - Math.random();
  498. })
  499. .join("");
  500. return result;
  501. };
  502. /**
  503. * 提取html字符串中的文字
  504. */
  505. export const getHtmlPlainText = (html_str = "") => {
  506. let text = html_str.replace(/<[^<>]+>/g, "").trim();
  507. return text;
  508. };
  509. //判断html中是否有文字或图片
  510. export const htmlHasContent = (html_str = "") => {
  511. let text = html_str.replace(/<[^<>]+>/g, "").trim();
  512. let imgReg = /<img [^>]*src=['"]([^'"]+)[^>]*>/gi;
  513. let imgUrls = html_str.match(imgReg) || [];
  514. imgUrls.filter((url) => {
  515. return url && url.match(/src=['"]?([^'"]*)['"]?/i);
  516. });
  517. return Boolean(text) || imgUrls.length > 0;
  518. };
  519. /**
  520. * 压缩图片方法
  521. * @param {file} file 文件或文件数组
  522. * @param {Number} quality 图片质量(取值0-1之间默认0.92)
  523. */
  524. export const compressImg = (file, quality) => {
  525. if (Array.isArray(file)) {
  526. return Promise.all(Array.from(file).map((e) => compressImg(e, quality))); // 如果是 file 数组返回 Promise 数组
  527. } else {
  528. let qualitys = 1;
  529. //单位:MB
  530. let fileSize = parseInt((file.size / 1024 / 1024).toFixed(2));
  531. if (1 < fileSize && fileSize < 5) {
  532. qualitys = 0.92;
  533. }
  534. if (5 < fileSize && fileSize < 10) {
  535. qualitys = 0.85;
  536. }
  537. if (10 < fileSize) {
  538. qualitys = 0.52;
  539. }
  540. if (quality) {
  541. qualitys = quality;
  542. }
  543. return new Promise((resolve) => {
  544. if (qualitys >= 1) {
  545. resolve(file);
  546. } else {
  547. let fileType = file.type;
  548. if (!fileType || !fileType.includes("image/")) {
  549. resolve(file);
  550. return;
  551. }
  552. const fileReader = new FileReader(); // 创建 FileReader
  553. fileReader.onload = ({ target: { result: src } }) => {
  554. const image = new Image(); // 创建 img 元素
  555. image.onload = () => {
  556. const mCanvas = document.createElement("canvas"); // 创建 canvas 元素
  557. const mCtx = mCanvas.getContext("2d");
  558. let targetWidth = image.width;
  559. let targetHeight = image.height;
  560. let originWidth = image.width;
  561. let originHeight = image.height;
  562. if (1 <= fileSize) {
  563. let maxWidth = 1400;
  564. let maxHeight = 1400;
  565. if (5 < fileSize) {
  566. maxWidth = 1920;
  567. maxHeight = 1920;
  568. }
  569. targetWidth = originWidth;
  570. targetHeight = originHeight;
  571. // 图片尺寸超过的限制
  572. if (originWidth > maxWidth || originHeight > maxHeight) {
  573. if (originWidth / originHeight > maxWidth / maxHeight) {
  574. // 更宽,按照宽度限定尺寸
  575. targetWidth = maxWidth;
  576. targetHeight = Math.round(
  577. maxWidth * (originHeight / originWidth)
  578. );
  579. } else {
  580. targetHeight = maxHeight;
  581. targetWidth = Math.round(
  582. maxHeight * (originWidth / originHeight)
  583. );
  584. }
  585. }
  586. }
  587. mCanvas.width = targetWidth;
  588. mCanvas.height = targetHeight;
  589. mCtx.clearRect(0, 0, targetWidth, targetHeight);
  590. mCtx.drawImage(image, 0, 0, targetWidth, targetHeight); // 绘制 canvas
  591. const canvasURL = mCanvas.toDataURL(fileType, qualitys);
  592. const buffer = atob(canvasURL.split(",")[1]);
  593. let length = buffer.length;
  594. const bufferArray = new Uint8Array(new ArrayBuffer(length));
  595. while (length--) {
  596. bufferArray[length] = buffer.charCodeAt(length);
  597. }
  598. const miniFile = new File([bufferArray], file.name, {
  599. type: fileType
  600. });
  601. resolve(miniFile);
  602. };
  603. image.src = src;
  604. };
  605. fileReader.readAsDataURL(file);
  606. }
  607. });
  608. }
  609. };
  610. export function uuid() {
  611. const s = [];
  612. const hexDigits = "0123456789abcdef";
  613. for (let i = 0; i < 36; i++) {
  614. let start = Math.floor(Math.random() * 0x10);
  615. s[i] = hexDigits.substring(start, start + 1);
  616. }
  617. s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  618. let start = (s[19] & 0x3) | 0x8;
  619. s[19] = hexDigits.substring(start, start + 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  620. s[8] = s[13] = s[18] = s[23] = "-";
  621. return s.join("");
  622. }
  623. export function getPosInDom(outerDom, innerDom) {
  624. // 元素的坐标和大小
  625. const rect = outerDom.getBoundingClientRect();
  626. const rect2 = innerDom.getBoundingClientRect();
  627. const x = rect2.left - rect.left;
  628. const y = rect2.top - rect.top;
  629. return {
  630. x: x,
  631. y: y,
  632. width: rect2.width,
  633. height: rect2.height
  634. };
  635. }
  636. export function getPosInDomByEvent(outerDom, event) {
  637. // 元素的坐标和大小
  638. const rect = outerDom.getBoundingClientRect();
  639. // 鼠标坐标
  640. const x = event.clientX;
  641. const y = event.clientY;
  642. // 计算鼠标在元素中的坐标
  643. const elementX = x - rect.left;
  644. const elementY = y - rect.top;
  645. return {
  646. x: elementX,
  647. y: elementY
  648. };
  649. }
  650. /**
  651. * 返回开始日期(以0点开始)和结束日期(以24点结束)的秒数
  652. * @param beginDate 开始日期
  653. * @param endDate 结束日期
  654. */
  655. export const dateRangeToSecond = ([beginDate, endDate]) => {
  656. let _begintime = null;
  657. let _endtime = null;
  658. if (beginDate) {
  659. let _beginDate = new Date(beginDate);
  660. _begintime = new Date(
  661. _beginDate.getFullYear(),
  662. _beginDate.getMonth(),
  663. _beginDate.getDate(),
  664. 0,
  665. 0,
  666. 0
  667. ).getTime();
  668. _begintime = parseInt(_begintime / 1000);
  669. }
  670. if (endDate) {
  671. let _endDate = new Date(endDate);
  672. _endtime = new Date(
  673. _endDate.getFullYear(),
  674. _endDate.getMonth(),
  675. _endDate.getDate(),
  676. 23,
  677. 59,
  678. 59
  679. ).getTime();
  680. _endtime = parseInt(_endtime / 1000);
  681. }
  682. return {
  683. begintime: _begintime,
  684. endtime: _endtime
  685. };
  686. };
  687. /**
  688. * 所有设备事件日志
  689. */
  690. export const doEventInfo = {
  691. 101: "更换SIM卡",
  692. 102: "违规开启蓝牙",
  693. 103: "USB连接电脑",
  694. 104: "USB拔出电脑",
  695. 105: "插入SD卡",
  696. 106: "拔出SD卡",
  697. 201: "账号登录",
  698. 202: "首次使用",
  699. 203: "账号退出",
  700. 211: "安装应用(安装了非应用商店应用违规)",
  701. 212: "卸载应用(卸载强制安装应用违规)",
  702. 213: "启动应用"
  703. };
  704. /**
  705. * 所有违规设备事件日志
  706. */
  707. export const breakRuleDoEvent = {
  708. 101: "更换SIM卡",
  709. 102: "违规开启蓝牙",
  710. 103: "USB连接电脑",
  711. 104: "USB拔出电脑",
  712. 105: "插入SD卡",
  713. 106: "拔出SD卡",
  714. 211: "安装应用(安装了非应用商店应用违规)",
  715. 212: "卸载应用(卸载强制安装应用违规)"
  716. };
  717. /**
  718. * 所有设备推送类型
  719. */
  720. export const pushTypeInfo = {
  721. 1: "发送消息",
  722. 2: "解除锁定",
  723. 3: "锁定",
  724. 4: "更新策略",
  725. 5: "重启设备",
  726. 6: "恢复出厂",
  727. 7: "解除管控",
  728. 8: "解除绑定"
  729. };