index.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. /**
  2. * Created by PanJiaChen on 16/11/18.
  3. */
  4. /**
  5. * Parse the time to string
  6. * @param {(Object|string|number)} time
  7. * @param {string} cFormat
  8. * @returns {string | null}
  9. */
  10. export function parseTime(time, cFormat) {
  11. if (arguments.length === 0 || !time) {
  12. return null
  13. }
  14. const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
  15. let date
  16. if (typeof time === 'object') {
  17. date = time
  18. } else {
  19. if ((typeof time === 'string')) {
  20. if ((/^[0-9]+$/.test(time))) {
  21. // support "1548221490638"
  22. time = parseInt(time)
  23. } else {
  24. // support safari
  25. // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
  26. time = time.replace(new RegExp(/-/gm), '/')
  27. }
  28. }
  29. if ((typeof time === 'number') && (time.toString().length === 10)) {
  30. time = time * 1000
  31. }
  32. date = new Date(time)
  33. }
  34. const formatObj = {
  35. y: date.getFullYear(),
  36. m: date.getMonth() + 1,
  37. d: date.getDate(),
  38. h: date.getHours(),
  39. i: date.getMinutes(),
  40. s: date.getSeconds(),
  41. a: date.getDay()
  42. }
  43. const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => {
  44. const value = formatObj[key]
  45. // Note: getDay() returns 0 on Sunday
  46. if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
  47. return value.toString().padStart(2, '0')
  48. })
  49. return time_str
  50. }
  51. /**
  52. * @param {number} time
  53. * @param {string} option
  54. * @returns {string}
  55. */
  56. export function formatTime(time, option) {
  57. if (('' + time).length === 10) {
  58. time = parseInt(time) * 1000
  59. } else {
  60. time = +time
  61. }
  62. const d = new Date(time)
  63. const now = Date.now()
  64. const diff = (now - d) / 1000
  65. if (diff < 30) {
  66. return '刚刚'
  67. } else if (diff < 3600) {
  68. // less 1 hour
  69. return Math.ceil(diff / 60) + '分钟前'
  70. } else if (diff < 3600 * 24) {
  71. return Math.ceil(diff / 3600) + '小时前'
  72. } else if (diff < 3600 * 24 * 2) {
  73. return '1天前'
  74. }
  75. if (option) {
  76. return parseTime(time, option)
  77. } else {
  78. return (
  79. d.getMonth() +
  80. 1 +
  81. '月' +
  82. d.getDate() +
  83. '日' +
  84. d.getHours() +
  85. '时' +
  86. d.getMinutes() +
  87. '分'
  88. )
  89. }
  90. }
  91. /**
  92. * @param {string} url
  93. * @returns {Object}
  94. */
  95. export function getQueryObject(url) {
  96. url = url == null ? window.location.href : url
  97. const search = url.substring(url.lastIndexOf('?') + 1)
  98. const obj = {}
  99. const reg = /([^?&=]+)=([^?&=]*)/g
  100. search.replace(reg, (rs, $1, $2) => {
  101. const name = decodeURIComponent($1)
  102. let val = decodeURIComponent($2)
  103. val = String(val)
  104. obj[name] = val
  105. return rs
  106. })
  107. return obj
  108. }
  109. /**
  110. * @param {string} input value
  111. * @returns {number} output value
  112. */
  113. export function byteLength(str) {
  114. // returns the byte length of an utf8 string
  115. let s = str.length
  116. for (var i = str.length - 1; i >= 0; i--) {
  117. const code = str.charCodeAt(i)
  118. if (code > 0x7f && code <= 0x7ff) s++
  119. else if (code > 0x7ff && code <= 0xffff) s += 2
  120. if (code >= 0xDC00 && code <= 0xDFFF) i--
  121. }
  122. return s
  123. }
  124. /**
  125. * @param {Array} actual
  126. * @returns {Array}
  127. */
  128. export function cleanArray(actual) {
  129. const newArray = []
  130. for (let i = 0; i < actual.length; i++) {
  131. if (actual[i]) {
  132. newArray.push(actual[i])
  133. }
  134. }
  135. return newArray
  136. }
  137. /**
  138. * @param {Object} json
  139. * @returns {Array}
  140. */
  141. export function param(json) {
  142. if (!json) return ''
  143. return cleanArray(
  144. Object.keys(json).map(key => {
  145. if (json[key] === undefined) return ''
  146. return encodeURIComponent(key) + '=' + encodeURIComponent(json[key])
  147. })
  148. ).join('&')
  149. }
  150. /**
  151. * @param {string} url
  152. * @returns {Object}
  153. */
  154. export function param2Obj(url) {
  155. const search = decodeURIComponent(url.split('?')[1]).replace(/\+/g, ' ')
  156. if (!search) {
  157. return {}
  158. }
  159. const obj = {}
  160. const searchArr = search.split('&')
  161. searchArr.forEach(v => {
  162. const index = v.indexOf('=')
  163. if (index !== -1) {
  164. const name = v.substring(0, index)
  165. const val = v.substring(index + 1, v.length)
  166. obj[name] = val
  167. }
  168. })
  169. return obj
  170. }
  171. /**
  172. * @param {string} val
  173. * @returns {string}
  174. */
  175. export function html2Text(val) {
  176. const div = document.createElement('div')
  177. div.innerHTML = val
  178. return div.textContent || div.innerText
  179. }
  180. /**
  181. * Merges two objects, giving the last one precedence
  182. * @param {Object} target
  183. * @param {(Object|Array)} source
  184. * @returns {Object}
  185. */
  186. export function objectMerge(target, source) {
  187. if (typeof target !== 'object') {
  188. target = {}
  189. }
  190. if (Array.isArray(source)) {
  191. return source.slice()
  192. }
  193. Object.keys(source).forEach(property => {
  194. const sourceProperty = source[property]
  195. if (typeof sourceProperty === 'object') {
  196. target[property] = objectMerge(target[property], sourceProperty)
  197. } else {
  198. target[property] = sourceProperty
  199. }
  200. })
  201. return target
  202. }
  203. /**
  204. * @param {HTMLElement} element
  205. * @param {string} className
  206. */
  207. export function toggleClass(element, className) {
  208. if (!element || !className) {
  209. return
  210. }
  211. let classString = element.className
  212. const nameIndex = classString.indexOf(className)
  213. if (nameIndex === -1) {
  214. classString += '' + className
  215. } else {
  216. classString =
  217. classString.substr(0, nameIndex) +
  218. classString.substr(nameIndex + className.length)
  219. }
  220. element.className = classString
  221. }
  222. /**
  223. * @param {string} type
  224. * @returns {Date}
  225. */
  226. export function getTime(type) {
  227. if (type === 'start') {
  228. return new Date().getTime() - 3600 * 1000 * 24 * 90
  229. } else {
  230. return new Date(new Date().toDateString())
  231. }
  232. }
  233. /**
  234. * @param {Function} func
  235. * @param {number} wait
  236. * @param {boolean} immediate
  237. * @return {*}
  238. */
  239. export function debounce(func, wait, immediate) {
  240. let timeout, args, context, timestamp, result
  241. const later = function() {
  242. // 据上一次触发时间间隔
  243. const last = +new Date() - timestamp
  244. // 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
  245. if (last < wait && last > 0) {
  246. timeout = setTimeout(later, wait - last)
  247. } else {
  248. timeout = null
  249. // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
  250. if (!immediate) {
  251. result = func.apply(context, args)
  252. if (!timeout) context = args = null
  253. }
  254. }
  255. }
  256. return function(...args) {
  257. context = this
  258. timestamp = +new Date()
  259. const callNow = immediate && !timeout
  260. // 如果延时不存在,重新设定延时
  261. if (!timeout) timeout = setTimeout(later, wait)
  262. if (callNow) {
  263. result = func.apply(context, args)
  264. context = args = null
  265. }
  266. return result
  267. }
  268. }
  269. /**
  270. * This is just a simple version of deep copy
  271. * Has a lot of edge cases bug
  272. * If you want to use a perfect deep copy, use lodash's _.cloneDeep
  273. * @param {Object} source
  274. * @returns {Object}
  275. */
  276. export function deepClone(source) {
  277. if (!source && typeof source !== 'object') {
  278. throw new Error('error arguments', 'deepClone')
  279. }
  280. const targetObj = source.constructor === Array ? [] : {}
  281. Object.keys(source).forEach(keys => {
  282. if (source[keys] && typeof source[keys] === 'object') {
  283. targetObj[keys] = deepClone(source[keys])
  284. } else {
  285. targetObj[keys] = source[keys]
  286. }
  287. })
  288. return targetObj
  289. }
  290. /**
  291. * @param {Array} arr
  292. * @returns {Array}
  293. */
  294. export function uniqueArr(arr) {
  295. return Array.from(new Set(arr))
  296. }
  297. /**
  298. * @returns {string}
  299. */
  300. export function createUniqueString() {
  301. const timestamp = +new Date() + ''
  302. const randomNum = parseInt((1 + Math.random()) * 65536) + ''
  303. return (+(randomNum + timestamp)).toString(32)
  304. }
  305. /**
  306. * Check if an element has a class
  307. * @param {HTMLElement} elm
  308. * @param {string} cls
  309. * @returns {boolean}
  310. */
  311. export function hasClass(ele, cls) {
  312. return !!ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'))
  313. }
  314. /**
  315. * Add class to element
  316. * @param {HTMLElement} elm
  317. * @param {string} cls
  318. */
  319. export function addClass(ele, cls) {
  320. if (!hasClass(ele, cls)) ele.className += ' ' + cls
  321. }
  322. /**
  323. * Remove class from element
  324. * @param {HTMLElement} elm
  325. * @param {string} cls
  326. */
  327. export function removeClass(ele, cls) {
  328. if (hasClass(ele, cls)) {
  329. const reg = new RegExp('(\\s|^)' + cls + '(\\s|$)')
  330. ele.className = ele.className.replace(reg, ' ')
  331. }
  332. }
  333. export function strArr2NumArr(actual) {
  334. const newArray = []
  335. for (let i = 0; i < actual.length; i++) {
  336. if (actual[i]) {
  337. newArray.push(parseInt(actual[i]))
  338. }
  339. }
  340. return newArray
  341. }
  342. // 格式化日期:yyyy-MM-dd
  343. export function formatDate(date) {
  344. var myyear = date.getFullYear()
  345. var mymonth = date.getMonth() + 1
  346. var myweekday = date.getDate()
  347. if (mymonth < 10) {
  348. mymonth = '0' + mymonth
  349. }
  350. if (myweekday < 10) {
  351. myweekday = '0' + myweekday
  352. }
  353. return (myyear + '-' + mymonth + '-' + myweekday)
  354. }
  355. // 获得某月的天数
  356. export function getMonthDays(myMonth) {
  357. var now = new Date() // 当前日期
  358. var nowYear = now.getFullYear() // 当前年
  359. var monthStartDate = new Date(nowYear, myMonth, 1)
  360. var monthEndDate = new Date(nowYear, myMonth + 1, 1)
  361. var days = (monthEndDate - monthStartDate) / (1000 * 60 * 60 * 24)
  362. return days
  363. }
  364. // 获得本季度的开始月份
  365. export function getQuarterStartMonth() {
  366. var now = new Date() // 当前日期
  367. var nowMonth = now.getMonth() // 当前月
  368. var quarterStartMonth = 0
  369. if (nowMonth < 3) {
  370. quarterStartMonth = 0
  371. }
  372. if (nowMonth > 2 && nowMonth < 6) {
  373. quarterStartMonth = 3
  374. }
  375. if (nowMonth > 5 && nowMonth < 9) {
  376. quarterStartMonth = 6
  377. }
  378. if (nowMonth > 8) {
  379. quarterStartMonth = 9
  380. }
  381. return quarterStartMonth
  382. }
  383. // 获得本周的开始日期
  384. export function getWeekStartDate() {
  385. var now = new Date() // 当前日期
  386. var nowDay = now.getDate() // 当前日
  387. var nowDayOfWeek = now.getDay() - 1 // 今天本周的第几天
  388. var nowMonth = now.getMonth()
  389. var nowYear = now.getFullYear() // 当前年
  390. var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek)
  391. return formatDate(weekStartDate)
  392. }
  393. // 获得本周的结束日期
  394. export function getWeekEndDate() {
  395. var now = new Date() // 当前日期
  396. var nowDay = now.getDate() // 当前日
  397. var nowMonth = now.getMonth() // 当前月
  398. var nowYear = now.getFullYear() // 当前年
  399. var nowDayOfWeek = now.getDay() - 1 // 今天本周的第几天
  400. var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek))
  401. return formatDate(weekEndDate)
  402. }
  403. // 获得上周的开始日期
  404. export function getLastWeekStartDate() {
  405. var now = new Date() // 当前日期
  406. var nowDay = now.getDate() // 当前日
  407. var nowMonth = now.getMonth() // 当前月
  408. var nowYear = now.getFullYear() // 当前年
  409. var nowDayOfWeek = now.getDay() - 1 // 今天本周的第几天
  410. var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek - 7)
  411. return formatDate(weekStartDate)
  412. }
  413. // 获得上周的结束日期
  414. export function getLastWeekEndDate() {
  415. var now = new Date() // 当前日期
  416. var nowDay = now.getDate() // 当前日
  417. var nowMonth = now.getMonth() // 当前月
  418. var nowYear = now.getFullYear() // 当前年
  419. var nowDayOfWeek = now.getDay() - 1 // 今天本周的第几天
  420. var weekEndDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek - 1)
  421. return formatDate(weekEndDate)
  422. }
  423. // 获得本月的开始日期
  424. export function getMonthStartDate() {
  425. var now = new Date() // 当前日期
  426. var nowMonth = now.getMonth() // 当前月
  427. var nowYear = now.getFullYear() // 当前年
  428. var monthStartDate = new Date(nowYear, nowMonth, 1)
  429. return formatDate(monthStartDate)
  430. }
  431. // 获得本月的结束日期
  432. export function getMonthEndDate() {
  433. var now = new Date() // 当前日期
  434. var nowMonth = now.getMonth() // 当前月
  435. var nowYear = now.getFullYear() // 当前年
  436. var monthEndDate = new Date(nowYear, nowMonth, getMonthDays(nowMonth))
  437. return formatDate(monthEndDate)
  438. }
  439. // 获得本年的开始日期
  440. export function getYearStartDate() {
  441. var now = new Date() // 当前日期
  442. var nowYear = now.getFullYear() // 当前年
  443. var monthStartDate = new Date(nowYear, 1, 1)
  444. return formatDate(monthStartDate)
  445. }
  446. // 获得本年的结束日期
  447. export function getYearEndDate() {
  448. var now = new Date() // 当前日期
  449. var nowYear = now.getFullYear() // 当前年
  450. var yarEndDate = new Date(nowYear, 11, 31)
  451. return formatDate(yarEndDate)
  452. }
  453. // 获得上月开始时间
  454. export function getLastMonthStartDate() {
  455. var now = new Date() // 当前日期
  456. var nowYear = now.getFullYear() // 当前年
  457. var nowMonth = now.getMonth() // 当前月
  458. var lastMonthStartDate
  459. if (nowMonth === 0) {
  460. lastMonthStartDate = new Date(nowYear - 1, 12, 1)
  461. } else {
  462. lastMonthStartDate = new Date(nowYear, nowMonth - 1, 1)
  463. }
  464. return formatDate(lastMonthStartDate)
  465. }
  466. // 获得上月结束时间
  467. export function getLastMonthEndDate() {
  468. var now = new Date() // 当前日期
  469. var nowMonth = now.getMonth() // 当前月
  470. var nowYear = now.getFullYear() // 当前年
  471. var lastMonthEndDate
  472. if (nowMonth === 0) {
  473. lastMonthEndDate = new Date(nowYear - 1, 12, 31)
  474. } else {
  475. lastMonthEndDate = new Date(nowYear, nowMonth - 1, getMonthDays(nowMonth - 1))
  476. }
  477. return formatDate(lastMonthEndDate)
  478. }
  479. // 获得本季度的开始日期
  480. export function getQuarterStartDate() {
  481. var now = new Date() // 当前日期
  482. var nowYear = now.getFullYear() // 当前年
  483. var quarterStartDate = new Date(nowYear, getQuarterStartMonth(), 1)
  484. return formatDate(quarterStartDate)
  485. }
  486. // 或的本季度的结束日期
  487. export function getQuarterEndDate() {
  488. var now = new Date() // 当前日期
  489. var nowYear = now.getFullYear() // 当前年
  490. var quarterEndMonth = getQuarterStartMonth() + 2
  491. var quarterStartDate = new Date(nowYear, quarterEndMonth, getMonthDays(quarterEndMonth))
  492. return formatDate(quarterStartDate)
  493. }
  494. // 平级转树结构
  495. /* treeArr 基础数据
  496. * id 唯一id
  497. * parentId 父级id
  498. * childrenList 子级数组名*/
  499. export function packageTreeData(params) {
  500. const treeArr = params && params.data || []
  501. const id = params && params.id || 'id'
  502. const parentId = params && params.parentId || 'parentId'
  503. const childrenList = params && params.children || 'children'
  504. const cloneData = JSON.parse(JSON.stringify(treeArr))
  505. return cloneData.filter(fatherItem => {
  506. const warpArr = cloneData.filter(sonItem => fatherItem[id] === sonItem[parentId])
  507. warpArr.length ? fatherItem[childrenList] = warpArr : null
  508. return !fatherItem[parentId]
  509. })
  510. }
  511. // 根据根id处理树结构
  512. export function getNestedChildren(arr = [], parent = 0) {
  513. const res = []
  514. for (const item of arr) {
  515. if (item.parent_id === parent) {
  516. const children = getNestedChildren(arr, item.id)
  517. if (children.length) {
  518. item.children = children
  519. }
  520. res.push(item)
  521. }
  522. }
  523. return res
  524. }
  525. export function Uint8ArrayToString(fileData) {
  526. var dataString = ''
  527. for (var i = 0; i < fileData.length; i++) {
  528. dataString += String.fromCharCode(fileData[i])
  529. }
  530. return dataString
  531. }
  532. export function NumConvertLM1(num) {
  533. var aArray = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
  534. var rArray = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
  535. var str = ''
  536. for (var i = 0; i < aArray.length; i++) {
  537. while (num >= aArray[i]) {
  538. str += rArray[i]
  539. num -= aArray[i]
  540. }
  541. }
  542. return str
  543. }
  544. // 只能转换 4000 以下的正整数阿拉伯数字
  545. export function NumConvertLM(num) {
  546. var Roman = [['', 'I', 'Ⅱ', 'Ⅲ', 'Ⅳ', 'Ⅴ', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ'],
  547. ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'],
  548. ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'],
  549. ['', 'M', 'MM', 'MMM', ' ', ' ', ' ', ' ', ' ', ' ']]
  550. if (isNaN(num)) return num
  551. var ReverseArr = num.toString().split('').reverse()
  552. var CorrectArr = []
  553. for (var i = 0; i < ReverseArr.length; i++) {
  554. CorrectArr.unshift(Roman[i][ReverseArr[i]])
  555. }
  556. return CorrectArr.join('')
  557. }
  558. export function isEmpty(val) {
  559. if (val === undefined || val === 'undefined' || val === null || val === '' || val === ' ') {
  560. return true
  561. }
  562. return false
  563. }
  564. // 风险类型
  565. export function riskType(val) {
  566. const strs = [
  567. '默认',
  568. '人',
  569. '物',
  570. '管'
  571. ]
  572. return strs[val]
  573. }
  574. // 风险等级
  575. export function riskLevel(val) {
  576. const strs = [
  577. '默认',
  578. '重大',
  579. '较大',
  580. '一般',
  581. '较小'
  582. ]
  583. return strs[val]
  584. }
  585. // 风险等级
  586. export function riskPointStatus(val) {
  587. const strs = [
  588. '未知',
  589. '安全受控',
  590. '失控'
  591. ]
  592. return strs[val]
  593. }
  594. // 风险点等级
  595. export function riskPointLevel(val) {
  596. const strs = [
  597. '默认',
  598. '重大',
  599. '较大',
  600. '一般',
  601. '较小'
  602. ]
  603. return strs[val]
  604. }
  605. export function taskPriority(i) {
  606. const strs = [
  607. '未知',
  608. '较低',
  609. '普通',
  610. '紧急',
  611. '非常紧急'
  612. ]
  613. return strs[i]
  614. }
  615. export function taskType(i) {
  616. const strs = [
  617. '未知',
  618. '常规',
  619. '审批任务',
  620. '巡检任务'
  621. ]
  622. return strs[i]
  623. }
  624. export function checkType(i) {
  625. const strs = [
  626. '未知',
  627. '常规检查',
  628. '临时检查',
  629. '扫码检查'
  630. ]
  631. return strs[i]
  632. }
  633. export function taskStatus(i) {
  634. const strs = [
  635. '待处理',
  636. '已完成'
  637. ]
  638. if (i === -1) {
  639. return '已撤消'
  640. } else {
  641. return strs[i]
  642. }
  643. }
  644. export function checkStatus(i) {
  645. const strs = [
  646. '待处理',
  647. '处理中',
  648. '已完成'
  649. ]
  650. if (i === -1) {
  651. return '已撤消'
  652. } else {
  653. return strs[i]
  654. }
  655. }
  656. export function checkResult(i) {
  657. const strs = [
  658. '没执行',
  659. '通过',
  660. '没通过',
  661. '有隐患',
  662. '已完成'
  663. ]
  664. return strs[i]
  665. }
  666. export function dangerStatus(i) {
  667. if (i >= 0) {
  668. const strs = [
  669. '处理中',
  670. '已完成'
  671. ]
  672. return strs[i]
  673. } else {
  674. return '已撤销'
  675. }
  676. }
  677. export function dangerLevel(i) {
  678. const strs = [
  679. '未知',
  680. '一般隐患',
  681. '重大隐患'
  682. ]
  683. return strs[i]
  684. }
  685. export function dangerSource(i) {
  686. const strs = [
  687. '自查',
  688. '内部反馈',
  689. '上级抽查',
  690. '政府执法'
  691. ]
  692. return strs[i]
  693. }
  694. export function rectifyCat(i) {
  695. const strs = [
  696. '自行整改',
  697. '外协整改'
  698. ]
  699. return strs[i]
  700. }
  701. export function wfInsStatus(i) {
  702. if (i >= 0) {
  703. const strs = [
  704. '未开始',
  705. '执行中',
  706. '已完成'
  707. ]
  708. return strs[i]
  709. } else {
  710. return '已撤销'
  711. }
  712. }
  713. export function wfActivityInsStatus(i) {
  714. const strs = [
  715. '未开始',
  716. '已完成'
  717. ]
  718. return strs[i]
  719. }
  720. export function dangerRectifyCat(i) {
  721. const strs = [
  722. '自行整改',
  723. '外协整改'
  724. ]
  725. return strs[i]
  726. }
  727. export function alertLevel(i) {
  728. const strs = [
  729. '未知',
  730. '1级',
  731. '2级',
  732. '3级',
  733. '4级',
  734. '5级',
  735. '6级'
  736. ]
  737. return strs[i]
  738. }
  739. export function alertStatus(i) {
  740. if (i >= 0) {
  741. const strs = [
  742. '待处理',
  743. '已处理'
  744. ]
  745. return strs[i]
  746. } else {
  747. return '已撤销'
  748. }
  749. }
  750. export function hosStoryTitle(i) {
  751. if (i >= 0) {
  752. const strs = [
  753. '未知',
  754. '平安医院',
  755. '质量医院',
  756. '满意医院',
  757. '智慧医院',
  758. '健康医院',
  759. '节约型医院'
  760. ]
  761. return strs[i]
  762. } else {
  763. return '未知'
  764. }
  765. }
  766. export function hosStory(code) {
  767. const enums = {
  768. 'pingAn': 1,
  769. 'zhiLiang': 2,
  770. 'manYi': 3,
  771. 'zhiHui': 4,
  772. 'jianKang': 5,
  773. 'jieYue': 6
  774. }
  775. return enums[code]
  776. }
  777. export function ocAccess(i) {
  778. const strs = [
  779. '未接入',
  780. '已接入'
  781. ]
  782. return strs[i]
  783. }