nestTableColumn.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template>
  2. <a-table-column
  3. v-if="col.children && col.children.length"
  4. :prop="col[propName]"
  5. :label="col[labelName]"
  6. :width="col.width"
  7. show-overflow-tooltip
  8. >
  9. <NestTableColumn
  10. v-for="childCol in col.children"
  11. :key="childCol[propName]"
  12. :col="childCol"
  13. :prop-name="propName"
  14. :label-name="labelName"
  15. />
  16. </a-table-column>
  17. <a-table-column
  18. v-else
  19. :prop="col[propName]"
  20. :label="col[labelName]"
  21. :width="col.width"
  22. show-overflow-tooltip
  23. >
  24. <template slot-scope="scope">
  25. <span
  26. v-if="col.clickHandler"
  27. class="cell-click"
  28. @click="col.clickHandler"
  29. >{{ scope.row[col[propName]] }}</span
  30. >
  31. <span v-else>{{ scope.row[col[propName]] }}</span>
  32. </template>
  33. </a-table-column>
  34. <!-- <a-table-column
  35. :prop="col[propName]"
  36. :label="col[labelName]"
  37. >
  38. <template v-for="childCol in col.children">
  39. <NestTableColumn
  40. v-if="childCol.children && childCol.children.length"
  41. :key="childCol[propName]"
  42. :col="childCol"
  43. :prop-name="propName"
  44. :label-name="labelName"
  45. />
  46. <a-table-column
  47. v-else
  48. :key="childCol[propName]"
  49. :prop="childCol[propName]"
  50. :label="childCol[labelName]"
  51. >
  52. <template slot-scope="scope">
  53. <span
  54. v-if="childCol.clickHandler"
  55. class="cell-click"
  56. >{{ scope.row[childCol[propName]] }}</span>
  57. <span v-else>{{ scope.row[childCol[propName]] }}</span>
  58. </template>
  59. </a-table-column>
  60. </template>
  61. </a-table-column> -->
  62. </template>
  63. <script>
  64. export default {
  65. name: "NestTableColumn",
  66. props: {
  67. col: {
  68. type: Object,
  69. required: true,
  70. },
  71. propName: {
  72. type: String,
  73. default: "prop",
  74. },
  75. labelName: {
  76. type: String,
  77. default: "label",
  78. },
  79. },
  80. };
  81. </script>
  82. <style>
  83. </style>