index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div>
  3. <el-table
  4. :data="tableData"
  5. border
  6. highlight-current-row
  7. >
  8. <el-table-column
  9. prop="generateTime"
  10. label="生成时间"
  11. width="160"
  12. />
  13. <el-table-column
  14. prop="datasource"
  15. label="数据源"
  16. width="200"
  17. />
  18. <el-table-column
  19. label="packageName"
  20. width="200"
  21. >
  22. <template slot-scope="scope">
  23. {{ scope.row.configContent.packageName }}
  24. </template>
  25. </el-table-column>
  26. <el-table-column
  27. label="删除前缀"
  28. width="100"
  29. show-overflow-tooltip
  30. >
  31. <template slot-scope="scope">
  32. {{ scope.row.configContent.delPrefix }}
  33. </template>
  34. </el-table-column>
  35. <el-table-column
  36. label="表名"
  37. >
  38. <template slot-scope="scope">
  39. <div v-if="scope.row.configContent.tableNames.length <= 5">
  40. {{ scope.row.configContent.tableNames.join('、') }}
  41. </div>
  42. <div v-else>
  43. {{ showArray(scope.row.configContent.tableNames, 3, '、') }}
  44. <el-popover
  45. placement="left"
  46. width="400"
  47. trigger="click">
  48. <el-table :data="scope.row.configContent.tableNames" max-height="400px">
  49. <el-table-column label="表名">
  50. <template slot-scope="scope">{{ scope.row }}</template>
  51. </el-table-column>
  52. </el-table>
  53. <el-button type="text" slot="reference">更多</el-button>
  54. </el-popover>
  55. </div>
  56. </template>
  57. </el-table-column>
  58. <el-table-column
  59. prop="templateNames"
  60. label="模板"
  61. show-overflow-tooltip
  62. >
  63. <template slot-scope="scope">
  64. {{ scope.row.templateNames && scope.row.templateNames.join('、') }}
  65. </template>
  66. </el-table-column>
  67. <el-table-column
  68. label="操作"
  69. width="100"
  70. >
  71. <template slot-scope="scope">
  72. <el-button type="text" @click="onGenerate(scope.row)">再次生成</el-button>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. </div>
  77. </template>
  78. <script>
  79. export default {
  80. name: 'GenerateHistory',
  81. data() {
  82. return {
  83. tableData: []
  84. }
  85. },
  86. created() {
  87. this.loadTable()
  88. },
  89. methods: {
  90. loadTable: function() {
  91. this.post('/history/list', {}, function(resp) {
  92. this.tableData = resp.data
  93. })
  94. },
  95. onGenerate(row) {
  96. const config = JSON.stringify(row.configContent)
  97. this.goRoute(`result/${config}`)
  98. },
  99. showArray(array, limit, split) {
  100. if (!array || array.length === 0) {
  101. return ''
  102. }
  103. const ret = []
  104. for (let i = 0; i < Math.min(limit, array.length); i++) {
  105. ret.push(array[i])
  106. }
  107. return ret.join(split)
  108. }
  109. }
  110. }
  111. </script>