<wxs src='../../../../utils/wxmlUtil.wxs' module="wxmlUtil"></wxs>
<wxs src='../../../../utils/numberFormat.wxs' module="numberFormat"></wxs>
<wxs module="txtIndexOf">
  function toIndexOf(value, value2) {
    return value.indexOf(value2)
  }
</wxs>
<van-dialog id="van-dialog" />
<loading wx:if="{{loading}}" loadingName="加载中" backgroundColor="#f2f2f2;" opacity="0.8"></loading>
<view style="margin-bottom: 15rpx;"></view>
<!-- 摄像头 -->
<view wx:if="{{scanBarcodeName!='扫描条码'}}">
  <camera mode="scanCode" frame-size="large" flash="auto" resolution="high" device-position="back" binderror="error" style="width: 100%; height: 176px;" bindscancode="takeCode" bindinitdone="bindinitdone" scan-area="[0,0,200, 200]"> </camera>
</view>
 
<view   wx:if="{{scanBarcodeName=='扫描条码'}}">
<!-- 主从业务员业务部门  -->
<view style="display:flex;">
  <!-- 主从业务员  -->
  <view style="width: 50%;">
    <van-cell id="staffItem" catchtap="openStaffDropdown" title="{{ form.staffName }}" value-width="1rpx" title-class="cell-value-staff-org" arrow-direction="down" is-link value="" />
  </view>
  <!-- 主从业务部门 -->
  <view style="width: 50%;">
    <van-cell title-class="staff-org" id="orgItem" catchtap="openOrgDropdown" title="{{form.orgName }}" value-width="1rpx" title-class="cell-value-staff-org" arrow-direction="down" is-link value="" />
  </view>
</view>
<!-- 蓝色信息相关 -->
<view style="margin: 0px 34rpx 0rpx 34rpx; box-shadow:2px 2px 5px #e5e5e6;">
  <view style="flex-direction: column;justify-content: center;align-items: flex-start;background: linear-gradient(90.12deg, #718AC6 0.84%, #4A5E98 99.43%);border-radius: 15rpx 15rpx 0rpx 0rpx;"> 
    <!-- 收货人 -->
    <view style="display: flex;padding-right: 32rpx;">

      <view style="padding-left: 32rpx;padding-top: 19rpx;width: 39rpx;">
        <view catchtap="toCustomer" style="width: 39rpx;height: 39rpx;background-color: #95A8CB;border-radius:50%;">
          <view style="width: 39rpx; height: 39rpx;text-align: center;">
            <van-image round width="20rpx" height="24rpx" src="/static/image/Vector.png" />
          </view>
        </view>
      </view>
      <view style="padding-left: 14rpx;padding-top: 19rpx;font-size: 26rpx;line-height: 36rpx;color: #FFFFFF;">
        {{form.customerName?form.customerName:''}}
      </view>

      <view style="padding-left: 22rpx;padding-top: 19rpx;font-size: 26rpx;line-height: 36rpx;color: #FFFFFF;">
        {{form.customerPhone?form.customerPhone:''}}
      </view>


    </view>
    <!-- 地址 -->
    <view style="display: flex;padding-right: 32rpx;">
      <view style="padding-left: 32rpx;padding-top: 15rpx;font-size: 26rpx;line-height: 36rpx;color: #FFFFFF;">
        {{ wxmlUtil.addressToIndexOf(form.addressFull)}}
      </view>
    </view>
   
    <view style="display: flex;padding-left: 32rpx;padding-top: 16rpx;padding-bottom: 15rpx;padding-right: 32rpx;">
      <view style="display: flex; width: 50%;line-height: 36rpx;" data-type='deliveryType'>
      <!-- 配送方式 -->
        <view style="font-size: 24rpx;line-height: 36rpx;color: #FFFFFF;">
           {{ form.deliveryType?form.deliveryType+">":"" }}   
        </view>
      </view>
      <view style="display: flex; width: 50%;line-height: 36rpx;" data-key="DeliveryFlag" catchtap="openData">
        <view style="font-size: 24rpx;line-height: 36rpx;color: #FFFFFF;">
          送货日期：{{ form.deliveryTime?wxmlUtil.format(form.deliveryTime):'' }}
        </view>
      </view>
    </view>
  </view> 
</view> 
</view>
<!-- todo 差了一个扫码 -->
 
<view wx:if="{{active==0}}" style="margin: 48rpx 32rpx 10px 32rpx;border-radius: 15rpx;box-shadow:2px 2px 5px #e5e5e6;">
  <view style="  background: #FFFFFF;box-shadow: 0rpx 10rpx 20rpx rgba(225, 229, 238, 0.6);border-radius: 15rpx;">
    <van-cell wx:if="{{goodsList.length==0}}" border="{{ false }}" style="border-radius: 15rpx;">
      <van-empty description="暂未选择商品" />
    </van-cell>
  </view>
</view> 
<!-- 商品信息 -->
<view style="margin: 26rpx 34rpx 26rpx 34rpx;box-shadow:2px 2px 5px #e5e5e6;">
  <view style="background: #FFFFFF;box-shadow: 0rpx 10rpx 20rpx rgba(225, 229, 238, 0.6);border-radius: 15rpx 15rpx 0rpx 0rpx;">
    <view style="padding: 10px 32rpx 10px 32rpx;color: #1B365D;font-size: 32rpx;display: flex;">
      <view style="width: 70%;font-weight: bold;display: flex;">
        <view>商品明细</view>

      </view>
      <view style="width: 30%; padding-right: 3%; background: white; display: flex; justify-content: center; align-items: center; border-radius: 8rpx;">
        <view  >
          <view wx:if="{{isStockUp}}" class="choose-goods" style="  width: 111%; border-radius: 8rpx;">
            <view class="choose-goods-text">备货齐套</view>
          </view>
          <view wx:else class="choose-goods" style=" width: 111%; border-radius: 8rpx;background-color: red;">
            <view class="choose-goods-text">备货不足</view>
          </view>
        </view>
      </view>
    </view>
    <van-cell wx:if="{{goodsList.length==0}}" border="{{ false }}" style="border-radius: 15rpx;">
      <van-empty description="暂无明细" />
    </van-cell>
    <view wx:for="{{goodsList}}" data-item="{{item}}" data-index="{{index}}" wx:for-item="item" wx:key="index" border="{{ true }}">
      <van-swipe-cell right-width="{{ 65 }}" data-index="{{index}}" async-close bind:close="onCloseDel">
        <van-card wx:if="{{index < 2  || collapseFlag}}" data-item="{{item}}" data-index="{{index}}" bindtap="openChoosedItemInfo">
          <view slot="thumb">
            <van-image radius="5px" width="80" height="80" src="{{item.iconThumPath }}" />
          </view>
          <view slot="title" style="display: flex;">
            <!-- 标题 -->
            <view style="display: flex;">
              <dk-title titleTag="{{item.titleTag}}" title="{{item.skuModel}}"></dk-title>
            </view>

          </view>
          <!-- 描述 -->
          <view slot="desc">
            <view style="padding-top: 15rpx; padding-bottom: 12rpx; width: 100%;">
              <dk-text fontWeight="nomal" value="{{item.skuName}}"></dk-text>
            </view>

          </view>
          <view slot="price">
            <view style="display: flex;width: 100%;flex-direction: row; ">
              <view style="width: 100%;">
                <dk-cell contentFontSize="16" height="45rpx" fontWeight="bold" left="0rpx" contentColor="#CAA977" title="" content="{{item.orderPriceSale}}"></dk-cell>
              </view>
              <view style="width: 100%;text-align: right;font-size:24rpx;color: #95A8CB;line-height: 34rpx;"> 
                      <van-stepper integer="{{true}}" value="{{currentChoosedItem.itemQuantity}}" data-index="{{index}}" min="0" max="999999999" bind:change="changeChooseItemQuantity" /> 
              </view>
            </view>
          </view>

          <!-- 底部明细 -->
          <view slot="footer">
            <view style="margin-top: 15rpx;" wx:if="{{item.goodsSkuList.length > 0  || item.combinedList.length > 0}}">
              <view style="width: 100%;display: flex;">
                <view style="font-size:12px;color: #95A8CB;width: 50%;text-align: left;">
                  明细
                </view>
                <view style="font-size:12px;color: #95A8CB;width: 50%;text-align: right;" data-item="{{item}}" data-index="{{index}}" catchtap="onChangeOpenGoodsList">
                  {{item.packageDetailsFlag ? '收起' :'展开'}}
                  <van-icon name="{{item.packageDetailsFlag ? 'arrow-up' :'arrow-down' }}" />
                </view>
              </view>

              <!--子件-->
              <view class="goods-class" wx:if="{{item.packageDetailsFlag}}">
                <view wx:for="{{item.goodsSkuList}}" data-item="{{item2}}" wx:for-item="item2" wx:key="index2">
                  <view class="goods-item-class" wx:if="{{item2.hasChild == 0}}">
                    <view>
                      <van-image radius="15rpx" custom-class="goods-item-image" fit="fill" src="{{item2.iconThumPath }}" />
                    </view>
                    <view class="goods-item-tag">
                      <view style="display: flex;">
                        <view class="{{(item2.replaceableSku && item2.replaceableSku.length > 0)?'goods-item-title-replace':''}}">
                          <dk-title titleTag="{{item2.titleTag}}" title="{{item2.skuModel}}"></dk-title>
                        </view>

                      </view>
                      <view style="width: 100%;display: flex;">
                        <dk-text fontWeight="normal" value="{{item2.skuName}}"></dk-text>
                      </view>
                      <!--子级明细价格-->
                      <view style="display: flex;width: 100%;flex-direction: row;">
                        <view style="width: 90%;">
                          <dk-cell contentFontSize="12" height="45rpx" fontWeight="bold" left="0rpx" contentColor="#CAA977" title="" content="{{ item2.orderPriceSalet}}"></dk-cell>
                        </view>
                        <view style="width: 10%">
                          <dk-text fontWeight="nomal" color="#95A8CB" value="x {{item2.tItemQuantity }}"></dk-text>
                        </view>

                      </view>
                    </view>
                  </view>
                </view>
              </view>
            </view>
          
            <view   >
              <view  style="display: flex;margin: 1vw;font-size: 13px;">
                <view style="color: #95A8CB; width: 20vw;align-self: center;text-align: -webkit-center;">仓库
                </view>
                <view style="color: #1B365D;width: 55vw;align-self: center;text-align: -webkit-center;">{{item.whName}} >
                </view>

                <view style="white-space: nowrap;color: red;width: 25vw;align-self: center;text-align: -webkit-center;">可售量：{{item.usableQty?item.usableQty:0}}
                </view>
              </view>
            </view>

            <view style="display: flex;width: 100%;align-items: center;height: 60rpx;" data-index="{{index}}" catchtap="openRemark">
              <view style="width: 50%;text-align: left;font-size:12px;color: #95A8CB;">
                <van-image width="19rpx" height="20rpx" src="/static/image/edit.png" />
                备注：<span style="line-height:56rpx;">{{item.remarks ? item.remarks : '请输入内容'}}</span>
              </view>

            </view>
            <view class="divide-class"></view>
          </view>
        </van-card>
        <view slot="right">删除</view>
      </van-swipe-cell>


    </view>

    <view catchtap="collapseFlagChange" data-index="{{index}}" wx:if="{{goodsList.length > 2}}" style="padding: 30rpx 32rpx 30rpx 32rpx;border-radius: 16rpx;color:#95A8CB;text-align: center;font-size: 26rpx;display: flex;justify-content: center;">
      <view>{{!collapseFlag ? '展开查看更多' : '收起查看更多'}}</view>
      <view style="padding-left: 10rpx;">
        <van-icon name="{{!collapseFlag ? 'arrow-down':'arrow-up'}}" size="24rpx" />
      </view>
    </view>

  </view>


  <view style="background: #FFFFFF;box-shadow: 0rpx 10rpx 20rpx rgba(225, 229, 238, 0.6);border-radius:0rpx 0rpx 15rpx 15rpx;">


    <view style="display:flex;;margin-right: 24rpx;">
      <view style="width: 48%;">
        <view style="padding-left: 30rpx;padding-top: 25rpx;">
          <text style="color: #95A8CB;font-size: 32rpx;">{{form.categoryQuantity ? form.categoryQuantity : 0}}品类 共计{{form.sumOutGoingQuantity ? form.sumOutGoingQuantity : 0}}件</text>
        </view>
      </view>

      <view style="width: 52%;">
        <dk-cell fontSize="13" contentColor="#CAA977" titleColor="#1B365D;" contentRight="right" fontWeight="bold" title="合计金额:" content="{{form.sumOutGoingAmount}}"></dk-cell>
      </view>
    </view>


  </view>

</view>

<!--扫码明细-->
<view wx:if="{{active==1}}" wx:for="{{goodsList}}" data-item="{{item}}" wx:for-item="item" wx:key="index" border="{{ false }}" style="margin: 0rpx 32rpx  0px 32rpx;border-radius: 15rpx;box-shadow:2px 2px 5px #e5e5e6;">

  <view style="display: flex; justify-content: center; align-items: center;">
    <!-- 第一个面板 -->
    <view class="panel">
      <view class="panel-header" data-index="{{index}}" bindtap="togglePanel1">
        <!-- 头部样式 -->
        <view style="color: #1B365D;flex: 1;">{{item.skuName}}</view>
        <view class="arrow" wx:if="{{item.showPanel}}">收起</view>
        <view class="arrow" wx:else>展开</view>
      </view>
      <view class="panel-content" wx:if="{{item.showPanel}}">
        <van-swipe-cell wx:for="{{item.barcodeList}}" right-width="{{ 65 }}" data-indexscan="{{indexscan}}" data-fatherindex="{{index}}" wx:for-index="indexscan"   wx:for-item="itemscan" async-close bind:close="onCloseDel">
          <view>   
            <view style="font-size:15px;color: #1B365D;margin: 10rpx;">条码：{{itemscan.barcode}}</view>
          </view>
          <view style="font-size:small;" slot="right">删除</view>
        </van-swipe-cell>
      </view>
    </view>
  </view>


</view>
<!-- 其他信息 -->
<view style="margin: 10px 32rpx 10px 32rpx;margin-top: 41rpx;border-radius: 15rpx;box-shadow:2px 2px 5px #e5e5e6;">
  <view style="background: #FFFFFF;box-shadow: 0rpx 10rpx 20rpx rgba(225, 229, 238, 0.6);border-radius: 0px 0px 15rpx 15rpx;">
    <view style=" padding: 10px 32rpx 10px 32rpx;color: #1B365D;font-size: 32rpx;">其他信息</view>

    <van-field input-width="200rpx" input-class="dk-cell-value-class" input-align="left" label-class="nomal-label" data-key="remarks" maxlength="50" value="{{ form.remarks }}" input-align="right" label="备注" placeholder="请输入备注" autosize border="{{ false }}" bind:change="changeField">
    </van-field>

    <view style="display:flex;width:100%;margin: 1vw;padding-top:20rpx;">
      <view style="width: 30%; flex:1;color: #95A8CB;font-size: 28rpx;padding-left: 27rpx;white-space: nowrap;">出库附件</view>
      <view style="width: 70%;text-align: left;">
        <van-uploader max-count="5" accept="image" style="margin-left: 4%;border-radius: 15rpx;" preview-size="160rpx;" file-list="{{ fileList }}" bind:delete="deleteImg" bind:after-read="afterRead" multiple="true" imageFit="aspectFit" />
      </view>
    </view>
    <view style="display:flex;width:100%;margin: 1vw;padding-top:20rpx;">
      <view style="width: 30%; flex:1;color: #95A8CB;font-size: 28rpx;padding-left: 27rpx;white-space: nowrap;">订单附件</view>
      <view style="width: 70%;text-align: left;">
        <van-uploader disabled max-count="5" accept="image" style="margin-left: 4%;border-radius: 15rpx;" preview-size="160rpx;" file-list="{{ orderfileList }}"   multiple="true" imageFit="aspectFit" />
      </view>
    </view>

    <view style="height: 40rpx;"></view>
  </view>


</view>

<view style="height: 200rpx;"></view>


<!--编辑商品-->
<van-popup custom-class="dk-popup" show="{{ showEditProduct }}" round="{{true}}" position="bottom" bind:close="closeChoosedItemInfo">
  <view style="  position:relative; top:280rpx;background-color: transparent; height: 44rpx;"></view>

  <view class="special-topic">
    <view class="special-topic-content">
      <van-image radius="15rpx" custom-class="goods-pop-image" fit="fill" src="{{ currentChoosedItem.iconThumPath }}">
      </van-image>
      <!--  -->
    </view>
    <view class="special-topic-title">
      <dk-title id="titleTagPop" titleTag="{{currentChoosedItem.titleTag}}" title="{{currentChoosedItem.skuModel}}"></dk-title>
      <view style="padding-top: 10rpx;white-space: nowrap;">
        <dk-text fontWeight="" value="{{currentChoosedItem.skuName}}"> </dk-text>
      </view>

      <!--sku编码-->
      <view style="padding-top:3px !important;display:flex;font-size: 14px;color: #1B365D;justify-content: flex-end; margin-right: 14vw;margin-top: 5vw;">
        <view style="margin: 2vw;">库存量：{{currentChoosedItem.ivtQty}}</view>
        <view style="margin: 2vw;">可售量：{{currentChoosedItem.usableQty}}</view>
      </view>

    </view>
  </view>
  <view class="pop-content-class">
    <van-cell-group>
      <view style="height:calc({{windowHeight+'px'}} - 676rpx);overflow-y: scroll;overflow-x: hidden;">
        <!-- 正常品 -->
        <view>

          <!-- 就一个商品 -->
          <view wx:if="{{currentChoosedItem.specsList.length == 0}}" style="display: flex;justify-content: space-between;">
            <view style="width: 30%;">
            </view>
            <!--显示已选商品编码-->
            <view style="align-items: center; padding-top: 12rpx;">
              <dk-text fontSize="10px" fontWeight="" value="编码：{{currentChoosedItem.skuCode}}"> </dk-text>
            </view>
          </view>

          <view wx:for="{{currentChoosedItem.specsList}}" wx:key="index" wx:for-item="itemspecs">
            <view style="display: flex;justify-content: space-between;">
              <view style="width: 30%;">
                <dk-text fontSize="13px" value="{{itemspecs.specsName}}"></dk-text>
              </view>
              <!--显示已选商品编码-->
              <view style="align-items: center; padding-top: 12rpx;" wx:if="{{currentChoosedItem.skuCode && index == 0}}">
                <dk-text fontSize="10px" fontWeight="" value="编码：{{currentChoosedItem.skuCode}}"> </dk-text>
              </view>
            </view>
            <view class="tags">
              <view class="tag-bom-item" wx:key="indext" wx:for="{{itemspecs.specsValues}}" wx:for-index="indext" wx:for-item="itemt">
                <van-button size="small" custom-class="button-selected-class">
                  <view style="display: flex;  justify-content: center;  align-items: center; height: 100%;"> {{ itemt }} </view>
                </van-button>

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


        <van-cell border="{{ false }}" title="待出库量" title-class="red-label">
          <van-stepper value="{{currentChoosedItem.outGoingQuantity}}" integer="{{true}}" data-index="{{index}}" min="0" max="999999999" data-type="待出库量" bind:change="changeAllreadyChooseQuantityPop" />
        </van-cell>
        <van-cell border="{{ false }}" title="本次出库量" title-class="red-label">
          <van-stepper value="{{currentChoosedItem.outQuantity}}" integer="{{true}}" data-index="{{index}}" min="0" max="999999999" data-type="本次出库量" bind:change="changeAllreadyChooseQuantityPop" />
        </van-cell>

        <van-field disabled label-class="nomal-label" label="库区" value="{{currentChoosedItem.whName}}" input-align="right" border="{{ false }}" />

        <van-field disabled label-class="nomal-label" label="色号" value="{{currentChoosedItem.nonStdCode}}" input-align="right" border="{{ false }}" />


        <view style="height: 100rpx;"></view>
      </view>
      <van-cell value-class="button-pop-cell-class">
        <view style="text-align: center;">
          <van-button round size="large" color="#1B365D" custom-style="height:88rpx;width:640rpx;" type="info" data-item="{{currentChoosedItem}}" size="small" bindtap="updateToChooseList">确定</van-button>
        </view>
      </van-cell>
    </van-cell-group>
  </view>
</van-popup>

<view style="height: 235rpx;"></view>

<!--保存按钮  （我提出来了）-->
<view wx:if="{{form.sale2OpeMode != '分销模式-代送'}}" class="bottom-class-1">
  <view style="display: flex; padding:35rpx 34rpx 62rpx 34rpx;">
    <view style="width: calc(100% - 65%); height: 85rpx; ">
      <van-button size="large" round color="#4A5E98" custom-style="height:88rpx;" bind:click="scanBarcode" type="default">{{scanBarcodeName}}
      </van-button>
    </view>
    <!-- 保存确定区域 -->
    <view style="width:65%;justify-content: center;display:flex;">
      <van-button style="width:40%;margin-right: 5%;" plain round custom-class="save-button-class-canl" size="large" color="purple" custom-style="height:88rpx;" bind:click="allClean" type="default">暂存</van-button>

      <van-button style="width: 40%;" size="large" round color="#1B365D" custom-style="height:88rpx;" bind:click="submit" type="default">出库
      </van-button>
    </view>
  </view>
</view>





<!--备注-->
<van-popup show="{{ remarkFlag }}" style="z-index: 999;" round="{{true}}" position="bottom" bind:close="closeChoosedItemInfo_remark">

  <van-cell-group>
    <van-cell border="{{ false }}">
      <view style="display: flex;">
        <view style="width:80%;font-size:16px;color:#34495e;text-align:left;">
          备注修改
        </view>
        <view style="text-align: right; width:20%; ">
        </view>
      </view>
    </van-cell>
    <van-divider />
    <van-field rows="5" autosize label="备注" value="{{goodsList[remarksIndex].remarks}}" type="textarea" maxlength="1000" placeholder="请输入备注" data-item="{{goodsList[remarksIndex].remarks}}" data-key="remarks" input-class="input-class" bind:change="changeRemarksField" border="{{ false }}" />
    <view style="height: 450rpx;"></view>
    <view style="text-align: center;">
      <van-button round size="large" color="#1B365D" custom-style="height:88rpx;width:640rpx;" type="info" size="small" bindtap="updateToChooseList_remark">确定</van-button>
    </view>
    <view style="height: 40rpx;"></view>
  </van-cell-group>
</van-popup>








<!-- 收货日期 -->
<van-popup show="{{ deliveryFlag }}" data-key="deliveryTime" position="bottom" bind:close="onConfirmChooseDateClose" bind:click-overlay="onConfirmChooseDateClose">
  <view style="display:flex;justify-content: space-around;height:80rpx;">
    <view style="width:45%;text-align: left;color:#b6b6b6;line-height:80rpx;" data-key="deliveryTime" catchtap="onConfirmChooseDateClose">取消</view>
    <view style="width:45%;text-align: right;color:#1989fa;line-height:80rpx;" data-key="deliveryTime" catchtap="onConfirmChooseDate">确定</view>
  </view>
  <van-datetime-picker show-toolbar="{{false}}" data-key="deliveryTime" bindonlyinput="changeDate" data-index="0" type="date" loading="{true}" value="{{ deliveryTimeDefaultSearch }}" />
</van-popup>
<!-- 业务部门 -->
<dk-single-dropdown-item show="{{orgFlag}}" id='org' typeName='org' contentID="{{form.orgId}}" bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 业务员 -->
<dk-single-dropdown-item show="{{staffFlag}}" id='staff' typeName='staff' contentID="{{form.staffId}}" bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 出库原因 -->
<dk-single-dropdown-item show="{{outReasonFlag}}" id='outReason' typeName='outReason' contentID="{{form.outboundForm.outReason}}" bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>