<wxs src='../../../../utils/numberFormat.wxs' module="numberFormat"></wxs>
<van-dialog id="van-dialog" />
<loading wx:if="{{loading}}" loadingName="加载中" backgroundColor="#f2f2f2;" opacity="0.8"></loading>

<!-- 主从业务员业务部门  -->
<view style="display:flex;margin-bottom:1vw;">
  <!-- 主从业务员  -->
  <view style="width: 50%;">
    <van-cell id="staffItem" title="{{form.makingUserName}}" value-width="1rpx" title-class="cell-value-staff-org" arrow-direction="down" is-link value="" />
  </view>
  <!-- 主从业务部门 -->
  <view style="width: 50%;">
    <van-cell id="orgItem" title="{{form.orgName}}" value-width="1rpx" title-class="cell-value-staff-org" arrow-direction="down" is-link value="" />
  </view>
</view>


<!-- 客户信息组件 -->
<dk-customer-detail customerName="{{form.customerName}}" textColor="black" backgroundColor="white,white,white" customerPhone="{{form.customerPhone}}" addressFull="{{form.addressFull}}"></dk-customer-detail>


<!--收款金额  -->
<view class="return-style">
  <view style="display: flex;  margin-bottom: 3vw;">
    <view style="width:50%;color:#1B365D;text-align: center;font-size:4vw; border-right: 1rpx lightgray solid ;" bindtap="toChooseGoods">
      <view style="font-weight:bold;font-size:15px; margin-bottom: -11px;">
        <!-- 合计金额 - 合计退货金额 -->
        <!-- ￥{{form.canReturnAmount}} -->
        <dk-cell left="0rpx" center="center" fontSize="13" contentFontSize="13" contentColor="#1B365D" spaceWidth="0" contentFontWeight="bold" content="{{form.canReturnAmount}}"></dk-cell>
      </view>
      <view style="font-size:13px;">退货前总额</view>
    </view>
    <view style="width:50%;color:#1B365D;text-align: center;font-size:4vw; " bindtap="scanQRCode">
      <view style="margin-bottom: -11px;">
        <!-- 退货后总额 =  退货前 + 合计 -->
        <!-- {{'¥'+ form.sumEndAmount }} -->
        <dk-cell left="0rpx" center="center" fontSize="13" contentFontSize="13" contentColor="#A5814A" spaceWidth="0" contentFontWeight="bold" content="{{form.sumEndAmount}}"></dk-cell>
      </view>
      <view style="font-size:13px;">退货后总额</view>
    </view>
  </view>
  <view style="padding-left:5vw;padding-right: 5vw;    margin-bottom: -3vw;">
    <van-field  input-width="200rpx"  label-class="nomal-label" input-align="right" data-key="estate" maxlength="25" type="text" value="{{ form.rejectReasonTypeName }}" label="退货类别" placeholder="请选择退货类别" autosize
   border="{{ false }}"  color="#95A8CB" data-type='rejectReasonType' catchtap="openRejectReasonType" readonly="{{true}}">
    </van-field>
    
  </view>
  <view style="padding-left:5vw;padding-right: 5vw;  margin-bottom: -3vw;">
    <van-field value="{{ form.mReasonForReturn }}" input-align="right" label="退货原因" placeholder="请输入退货原因" bind:change="onmReasonForReturnChange" />
  </view>
  <view style="padding-left:5vw;padding-right: 5vw; ">
    <van-field value="{{ form.mRefundAccountNumber }}" input-align="right" label="退款账号" placeholder="请输入退款账号" bind:change="onmRefundAccountNumberChange" />
  </view>

</view>

<!-- 空高度  -->
<view style="margin-top: 10rpx;"></view>
<!--商品明细  -->
<view class="goods-detail">
  <van-collapse value="{{ activeNames }}" bind:change="onChange">
    <!--商品明细  -->
    <van-collapse-item name="1" id="menu_1">
      <view slot="title" style="color: #1B365D;">商品明细</view>

      <van-cell wx:if="{{goodsList.length==0}}" border="{{ false }}">
        <van-empty description="暂未选择商品" />
      </van-cell>
      <view wx:for="{{goodsList}}" wx:key="index" border="{{ true }}">
        <van-card>
          <view slot="thumb">
            <van-image radius="5px" width="80" height="80" src="{{item.iconThumPath }}" />
          </view>
          <view slot="title">
            <dk-title titleTag="HEGII恒洁" title="{{item.skuCode}}"></dk-title>
          </view>
          <view slot="desc">
            <dk-text value="{{item.skuName}}"></dk-text>
          </view>
          <view slot="price">
            <view style="display: flex;width: 100%;flex-direction: row;">
              <view style="font-size:14px;width:100%;font-family:'PingFang HK';font-style:normal;">
                <!-- <dk-cell height="46rpx" spaceWidth="1rpx" left="0" fontSize="13" contentColor="#CAA977" contentFontWeight="bold" title="" content="{{item.orderPriceSale}}"></dk-cell> -->
                <!-- 销售单价（本次退货价格） （可修改 ）-->
                <dk-number-input inputValue="{{item.rejectPrice}}" bind:triggerBindBlur="sumFeeAmountBindinputBlur" bind:triggerBindValue="orderPriceSaleInput" data-index="{{index}}" inputColor="#CAA977" fontWeight="bold" center="left"></dk-number-input>
              </view>
              <view style="width: 100%;text-align: right;font-size: 3.5vw;">
                <!-- 限制 min : 可出库数量 = 出库数量 - 退货数量 -->
                <van-stepper integer="{{true}}" value="{{item.rejectQuantity}}" max="{{-1}}" min="{{item.rejectQuantityTemp}}" data-index="{{index}}" bind:change="onChangeStepper" />
              </view>
            </view>
          </view>
          <view slot="footer">
            <view class="hr"></view>
            <view style="display: flex;width: 100%;margin-top:5px; align-items: center;">
              <view style="width: 70%;text-align: left;font-size: 13px;color: #95A8CB;">
                备注：<span style="line-height:56rpx;">{{item.remarks ? item.remarks : ''}}</span>
              </view>
              <!-- <view style="width: 50%;text-align: right;font-size: 3.5vw;margin-left: 14%;">  -->
              <view style="width: 50%;">
                <!-- <dk-cell fontSize="13" contentColor="#CAA977" titleColor="#95A8CB;" title="金额" contentFontWeight="bold" content="{{ item.rejectAmount}}">
                </dk-cell> -->
   
                <dk-number-input inputValue="{{item.rejectAmount}}" bind:triggerBindBlur="sumFeeAmountBindinputBlur" bind:triggerBindValue="rejectAmountInput"
                titleValue="金额"titleColor="#95A8CB;"  inputColor="#CAA977" fontWeight="bold"  center="left" data-index="{{index}}"></dk-number-input>

              </view>


            </view>
          </view>
        </van-card>
        <van-divider />
      </view>
      <!-- 货物金额 -->
      <view style="padding-bottom: 10px;">
        <dk-cell titleColor="#95A8CB" height="46rpx" spaceWidth="346rpx" contentColor="#CAA977" contentFontWeight="bolder" title="货物金额" content="{{form.sumRejectGoodsAmount}}"></dk-cell>
      </view>
      <!-- 服务费用 -->
      <van-cell title-class="title-cell-style" value-class="value-cell-style" border="{{ false }}" title-width="350rpx">
        <view slot="title">
          服务费用
        </view>
        <view Cell Slot="value">
          <dk-number-input negativeFlag="{{false}}" inputValue="{{form.sumRejectFeeAmount}}" bind:triggerBindBlur="sumFeeAmountBindinputBlur" bind:triggerBindValue="sumFeeAmountBindinput"></dk-number-input>
        </view>
      </van-cell>

      <!-- 合计金额 -->
      <view style="display:flex;  ">
        <view style="width: 50%;">
          <view style="padding-left: 30rpx;padding-top: 10px;padding-bottom: 10px;">
            <text style="color: #95A8CB;font-size: 13px;">{{spuCategoryNum}} 品类,共计 {{sumRejectQuantity}} 件</text>
          </view>
        </view>
        <view style="width: 50%;padding-top: 10px;padding-bottom: 10px;">
          <dk-cell titleColor="#1B365D" height="39rpx" spaceWidth="20rpx" contentColor="#CAA977" fontSize="15" contentFontWeight="bolder" title="合计金额" content="{{form.sumRejectAmount}}"></dk-cell>
        </view>
      </view>
      <!-- 实收金额 -->
      <view style="padding-top: 10px;">
        <dk-cell titleColor="#95A8CB" height="46rpx" spaceWidth="346rpx" contentColor="#CAA977" contentFontWeight="bolder" title="实收金额" content="{{form.sumCollectedAmount}}"></dk-cell>
      </view>
    </van-collapse-item>
    <view style="margin-bottom: 10rpx;"></view>
    <!-- 其他信息 -->
    <van-collapse-item name="2" id="menu_2">
      <view slot="title" style="color: #1B365D;"> 其他信息</view>
      <van-field title-class="color-style" label="备注" bind:change="changeRemarksField" data-key="remarks" value="{{item.remarks}}" input-align="right" placeholder="请输入备注" border="{{ true }}" />
    </van-collapse-item>
    <view style="margin-bottom: 10rpx;"></view>
  </van-collapse>
</view>
<!-- 空高度  -->
<view style="width: 100%;height: 100px;"></view>
<!-- 合计报价保存相关组件  退货后总额 - 实收金额 = 需收款-->
<!-- <dk-save-bottom flagTypeName="order-save-deal" totallength="{{form.needReceivable}}" item="{{item}}" bind:allClean="{{form.needReceivable < 0 ? 'submit' :'allClean'}}" allCleanFlag="{{form.needReceivable > 0}}" bind:submit="submit" disabledFlag="{{loadingButtonFlag}}" ></dk-save-bottom> -->
<!-- 2023/11/07 现在如果有收款iboss那面会异常。按钮改成保存【未收款成交】 -->
<!-- <dk-save-bottom flagTypeName="order-save-deal" totallength="{{form.needReceivable}}" item="{{item}}"  allCleanFlag="{{false}}" bind:submit="submit" disabledFlag="{{loadingButtonFlag}}" ></dk-save-bottom> -->

<!-- 底部按钮相关 -->
<view class="bottom-class-1">
  <view style="padding:10rpx 34rpx 61rpx 43rpx; display: flex;">
    <view style="width:50%;padding-top: 10rpx;">
      <view style="color: #CAA977;font-size: 30rpx;padding-top: 10rpx;">
        <dk-cell contentFontSize="16" height="44rpx" fontWeight="600" left="0rpx" contentColor="#CAA977" title="需收款：" content="{{form.needReceivable}}"></dk-cell>
      </view>
      <view style="display: flex;justify-content: left;align-items: center;" wx:if="{{saleLinkPsiSystem}}">
        <van-checkbox value="{{ flgAutoIvt }}" data-index="{{index}}" data-index_="{{index_}}" bind:change="onChangeAOP" checked-color="#E4002B"></van-checkbox>
        <view style="color: #1B365D; font-size: 26rpx;padding-left:10rpx">自动库存办理</view>
      </view>
    </view>
    <!-- 保存确定区域 -->
    <view style="width: 50%; display: flex;padding-top: 42rpx;">
        <view style="border-radius: 15rpx;width: 196rpx; height: 88rpx;font-size: 32rpx;line-height: 40rpx;">
        <van-button size="large" round color="#506483" plain custom-style="height:88rpx;"   bind:click="deal" type="info" disabled="{{disabledFlag}}" loading="{{disabledFlag}}">收款成交
        </van-button>
      </view>
      <view style="width: 19rpx;"></view>
      
      <view style="border-radius: 15rpx;width: 196rpx; height: 88rpx;font-size: 32rpx;line-height: 40rpx;">
          <van-button round size="large" color="#CAA977" custom-style="height:88rpx;" loading="{{disabledFlag}}" disabled="{{disabledFlag}}" bind:click="submit" type="info">未收款成交
        </van-button>
      </view>
    </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="{{ true }}">
      <view style="width:100%;font-size:5vw;color:#34495e;text-align:left;">
        备注修改
      </view>
    </van-cell>
    <van-divider />
    <van-field label="备注" bind:focus="clearZero" type="quantity" bind:change="changeRemarksField" data-item="{{goodsList[remarksIndex].remarks}}" data-key="remarks" value="{{goodsList[remarksIndex].remarks}}" input-align="right" placeholder="请输入备注" border="{{ true }}" />
    <view style="height: 50px;"></view>

    <van-cell border="{{ true }}">
      <van-button custom-style="width:100%;" type="info" size="small" bindtap="updateToChooseList_remark">确定</van-button>
    </van-cell>
  </van-cell-group>
</van-popup>

<dk-single-dropdown-item show="{{rejectReasonTypeFlag}}" id='rejectReasonType' typeName='rejectReasonType' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
