formTable.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <script setup lang="ts">
  2. import { onMounted, computed,ref } from 'vue'
  3. const props = defineProps({
  4. content: {
  5. type: String,
  6. default: ''
  7. },
  8. })
  9. const show = ref(false)
  10. const tableData = computed(() => {
  11. let arr = []
  12. if (props.content.includes('json')) {
  13. arr = JSON.parse(props.content.split('json')[1].split('```')[0])
  14. }
  15. else arr = JSON.parse(props.content)
  16. if (arr[0].data) show.value = true
  17. return arr.map((_:any) => ({
  18. label: _.label ?? _.findByValue,
  19. source: _.excelColumn,
  20. value:_.data
  21. }))
  22. })
  23. </script>
  24. <template>
  25. <div class="mb-2" >抽取对应关系</div>
  26. <el-table :data="tableData" style="width: 100%">
  27. <el-table-column show-overflow-tooltip prop="label" label="表单项" width="100" />
  28. <el-table-column show-overflow-tooltip prop="source" label="数据源" width="100" />
  29. <el-table-column v-if="show" show-overflow-tooltip prop="value" label="数据值" width="100" />
  30. </el-table>
  31. </template>
  32. <style scoped lang="scss">
  33. .els {
  34. white-space: nowrap; /* 强制文本不换行 */
  35. overflow: hidden; /* 隐藏溢出内容 */
  36. text-overflow: ellipsis; /* 显示省略号 */
  37. }
  38. .document_r {
  39. display: flex;
  40. flex-direction: column;
  41. align-items: end;
  42. }
  43. .document_content {
  44. width: 240px;
  45. height: 50px;
  46. display: flex;
  47. align-items: center;
  48. justify-content: start;
  49. padding: 8px 8px;
  50. background-color: rgba(255, 255, 255, 0.3);
  51. border: 1px solid rgba(102, 102, 102, 0.3);
  52. border-radius: 6px;
  53. margin-bottom: 6px;
  54. .document_img {
  55. margin-right: 8px;
  56. height: 32px;
  57. }
  58. .document_text {
  59. flex-shrink: 0;
  60. width: calc(100% - 56px);
  61. }
  62. }
  63. .document_content1 {
  64. width: fit-content;
  65. max-width: 240px;
  66. padding: 10px 12px;
  67. border-radius: 6px;
  68. background-color: rgba(255, 255, 255, 0.8);
  69. }
  70. </style>