mtaTable.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <table class="mta-table">
  3. <thead>
  4. <tr>
  5. <th v-for="item in config" :key="item.key">{{item.label}}</th>
  6. </tr>
  7. </thead>
  8. <tbody>
  9. <tr v-for="(itemTd,index) in data" :key="index">
  10. <td v-for="item in config" :key="item.key">
  11. <template v-if="item.key === 'name'">
  12. <span>
  13. {{itemTd[item.key]}}
  14. <i class="table-shikan mta-hidden-xs" v-if="itemTd['shikanUrl']" @click="shikan(itemTd['shikanUrl'])">试看</i>
  15. </span>
  16. </template>
  17. <template v-else>
  18. <span>{{itemTd[item.key]}}</span>
  19. </template>
  20. </td>
  21. </tr>
  22. </tbody>
  23. </table>
  24. </template>
  25. <script>
  26. export default {
  27. name: "mtaTable",
  28. props: {
  29. data: {
  30. type: Array,
  31. default: () => ([])
  32. },
  33. config: {
  34. type: Array,
  35. default: () => ([])
  36. }
  37. },
  38. methods: {
  39. shikan(url) {
  40. this.$emit('shi-kan', {url})
  41. }
  42. }
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .table-shikan {
  47. cursor: pointer;
  48. color: #00b96b;
  49. font-size: 14px;
  50. font-weight: 500;
  51. margin-left: 20px;
  52. }
  53. .mta-table {
  54. width: 100%;
  55. border: 1px solid #E8E8E8;
  56. border-collapse: collapse;
  57. td {
  58. font-size: 14px;
  59. font-weight: 500;
  60. color: #565656;
  61. line-height: 60px;
  62. padding: 5px 20px;
  63. border: 1px solid #E8E8E8;
  64. }
  65. th {
  66. padding: 5px 20px;
  67. color: #565656;
  68. line-height: 60px;
  69. font-size: 14px;
  70. border: 1px solid #E8E8E8;
  71. }
  72. }
  73. @media (max-width: 768px) {
  74. .mta-table {
  75. td {
  76. line-height: 14px;
  77. padding: 5px 5px ;
  78. font-size: 12px;
  79. display: inline-block;
  80. box-sizing: border-box;
  81. span {
  82. display: inline-block;
  83. width: 100%;
  84. text-overflow: ellipsis;overflow: hidden;word-wrap: break-word;white-space: nowrap;word-break: break-all;
  85. }
  86. &:first-child {
  87. width: 60%;
  88. }
  89. &:nth-child(2) {
  90. width: 20%;
  91. }
  92. &:last-child {
  93. width: 20%;
  94. }
  95. }
  96. th {
  97. line-height: 14px;
  98. padding: 5px 5px;
  99. font-size: 12px;
  100. display: inline-block;
  101. box-sizing: border-box;
  102. &:first-child {
  103. width: 60%;
  104. }
  105. &:nth-child(2) {
  106. width: 20%;
  107. }
  108. &:last-child {
  109. width: 20%;
  110. }
  111. }
  112. }
  113. }
  114. </style>