hailu
2023-11-21 f3773d4aa18f3b0814d9720e26fa61b762020eb2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<scroll-view scroll-x="true" style="width:100%;"  class="table table-border">
    <!-- 表格头 start -->
    <view 
        class="thead {{ border ? 'thead-border' : ''}} header-row-class-name" 
        style="width:{{ scrolWidth }}rpx;"
    >
      <view 
        wx:for="{{ headers }}" 
        wx:key="*this" 
        class="td" 
        style="width:{{ item.width }}rpx;"
      >
      {{ item.label }}
      </view>
    </view>  
    <!-- 表格头 end -->
    
    <!-- 表格体 start -->
    <scroll-view 
        scroll-y="true" 
        class="tbody"
        style="width:{{ scrolWidth }}rpx; height:{{ height ? height : 'auto' }};" 
    >
      <block 
        wx:if="{{ data.length > 0 }}" 
        wx:for-item="it" 
        wx:for="{{ data }}" 
        wx:key="*this" 
        wx:for-index="idx"
      >
        <view class="tbody-tr {{ stripe ? 'tbody-tr-stripe' : '' }} {{ border ? 'tbody-tr-border' : ''}} row-class-name">
          <view wx:for-item="head" 
            wx:for="{{ headers }}" 
            wx:key="*this" 
            class="td cell-class-name" 
            data-it="{{it}}" 
            data-row="{{index}}" 
            data-column="{{idx+1}}"
            style="width:{{ headers[index].width }}rpx;color:{{ headers[index].color }};" 
            bindtap="onRowClick"
            bind:cellClick="onCellClick" 
          >     
          {{it[head["prop"]]}}
          </view>
          <!-- <slot name="action"></slot>         -->
        </view>
       
      </block>
      <!-- 列表无数据处理 -->
      <block wx:if="{{ data.length === 0 }}">
        <view class="no-data">{{ msg }}</view>
      </block>
    </scroll-view>
    <!-- 表格体 end -->
</scroll-view>