<!--pages/loadAppoint/dispatch.wxml-->
<view class="container listMain">
  <block wx:if="{{loginStatus}}">
    <view url="" class="addBtn" catch:tap="showPopup" hover-class="none" catchtouchmove="buttonMove" 
    bindtouchstart="buttonStart" bindtouchend="buttonEnd" style="top:{{buttonTop}}px;left:{{buttonLeft}}px;" wx:if="{{roleCodeList == 'dispatcher' || roleCodeList == 'bizAdmin'}}">
      <van-icon name="plus" size="30px" />
    </view>

    <view class="width710">
      <block wx:if="{{!requestStatu}}">
        <block wx:if="{{resData.length>0}}">
          <block wx:for="{{resData}}" wx:key="index">
            <navigator url="info?id={{item.id}}&loadPoint={{item.loadPoint}}&index={{index}}" class="listItem">
              <view class="title van-ellipsis">
                <van-icon class='iconfont' name='/images/menuImg1.png' size="36rpx"></van-icon>
                <text>{{item.loadPoint}}</text>
              </view>
              <!-- <view class="user"><van-icon name="user-o" size="18"/><text> {{ item.userName }}</text></view> -->
              <view class="info"><van-icon name="coupon-o" size="18"/><text> 可约次数：{{ item.availableNumber }}</text> / <text> 已约次数：{{ item.alreadyNumber }}</text></view>
              <view class="time"><van-icon name="clock-o" size="18"/><text> {{ item.beginTime }} ~ {{item.endTime}}</text></view>
              
              <view class="bottomBtn">
                <van-button type="info" size="small" data-id="{{ item.id }}" data-load-point="{{ item.loadPointId }}" data-load-time="{{ item.loadTimeId }}" catchtap="showPopup" style="margin-right: 20rpx;">更换</van-button>
                <van-button type="danger" size="small" data-id="{{item.id}}" data-load-point="{{item.loadPoint}}" catchtap="delFun">删除</van-button>
              </view>
            </navigator>
          </block>
          <!-- 底部加载动画 -->
          <view class='more'>
            <block wx:if="{{more}}">
              <van-loading size="24px" color="#1989fa">加载中...</van-loading>
            </block>
            <block wx:else>{{nomore}}</block>
          </view>
          <view style="height: 180rpx;"> </view>
        </block>
        <block wx:else>
          <van-empty description="未搜索到装货分配记录" image="/images/null1.png" />
        </block>
      </block>
    </view>
  </block>
  <block wx:else>
    <view>
      <van-empty image="/images/loginNull.png">
        <view slot="description" style="text-align: center;">
          <text style="display:block;margin-bottom: 20rpx;">您还未登录，登录后查看更多～</text>
          <van-button type="info" bindtap="toLogin">立即登录</van-button>
        </view>
      </van-empty>
    </view>
  </block>
</view>

<!-- 添加弹窗 -->
<van-popup show="{{ show }}" position="bottom" round closeable custom-style="width:100%;padding:0rpx 30rpx 320rpx;" bind:close="onClose">
  <view style="height: 90rpx;line-height: 90rpx;text-align: center;" wx:if="{{ id == '' }}">添加装货分配</view>
  <view style="height: 90rpx;line-height: 90rpx;text-align: center;" wx:else>更换装货分配</view>
  <form bindsubmit="formSubmitAllocation">
    <input name="id" value='{{ id }}' hidden='true' />
    <input name="appointId" value='{{ appointId }}' hidden='true' />
    <view class="part">
      <!-- 装货点位 -->
      <van-field label="装货点位" required input-align="right" bindtap="hideKeybord" is-link>
        <view slot="input" style="width: 100%;">
          <input name="loadPointId" value='{{loadPointArray[loadPointIndex].id}}' hidden='true' />
          <picker bindchange="bindPickerChange" value="{{loadPointIndex}}" range="{{loadPointArray}}" range-key="loadPoint" data-pickername='loadPoint'>
            <view class="selectPlaceholder"> {{loadPointArray[loadPointIndex].loadPoint?loadPointArray[loadPointIndex].loadPoint:defaultText}}</view>
          </picker>
        </view>
      </van-field>

      <!-- 装货时段 -->
      <van-field label="装货时段" required input-align="right" bindtap="hideKeybord" wx:if="{{loadTimeArray.length>0}}" type="textarea" autosize  is-link>
        <view slot="input" style="width: 100%;">
          <input name="loadTimeId" value='{{loadTimeArray[loadTimeIndex].id}}' hidden='true' />
          <picker bindchange="bindPickerChange" value="{{loadTimeIndex}}" range="{{loadTimeArray}}" range-key="time" data-pickername='loadTime'>
            <view class="selectPlaceholder">{{loadTimeArray[loadTimeIndex].time?loadTimeArray[loadTimeIndex].time:defaultText}}</view>
          </picker>
        </view>
      </van-field>
      <van-field required wx:else label="装货时段" name="loadTimeId" value="" readonly input-align="right" placeholder="请先选择装货点位" placeholder-style="color:red;" />
      
      <!-- 执行员 -->
      <!-- <van-field label="执行员" required input-align="right" bindtap="hideKeybord" is-link>
        <view slot="input" style="width: 100%;">
          <input name="userId" value='{{loadUserArray[loadUserIndex].id}}' hidden='true' />
          <picker bindchange="bindPickerChange" value="{{loadUserIndex}}" range="{{loadUserArray}}" range-key="name" data-pickername='loadUser'>
            <view class="selectPlaceholder"> {{loadUserArray[loadUserIndex].name?loadUserArray[loadUserIndex].name:defaultText}}</view>
          </picker>
        </view>
      </van-field> -->

      <van-field wx:if="{{loadTimeArray[loadTimeIndex].id}}" label="可约次数" name="availableNumber" value="{{ availableNumber }}" readonly input-align="right" ></van-field>
      <van-field wx:if="{{loadTimeArray[loadTimeIndex].id}}" label="已约次数" name="alreadyNumber" value="{{ alreadyNumber }}" readonly input-align="right" ></van-field>

    </view>

    <view class="fixedBtn submitBtn">
      <van-button loading="{{isSubmitting}}" round block disabled="{{isSubmitting}}" loading-text="{{isSubmitting?'提交中...':''}}" type="info" form-type="submit">确定
      </van-button>
    </view>
  </form>
</van-popup>

<wxs module="filters" src="../../utils/filter.wxs"></wxs>
