record-care.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. return data;
  29. },
  30. }
  31. );
  32. if (res) {
  33. this.setData({
  34. careDetail: res,
  35. }, () => {
  36. this._getData();
  37. });
  38. }
  39. },
  40. async _getData() {
  41. if (this.data.careDetail.patientConditioningScores?.length > 0) {
  42. const option = {
  43. title: {
  44. text: "健康评分",
  45. left: "center",
  46. top: 0,
  47. textStyle: {
  48. fontSize: 18
  49. }
  50. },
  51. tooltip: {
  52. trigger: "axis",
  53. },
  54. xAxis: {
  55. type: "category",
  56. data: this.data.careDetail.patientConditioningScores.map((item: any) => item.time4),
  57. axisLabel: {
  58. interval: 0,
  59. rotate: 45,
  60. fontSize: 12
  61. },
  62. axisTick: {
  63. alignWithLabel: true
  64. }
  65. },
  66. yAxis: {
  67. type: "value",
  68. name: "",
  69. min: 0,
  70. max: 100
  71. },
  72. series: [
  73. {
  74. data: this.data.careDetail.patientConditioningScores.map((item: any) => item.score),
  75. type: "line",
  76. smooth: true,
  77. symbol: 'circle',
  78. symbolSize: 8,
  79. lineStyle: {
  80. color: "#1976d2",
  81. width: 3
  82. },
  83. itemStyle: {
  84. color: "#1976d2",
  85. borderWidth: 2,
  86. borderColor: '#fff'
  87. },
  88. label: {
  89. show: true,
  90. position: 'top',
  91. formatter: function(params: any) {
  92. return params.value;
  93. },
  94. fontSize: 12,
  95. color: '#666'
  96. }
  97. },
  98. ],
  99. grid: {
  100. left: '5%',
  101. right: '5%',
  102. bottom: '15%',
  103. top: '15%',
  104. containLabel: true
  105. },
  106. };
  107. // 获取组件实例
  108. const ecComponent = this.selectComponent('#effectChart');
  109. if (ecComponent) {
  110. ecComponent.init((canvas: any, width: number, height: number, dpr: number) => {
  111. const chart = echarts.init(canvas, null, {
  112. width: width,
  113. height: height,
  114. devicePixelRatio: dpr
  115. });
  116. canvas.setChart(chart);
  117. chart.setOption(option);
  118. return chart;
  119. });
  120. }
  121. }
  122. },
  123. onInit(canvas: any, width: number, height: number, dpr: number) {
  124. const chart = echarts.init(canvas, null, {
  125. width: width,
  126. height: height,
  127. devicePixelRatio: dpr
  128. });
  129. canvas.setChart(chart);
  130. return chart;
  131. }
  132. }
  133. })