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.

165 lines
5.5 KiB

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