<!--pages/loadAppoint/index.wxml-->
<view class="container listMain">
  <block wx:if="{{loginStatus}}">
    <van-sticky>
      <view class="topFilter">
        <view class="topSeach">
          <view class="rightBox" style="position: relative;">
            <van-search value="{{ searchVal }}" shape="round" placeholder="查询预约单号" bind:change="onChange" bind:search="onSearch" bind:cancel="onCancel" use-action-slot>
            </van-search>
          </view>
        </view>
      </view>
    </van-sticky>

    <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}}&loadNumber={{item.loadNumber}}&index={{index}}" class="listItem">
              <view class="title van-ellipsis">
                <van-icon class='iconfont' name='/images/codeNumber.png' size="36rpx"></van-icon>
                <text>{{item.loadNumber}}</text>
                <text wx:if="{{item.status}}" class="status orderStatus{{item.status}}">{{item.statusName}}</text>
              </view>
              <view class="info">
                <text>客户名称：{{item.customerName?item.customerName:'未填写'}}</text>
              </view>
              <view class="info">
                <text decode="{{true}}">货品信息：{{item.goodsName?item.goodsName:'未填写'}}/{{item.goodsModel?item.goodsModel:'未填写'}}</text>
              </view>
              <view class="info"><text>订单重量：{{item.orderWeight + '吨'}}</text></view>
              <view class="info"><text>单价：{{item.orderPrice + ' 元/吨'}}</text> / <text>总价：{{item.orderAmount + ' 元'}}</text></view>
             
              <view class="bottomBtn" wx:if="{{ (roleCodeList == 'dispatcher' && (item.status == '4' || item.status == '5' || item.status == '6') && item.arriveStatus == '2') || (roleCodeList == 'bizAdmin' && (item.status == '5' || item.status == '6')) || ( roleCodeList == 'load' && item.status == '7') }}">
                <van-button type="primary" size="small" data-url="allocation?appointId={{item.id}}" wx:if="{{ roleCodeList == 'dispatcher' && (item.status == '4' || item.status == '5' || item.status == '6') && item.arriveStatus == '2' }}" catchtap="toLink" style="margin-right: 20rpx;">起卸调度</van-button>

                <van-button type="info" size="small" data-url="dispatch?appointId={{item.id}}" wx:if="{{ roleCodeList == 'dispatcher' && (item.status == '4' || item.status == '5' || item.status == '6') && item.arriveStatus == '2' }}" catchtap="toLink" style="margin-right: 20rpx;">装货调度</van-button>

                <van-button type="danger" size="small" data-id="{{ item.id }}" data-load-number="{{ item.loadNumber }}" wx:if="{{ roleCodeList == 'bizAdmin' && (item.status == '5' || item.status == '6')}}" catchtap="showPopupOver" style="margin-right: 20rpx;">结束</van-button>

                <van-button type="info" size="small" data-id="{{item.id}}" wx:if="{{ roleCodeList == 'load' && item.status == '7' }}" catchtap="showPopupFill">填报</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="{{ showOver }}" position="bottom" round closeable custom-style="width:100%;padding:0rpx 30rpx 160rpx;" bind:close="onClose">
  <view style="height: 90rpx;line-height: 90rpx;text-align: center;">结束</view>
  <form bindsubmit="formSubmitOver">
    <view class="part">
      <view class="height20"> </view>
      <input name="id" value='{{id}}' hidden='true' />      
      <van-field label="结束说明" required name="endReason" value="{{ endReason }}" type="textarea" input-align="right" placeholder="请输入结束说明" autosize></van-field>
    </view>

    <view class="submitBtn">
      <view style="padding-top: 60rpx;">
        <van-button block round type="info" form-type="submit" color="#0396FF">提交</van-button>
      </view>
    </view>
  </form>
</van-popup>

<!-- 填报 -->
<van-popup show="{{ showFill }}" position="bottom" round closeable custom-style="width:100%;padding:0rpx 30rpx 160rpx;" bind:close="onClose">
  <view style="height: 90rpx;line-height: 90rpx;text-align: center;">填报</view>
  <form bindsubmit="formSubmitFill">
    <view class="part">
      <view class="height20"> </view>
      <input name="id" value='{{id}}' hidden='true' />      
      <van-field label="起卸重量" required type="digit" required name="fillWeight" value="{{ fillWeight }}" placeholder="请输入起卸重量" input-align="right" border="{{ false }}">
          <view slot="right-icon">
            <text>吨</text>
          </view>
        </van-field>
    </view>

    <view class="submitBtn">
      <view style="padding-top: 60rpx;">
        <van-button block round type="info" form-type="submit" color="#0396FF">提交</van-button>
      </view>
    </view>
  </form>
</van-popup>


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