<!--pages/install/install.wxml-->
<wxs src="/wxs/util.wxs" module="util"></wxs>
<view class="content-list-warehouse">
  <view class="content-address-warehouse">
    <picker bindchange="bindWarehourseList" range="{{warehourseList}}" range-key='name'>
      <view class="content-picker-warehouse">
        <text style="color: red;">*</text>所属仓库
        <view style="flex: 1; margin-left: 20rpx;">
          {{warehourseName}}
        </view>
        <image src="../../img/arrow.png" class="content-img-right-warehouse" />
      </view>
    </picker>
  </view>
</view>

<!-- 并网箱 -->
<view class="content">
  <view class="content-title">
    <view class="content-title-flex">
      并网箱
    </view>
    <text style="color: blue;" bindtap="installOwn" data-type="1">添加使用</text>
  </view>
  <view class="content-line"></view>
  <view class="content-list-view-delete" wx:for="{{cagesList}}" wx:key="index">
    <view class="content-list-view">
      <view class="content-list">
        物料号
        <text style="margin-left: 20rpx;">{{item.code}}</text>
      </view>
      <view class="content-list">
        物料名称
        <text style="margin-left: 20rpx;">{{item.name}}</text>
      </view>
      <view class="content-list">
        物料规格
        <text style="margin-left: 20rpx;">{{item.spec}}</text>

      </view>
      <view class="content-list">
        使用数量
        <text style="margin-left: 20rpx;">{{item.amount}}</text>
      </view>
    </view>

    <block wx:if="{{item.oldFlag!=2}}">
      <image src="../../img/delete.png" class="content-list-delete content-list-delete-right" bindtap="deleteUsedRocerd" data-id="{{item.id}}" data-oldFlag="{{item.oldFlag}}" />
    </block>
  </view>
</view>

<!-- 支架 -->
<view class="content">
  <view class="content-title">
    <view class="content-title-flex">
      支架
    </view>
    <text style="color: blue;" bindtap="installOwn" data-type="2">添加使用</text>
  </view>
  <view class="content-line"></view>
  <view class="content-list-view-delete" wx:for="{{supportList}}" wx:key="index">
    <view class="content-list-view">
      <view class="content-list">
        物料号
        <text style="margin-left: 20rpx;">{{item.code}}</text>
      </view>
      <view class="content-list">
        物料名称
        <text style="margin-left: 20rpx;">{{item.name}}</text>
      </view>
      <view class="content-list">
        物料规格
        <text style="margin-left: 20rpx;">{{item.spec}}</text>

      </view>
      <view class="content-list">
        使用数量
        <text style="margin-left: 20rpx;">{{item.amount}}</text>
      </view>
    </view>

    <block wx:if="{{item.oldFlag!=2}}">
      <image src="../../img/delete.png" class="content-list-delete content-list-delete-right" bindtap="deleteUsedRocerd" data-id="{{item.id}}" data-oldFlag="{{item.oldFlag}}" />
    </block>
  </view>
</view>


<!-- 逆变器 -->
<view class="content">
<block wx:for="{{nbqList}}" wx:key="pIndex" wx:for-index="pIndex" wx:for-item="pitem">
  <view class="content-title">
    <view class="content-title-flex">
      逆变器(<block wx:if="{{pitem.materialModel}}">{{pitem.materialModel}}|</block>{{pitem.model}}+{{pitem.num}}台)
    </view>
    <!-- <text style="color: blue;" bindtap="addMaterial" data-title="逆变器物料条码" data-spec="{{pitem.model}}" data-type="1">手动添加</text> -->
    <image src="../../img/scan-code.png" class="content-list-delete" data-type="1" data-num="{{pitem.num - (util.itemListLen(converterList, pitem.materialModel, pitem.model))}}" data-zb="{{pitem.zb}}" data-spec="{{pitem.model}}" data-model="{{pitem.materialModel}}" bindtap="goScanCode" wx:if="{{(util.itemListLen(converterList, pitem.materialModel, pitem.model)<pitem.num) || converterList.length===0}}" />
  </view>
  <view class="content-line"></view>
  <view class="content-list-view-delete" wx:for="{{converterList}}" wx:for-index="cIndex" wx:key="index" wx:if="{{item.spec == pitem.model && item.model == pitem.materialModel}}">
    <view class="content-list-view">
      <view class="content-list">
        物料品牌
        <text style="margin-left: 20rpx;">{{item.materialBrand}}</text>
      </view>
      <view class="content-list">
        物料规格
        <text style="margin-left: 20rpx;">{{item.spec}}</text>
      </view>
      <view class="nbq-code-box" wx:for="{{item.itemList}}" wx:for-item="itemList" wx:key="index">
      <view class="content-list">
        <view style="flex: 1; margin-left: 20rpx;">{{index+1}}</view>
        <block wx:if="{{itemList.oldFlag!=2}}">
          <image src="../../img/delete.png" class="content-list-delete" data-type="nbp" bindtap="deleteUsedRocerd" data-index="{{index}}" data-id="{{itemList.id}}" data-oldFlag="{{itemList.oldFlag}}" />
        </block>
      </view>
      <view class="content-list">
        <text style="color: red; margin-left: 20rpx;">*</text>
        <view class="content-title-item">SN码</view>
        <input type="text" class="content-input" placeholder="请输入" model:value="{{itemList.barcode}}" data-type="nbqSn" data-way="input" data-cind="{{cIndex}}" data-ind="{{index}}" disabled bindinput="snFn" />
        <!-- <image src="../../img/scan-code.png" class="content-list-delete" data-type="sn" data-cind="{{cIndex}}" data-way="scan" data-ind="{{index}}" bindtap="snFn" /> -->
      </view>
      <view class="content-list" wx:if="{{item.materialBrand=='固德威' || item.materialBrand=='爱士惟'}}">
        <text style="color: red; margin-left: 20rpx;">*</text>
        <view class="content-title-item">验证码</view>
        <input type="text" class="content-input" placeholder="请输入" model:value="{{itemList.yzCode}}" data-type="yzm" data-way="input" data-cind="{{cIndex}}" data-ind="{{index}}" bindinput="snFn" />        
      </view>
      <view class="content-list">
        <text style="color: red; margin-left: 20rpx;">*</text>
        <view class="content-title-item">通讯棒SN码</view>
        <input type="text" class="content-input" placeholder="请输入" model:value="{{itemList.sn}}" data-way="input" data-type="sn" data-cind="{{cIndex}}" data-ind="{{index}}" bindinput="snFn" />
        <image src="../../img/scan-code.png" class="content-list-delete" data-way="scan" data-type="sn" data-cind="{{cIndex}}" data-ind="{{index}}" bindtap="snFn" />
      </view>
      </view>
    </view>
  </view>
</block>
</view>


<!-- 组件 -->
<view class="content">
  <view class="content-title">
    <view class="content-title-flex">
      组件(<block wx:if="{{zjMap.materialModel}}">{{zjMap.materialModel}}|</block>{{zjMap.model}}Wp+{{zjMap.num}}片)
    </view>
    <!-- <text style="color: blue;" bindtap="addMaterial" data-title="组件物料条码" data-type="3">手动添加</text> -->
    <image src="../../img/scan-code.png" class="content-list-delete" data-type="3" data-zb="{{zjMap.zb}}" data-num="{{zjMap.num - componentList.length}}" data-spec="{{zjMap.model}}" data-model="{{zjMap.materialModel}}"  bindtap="goScanCode" wx:if="{{componentList.length<zjMap.num}}" />
  </view>
  <view class="content-line"></view>
  <view class="content-list-view-delete" wx:for="{{componentList}}" wx:key="index">
    <view class="content-list-view">
      <!-- <view class="content-list">
        物料号
        <text style="margin-left: 20rpx;">{{item.code}}</text>
      </view>
      <view class="content-list">
        物料名称
        <text style="margin-left: 20rpx;">{{item.name}}</text>
      </view> -->
      <view class="content-list">
        物料规格
        <text style="margin-left: 20rpx;">{{item.spec}}</text>
        Wp
      </view>
      <view class="content-list">
        物料条码（已扫码：{{item.itemList.length}}，剩余待扫码：{{zjMap.num - item.itemList.length}}）
      </view>

      <view class="content-list" wx:for="{{item.itemList}}" wx:for-item="itemList" wx:key="index">
        <view style="flex: 1; margin-left: 20rpx;">{{index+1}}：{{itemList.barcode}}</view>
        <block wx:if="{{itemList.oldFlag!=2}}">
          <image src="../../img/delete.png" class="content-list-delete" bindtap="deleteUsedRocerd" data-id="{{itemList.id}}" data-oldFlag="{{itemList.oldFlag}}" />
        </block>
      </view>

    </view>
  </view>

</view>


<!-- 空白底 -->
<view class="buttom-margin"></view>
<van-popup show="{{ mshow }}" round bind:close="onClose">
  <view class="material-box ">
    <view class="add-material-box">    
      <view>
        <text style="color: red;">*</text>
        <text>{{title}}</text>
      </view>
      <input type="text" class="content-input" placeholder="请输入" model:value="{{materialCode}}" />    
    </view>
    <view class="bottom-btn-box">
      <view bind:tap="onClose">取消</view>
      <view class="confirm" bind:tap="onConfirm">提交</view>
    </view>
  </view>
</van-popup>

<view class="from-submit-buttom">
  <!-- <view class="from-submit-buttom-cancle" bindtap="scanCode">扫码</view> -->
  <view class="from-submit-buttom-confirm {{converterList.length>0?'':'from-submit-buttom-confirm-gray'}}" bindtap="{{converterList.length>0?'submit':''}}">保存</view>
  <!-- <view class="from-submit-buttom-cancle {{converterList.length>0?'':'from-submit-buttom-confirm-gray'}}" bindtap="{{converterList.length>0?'submit':''}}">安装完成</view> -->
</view>