methods.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. import Apis from '@/common/apis/index'
  2. import uCharts from '@/common/utils/u-charts/u-charts.js'
  3. let chartsLine = {
  4. "type": "line",
  5. "loadingType": "1",
  6. "canvasId": "",
  7. "canvas2d": false,
  8. "background": "none",
  9. "animation": true,
  10. "timing": "easeOut",
  11. "duration": 1000,
  12. "padding": [
  13. 15,
  14. 10,
  15. 0,
  16. 15
  17. ],
  18. "rotate": false,
  19. "errorReload": true,
  20. "fontSize": 12,
  21. "fontColor": "#666666",
  22. "enableScroll": false,
  23. "touchMoveLimit": 60,
  24. "enableMarkLine": false,
  25. "dataLabel": false,
  26. "dataPointShape": true,
  27. "dataPointShapeType": "solid",
  28. "tapLegend": true,
  29. "xAxis": {
  30. "disabled": false,
  31. "axisLine": true,
  32. "axisLineColor": "#CCCCCC",
  33. "calibration": false,
  34. "fontColor": "#666666",
  35. "fontSize": 13,
  36. "rotateLabel": false,
  37. "itemCount": 5,
  38. "boundaryGap": "center",
  39. "disableGrid": true,
  40. "gridColor": "#CCCCCC",
  41. "gridType": "solid",
  42. "dashLength": 4,
  43. "gridEval": 1,
  44. "scrollShow": false,
  45. "scrollAlign": "left",
  46. "scrollColor": "#A6A6A6",
  47. "scrollBackgroundColor": "#EFEBEF",
  48. "format": "xAxisYear"
  49. },
  50. "yAxis": {
  51. "disabled": false,
  52. "disableGrid": false,
  53. "splitNumber": 5,
  54. "gridType": "dash",
  55. "dashLength": 2,
  56. "gridColor": "#CCCCCC",
  57. "padding": 10,
  58. "showTitle": false,
  59. "data": [{
  60. "type": "value",
  61. "position": "left",
  62. "disabled": false,
  63. "axisLine": true,
  64. "axisLineColor": "#CCCCCC",
  65. "calibration": false,
  66. "fontColor": "#666666",
  67. "fontSize": 12,
  68. "textAlign": "right",
  69. "title": "",
  70. "titleFontSize": 14,
  71. "titleOffsetY": 0,
  72. "titleOffsetX": 0,
  73. "titleFontColor": "#666666",
  74. "min": 4,
  75. "max": 5.3,
  76. "tofix": 1,
  77. "unit": "",
  78. "format": ""
  79. }]
  80. },
  81. "legend": {
  82. "show": true,
  83. "position": "top",
  84. "float": "right",
  85. "padding": 10,
  86. "margin": 0,
  87. "backgroundColor": "rgba(0,0,0,0)",
  88. "borderColor": "rgba(0,0,0,0)",
  89. "borderWidth": 0,
  90. "fontSize": 13,
  91. "fontColor": "#666666",
  92. "lineHeight": 11,
  93. "hiddenColor": "#CECECE",
  94. "itemGap": 10
  95. },
  96. "extra": {
  97. "line": {
  98. "type": "curve",
  99. "width": 2
  100. },
  101. "tooltip": {
  102. "showBox": true,
  103. "showArrow": true,
  104. "showCategory": false,
  105. "borderWidth": 0,
  106. "borderRadius": 0,
  107. "borderColor": "#000000",
  108. "borderOpacity": 0.7,
  109. "bgColor": "#000000",
  110. "bgOpacity": 0.7,
  111. "gridType": "solid",
  112. "dashLength": 4,
  113. "gridColor": "#CCCCCC",
  114. "fontColor": "#FFFFFF",
  115. "splitLine": true,
  116. "horizentalLine": false,
  117. "xAxisLabel": false,
  118. "yAxisLabel": false,
  119. "labelBgColor": "#FFFFFF",
  120. "labelBgOpacity": 0.7,
  121. "labelFontColor": "#666666"
  122. },
  123. "markLine": {
  124. "type": "solid",
  125. "dashLength": 4,
  126. "data": []
  127. }
  128. }
  129. }
  130. export default {
  131. async inData() {
  132. try {
  133. uni.showLoading({
  134. title: '数据获取中'
  135. });
  136. const res = await Apis.GetHealthReport({
  137. id: this.patientId
  138. })
  139. res.data.forEach((v) => {
  140. v.date = v.time && v.time.split(' ')[0].replaceAll('-', '/')
  141. })
  142. this.data = res.data
  143. this.getNaked();
  144. uni.hideLoading();
  145. } catch (error) {
  146. console.error(error)
  147. }
  148. },
  149. getNaked() {
  150. let LinA = {
  151. categories: this.data.map(v => v.date),
  152. series: [{
  153. name: '右眼',
  154. lineType: 'solid',
  155. legendShape: 'circle',
  156. color: '#FF8673',
  157. data: this.data.map(v => v.result.visual.r_naked)
  158. },
  159. {
  160. name: '左眼',
  161. lineType: 'solid',
  162. legendShape: 'circle',
  163. color: '#24B1E9',
  164. data: this.data.map(v => v.result.visual.l_naked)
  165. }
  166. ]
  167. }
  168. this.chartsDataA = LinA
  169. this.showCanvasLine("canvasLineA");
  170. let LinB = JSON.parse(JSON.stringify(LinA))
  171. LinB.series[0].data = this.data.map(v => v.result.visual.r_mirror)
  172. LinB.series[1].data = this.data.map(v => v.result.visual.l_mirror)
  173. this.chartsDataB = LinB
  174. this.showCanvasLine("canvasLineB");
  175. let LinC = JSON.parse(JSON.stringify(LinB))
  176. LinC.series[0].data = this.data.map(v => v.result.optometry.r_sph)
  177. LinC.series[1].data = this.data.map(v => v.result.optometry.l_sph)
  178. this.chartsDataC = LinC
  179. this.showCanvasLine("canvasLineC", {
  180. min: -20,
  181. max: 20,
  182. type: '1'
  183. });
  184. let LinD = JSON.parse(JSON.stringify(LinC))
  185. LinD.series[0].data = this.data.map(v => v.result.optometry.r_cyl)
  186. LinD.series[1].data = this.data.map(v => v.result.optometry.l_cyl)
  187. this.chartsDataD = LinD
  188. this.showCanvasLine("canvasLineD", {
  189. min: -6,
  190. max: 6,
  191. type: '2'
  192. });
  193. let LinE = JSON.parse(JSON.stringify(LinD))
  194. LinE.series[0].data = this.data.map(v => v.result.optometry.r_axis)
  195. LinE.series[1].data = this.data.map(v => v.result.optometry.l_axis)
  196. this.chartsDataE = LinE
  197. this.showCanvasLine("canvasLineE", {
  198. min: 0,
  199. max: 190,
  200. type: '3'
  201. });
  202. },
  203. showCanvasLine(canvasId, opt) {
  204. let line = JSON.parse(JSON.stringify(chartsLine))
  205. line.canvasId = canvasId
  206. if (opt) {
  207. line.yAxis.data[0].min = opt.min
  208. line.yAxis.data[0].max = opt.max
  209. line.yAxis.data[0].tofix = 2
  210. this[`chartsOpts${opt.type}`] = line
  211. } else {
  212. this.chartsOpts = line
  213. }
  214. },
  215. }