methods.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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": true,
  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": true,
  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. "labelCount": 5,
  38. "itemCount": 5,
  39. "boundaryGap": "center",
  40. "disableGrid": true,
  41. "gridColor": "#CCCCCC",
  42. "gridType": "solid",
  43. "dashLength": 4,
  44. "gridEval": 1,
  45. "scrollShow": false,
  46. "scrollAlign": "left",
  47. "scrollColor": "#A6A6A6",
  48. "scrollBackgroundColor": "#EFEBEF",
  49. "format": "xAxisYear"
  50. },
  51. "yAxis": {
  52. "disabled": false,
  53. "disableGrid": false,
  54. "splitNumber": 5,
  55. "gridType": "dash",
  56. "dashLength": 2,
  57. "gridColor": "#CCCCCC",
  58. "padding": 10,
  59. "showTitle": true,
  60. "data": [{
  61. "type": "value",
  62. "position": "left",
  63. "disabled": false,
  64. "axisLine": true,
  65. "axisLineColor": "#CCCCCC",
  66. "calibration": false,
  67. "fontColor": "#666666",
  68. "fontSize": 12,
  69. "textAlign": "right",
  70. "title": "",
  71. "titleFontSize": 17,
  72. "titleOffsetY": -15,
  73. "titleOffsetX": 40,
  74. "titleFontColor": "#666666",
  75. "min": 4,
  76. "max": 5.3,
  77. "tofix": 1,
  78. "unit": "",
  79. "format": ""
  80. }]
  81. },
  82. "legend": {
  83. "show": true,
  84. "position": "top",
  85. "float": "right",
  86. "padding": 10,
  87. "margin": 0,
  88. "backgroundColor": "rgba(0,0,0,0)",
  89. "borderColor": "rgba(0,0,0,0)",
  90. "borderWidth": 0,
  91. "fontSize": 13,
  92. "fontColor": "#666666",
  93. "lineHeight": 11,
  94. "hiddenColor": "#CECECE",
  95. "itemGap": 10
  96. },
  97. "extra": {
  98. "line": {
  99. "type": "curve",
  100. "width": 2
  101. },
  102. "tooltip": {
  103. "showBox": true,
  104. "showArrow": true,
  105. "showCategory": false,
  106. "borderWidth": 0,
  107. "borderRadius": 0,
  108. "borderColor": "#000000",
  109. "borderOpacity": 0.7,
  110. "bgColor": "#000000",
  111. "bgOpacity": 0.7,
  112. "gridType": "solid",
  113. "dashLength": 4,
  114. "gridColor": "#CCCCCC",
  115. "fontColor": "#FFFFFF",
  116. "splitLine": true,
  117. "horizentalLine": false,
  118. "xAxisLabel": false,
  119. "yAxisLabel": false,
  120. "labelBgColor": "#FFFFFF",
  121. "labelBgOpacity": 0.7,
  122. "labelFontColor": "#666666"
  123. },
  124. "markLine": {
  125. "type": "solid",
  126. "dashLength": 4,
  127. "data": []
  128. }
  129. }
  130. }
  131. export default {
  132. async inData() {
  133. try {
  134. uni.showLoading({
  135. title: '数据获取中'
  136. });
  137. const res = await Apis.GetHealthReport({
  138. id: this.patientId
  139. })
  140. res.data.forEach((v) => {
  141. v.date = v.time && v.time.split(' ')[0].replaceAll('-', '/')
  142. })
  143. this.data = res.data
  144. this.getNaked();
  145. uni.hideLoading();
  146. } catch (error) {
  147. console.error(error)
  148. }
  149. },
  150. getNaked() {
  151. let LinA = {
  152. categories: this.data.map(v => v.date),
  153. series: [{
  154. name: '右眼',
  155. lineType: 'solid',
  156. legendShape: 'circle',
  157. color: '#FF8673',
  158. data: this.data.map(v => v.result.visual.r_naked)
  159. },
  160. {
  161. name: '左眼',
  162. lineType: 'solid',
  163. legendShape: 'circle',
  164. color: '#24B1E9',
  165. data: this.data.map(v => v.result.visual.l_naked)
  166. }
  167. ]
  168. }
  169. this.chartsDataA = LinA
  170. this.showCanvasLine({
  171. title: '裸眼数据',
  172. optName: 'chartsOpts1'
  173. });
  174. let LinB = JSON.parse(JSON.stringify(LinA))
  175. LinB.series[0].data = this.data.map(v => v.result.visual.r_mirror)
  176. LinB.series[1].data = this.data.map(v => v.result.visual.l_mirror)
  177. this.chartsDataB = LinB
  178. this.showCanvasLine({
  179. title: '戴镜数据',
  180. optName: 'chartsOpts2'
  181. });
  182. let LinC = JSON.parse(JSON.stringify(LinB))
  183. LinC.series[0].data = this.data.map(v => v.result.optometry.r_sph)
  184. LinC.series[1].data = this.data.map(v => v.result.optometry.l_sph)
  185. this.chartsDataC = LinC
  186. this.showCanvasLine({
  187. title: '球镜',
  188. min: -20,
  189. max: 20,
  190. titleOffsetX: -50,
  191. optName: 'chartsOpts3'
  192. });
  193. let LinD = JSON.parse(JSON.stringify(LinC))
  194. LinD.series[0].data = this.data.map(v => v.result.optometry.r_cyl)
  195. LinD.series[1].data = this.data.map(v => v.result.optometry.l_cyl)
  196. this.chartsDataD = LinD
  197. this.showCanvasLine({
  198. title: '柱镜',
  199. min: -6,
  200. max: 6,
  201. titleOffsetX: -50,
  202. optName: 'chartsOpts4'
  203. });
  204. let LinE = JSON.parse(JSON.stringify(LinD))
  205. LinE.series[0].data = this.data.map(v => v.result.optometry.r_axis)
  206. LinE.series[1].data = this.data.map(v => v.result.optometry.l_axis)
  207. this.chartsDataE = LinE
  208. this.showCanvasLine({
  209. title: '轴位',
  210. min: 0,
  211. max: 190,
  212. titleOffsetX: -50,
  213. optName: 'chartsOpts5'
  214. });
  215. },
  216. showCanvasLine(opt) {
  217. let line = JSON.parse(JSON.stringify(chartsLine))
  218. line.yAxis.data[0].title = opt.title || ''
  219. if (opt && opt.max) {
  220. line.yAxis.data[0].min = opt.min
  221. line.yAxis.data[0].max = opt.max
  222. line.yAxis.data[0].tofix = 2
  223. line.yAxis.data[0].titleOffsetX = opt.titleOffsetX || ''
  224. }
  225. this.$set(this, opt.optName, line)
  226. }
  227. }