dropdown.wxml 6.56 KB
<view class='dropdown'>
  <view class='dropdown-box' style="width:{{width}}" wx:for='{{list}}' wx:key='index'>
    <picker bindchange="chooseTime" bindcancel='cancel' wx:if='{{item.type == "time"}}' mode='date' fields='month' start="2020-01-01" end="{{today}}" value='{{_time_}}' data-target-name='parentCount' data-parent-index='{{index}}'>
      <view class="dropdown-title {{index == parentCount?'dropdown-title-active':''}}" bindtap="showDropdown" data-parent-index='{{index}}' data-target-name='parentCount'>{{time ||item.title}}
        <view class="dropdown-title-icon"></view>
      </view>
    </picker>
    <view wx:else class="dropdown-title {{index == parentCount?'dropdown-title-active':''}}" bindtap="showDropdown" data-parent-index='{{index}}' data-target-name='parentCount'>{{value[index]||item.title}}
      <view class="dropdown-title-icon"></view>
    </view>
    <view class="dropdown-bg-box" hidden="{{index != parentCount}}" style='left:-{{index*100 + (2.8*list.length)}}%' bind>
      <view class="dropdown-bg" bindtap="close" data-parent-index='{{index}}' data-target-name='parentCount' catchtouchmove='noScroll'></view>
      <view class="dropdown-list" style="padding-right:{{item.type =='more'?0:'40rpx'}}">
        <view class="dropdown-item dropdown-search" wx:if='{{item.havaSearch}}'>
          <view class="dropdown-input {{hideSearch?'w90':''}}">
            <input bindfocus='focus' bindblur='blur' bindinput='input' value='{{searchValue}}' bindconfirm='confirm' confirm-type='search'></input>
            <view class="search" wx:if='{{!searchValue}}'>
              <image src="./images/search.png"></image>
              <text>搜索</text>
            </view>
            <view class="clear" bindtap="confirm" data-type='clear'>
              <image src="../../images/status-2.png" hidden="{{!searchValue}}"></image>
            </view>
          </view>
          <view class='dropdown-cancel' bindtap="confirm" data-type='clear'>取消</view>
        </view>
        <block wx:if='{{item.type == "date"}}'>
          <view class='dropdown-radio-group'>
            <block wx:for='{{item.data}}' wx:for-index='ind' wx:for-item='i' wx:key='ind'>
              <view class='dropdown-radio {{i.name == dateData ? "active":""}}' bindtap="radio" data-value='{{i.value}}' data-name='{{i.name}}'>{{i.name}}</view>
            </block>
          </view>
          <view class='dropdown-picker-group'>
            <picker class='dropdown-picker' data-target='start' bindchange="pickerChange" mode="date" value="{{startDate}}" start="2020-01-01" end="{{today}}">
              <text style='color:{{startDate?"":"#999"}}'>{{startDate||'请选择'}}</text>
            </picker>
            <picker disabled='{{!startDate}}' data-target='end' class='dropdown-picker' bindchange="pickerChange" mode="date" value="{{endDate}}" start="{{startDate}}" end="{{today}}">
              <text style='color:{{endDate?"":"#999"}}'>{{endDate||'请选择'}}</text>
            </picker>
          </view>
          <view class="dropdown-btn-group">
            <view class='dropdown-btn btn-default' bindtap="clearTime">重置</view>
            <view class='dropdown-btn btn-primary' bindtap="submit" data-target-name='parentCount' data-parent-index='{{index}}'>确定</view>
          </view>
        </block>
        <block wx:elif='{{item.type == "more"}}'>
          <view class="dropdown-more-title">任务状态</view>
          <view class='dropdown-more-group clearfix'>
            <view class='dropdown-more-item {{statusIndex == i.value?"active":""}}' wx:for='{{item.status}}' wx:for-index='ind' wx:for-item='i' wx:key='ind' bindtap="chooseMore" data-target="statusIndex" data-value='{{i.value}}' data-variable='{{i.variable}}'>
              {{i.name}}
            </view>
          </view>
          <view class="dropdown-more-title">产品</view>
          <view class='dropdown-more-group clearfix'>
            <view class='dropdown-more-item {{productIndex == i.value?"active":""}}' wx:for='{{item.product}}' wx:for-index='ind' wx:for-item='i' wx:key='ind' bindtap="chooseMore" data-target="productIndex" data-value='{{i.value}}' data-variable='{{i.variable}}'>
              {{i.name}}
            </view>
          </view>
          <block wx:if='{{type == 2}}'>
            <view class="dropdown-more-title">业务员
              <view class='more-btn' bindtap="showMore" wx:if='{{item.salesman.length > 3}}'>更多
                <view class="dropdown-title-icon"></view>
              </view>
            </view>
            <view class='dropdown-more-group clearfix'>
              <view class='dropdown-more-item {{salesmanIndex == i.value?"active":""}}' wx:for='{{item.salesman}}' wx:for-index='ind' wx:for-item='i' wx:key='ind' hidden='{{ind>2&&hideMore}}' bindtap="chooseMore" data-target="salesmanIndex" data-value='{{i.value}}'
                data-variable='{{i.variable}}'>
                {{i.name}}
              </view>
            </view>
          </block>
          <view class="dropdown-btn-group" style="margin-right: 0">
            <view class='dropdown-btn btn-default' bindtap="clearData">重置</view>
            <view class='dropdown-btn btn-primary' bindtap="sumbitMore" data-target-name='parentCount' data-parent-index='{{index}}'>确定</view>
          </view>
        </block>
        <block wx:else>
          <block wx:for='{{item.data}}' wx:for-index='ind' wx:for-item='i' wx:key='ind'>
            <view class="dropdown-item" wx:if='{{!i.data}}' data-target-name='parentCount' bindtap="choose" data-value='{{i.value}}' data-parent-index='{{index}}' data-name='{{i.name}}'>
              {{i.name}}
              <image src="./images/choose.png" class="{{i.value === count[index] || (item.title == i.name && !count[index])?'active':''}}"></image>
            </view>
            <view class="dropdown-item {{ ind == childCount ?'dropdown-item-child':''}}" wx:else bindtap="showDropdown" data-parent-index='{{ind}}' data-target-name='childCount'>
              <view class="dropdown-item-child-title">
                {{i.name}}
                <view class="dropdown-item-arrow"></view>
              </view>

              <view hidden='{{ind != childCount}}' class="dropdown-item" wx:for='{{i.data}}' wx:for-index='childIndex' wx:for-item='x' wx:key='childIndex' bindtap="choose" data-target-name='parentCount' data-value='{{x.value}}' data-parent-index='{{index}}' data-name='{{x.name}}'>
                {{x.name}}
                <image src="./images/choose.png" class="{{x.value == count[index]?'active':''}}"></image>
              </view>

            </view>
          </block>
        </block>
      </view>
    </view>
  </view>
</view>