securityCheckTableWaybill.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div class="security-check-table-wrapper" :style="{ height: tableWrapperHeight }">
  3. <a-table
  4. :data-source="tableData"
  5. :columns="columns"
  6. :row-key="rowKey"
  7. :row-selection="withSelection ? { selectedRowKeys: selectedRowKeys, onChange: onSelectChange } : null"
  8. :rowClassName="rowClassName"
  9. bordered
  10. :pagination="pagination"
  11. @change="handleTableChange"
  12. :loading="loading"
  13. :scroll="{ y: 600 }"
  14. >
  15. <template v-if="withOperateColumn" slot="operation" slot-scope="text, record">
  16. <div class="column-operate">
  17. <span class="cell-operate-edit" @click="editRow(record)">修改</span>
  18. <span class="cell-operate-delete" @click="deleteRow(record)">删除</span>
  19. </div>
  20. </template>
  21. </a-table>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. name: 'SecurityCheckTable',
  27. props: {
  28. height: {
  29. type: [Number, String],
  30. default: '50vh',
  31. },
  32. tableCols: {
  33. type: Array,
  34. default: () => [],
  35. },
  36. tableData: {
  37. type: Array,
  38. default: () => [],
  39. },
  40. rowKey: {
  41. type: String,
  42. default: 'key',
  43. },
  44. withSelection: {
  45. type: Boolean,
  46. default: false,
  47. },
  48. loading: {
  49. type: Boolean,
  50. default: false,
  51. },
  52. showSummary: {
  53. type: Boolean,
  54. default: false,
  55. },
  56. pagination: {
  57. type: Object,
  58. default: null,
  59. },
  60. },
  61. data() {
  62. return {
  63. selectedRowKeys: [],
  64. }
  65. },
  66. computed: {
  67. columns() {
  68. function setClickHandler(columns) {
  69. return columns.map((col) => {
  70. if (col.clickHandler) {
  71. col.customCell = (row, rowIndex) => {
  72. return {
  73. class: 'cell-click',
  74. on: {
  75. click: () => {
  76. col.clickHandler(row, rowIndex)
  77. },
  78. },
  79. }
  80. }
  81. }
  82. if (col.children) {
  83. setClickHandler(col.children)
  84. }
  85. return col
  86. })
  87. }
  88. return setClickHandler(this.tableCols)
  89. },
  90. tableWrapperHeight() {
  91. return typeof this.height === 'number' ? this.height + 'px' : this.height
  92. },
  93. withOperateColumn() {
  94. return this.columns.find((col) => col.dataIndex === 'operation')
  95. },
  96. },
  97. methods: {
  98. onSelectChange(selectedRowKeys, selectedRows) {
  99. // console.log(selectedRowKeys)
  100. this.selectedRowKeys = selectedRowKeys
  101. },
  102. rowClassName(index) {
  103. if (index.index % 2 == 0) {
  104. return 'warning-row'
  105. } else {
  106. return 'warning-rows'
  107. }
  108. },
  109. editRow(row) {
  110. // console.log('edit')
  111. },
  112. deleteRow(row) {
  113. // console.log('delete')
  114. },
  115. clickHandler(index) {
  116. // console.log(index)
  117. },
  118. handleTableChange(pagination, filters, sorter) {
  119. this.$emit('handleTableChange', pagination)
  120. },
  121. },
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .security-check-table-wrapper {
  126. width: 100%;
  127. ::v-deep .ant-table {
  128. width: 100%;
  129. // .ant-table-content {
  130. // height: 550px !important;
  131. // }
  132. // .ant-table-placeholder {
  133. // min-height: 600px;
  134. // }
  135. .ant-table-body {
  136. height: 600px !important;
  137. }
  138. // .ant-table-tbody {
  139. // min-height: 600px !important;
  140. // }
  141. .ant-table-thead {
  142. th {
  143. padding: 15px 12px;
  144. }
  145. .ant-table-column-title {
  146. font-size: 14px;
  147. font-family: Helvetica, 'Microsoft YaHei';
  148. color: #101116;
  149. font-weight: bold;
  150. }
  151. }
  152. .ant-table-tbody {
  153. .warning-row {
  154. background-color: #f3f5f8;
  155. padding: 9px 16px;
  156. }
  157. .warning-rows {
  158. background-color: #fff;
  159. padding: 9px 16px;
  160. }
  161. td {
  162. font-size: 14px;
  163. font-family: Helvetica, 'Microsoft YaHei';
  164. color: #101116;
  165. padding: 13px 8px;
  166. &.cell-click {
  167. color: #2d67e3;
  168. cursor: pointer;
  169. }
  170. }
  171. .column-operate {
  172. span {
  173. cursor: pointer;
  174. &:not(:last-child) {
  175. margin-right: 25px;
  176. }
  177. &.cell-operate-edit {
  178. color: #2d67e3;
  179. }
  180. &.cell-operate-delete {
  181. color: #ea4545;
  182. }
  183. }
  184. }
  185. }
  186. }
  187. }
  188. </style>