You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
3.5 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <div v-if="null !== props.log" class="h-full flex flex-col">
  3. <div class="border rounded p-3 whitespace-pre bg-white mb-3">
  4. 执行动作 : {{ props.log.action }}
  5. </div>
  6. <div class="border rounded p-3 whitespace-pre bg-white mb-3">
  7. <div>参数列表</div>
  8. <div v-for="(item,index) of props.log.params" :key="index" class="mr-2">
  9. {{ JSON.stringify(item, null, 2) }}
  10. </div>
  11. </div>
  12. <div class="border rounded p-3 whitespace-pre bg-white mb-3 h-0 grow overflow-y-auto">
  13. <div>响应内容</div>
  14. <div class="select-all">{{ JSON.stringify(props.log.response, null, 2) }}</div>
  15. </div>
  16. <a-modal v-model:open="chartEnable" title="曲线" width="90%" @ok="chartEnable = false">
  17. <div ref="chartContainer" class="w-full bg-white mb-3 border rounded" style="height:600px;"></div>
  18. </a-modal>
  19. </div>
  20. </template>
  21. <script setup>
  22. import * as echarts from 'echarts';
  23. import { ref, nextTick, watch } from 'vue';
  24. /** @var {Object} */
  25. const props = defineProps({
  26. log: Object,
  27. });
  28. /** @var {Element} */
  29. const chartContainer = ref(null);
  30. /** @var {Boolean} */
  31. const chartEnable = ref(false);
  32. /** @var {echarts} */
  33. let chart = null;
  34. // watch log
  35. watch(() => props.log, handleLogChange, {deep:true});
  36. // handle log change
  37. async function handleLogChange() {
  38. chartEnable.value = false;
  39. if ( null !== chart ) {
  40. chart.dispose();
  41. chart = null;
  42. }
  43. if ( null === props.log
  44. || undefined === props.log.response
  45. || null === props.log.response ) {
  46. return ;
  47. }
  48. if ( 'A8kScanCurve' === props.log.response.$dataType ) {
  49. chartEnable.value = true;
  50. let minY = Math.min(... props.log.response.scanDataCurve) - 100;
  51. let maxY = Math.max(... props.log.response.scanDataCurve) + 100;
  52. let refLine = props.log.response.refLine.map((v,i) => [i,v]);
  53. let scanDataCurve = props.log.response.scanDataCurve.map((v,i) => [i,v]);
  54. let refCurve = props.log.response.refCurve || [];
  55. refCurve = refCurve.map(v => ({xAxis:v}));
  56. await nextTick();
  57. chart = echarts.init(chartContainer.value);
  58. chart.setOption({
  59. xAxis: {type: 'value', axisLabel : {show:true}},
  60. yAxis: {type: 'value', axisLabel : {show:true}, min:minY, max:maxY},
  61. grid: {left: '3%', right: '4%', bottom: '3%', top:'3%', containLabel: true},
  62. dataZoom : [{type:'inside'},{type:'inside',orient:'vertical'}],
  63. tooltip: {trigger:'axis'},
  64. series: [{
  65. name: 'RefLine',
  66. type: 'line',
  67. itemStyle : {normal:{lineStyle:{width:1},color:'#ffb2b3'}},
  68. showSymbol : false,
  69. data: refLine
  70. }, {
  71. name: 'ScanDataCurve',
  72. type: 'line',
  73. data: scanDataCurve,
  74. itemStyle : {normal:{lineStyle:{width:1},color:'#4d90ff'}},
  75. showSymbol : false,
  76. markLine : {
  77. slient : true,
  78. symbol : 'none',
  79. data : refCurve,
  80. label:{show:false},
  81. lineStyle : {normal:{type:'solid'}}
  82. },
  83. }]
  84. });
  85. }
  86. else if ( 'FileToBeDownload' === props.log.response.$dataType ) {
  87. var url = process.env.NODE_ENV === 'production' ? `${props.log.response.url}` : `http://localhost:80${props.log.response.url}`;
  88. window.open(url);
  89. }
  90. }
  91. </script>