sceneEchart.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 sgList = ref<number[]>([]);
  26. const sgobjList = ref<number[]>([]);
  27. const yzlList = ref<number[]>([]);
  28. const yixStringData = ref<string[]>([]);
  29. const echartTypr = ref('line')
  30. const nameList = ref<string[]>(['四维看见/Mesh','四维看看/Mesh','四维深时/点云','四维深时/Mesh','四维深光/点云','四维深光/Mesh','圆周率/Mesh']);
  31. const maxSize = ref(0);
  32. const chartRef = ref<HTMLDivElement | null>(null);
  33. const { setOptions } = useECharts(chartRef as Ref<HTMLDivElement>)
  34. function Search(val){
  35. emit('change',val)
  36. }
  37. function expor(val){
  38. let fileTile = props.title||'订单数据'
  39. let fields = {
  40. 'time':'日期',
  41. 'kj': nameList.value[0],
  42. 'kk': nameList.value[1],
  43. 'ss':nameList.value[2],
  44. 'dy':nameList.value[3],
  45. 'sg':nameList.value[4],
  46. 'sgdy':nameList.value[5],
  47. 'yzl':nameList.value[6],
  48. }
  49. if('场景趋势分析' == fileTile){
  50. fileTile = `${val && val.value == 0?'新增':'累计'}`+fileTile
  51. }
  52. let data = yixStringData.value.map((ele,index) => {
  53. return {
  54. 'time':ele,
  55. 'kj':kjList.value && kjList.value[index] || 0,
  56. 'kk':kkList.value && kkList.value[index] || 0,
  57. 'ss':ssList.value && ssList.value[index] || 0,
  58. 'dy':ssobjList.value && ssobjList.value[index] || 0,
  59. 'sg':sgList.value && sgList.value[index] || 0,
  60. 'sgdy':sgobjList.value && sgobjList.value[index] || 0,
  61. 'yzl':yzlList.value && yzlList.value[index] || 0,
  62. }
  63. })
  64. exportElsxFile(data,fields,fileTile)
  65. }
  66. function handlesetOptions() {
  67. setOptions({
  68. tooltip: {
  69. trigger: 'axis',
  70. axisPointer: {
  71. lineStyle: {
  72. width: 1,
  73. color: '#019680',
  74. },
  75. },
  76. },
  77. legend: {
  78. orient: 'horizontal',
  79. bottom: 0,
  80. },
  81. // grid: { left: '2%', right: '2%', top: '10%', bottom: '10%', containLabel: true },
  82. xAxis: {
  83. type: 'category',
  84. // data: [...new Array(30)].map((_item, index) => `${index + 1}日`),
  85. data: yixStringData.value,
  86. },
  87. yAxis: {
  88. type: 'value',
  89. // max: maxSize.value,
  90. splitNumber: 4,
  91. },
  92. series: [
  93. {
  94. data: kjList.value,
  95. type: echartTypr.value,
  96. itemStyle: { color: '#38a0ff' },
  97. barMaxWidth: 80,
  98. name: nameList.value[0],
  99. },
  100. {
  101. data: kkList.value,
  102. type: echartTypr.value,
  103. itemStyle: { color: '#4cca73' },
  104. barMaxWidth: 80,
  105. name: nameList.value[1],
  106. },
  107. {
  108. data: ssList.value,
  109. type: echartTypr.value,
  110. itemStyle: { color: '#FDD56A' },
  111. barMaxWidth: 80,
  112. name: nameList.value[2],
  113. },
  114. {
  115. data: ssobjList.value,
  116. type: echartTypr.value,
  117. itemStyle: { color: '#d58b55' },
  118. barMaxWidth: 80,
  119. name: nameList.value[3],
  120. },
  121. {
  122. data: sgList.value,
  123. type: echartTypr.value,
  124. itemStyle: { color: '#55d187' },
  125. barMaxWidth: 80,
  126. name: nameList.value[4],
  127. },
  128. {
  129. data: sgobjList.value,
  130. type: echartTypr.value,
  131. itemStyle: { color: '#faa19d' },
  132. barMaxWidth: 80,
  133. name: nameList.value[5],
  134. },
  135. {
  136. data: yzlList.value,
  137. type: echartTypr.value,
  138. itemStyle: { color: '#00c8af' },
  139. barMaxWidth: 80,
  140. name: nameList.value[6],
  141. },
  142. ],
  143. });
  144. }
  145. watch(
  146. () => props.echartData,
  147. (echartData) => {
  148. kjList.value = echartData.kjList ||[]
  149. kkList.value = echartData.kkList ||[]
  150. ssList.value = echartData.ssList ||[]
  151. ssobjList.value = echartData.ssobjList ||[]
  152. sgList.value = echartData.sgList ||[]
  153. sgobjList.value = echartData.sgobjList ||[]
  154. yzlList.value = echartData.yzlList ||[]
  155. yixStringData.value = echartData.xdata ||[]
  156. if(echartData.nameList){
  157. nameList.value = echartData.nameList
  158. }
  159. if(echartData.echartTypr){
  160. echartTypr.value = echartData.echartTypr
  161. }
  162. handlesetOptions();
  163. },
  164. {
  165. immediate: true,
  166. deep: true,
  167. },
  168. );
  169. </script>