securityCheckTable.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <div
  3. v-loading="loading"
  4. class="security-check-table-wrapper"
  5. :style="{ height: tableWrapperHeight }"
  6. >
  7. <a-table
  8. ref="table"
  9. :data-source="tableData"
  10. :columns="tableCols"
  11. stripeed
  12. fited
  13. bordered
  14. height="100%"
  15. >
  16. <template v-if="withSelection">
  17. <a-table-column type="selection" width="35" />
  18. </template>
  19. <template v-for="col in cols">
  20. <NestTableColumn :key="col.prop" :col="col" />
  21. </template>
  22. <template v-if="withOperateColumn">
  23. <a-table-column label="操作" class-name="column-operate" :width="130">
  24. <template slot-scope="scope">
  25. <span class="cell-operate-edit" @click="editRow(scope.row)"
  26. >修改</span
  27. >
  28. <span class="cell-operate-delete" @click="deleteRow(scope.row)"
  29. >删除</span
  30. >
  31. </template>
  32. </a-table-column>
  33. </template>
  34. </a-table>
  35. </div>
  36. </template>
  37. <script>
  38. import NestTableColumn from "./nestTableColumn.vue";
  39. export default {
  40. name: "SecurityCheckTable",
  41. components: { NestTableColumn },
  42. props: {
  43. height: {
  44. type: [Number, String],
  45. default: "50vh",
  46. },
  47. tableCols: {
  48. type: Array,
  49. default: () => [],
  50. },
  51. tableData: {
  52. type: Array,
  53. default: () => [],
  54. },
  55. withSelection: {
  56. type: Boolean,
  57. default: false,
  58. },
  59. showSummary: {
  60. type: Boolean,
  61. default: false,
  62. },
  63. withOperateColumn: {
  64. type: Boolean,
  65. default: false,
  66. },
  67. },
  68. data() {
  69. return {
  70. loading: false,
  71. cols: [],
  72. data: [],
  73. };
  74. },
  75. computed: {
  76. tableWrapperHeight() {
  77. return typeof this.height === "number" ? this.height + "px" : this.height;
  78. },
  79. },
  80. watch: {
  81. tableCols: {
  82. handler(val) {
  83. this.cols = val;
  84. },
  85. deep: true,
  86. immediate: true,
  87. },
  88. tableData: {
  89. handler(val) {
  90. this.data = val;
  91. },
  92. deep: true,
  93. immediate: true,
  94. },
  95. },
  96. updated() {
  97. this.$refs["table"].doLayout();
  98. },
  99. methods: {
  100. editRow(row) {
  101. console.log("edit");
  102. },
  103. deleteRow(row) {
  104. console.log("delete");
  105. },
  106. },
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .security-check-table-wrapper {
  111. width: 100%;
  112. ::v-deep .ant-table-column-title {
  113. font-size: 14px;
  114. font-family: Helvetica, "Microsoft YaHei";
  115. color: #101116;
  116. font-weight: bold;
  117. }
  118. ::v-deep .ant-table {
  119. width: 100%;
  120. .ant-table__cell {
  121. .cell {
  122. // padding: 0 19px;
  123. font-size: 14px;
  124. font-family: Helvetica, "Microsoft YaHei";
  125. color: #101116;
  126. }
  127. &.ant-table-column--selection .cell {
  128. padding: 0;
  129. text-align: center;
  130. }
  131. }
  132. .ant-table__header {
  133. .ant-table__cell {
  134. > .cell {
  135. font-weight: bold;
  136. }
  137. &:not(.is-leaf) > .cell {
  138. text-align: center;
  139. }
  140. }
  141. }
  142. .ant-table__body {
  143. .cell .cell-click {
  144. color: #2d67e3;
  145. cursor: pointer;
  146. }
  147. .column-operate .cell {
  148. span {
  149. cursor: pointer;
  150. &:not(:last-child) {
  151. margin-right: 25px;
  152. }
  153. &.cell-operate-edit {
  154. color: #2d67e3;
  155. }
  156. &.cell-operate-delete {
  157. color: #ea4545;
  158. }
  159. }
  160. }
  161. }
  162. }
  163. }
  164. </style>