sceneEchart.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <Card :title="title||'订单数据统计'">
  3. <template #extra>
  4. <condition type="2" @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[]>(['看看场景',]);//'看看场景','深时场景','深时obj']);
  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. let fileTile = props.title||'订单数据'
  36. let fields = {
  37. 'time':'日期',
  38. 'kj':'看看场景',
  39. // 'kk':'看看场景',
  40. // 'ss':'深时场景',
  41. // 'dy':'深时obj',
  42. }
  43. if('场景趋势分析' == fileTile){
  44. fileTile = `${val && val.value == 0?'新增':'累计'}`+fileTile
  45. }
  46. let data = yixStringData.value.map((ele,index) => {
  47. return {
  48. 'time':ele,
  49. 'kj':kjList.value && kjList.value[index] || 0,
  50. // 'kk':kkList.value && kkList.value[index] || 0,
  51. // 'ss':ssList.value && ssList.value[index] || 0,
  52. // 'dy':ssobjList.value && ssobjList.value[index] || 0,
  53. }
  54. })
  55. exportElsxFile(data,fields,fileTile)
  56. }
  57. function handlesetOptions() {
  58. setOptions({
  59. tooltip: {
  60. trigger: 'axis',
  61. axisPointer: {
  62. lineStyle: {
  63. width: 1,
  64. color: '#019680',
  65. },
  66. },
  67. },
  68. legend: {
  69. orient: 'horizontal',
  70. bottom: 0,
  71. },
  72. // grid: { left: '2%', right: '2%', top: '10%', bottom: '10%', containLabel: true },
  73. xAxis: {
  74. type: 'category',
  75. // data: [...new Array(30)].map((_item, index) => `${index + 1}日`),
  76. data: yixStringData.value,
  77. },
  78. yAxis: {
  79. type: 'value',
  80. // max: maxSize.value,
  81. splitNumber: 4,
  82. },
  83. series: [
  84. {
  85. data: kjList.value,
  86. type: echartTypr.value,
  87. itemStyle: { color: '#38a0ff' },
  88. barMaxWidth: 80,
  89. name: nameList.value[0],
  90. },
  91. // {
  92. // data: kkList.value,
  93. // type: echartTypr.value,
  94. // itemStyle: { color: '#4cca73' },
  95. // barMaxWidth: 80,
  96. // name: nameList.value[1],
  97. // },
  98. // {
  99. // data: ssList.value,
  100. // type: echartTypr.value,
  101. // itemStyle: { color: '#FDD56A' },
  102. // barMaxWidth: 80,
  103. // name: nameList.value[2],
  104. // },
  105. // {
  106. // data: ssobjList.value,
  107. // type: echartTypr.value,
  108. // itemStyle: { color: '#d58b55' },
  109. // barMaxWidth: 80,
  110. // name: nameList.value[3],
  111. // },
  112. ],
  113. });
  114. }
  115. watch(
  116. () => props.echartData,
  117. (echartData) => {
  118. kjList.value = echartData.kjList ||[]
  119. kkList.value = echartData.kkList ||[]
  120. ssList.value = echartData.ssList ||[]
  121. ssobjList.value = echartData.ssobjList ||[]
  122. yixStringData.value = echartData.xdata ||[]
  123. if(echartData.nameList){
  124. nameList.value = echartData.nameList
  125. }
  126. if(echartData.echartTypr){
  127. echartTypr.value = echartData.echartTypr
  128. }
  129. handlesetOptions();
  130. },
  131. {
  132. immediate: true,
  133. deep: true,
  134. },
  135. );
  136. </script>