UploadInforTable.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="table_template">
  3. <table class="table">
  4. <thead>
  5. <tr>
  6. <td>序号</td>
  7. <td>经销商名称</td>
  8. <td>DLR Code</td>
  9. <td>所属区域</td>
  10. <td>筛选</td>
  11. </tr>
  12. </thead>
  13. <tbody>
  14. <tr v-for="(obj, index) in tableData" :key="index" :class="{ table_gray: index%2 === 0 }">
  15. <td>{{ index + 1 }}</td>
  16. <td v-for="(item, index) in obj" :key="index" >
  17. {{ item }}
  18. </td>
  19. <td>
  20. <img src="../../../img/add.png" @click="changeIcon(index)" v-if="imgFlag[index]">
  21. <img src="../../../img/delete.png" @click="changeIcon(index)" v-else>
  22. </td>
  23. </tr>
  24. </tbody>
  25. </table>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. props: {
  31. // 表数据
  32. tableData: {
  33. type: Array,
  34. default: () => {
  35. return []
  36. }
  37. },
  38. // 操作样式
  39. operationStyle: {
  40. type: Object,
  41. default: () => {
  42. return {
  43. color: '#0000ff'
  44. }
  45. }
  46. },
  47. // imgFlag
  48. imgFlag: {
  49. type: Array,
  50. default: () => {
  51. let arr = new Array(20).fill(20);
  52. return arr
  53. }
  54. }
  55. },
  56. methods: {
  57. changeIcon: function(index) {
  58. console.log(index);
  59. this.$emit('change_icon', index);
  60. }
  61. },
  62. mounted() {
  63. },
  64. data() {
  65. return {
  66. }
  67. }
  68. };
  69. </script>
  70. <style scoped lang="less">
  71. .table_template{
  72. text-align: center;
  73. .table{
  74. background-color: #fff;
  75. border-collapse:collapse;
  76. border:none;
  77. width: 100%;
  78. thead{
  79. background-color: #8D9092;
  80. height: 36px;
  81. color: #fff;
  82. }
  83. td{
  84. border: 1px solid #ccc;
  85. }
  86. span{
  87. &:hover{
  88. cursor: pointer;
  89. }
  90. }
  91. }
  92. }
  93. .table_gray{
  94. background: #f5f5f5;
  95. }
  96. img{
  97. width: 20px;
  98. height: 20px;
  99. }
  100. td{
  101. width: 20%;
  102. height: 36px;
  103. }
  104. </style>