RelationalPreflightReport.vue 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <script setup lang="ts">
  2. export interface RelationalPreflightReport {
  3. schema: string;
  4. objectName: string;
  5. businessKey: string;
  6. objects: { name: string; kind: string }[];
  7. columns: { name: string; type: string; nullable: boolean | null; length: number | null; precision: number | null; scale: number | null; encoding: string | null; default: string | null }[];
  8. sample: { name: string; sampled: number; missing: number; distinct: number }[];
  9. minimumGrant: string | null;
  10. advice?: {
  11. keys: { name: string; primary: boolean; columns: string[] }[];
  12. timeIndex: string | null;
  13. estimatedRows: number | null;
  14. estimatedRawBytes: number | null;
  15. estimatedReadSeconds: number | null;
  16. };
  17. checks: { code: string; severity: 'pass' | 'warning' | 'block'; message: string }[];
  18. }
  19. defineProps<{ report: RelationalPreflightReport }>();
  20. const emit = defineEmits<{ object: [name: string] }>();
  21. const severity = { pass: '通过', warning: '警告', block: '阻断' } as const;
  22. </script>
  23. <template>
  24. <div>
  25. <p>{{ report.schema }}.{{ report.objectName }}<template v-if="report.businessKey"> · 业务键 {{ report.businessKey }}</template></p>
  26. <ul aria-label="来源预检">
  27. <li v-for="check in report.checks" :key="check.code">{{ severity[check.severity] }} · {{ check.message }}</li>
  28. </ul>
  29. <el-collapse>
  30. <el-collapse-item v-if="report.advice" title="候选业务键、索引和容量估算">
  31. <p v-for="key in report.advice.keys" :key="key.name">{{ key.primary ? '主键' : '非空唯一索引' }} {{ key.name }}({{ key.columns.join('、') }})</p>
  32. <p v-if="!report.advice.keys.length">源目录未提供已证实的非空唯一键</p>
  33. <p v-if="report.advice.timeIndex">时间分页索引 {{ report.advice.timeIndex }}</p>
  34. <p>源端目录估计 {{ report.advice.estimatedRows ?? '未知' }} 行 · Raw {{ report.advice.estimatedRawBytes ?? '未知' }} 字节 · 源端读取 {{ report.advice.estimatedReadSeconds ?? '未知' }} 秒</p>
  35. </el-collapse-item>
  36. <el-collapse-item title="授权架构中的表和视图">
  37. <el-table :data="report.objects" max-height="220">
  38. <el-table-column label="对象"><template #default="{ row }"><el-button link @click="emit('object', row.name)">{{ row.name }}</el-button></template></el-table-column>
  39. <el-table-column prop="kind" label="类型" />
  40. </el-table>
  41. </el-collapse-item>
  42. <el-collapse-item title="当前对象字段和类型">
  43. <el-table :data="report.columns" max-height="240">
  44. <el-table-column prop="name" label="字段" />
  45. <el-table-column prop="type" label="类型" />
  46. <el-table-column label="可空"><template #default="{ row }">{{ row.nullable ? '是' : '否' }}</template></el-table-column>
  47. <el-table-column prop="length" label="长度" />
  48. <el-table-column prop="precision" label="精度" />
  49. <el-table-column prop="scale" label="小数位" />
  50. <el-table-column prop="encoding" label="字符集" />
  51. </el-table>
  52. </el-collapse-item>
  53. <el-collapse-item v-if="report.sample.length" title="样本统计">
  54. <el-table :data="report.sample">
  55. <el-table-column prop="name" label="字段" />
  56. <el-table-column prop="sampled" label="抽样行数" />
  57. <el-table-column prop="missing" label="空值" />
  58. <el-table-column prop="distinct" label="非空不同值" />
  59. </el-table>
  60. </el-collapse-item>
  61. <el-collapse-item v-if="report.minimumGrant" title="对象最小读取权限示例">
  62. <pre>{{ report.minimumGrant }}</pre>
  63. </el-collapse-item>
  64. </el-collapse>
  65. </div>
  66. </template>