FilterBar.wxml 3.08 KB
<view class="filter-bar">
  <!-- Search Area -->
  <view class="search-box">
    <view class="search-input">
      <image src="/images/search.png" class="search-icon" />
      <input type="text" placeholder="{{searchPlaceholder}}" class="input" value="{{ searchValue }}" placeholder-class="input-placeholder" bindinput="onSearchInput" bindconfirm="onSearch" />
      <block wx:if="{{ searchValue }}">
        <image src="/images/clear.png" class="search-clear" catchtap="clearSearch" />
      </block>
    </view>
  </view>

  <!-- Filter Area -->
  <view class="filter-box" wx:if="{{filters.length > 0}}">
    <view class="filter-list">
      <block wx:for="{{filters}}" wx:key="key">
        <!-- Date Range Filter -->
        <block wx:if="{{item.type === 'date-range'}}">
          <calendar 
            class="calendar-wrapper"
            allowSameDay 
            shortcut 
            bindselect="onDateRangeSelect" 
            calenderColor="#347BFF" 
            vertical 
            dateType='range' 
            minDate="2025-01-01" 
            maxDate="{{ maxDateForCalendar }}" 
            isComponents
            data-index="{{index}}"
          >
            <view class="filter-item {{searchObj[item.key] ? 'active' : ''}}">
              <text class="filter-text">{{searchObj[item.showKey || item.key] || item.label}}</text>
              <image class="filter-icon" src="{{IMG_URL}}{{searchObj[item.key] ? 'expand_icon_blue' : 'expand_icon'}}.png" mode="" />
            </view>
          </calendar>
        </block>

        <!-- Other Filters (Month, Select) -->
        <block wx:else>
          <view class="filter-item {{searchObj[item.key] ? 'active' : ''}}" bindtap="onFilterTagTap" data-index="{{index}}">
            <text class="filter-text">{{searchObj[item.showKey || item.key] || item.label}}</text>
            <image class="filter-icon" src="{{IMG_URL}}{{searchObj[item.key] ? 'expand_icon_blue' : 'expand_icon'}}.png" mode="" />
          </view>
        </block>
      </block>
    </view>

    <!-- Reset Button -->
    <view class="reset-btn" bindtap="resetFilters">
      重置
    </view>
  </view>
</view>

<!-- Dynamic Popup -->
<TopToolbarPopup show="{{showPopup}}" title="" bind:cancel="closePopup" bind:confirm="confirmPopup" height="{{height}}">
  <!-- Content depends on active filter type -->
  <block wx:if="{{activeFilterIndex > -1}}">

    <!-- Type: Month -->
    <block wx:if="{{filters[activeFilterIndex].type === 'month'}}">
      <van-datetime-picker 
        type="{{filters[activeFilterIndex].pickerType || 'year-month'}}" 
        value="{{pickerViewValue}}" 
        bind:input="onDatePickChange"
        show-toolbar="{{false}}"
        min-date="{{minDate}}"
        max-date="{{maxDate}}"
      />
    </block>

    <!-- Type: Select -->
    <block wx:elif="{{filters[activeFilterIndex].type === 'select'}}">
      <van-picker 
        columns="{{ currentSelectOptions }}" 
        value-key="confLabel"
        default-index="{{ tempSelectIndex }}"
        bind:change="onSelectPickerChange"
        show-toolbar="{{false}}"
      />
    </block>

  </block>
</TopToolbarPopup>