t-table.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view class="t-table" :style="{ 'border-width': border + 'px', 'border-color': borderColor }">
  3. <slot />
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. props: {
  9. border: {
  10. type: String,
  11. default: '1'
  12. },
  13. borderColor: {
  14. type: String,
  15. default: '#d0dee5'
  16. },
  17. isCheck: {
  18. type: Boolean,
  19. default: false
  20. }
  21. },
  22. provide() {
  23. return {
  24. table: this
  25. };
  26. },
  27. data() {
  28. return {};
  29. },
  30. created() {
  31. this.childrens = [];
  32. this.index = 0;
  33. },
  34. methods: {
  35. fire(e, index, len) {
  36. let childrens = this.childrens;
  37. console.log(childrens);
  38. // 全选
  39. if (index === 0) {
  40. childrens.map((vm, index) => {
  41. vm.checkboxData.checked = e;
  42. return vm;
  43. });
  44. } else {
  45. let isAll = childrens.find((n, ids) => ids !== 0 && !n.checkboxData.checked);
  46. childrens[0].checkboxData.checked = isAll ? false : true;
  47. }
  48. let fireArr = [];
  49. for (let i = 0; i < childrens.length; i++) {
  50. if (childrens[i].checkboxData.checked && i !== 0) {
  51. fireArr.push(childrens[i].checkboxData.value - 1);
  52. }
  53. }
  54. this.$emit('change', {
  55. detail: fireArr
  56. });
  57. }
  58. }
  59. };
  60. </script>
  61. <style scoped>
  62. .t-table {
  63. width: 100%;
  64. border: 1px #d0dee5 solid;
  65. border-left: none;
  66. border-top: none;
  67. box-sizing: border-box;
  68. border-radius: 10px;
  69. overflow: hidden;
  70. }
  71. .t-table>>>t-tr {
  72. display: flex;
  73. }
  74. .t-table>>>t-tr:nth-child(2n-1) {
  75. background: #BFF2FC;
  76. }
  77. .t-table>>>t-tr:nth-child(2n) {
  78. /* background: #f5f5f5; */
  79. background: #ECFCFF;
  80. }
  81. /* #ifdef H5 */
  82. .t-table>>>.t-tr:nth-child(2n) {
  83. background: #f5f5f5;
  84. }
  85. /* #endif */
  86. </style>