healthLineChart.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <div class="pageBox">
  3. <wt-chooser @change="switchWt" :wpId="wpId" :wtId="wtId"></wt-chooser>
  4. <simple-line-chart :height="'100px'" v-for="(item, index) in chartData" :key="index" :title="item.title" :data="item.data" :color="item.color" :lineTitle="item.lineTitle" />
  5. </div>
  6. </template>
  7. <script>
  8. import SimpleLineChart from "../../components/chart/line/simple-line-chart.vue";
  9. import WtChooser from "@com/coms/wt-chooser/wt-chooser.vue"
  10. export default {
  11. setup() {},
  12. components: { SimpleLineChart ,WtChooser},
  13. data() {
  14. return {
  15. chartData:[]
  16. };
  17. },
  18. created() {
  19. this.wtId = this.$route.params.wtId;
  20. this.wpId = this.$route.params.wpId;
  21. this.requestData();
  22. },
  23. methods:{
  24. switchWt(data){
  25. this.$router.push(`/health/health4/healthLineChart/${data.wpId}/${data.wtId}`);
  26. this.wtId = this.$route.params.wtId;
  27. this.wpId = this.$route.params.wpId;
  28. this.requestData();
  29. },
  30. requestData(){
  31. let that=this;
  32. that.API.requestData({
  33. method: "POST",
  34. subUrl: "healthsub/hsFjValueIndex",
  35. data:{
  36. wtId: that.wtId
  37. },
  38. success(res) {
  39. const color=["green","yellow","purple","blue","orange"];
  40. let chartData=[];
  41. let lineTitle=[];
  42. res.data.xData.forEach(ele=>{
  43. lineTitle.push(new Date(ele).formatDate("hh:mm"));
  44. });
  45. res.data.datasets.forEach((ele,index)=>{
  46. chartData.push({
  47. title:ele.name,
  48. data:ele.data,
  49. color:color[index],
  50. lineTitle
  51. });
  52. });
  53. that.chartData=chartData;
  54. },
  55. });
  56. }
  57. }
  58. };
  59. </script>
  60. <style lang="less" scoped>
  61. .pageBox {
  62. width: 100%;
  63. height:calc(100% - 1.481vh * 2);
  64. display: flex;
  65. flex-direction: column;
  66. justify-content: space-between;
  67. .chart{
  68. width: 100%;
  69. height:25%;
  70. }
  71. }
  72. </style>