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.

146 lines
4.8 KiB

1 year ago
1 year ago
1 year ago
1 year ago
7 months ago
1 year ago
1 year ago
1 year ago
1 year ago
7 months ago
1 year ago
1 year ago
1 year ago
7 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
7 months 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. <a-modal v-model:open="reultDisplay" title="" width="90%" @ok="reultDisplay = false">
  13. <div class="border rounded p-3 whitespace-pre bg-white mb-3 h-0 grow overflow-y-auto" style="height:600px;">
  14. <vue-json-pretty :data="resultContent" :deep="1"></vue-json-pretty>
  15. </div>
  16. </a-modal>
  17. <a-modal v-model:open="chartEnable" title="曲线" width="90%" @ok="chartEnable = false">
  18. <div ref="chartContainer" class="w-full bg-white mb-3 border rounded" style="height:600px;"></div>
  19. </a-modal>
  20. </div>
  21. </template>
  22. <script setup>
  23. import * as echarts from 'echarts';
  24. import { ref, nextTick, watch } from 'vue';
  25. import VueJsonPretty from 'vue-json-pretty';
  26. import 'vue-json-pretty/lib/styles.css';
  27. /** @var {Object} */
  28. const props = defineProps({
  29. log: Object,
  30. });
  31. /** @var {Element} */
  32. const chartContainer = ref(null);
  33. /** @var {Boolean} */
  34. const chartEnable = ref(false);
  35. const reultDisplay = ref(false);
  36. const resultContent = ref({});
  37. /** @var {echarts} */
  38. let chart = null;
  39. // watch log
  40. watch(() => props.log, handleLogChange, { deep: true });
  41. // handle log change
  42. async function handleLogChange() {
  43. chartEnable.value = false;
  44. if (null !== chart) {
  45. chart.dispose();
  46. chart = null;
  47. }
  48. if (null === props.log
  49. || undefined === props.log.response
  50. || null === props.log.response) {
  51. return;
  52. }
  53. if ('A8kScanCurve' === props.log.response.$dataType) {
  54. chartEnable.value = true;
  55. let minY = Math.min(...props.log.response.scanDataCurve) - 100;
  56. let maxY = Math.max(...props.log.response.scanDataCurve) + 100;
  57. let refLine = props.log.response.refLine.map((v, i) => [i, v]);
  58. let scanDataCurve = props.log.response.scanDataCurve.map((v, i) => [i, v]);
  59. let refCurve = props.log.response.refCurve || [];
  60. refCurve = refCurve.map(v => ({ xAxis: v }));
  61. await nextTick();
  62. chart = echarts.init(chartContainer.value);
  63. chart.setOption({
  64. xAxis: { type: 'value', axisLabel: { show: true } },
  65. yAxis: { type: 'value', axisLabel: { show: true }, min: minY, max: maxY },
  66. grid: { left: '3%', right: '4%', bottom: '3%', top: '3%', containLabel: true },
  67. dataZoom: [{ type: 'inside' }, { type: 'inside', orient: 'vertical' }],
  68. tooltip: { trigger: 'axis' },
  69. series: [{
  70. name: 'RefLine',
  71. type: 'line',
  72. itemStyle: { normal: { lineStyle: { width: 1 }, color: '#ffb2b3' } },
  73. showSymbol: false,
  74. data: refLine
  75. }, {
  76. name: 'ScanDataCurve',
  77. type: 'line',
  78. data: scanDataCurve,
  79. itemStyle: { normal: { lineStyle: { width: 1 }, color: '#4d90ff' } },
  80. showSymbol: false,
  81. markLine: {
  82. slient: true,
  83. symbol: 'none',
  84. data: refCurve,
  85. label: { show: true },
  86. lineStyle: { normal: { type: 'solid' } }
  87. },
  88. }]
  89. });
  90. }
  91. else if ('FileToBeDownload' === props.log.response.$dataType) {
  92. var url = process.env.NODE_ENV === 'production' ? `${props.log.response.url}` : `http://localhost:80${props.log.response.url}`;
  93. window.open(url);
  94. }
  95. else if ('ExtApiCurve' === props.log.response.$dataType) {
  96. let response = props.log.response;
  97. chartEnable.value = true;
  98. let curve = response.data;
  99. let markLine = response.markLine || [];
  100. markLine = markLine.map(v => ({ xAxis: v }));
  101. await nextTick();
  102. chart = echarts.init(chartContainer.value);
  103. chart.setOption({
  104. xAxis: { type: response.xtype, axisLabel: { show: true } },
  105. yAxis: { type: response.ytype, axisLabel: { show: true }, min: response.minY, max: response.maxY },
  106. grid: { left: '3%', right: '4%', bottom: '3%', top: '3%', containLabel: true },
  107. dataZoom: [{
  108. type: 'slider', // 滑动条缩放
  109. show: true,
  110. xAxisIndex: [0], // 只作用于x轴
  111. }, {
  112. type: 'slider', // 滑动条缩放
  113. show: true,
  114. yAxisIndex: [0], // 只作用于y轴
  115. }],
  116. tooltip: { trigger: 'axis' },
  117. series: [{
  118. name: response.name,
  119. type: 'line',
  120. data: curve,
  121. itemStyle: { normal: { lineStyle: { width: 1 }, color: '#4d90ff' } },
  122. showSymbol: false,
  123. markLine: {
  124. slient: true,
  125. symbol: 'none',
  126. data: markLine,
  127. label: { show: true },
  128. lineStyle: { normal: { type: 'solid' } }
  129. },
  130. }]
  131. });
  132. } else {
  133. resultContent.value = props.log.response;
  134. reultDisplay.value = true;
  135. }
  136. }
  137. </script>