publicMethod.ts 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. import { dapingImage } from "@/utils/dapingImage";
  2. import { ref } from "vue";
  3. var selectColor = function (value: any, typestr: string, floor: any) {
  4. if (value === null || value === undefined) return null;
  5. const {
  6. yellowlight,
  7. redlight,
  8. greenlight,
  9. bluegreen,
  10. yellowgreen,
  11. redyellow,
  12. bluelight,
  13. } = dapingImage;
  14. var colorArr: { [key: string]: Array<any> } = {
  15. temp: [
  16. {
  17. min: Number.NEGATIVE_INFINITY,
  18. max: 20,
  19. image: bluelight,
  20. color: "#52A0FF",
  21. fcolor: "rgba(0, 95, 163, 0.76)",
  22. },
  23. {
  24. min: 20,
  25. max: 22,
  26. image: bluegreen,
  27. color: "#40DDCE",
  28. fcolor: "rgba(0, 160, 163, 0.76)",
  29. },
  30. {
  31. min: 22,
  32. max: 27,
  33. image: greenlight,
  34. color: "#7ED874",
  35. fcolor: "rgba(34, 139, 81, 0.76)",
  36. },
  37. {
  38. min: 27,
  39. max: 28,
  40. image: yellowgreen,
  41. color: "#C4E34F",
  42. fcolor: "rgba(133, 148, 0, 0.76)",
  43. },
  44. {
  45. min: 28,
  46. max: 30,
  47. image: redyellow,
  48. color: "#EE9F2B",
  49. fcolor: "rgba(173, 107, 0, 0.8)",
  50. },
  51. {
  52. min: 30,
  53. max: Number.POSITIVE_INFINITY,
  54. image: redlight,
  55. color: "#F5483D",
  56. fcolor: "rgba(154, 40, 40, 0.8)",
  57. },
  58. ],
  59. humidity: [
  60. {
  61. min: 0,
  62. max: 30,
  63. image: redlight,
  64. color: "#F5483D",
  65. fcolor: "rgba(173, 107, 0, 0.8)",
  66. },
  67. {
  68. min: 30,
  69. max: 35,
  70. image: redyellow,
  71. color: "#EE9F2B",
  72. fcolor: "rgba(133, 148, 0, 0.76)",
  73. },
  74. {
  75. min: 35,
  76. max: 65,
  77. image: greenlight,
  78. color: "#7ED874",
  79. fcolor: "rgba(34, 139, 81, 0.76)",
  80. },
  81. {
  82. min: 65,
  83. max: 95,
  84. image: bluegreen,
  85. color: "#40DDCE",
  86. fcolor: "rgba(0, 160, 163, 0.76)",
  87. },
  88. {
  89. min: 95,
  90. max: Number.POSITIVE_INFINITY,
  91. image: bluelight,
  92. color: "#52A0FF",
  93. fcolor: "rgba(0, 95, 163, 0.76)",
  94. },
  95. ],
  96. co2: [
  97. {
  98. min: 0,
  99. max: 800,
  100. image: greenlight,
  101. color: "#7ED874",
  102. fcolor: "rgba(34, 139, 81, 0.76)",
  103. },
  104. {
  105. min: 800,
  106. max: 1000,
  107. image: yellowgreen,
  108. color: "#C4E34F",
  109. fcolor: "rgba(133, 148, 0, 0.76)",
  110. },
  111. {
  112. min: 1000,
  113. max: 2500,
  114. image: redyellow,
  115. color: "#EE9F2B",
  116. fcolor: "rgba(173, 107, 0, 0.8)",
  117. },
  118. {
  119. min: 2500,
  120. max: Number.POSITIVE_INFINITY,
  121. image: redlight,
  122. color: "#F5483D",
  123. fcolor: "rgba(154, 40, 40, 0.8)",
  124. },
  125. ],
  126. methanal: [
  127. {
  128. min: 0,
  129. max: 0.08,
  130. image: greenlight,
  131. color: "#7ED874",
  132. fcolor: "rgba(34, 139, 81, 0.76)",
  133. },
  134. {
  135. min: 0.08,
  136. max: 0.1,
  137. image: yellowgreen,
  138. color: "#C4E34F",
  139. fcolor: "rgba(133, 148, 0, 0.76)",
  140. },
  141. {
  142. min: 0.1,
  143. max: 0.2,
  144. image: redyellow,
  145. color: "#EE9F2B",
  146. fcolor: "rgba(173, 107, 0, 0.8)",
  147. },
  148. {
  149. min: 0.2,
  150. max: Number.POSITIVE_INFINITY,
  151. image: redlight,
  152. color: "#F5483D",
  153. fcolor: "rgba(154, 40, 40, 0.8)",
  154. },
  155. ],
  156. pm25: [
  157. {
  158. min: 0,
  159. max: 35,
  160. image: greenlight,
  161. color: "#7ED874",
  162. fcolor: "rgba(34, 139, 81, 0.76)",
  163. },
  164. {
  165. min: 35,
  166. max: 75,
  167. image: yellowgreen,
  168. color: "#C4E34F",
  169. fcolor: "rgba(133, 148, 0, 0.76)",
  170. },
  171. {
  172. min: 75,
  173. max: 150,
  174. image: yellowlight,
  175. color: "#EFD62E",
  176. fcolor: "rgba(156, 137, 0, 0.76)",
  177. },
  178. {
  179. min: 150,
  180. max: 250,
  181. image: redyellow,
  182. color: "#EE9F2B",
  183. fcolor: "rgba(173, 107, 0, 0.8)",
  184. },
  185. {
  186. min: 250,
  187. max: Number.POSITIVE_INFINITY,
  188. image: redlight,
  189. color: "#F5483D",
  190. fcolor: "rgba(154, 40, 40, 0.8)",
  191. },
  192. ],
  193. };
  194. var nowColorArr = colorArr[typestr];
  195. var colorImage = null;
  196. nowColorArr.forEach((ele: any) => {
  197. if (value > ele.min && value < ele.max) {
  198. colorImage = floor ? ele.fcolor : ele.image;
  199. }
  200. });
  201. return colorImage;
  202. };
  203. var operateNum = function (num: any) {
  204. return num.toFixed(1);
  205. };
  206. export { selectColor };