record-care.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import * as echarts from '../ec-canvas/echarts.min';
  2. import { Post } from "../../../lib/request/method"
  3. Component({
  4. lifetimes: {
  5. async attached() {
  6. const careId = wx.getStorageSync('careId');
  7. if (careId) {
  8. await this.getCareDetail(careId);
  9. }
  10. }
  11. },
  12. properties: {
  13. },
  14. data: {
  15. charts: {} as any,
  16. careDetail: {} as any,
  17. ec: {
  18. lazyLoad: true
  19. }
  20. },
  21. methods: {
  22. async getCareDetail(id: number) {
  23. const res = await Post(
  24. `/patientCrManage/getPcrProcessById/${id}`,
  25. {},
  26. {
  27. transform({ data }: any) {
  28. console.log(data, "获取健康评分数据");
  29. return data;
  30. },
  31. }
  32. );
  33. if (res) {
  34. this.setData({
  35. careDetail: res,
  36. }, () => {
  37. this._getData();
  38. });
  39. }
  40. },
  41. async _getData() {
  42. if (this.data.careDetail.patientConditioningScores?.length > 0) {
  43. const option = {
  44. title: {
  45. text: "健康评分",
  46. left: "center",
  47. top: 0,
  48. textStyle: {
  49. fontSize: 18
  50. }
  51. },
  52. tooltip: {
  53. trigger: "axis",
  54. },
  55. xAxis: {
  56. type: "category",
  57. data: this.data.careDetail.patientConditioningScores.map((item: any) => item.time4),
  58. axisLabel: {
  59. interval: 0,
  60. rotate: 45,
  61. fontSize: 12
  62. },
  63. axisTick: {
  64. alignWithLabel: true
  65. }
  66. },
  67. yAxis: {
  68. type: "value",
  69. name: "",
  70. min: 0,
  71. max: 100
  72. },
  73. series: [
  74. {
  75. data: this.data.careDetail.patientConditioningScores.map((item: any) => item.score),
  76. type: "line",
  77. smooth: true,
  78. symbol: 'circle',
  79. symbolSize: 8,
  80. lineStyle: {
  81. color: "#1976d2",
  82. width: 3
  83. },
  84. itemStyle: {
  85. color: "#1976d2",
  86. borderWidth: 2,
  87. borderColor: '#fff'
  88. },
  89. label: {
  90. show: true,
  91. position: 'top',
  92. formatter: function(params: any) {
  93. return params.value;
  94. },
  95. fontSize: 12,
  96. color: '#666'
  97. }
  98. },
  99. ],
  100. grid: {
  101. left: '5%',
  102. right: '5%',
  103. bottom: '15%',
  104. top: '15%',
  105. containLabel: true
  106. },
  107. };
  108. // 获取组件实例
  109. const ecComponent = this.selectComponent('#effectChart');
  110. if (ecComponent) {
  111. ecComponent.init((canvas: any, width: number, height: number, dpr: number) => {
  112. const chart = echarts.init(canvas, null, {
  113. width: width,
  114. height: height,
  115. devicePixelRatio: dpr
  116. });
  117. canvas.setChart(chart);
  118. chart.setOption(option);
  119. return chart;
  120. });
  121. }
  122. }
  123. },
  124. onInit(canvas: any, width: number, height: number, dpr: number) {
  125. const chart = echarts.init(canvas, null, {
  126. width: width,
  127. height: height,
  128. devicePixelRatio: dpr
  129. });
  130. canvas.setChart(chart);
  131. return chart;
  132. }
  133. }
  134. })