sceneEchart.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <Card :title="title||'订单数据统计'">
  3. <template #extra>
  4. <condition @change="Search" @expor="expor" />
  5. </template>
  6. <div ref="chartRef" :style="{ height, width }"></div>
  7. </Card>
  8. </template>
  9. <script lang="ts" setup>
  10. import { basicProps } from './props';
  11. import condition from './condition.vue';
  12. import { Card, DatePicker } from 'ant-design-vue';
  13. import { ref, Ref, watch, defineEmits } from 'vue';
  14. import { useECharts } from '/@/hooks/web/useECharts';
  15. import { exportElsxFile, } from '/@/utils/file/download';
  16. const props = defineProps({
  17. loading: Boolean,
  18. ...basicProps,
  19. });
  20. const emit = defineEmits(["alertSome"])
  21. const kjList = ref<number[]>([]);
  22. const kkList = ref<number[]>([]);
  23. const ssList = ref<number[]>([]);
  24. const ssobjList = ref<number[]>([]);
  25. const yixStringData = ref<string[]>([]);
  26. const echartTypr = ref('line')
  27. const nameList = ref<string[]>(['看见场景','看看场景','深时场景','点云场景']);
  28. const maxSize = ref(0);
  29. const chartRef = ref<HTMLDivElement | null>(null);
  30. const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
  31. function Search(val){
  32. emit('change',val)
  33. }
  34. function expor(val){
  35. // emit('expor',val)
  36. let hader = ['时间', ...nameList.value]
  37. let data = yixStringData.value.map((ele,index) => {
  38. return {
  39. '时间':ele,
  40. '看见场景':kjList.value && kjList.value[index] || 0,
  41. '看看场景':kkList.value && kkList.value[index] || 0,
  42. '深时场景':ssList.value && ssList.value[index] || 0,
  43. '点云场景':ssobjList.value && ssobjList.value[index] || 0,
  44. }
  45. })
  46. exportElsxFile(hader,data,'订单数据')
  47. }
  48. function handlesetOptions() {
  49. setOptions({
  50. tooltip: {
  51. trigger: 'axis',
  52. axisPointer: {
  53. lineStyle: {
  54. width: 1,
  55. color: '#019680',
  56. },
  57. },
  58. },
  59. legend: {
  60. orient: 'horizontal',
  61. bottom: 0,
  62. },
  63. // grid: { left: '2%', right: '2%', top: '10%', bottom: '10%', containLabel: true },
  64. xAxis: {
  65. type: 'category',
  66. // data: [...new Array(30)].map((_item, index) => `${index + 1}日`),
  67. data: yixStringData.value,
  68. },
  69. yAxis: {
  70. type: 'value',
  71. // max: maxSize.value,
  72. splitNumber: 4,
  73. },
  74. series: [
  75. {
  76. data: kjList.value,
  77. type: echartTypr.value,
  78. itemStyle: { color: '#38a0ff' },
  79. barMaxWidth: 80,
  80. name: nameList.value[0],
  81. },
  82. {
  83. data: kkList.value,
  84. type: echartTypr.value,
  85. itemStyle: { color: '#4cca73' },
  86. barMaxWidth: 80,
  87. name: nameList.value[1],
  88. },
  89. {
  90. data: ssList.value,
  91. type: echartTypr.value,
  92. itemStyle: { color: '#FDD56A' },
  93. barMaxWidth: 80,
  94. name: nameList.value[2],
  95. },
  96. {
  97. data: ssobjList.value,
  98. type: echartTypr.value,
  99. itemStyle: { color: '#d58b55' },
  100. barMaxWidth: 80,
  101. name: nameList.value[3],
  102. },
  103. ],
  104. });
  105. }
  106. watch(
  107. () => props.echartData,
  108. (echartData) => {
  109. kjList.value = echartData.kjList ||[]
  110. kkList.value = echartData.kkList ||[]
  111. ssList.value = echartData.ssList ||[]
  112. ssobjList.value = echartData.ssobjList ||[]
  113. yixStringData.value = echartData.xdata ||[]
  114. if(echartData.nameList){
  115. nameList.value = echartData.nameList
  116. }
  117. if(echartData.echartTypr){
  118. echartTypr.value = echartData.echartTypr
  119. }
  120. handlesetOptions();
  121. },
  122. {
  123. immediate: true,
  124. deep: true,
  125. },
  126. );
  127. </script>