config.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. import dayjs from "dayjs";
  2. export const formatTofixed = val => val != 0 && !val ? '' : val.toFixed(2);
  3. // const formatTofixed = val => val
  4. export const columns = [
  5. {
  6. title: "检测日期",
  7. key: "vdateTime",
  8. width: 80,
  9. fixed: "left",
  10. render: ({ vdateTime }) => dayjs(vdateTime).format("YYYY-MM-DD")
  11. },
  12. {
  13. title: "检测小时",
  14. key: "testHour",
  15. width: 60,
  16. render: ({ testHour }) => dayjs(testHour).format("HH")
  17. },
  18. // {
  19. // title: "进水流量",
  20. // key: "jsll",
  21. // width: 100,
  22. // render: ({ jsll }) => formatTofixed(jsll)
  23. // },
  24. {
  25. title: "#1好氧池硝酸盐",
  26. key: "no3Hlj1Jqr",
  27. width: 100,
  28. render: ({ no3Hlj1Jqr }) => formatTofixed(no3Hlj1Jqr)
  29. },
  30. {
  31. title: "#2好氧池硝酸盐",
  32. key: "no3Hlj2Jqr",
  33. width: 100,
  34. render: ({ no3Hlj2Jqr }) => formatTofixed(no3Hlj2Jqr)
  35. },
  36. {
  37. title: "#1缺氧氨氮",
  38. key: "nh31Jqr",
  39. width: 100,
  40. render: ({ nh31Jqr }) => formatTofixed(nh31Jqr)
  41. },
  42. {
  43. title: "#2缺氧氨氮",
  44. key: "nh32Jqr",
  45. width: 100,
  46. render: ({ nh32Jqr }) => formatTofixed(nh32Jqr)
  47. },
  48. {
  49. title: "#1缺氧硝酸盐",
  50. key: "qyckxsyAll1",
  51. width: 100,
  52. render: ({ qyckxsyAll }) => {
  53. let num = ''
  54. if ( qyckxsyAll ) {
  55. const n = JSON.parse(qyckxsyAll)[0];
  56. num = formatTofixed(n);
  57. }
  58. return num;
  59. }
  60. },
  61. {
  62. title: "#2缺氧硝酸盐",
  63. key: "qyckxsyAll2",
  64. width: 100,
  65. render: ({ qyckxsyAll }) =>{
  66. let num = ''
  67. if ( qyckxsyAll ) {
  68. const n = JSON.parse(qyckxsyAll)[1];
  69. num = formatTofixed(n);
  70. }
  71. return num;
  72. }
  73. },
  74. // {
  75. // title: "好氧池正磷酸盐",
  76. // key: "hyzlsyAll",
  77. // width: 120,
  78. // render: ({ hyzlsyAll }) => formatTofixed(hyzlsyAll)
  79. // },
  80. {
  81. title: "二沉池正鳞酸盐",
  82. key: "tpRccJqr",
  83. width: 100,
  84. render: ({ tpRccJqr }) => formatTofixed(tpRccJqr)
  85. },
  86. ];
  87. export const ForecastColumns = [
  88. {
  89. title: "时间",
  90. key: "remark",
  91. width: 140,
  92. fixed: "left",
  93. },
  94. {
  95. title: "预测类型",
  96. key: "category",
  97. width: 120,
  98. },
  99. {
  100. title: "预测1时间",
  101. key: "forecastTimeOne",
  102. width: 130,
  103. },
  104. {
  105. title: "实际1小时值",
  106. key: "realOne",
  107. width: 100,
  108. render: ({ realOne }) => formatTofixed(realOne)
  109. },
  110. {
  111. title: "预测1小时值",
  112. key: "hsForecastOne",
  113. width: 100,
  114. render: ({ hsForecastOne }) => formatTofixed(hsForecastOne)
  115. },
  116. {
  117. title: "预测1小时误差值",
  118. key: "hsOneSubtract",
  119. width: 130,
  120. render: ({ hsOneSubtract }) => formatTofixed(hsOneSubtract)
  121. },
  122. {
  123. title: "预测1小时百分比误差",
  124. key: "hsErrorRateOneStr",
  125. width: 160,
  126. },
  127. {
  128. title: "机理模型1小时值",
  129. key: "jlForecastOne",
  130. width: 140,
  131. render: ({ jlForecastOne }) => formatTofixed(jlForecastOne)
  132. },
  133. {
  134. title: "机理模型1小时误差值",
  135. key: "jlOneSubtract",
  136. width: 150,
  137. render: ({ jlOneSubtract }) => formatTofixed(jlOneSubtract)
  138. },
  139. {
  140. title: "机理模型1小时百分比误差",
  141. key: "jlErrorRateOneStr",
  142. width: 180,
  143. },
  144. {
  145. title: "预测2时间",
  146. key: "forecastTimeTwo",
  147. width: 130,
  148. },
  149. {
  150. title: "实际2小时值",
  151. key: "realTwo",
  152. width: 100,
  153. render: ({ realTwo }) => formatTofixed(realTwo)
  154. },
  155. {
  156. title: "预测2小时值",
  157. key: "hsForecastTwo",
  158. width: 100,
  159. render: ({ hsForecastTwo }) => formatTofixed(hsForecastTwo)
  160. },
  161. {
  162. title: "预测2误差值",
  163. key: "hsTwoSubtract",
  164. width: 100,
  165. render: ({ hsTwoSubtract }) => formatTofixed(hsTwoSubtract)
  166. },
  167. {
  168. title: "预测2小时百分比误差",
  169. key: "hsErrorRateTwoStr",
  170. width: 160,
  171. },
  172. {
  173. title: "机理模型2小时值",
  174. key: "jlForecastTwo",
  175. width: 140,
  176. render: ({ jlForecastTwo }) => formatTofixed(jlForecastTwo)
  177. },
  178. {
  179. title: "机理模型2小时差值",
  180. key: "jlTwoSubtract",
  181. width: 150,
  182. render: ({ jlTwoSubtract }) => formatTofixed(jlTwoSubtract)
  183. },
  184. {
  185. title: "机理模型2小时百分比误差",
  186. key: "jlErrorRateTwoStr",
  187. width: 180,
  188. },
  189. {
  190. title: "预测3时间",
  191. key: "forecastTimeThree",
  192. width: 130,
  193. },
  194. {
  195. title: "实际3小时值",
  196. key: "realThree",
  197. width: 100,
  198. render: ({ realThree }) => formatTofixed(realThree)
  199. },
  200. {
  201. title: "预测3小时值",
  202. key: "hsForecastThree",
  203. width: 100,
  204. render: ({ hsForecastThree }) => formatTofixed(hsForecastThree)
  205. },
  206. {
  207. title: "预测3误差值",
  208. key: "hsThreeSubtract",
  209. width: 160,
  210. render: ({ hsThreeSubtract }) => formatTofixed(hsThreeSubtract)
  211. },
  212. {
  213. title: "预测3小时百分比误差",
  214. key: "hsErrorRateThreeStr",
  215. width: 160,
  216. },
  217. {
  218. title: "机理模型3小时值",
  219. key: "jlForecastThree",
  220. width: 140,
  221. render: ({ jlForecastThree }) => formatTofixed(jlForecastThree)
  222. },
  223. {
  224. title: "机理模型3小时差值",
  225. key: "jlThreeSubtract",
  226. width: 150,
  227. render: ({ jlThreeSubtract }) => formatTofixed(jlThreeSubtract)
  228. },
  229. {
  230. title: "机理模型3小时百分比误差",
  231. key: "jlErrorRateThreeStr",
  232. width: 180,
  233. },
  234. ];
  235. export const getEchartLineOptions = ({ xAxisData, seriesData }) => {
  236. const colorList = [
  237. "#FF6737",
  238. "#00AB84",
  239. "#85E822",
  240. "#21CCFF",
  241. "#FFE122",
  242. "#313CA9",
  243. "#F023FF",
  244. "#FFD22E",
  245. "#2181FF",
  246. "#F22",
  247. "#37DDE0",
  248. ];
  249. const series = seriesData.map((item, index) => {
  250. return {
  251. name: item.name,
  252. type: "line",
  253. smooth: true,
  254. showSymbol: false,
  255. itemStyle: {
  256. opacity: 0.8,
  257. color: colorList[index],
  258. },
  259. // tooltip: {
  260. // valueFormatter: function (value) {
  261. // return value;
  262. // },
  263. // },
  264. data: item.data,
  265. };
  266. });
  267. const option = {
  268. grid: {
  269. top: 80,
  270. bottom: 50,
  271. left: 40,
  272. right: 30,
  273. },
  274. tooltip: {
  275. trigger: "axis",
  276. // confine: true,
  277. appendToBody: true,
  278. },
  279. title: {
  280. show: !xAxisData.length,
  281. text: '暂无数据',
  282. x: 'center',
  283. y: 'center',
  284. textStyle: {
  285. fontSize: 14,
  286. fontWeight: 'normal',
  287. }
  288. },
  289. legend: [
  290. {
  291. show: !!xAxisData.length,
  292. data: ["进水流量", "#1好氧池硝酸盐", "#1缺氧氨氮", "#1缺氧硝酸盐"],
  293. top: 10,
  294. left: 10,
  295. icon: "rect",
  296. itemWidth: 10,
  297. itemHeight: 10,
  298. textStyle: {
  299. color: "rgba(0,0,0,0.65)",
  300. },
  301. selected: {
  302. '进水流量':false
  303. }
  304. },
  305. {
  306. show: !!xAxisData.length,
  307. data: ["二沉池正鳞酸盐", "#2好氧池硝酸盐", "#2缺氧氨氮", "#2缺氧硝酸盐"],
  308. top: 35,
  309. left: 10,
  310. icon: "rect",
  311. itemWidth: 10,
  312. itemHeight: 10,
  313. icon: "rect",
  314. itemWidth: 10,
  315. itemHeight: 10,
  316. textStyle: {
  317. color: "rgba(0,0,0,0.65)",
  318. },
  319. },
  320. ],
  321. xAxis: [
  322. {
  323. type: "category",
  324. data: xAxisData || [],
  325. boundaryGap: false,
  326. axisTick: {
  327. show: false,
  328. },
  329. axisLine: {
  330. lineStyle: {
  331. color: "#DAE0E1",
  332. },
  333. },
  334. axisLabel: {
  335. align: "center",
  336. color: "#828282",
  337. margin: 10,
  338. },
  339. },
  340. ],
  341. yAxis: [
  342. {
  343. scale: false,
  344. minInterval: 1,
  345. backgroundColor: "#FFFFFF",
  346. splitLine: {
  347. lineStyle: {
  348. color: ["#DAE0E1"],
  349. shadowColor: "#DAE0E1",
  350. shadowBlur: 1,
  351. opacity: 1,
  352. width: 1,
  353. type: "dashed",
  354. },
  355. },
  356. axisLine: {
  357. show: false,
  358. },
  359. axisLabel: {
  360. align: "center",
  361. color: "#828282",
  362. margin: 20,
  363. },
  364. },
  365. ],
  366. series
  367. };
  368. return option;
  369. };
  370. export const getEchartMultiLineOption = ({ xAxisData, echartData, specificData }) => {
  371. const colors = ["#5B8FF9", "#82c370", "#ffbf59"];
  372. const series = echartData.map(({ name, val: data }, index) => ({
  373. name,
  374. data,
  375. type: "line",
  376. showSymbol: false,
  377. lineStyle: {
  378. width: 2,
  379. color: colors[index],
  380. },
  381. smooth: true,
  382. xAxisIndex: 0,
  383. }));
  384. series.push({
  385. name: '预测值',
  386. tooltip: {
  387. show: false
  388. },
  389. type: "line",
  390. symbolSize: 8,
  391. itemStyle: {
  392. color: "red",
  393. },
  394. itemStyle: {
  395. color: colors[0],
  396. },
  397. xAxisIndex: 0,
  398. data: specificData,
  399. });
  400. const option = {
  401. dataZoom: [{
  402. bottom: 10,
  403. height: 20,
  404. show: true,
  405. start: 0,
  406. end: 100,
  407. xAxisIndex: [0],
  408. }],
  409. color: colors,
  410. grid: {
  411. left: "5%",
  412. top: "10%",
  413. right: "12%",
  414. bottom: '18%',
  415. containLabel: true,
  416. },
  417. legend: {
  418. left: "left",
  419. icon: "circle",
  420. orient: "vertical",
  421. left: "88%",
  422. top: "center",
  423. itemWidth: 8,
  424. itemHeight: 8,
  425. padding: [0, 30]
  426. },
  427. tooltip: {
  428. trigger: "axis",
  429. },
  430. xAxis: [
  431. {
  432. type: "category",
  433. boundaryGap: false,
  434. data: xAxisData,
  435. },
  436. ],
  437. yAxis: {
  438. type: "value",
  439. },
  440. series,
  441. };
  442. return option;
  443. };