index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <el-table
  3. v-if="innerValue.length"
  4. v-bind="$attrs"
  5. v-on="$listeners"
  6. :data="innerValue"
  7. border
  8. stripe
  9. highlight-current-row
  10. class="el-super-table"
  11. >
  12. <slot></slot>
  13. <el-table-column
  14. v-for="({ item, attr }, index) in showColumns"
  15. :key="index"
  16. :prop="item.key"
  17. :label="item.title"
  18. :width="item.width || 225"
  19. show-overflow-tooltip
  20. >
  21. <template slot-scope="scope">
  22. <component
  23. v-if="attr.is === 'el-dict-tag'"
  24. v-bind="attr"
  25. :size="$attrs.size"
  26. :value="scope.row[item.key]"
  27. :options="dict.type[attr.dictName]"
  28. ></component>
  29. <component
  30. v-else-if="attr.is === 'el-file-preview'"
  31. v-bind="attr"
  32. v-model="scope.row[item.key]"
  33. ></component>
  34. <component
  35. v-else-if="attr.is === 'el-computed-input-v2'"
  36. v-bind="attr"
  37. v-model="scope.row[item.key]"
  38. ></component>
  39. <component v-else is="span">{{
  40. scope.row[item.key] || "--"
  41. }}</component>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <el-empty v-else :image-size="200"></el-empty>
  46. </template>
  47. <script>
  48. export default {
  49. name: "SuperTable",
  50. props: {
  51. value: {
  52. type: [Array],
  53. require: true,
  54. },
  55. dict: {
  56. type: [Object],
  57. require: true,
  58. },
  59. columns: {
  60. type: [Array],
  61. require: true,
  62. },
  63. },
  64. components: {
  65. ElDictTag: () => import("@/components/DictTag/index.vue"),
  66. ElFilePreview: () => import("@/components/file-preview/index.vue"),
  67. ElComputedInputV2: () => import("@/components/computed-input-v2/index.vue"),
  68. },
  69. data() {
  70. return {};
  71. },
  72. computed: {
  73. innerValue: {
  74. get() {
  75. return this.value;
  76. },
  77. set(value) {
  78. this.$emit("input", value);
  79. },
  80. },
  81. showColumns: {
  82. get() {
  83. return this.columns.filter(({ attr }) => attr.isHidden);
  84. },
  85. },
  86. },
  87. watch: {},
  88. methods: {},
  89. created() {},
  90. mounted() {},
  91. destroyed() {},
  92. };
  93. </script>
  94. <style scoped></style>