t-tr.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="t-tr">
  3. <view v-if="isCheck" class="t-check-box" :style="{ 'border-width': thBorder + 'px' ,'border-color':borderColor}">
  4. <checkbox-group @change="checkboxChange">
  5. <checkbox :value="checkboxData.value + ''" :checked="checkboxData.checked" />
  6. </checkbox-group>
  7. </view>
  8. <slot></slot>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. props: {
  14. fontSize: String,
  15. color: String,
  16. align: String
  17. },
  18. inject: ['table'],
  19. provide() {
  20. return {
  21. tr: this
  22. };
  23. },
  24. data() {
  25. return {
  26. isCheck: false,
  27. checkboxData: {
  28. value: 0,
  29. checked: false
  30. },
  31. checked: false,
  32. thBorder: '1',
  33. borderColor: '#d0dee5'
  34. };
  35. },
  36. created() {
  37. this.thBorder = this.table.border;
  38. this.borderColor = this.table.borderColor;
  39. this.table.childrens.push(this);
  40. this.checkboxData.value = this.table.index++;
  41. this.isCheck = this.table.isCheck;
  42. },
  43. methods: {
  44. checkboxChange(e) {
  45. this.checkboxData.checked = !this.checkboxData.checked;
  46. this.table.childrens[this.checkboxData.value] = this;
  47. this.table.fire(e.detail.value[0] ? true : false, this.checkboxData.value, this.table.index);
  48. }
  49. }
  50. };
  51. </script>
  52. <style>
  53. .t-tr {
  54. width: 100%;
  55. display: flex;
  56. }
  57. .t-tr t-th,
  58. .t-tr t-td {
  59. display: flex;
  60. flex: 1;
  61. }
  62. .t-tr .t-check-box {
  63. flex-shrink: 0;
  64. display: flex;
  65. justify-content: center;
  66. align-items: center;
  67. width: 40px;
  68. color: #3b4246;
  69. border-left: 1px #d0dee5 solid;
  70. border-top: 1px #d0dee5 solid;
  71. }
  72. .t-tr .t-check-box checkbox {
  73. transform: scale(0.8);
  74. }
  75. </style>