<!-- 前台导入wxmlUtil.wxs -->
<wxs src='../../../../utils/wxmlUtil.wxs' module="wxmlUtil"></wxs>
<wxs src='../../../../utils/numberFormat.wxs' module="numberFormat"></wxs>

<wxs module="m1">
  function toReplace(value) {
    return value.replace("-", "/")
  }
</wxs>
<van-dialog id="van-dialog" />
<loading wx:if="{{loading}}" loadingName="加载中" backgroundColor="#f2f2f2;" opacity="0.8"></loading>



<view style="margin: 10px 32rpx 10px 32rpx;margin-top: 41rpx;border-radius: 15rpx;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 0px 0px;">
    <view style="display: flex;padding-right: 32rpx;width: 100%;">

      <!-- <view style="display: flex;">

            </view> -->
      <view style="display: flex; width: 85%;">

        <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.customerForm.customerName}}
        </view>


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



      <view style="right:50px;width: 15%;padding-top: 19rpx;text-align: right;">
        <!-- <view catchtap="openCustomer" style="width: 36rpx;height: 36rpx;background-color: #FFFFFF;border-radius:50%;justify-content: center; align-items: center;text-align: center;">
                    <van-image style="padding-bottom: 10rpx;" round width="22rpx" height="25rpx" src="/static/image/edit.png" />
                </view> -->
      </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.customerForm.addressFull)}}
      </view>
    </view>
    <view style="display: flex;padding-left: 32rpx;padding-top: 15rpx;padding-bottom: 15rpx;padding-right: 32rpx;">
      <view style="display: flex; width: 50%;line-height: 36rpx;" catchtap="openSingle" data-type='deliveryType'>
        <view style="font-size: 24rpx;line-height: 36rpx;color: #FFFFFF;">
          {{form.deliveryTypeName ? form.deliveryTypeName : '请选择'}}
        </view>
        <view style="padding-left: 15rpx;">
          <van-image round width="15rpx" height="18rpx" src="/static/img/arrow-right.png" />
        </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 style="padding-left: 15rpx;">
          <van-image round width="15rpx" height="18rpx" src="/static/img/arrow-right.png" />
        </view>



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



  <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-cell wx:if="{{goodsList.length==0}}" border="{{ false }}">
      <van-empty description="暂未选择商品" />
    </van-cell>
    <view wx:for="{{goodsList}}" data-item="{{item}}" wx:for-item="item" wx:key="index" border="{{ true }}">

      <van-card 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.title}}"></dk-title>
          </view>
        </view>

        <view slot="desc">
          <view style="display:flex;width: 100%;">
            <dk-text fontWeight="nomal" value="{{item.desc}}"></dk-text>

          </view>


          <view wx:if="{{item.nonGlassListShow}}" style="padding-top: 15rpx; padding-bottom: 15rpx; width: 100%;">
            <dk-text fontWeight="nomal" value="{{item.nonGlassListShow}}"></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="25rpx" fontWeight="bold" left="0rpx" contentColor="#CAA977" title="" content="{{ item.priceSale}}"></dk-cell>
            </view>
            <view style="width: 100%;text-align: right;font-size:24rpx;color: #95A8CB;line-height: 34rpx;">x {{item.tItemQuantity }}{{item.flgNonStandardType == 1 ? (' * ' + item.nonStandardArea + 'm²'): ''}}</view>
          </view>
        </view>




        <view slot="footer">
          <view wx:if="{{item.promotionType == 1 || item.promotionType == 0 }}" style="text-align: left;">
              <view style="font-size:12px;color: #95A8CB;">{{'已选: '+item.skuName}}</view>
            </view>
          <view style="margin-top: 15rpx;" wx:if="{{item.goodsSkuList.length > 0  || item.combinedList.length > 0}}">

            <view style="width: 100%;display: flex;font-size:24rpx;color: #95A8CB;">
              <view style="width: 50%;text-align: left;">
                明细
              </view>
              <view style="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 style="width: 15%;" wx:if="{{item2.replaceableSku && item2.replaceableSku.length > 0}}">
                                                <dk-van-tag radius="10rpx" roundFlag="{{true}}" dataItem="{{item2}}" bind:tap="flag_bindtap" value="替换" color="red"></dk-van-tag>
                                            </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.priceSale}}"></dk-cell>
                        <!-- <dk-text color="#CAA977" value="￥{{numberFormat.toThousandCents(item2.priceSale)}}"></dk-text> -->
                      </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 style="display: flex;width: 100%;margin-top:5px;" data-index="{{index}}" catchtap="openRemark">
            <view style="width: 70%;text-align: left;font-size:22rpx;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 style="width: 100%;text-align: right;font-size:28rpx;color: #95A8CB;">金额：<span style="line-height:56rpx;color:#CAA977;">￥{{ numberFormat.toThousandCents((item.priceSale ? item.priceSale : 0) * item.itemQuantity)}}</span></view> -->
            <!-- <view style="width: 100%;text-align: right;font-size:28rpx;color: #95A8CB;">金额：<span style="line-height:56rpx;color:#CAA977;">￥{{ numberFormat.toThousandCents( item.tItemAmount)}}</span></view> -->

            <view style="width: 50%;text-align: right;">
              <dk-cell contentFontSize="14" titleColor="#95A8CB" title="金额：" contentColor="#CAA977" content="{{numberFormat.toThousandCents( item.tItemAmount)}}"></dk-cell>
            </view>
          </view>
          <view style="margin-top:19rpx;margin-bottom:19rpx; width: 617rpx;border: 1rpx solid #E9F0FE;flex: none;order: 3;flex-grow: 0;z-index: 3;"></view>

        </view>
      </van-card>

    </view>
  </view>



  <view style="background: #FFFFFF;box-shadow: 0rpx 10rpx 20rpx rgba(225, 229, 238, 0.6);border-radius: 15rpx;">
    <van-cell border="{{ false }}" title-width="410rpx">
      <view slot="title" style="color: #95A8CB;">
        服务费用
      </view>
      <view Cell Slot="value">
        <dk-number-input inputValue="{{form.sumFeeAmount}}" bind:triggerBindBlur="sumFeeAmountBulr" bind:triggerBindValue="sumFeeAmountBindinput"></dk-number-input>
      </view>
    </van-cell>

    <van-cell border="{{ false }}" title-width="410rpx">
      <view slot="title" style="color: #95A8CB;">
        抵扣预存<text style="font-size: 12px;">(可用：￥{{numberFormat.toThousandCents(form.usablePrestore)}})</text>
      </view>
      <view Cell Slot="value">
        <dk-number-input readonly="{{form.usablePrestore <= 0}}" inputColor="#CAA977" max="{{form.sumAmount}}" inputValue="{{form.sumUsePrestore<0?0:form.sumUsePrestore}}" bind:triggerBindBlur="balanceAmountBulr" bind:triggerBindValue="sumUsePrestoreBindinput"></dk-number-input>
      </view>
    </van-cell>

    <view style="display:flex;">
      <view style="width: 50%;">
        <view style="padding-left: 30rpx;padding-top: 25rpx;">
          <text style="color: #95A8CB;font-size: 28rpx;">{{form.categoryQuantity ? form.categoryQuantity : 0}} 品类,共计 {{form.sumQuantity ? form.sumQuantity :0}} 件</text>
        </view>
      </view>

      <view style="width: 50%;">
        <dk-cell fontSize="16" fontWeight="bold" contentColor="#CAA977" titleColor="#1B365D;" title="合计金额" content="{{form.tSumAmount}}"></dk-cell>
        <!-- <dk-cell fontSize="13" contentColor="#CAA977" titleColor="#95A8CB;" title="合计金额" content="{{form.tSumAmount}}"></dk-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 value="{{ form.contractNo }}" data-key="contractNo" label-class="{{ORDER_CONTRACT_NO ? 'red-label' : 'nomal-label'}}" input-align="left" label="合同号" maxlength="50" placeholder="请输入合同号" autosize border="{{ false }}" bind:change="changeField" bind:blur="changeFieldblur">
    </van-field> -->

    <van-field value="{{ form.remarksInside }}" data-key="remarksInside" label-class="nomal-label" input-align="left" label="内部备注" placeholder="请输入内部备注" autosize border="{{ false }}" bind:change="changeField" bind:blur="changeFieldblur">
    </van-field>

    <van-field value="{{ form.remarks }}" data-key="remarks" label-class="nomal-label" input-align="left" label="备注" placeholder="请输入备注" autosize border="{{ false }}" bind:change="changeField" bind:blur="changeFieldblur">
    </van-field>
    <!-- <dk-remarks-magnifier bind:onChange="changeField" data-key="remarksInside" label="内部备注" value="{{ form.remarksInside }}"></dk-remarks-magnifier>
    <dk-remarks-magnifier bind:onChange="changeField" data-key="remarks" label="备注" value="{{ form.remarks }}"></dk-remarks-magnifier> -->


    <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;">附件</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>


</view>




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






<!-- 送货时间 -->
<van-popup show="{{ DeliveryFlag_time_flag }}" data-key="deliveryTime" position="bottom" bind:close="onConfirmChooseDate" bind:click-overlay="onCloseChooseDate">
  <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="onConfirmChooseDate">取消</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>


<van-popup show="{{ showEditCustomer }}" round="{{true}}" position="bottom" bind:close="closeChoosedItemInfo">
  <view style="padding-left: 25rpx;margin-top: 25rpx;">客户基本信息</view>
  <van-divider />
  <van-cell-group>
    <van-cell title-class="red-label" is-link border="{{ false }}" title-width="180rpx" title="客户来源" value="{{form.customerForm.customerFromName ? form.customerForm.customerFromName :'请选择' }}" data-type='customerFrom' catchtap="openSingle" />
    <van-cell title-class="red-label" is-link border="{{ false }}" title-width="180rpx" title="装修户型" value="{{form.customerForm.toiletCountName ? form.customerForm.toiletCountName :'请选择'}}" data-type='toiletCount' catchtap="openSingle" />
    <van-cell is-link border="{{ false }}" title-width="180rpx" title="装修类型" value="{{form.customerForm.fitupTypeName ? form.customerForm.fitupTypeName :'请选择'}}" data-type='fitupType' catchtap="openSingle" />
    <van-cell is-link border="{{ false }}" title-width="180rpx" title="房屋类型" value="{{form.customerForm.houseTypeName ? form.customerForm.houseTypeName :'请选择'}}" data-type='houseType' catchtap="openSingle" />
    <van-cell is-link border="{{ false }}" title-width="180rpx" title="装修风格" value="{{form.customerForm.fitupStyleName ? form.customerForm.fitupStyleName :'请选择'}}" data-type='fitupStyle' catchtap="openSingle" />
    <van-cell is-link border="{{ false }}" title-width="180rpx" title="年龄构成" value="{{form.customerForm.ageCompositionName ? form.customerForm.ageCompositionName :'请选择'}}" data-type='ageComposition' catchtap="openSingle" />
    <van-cell is-link border="{{ false }}" title-width="180rpx" title="决策者" value="{{form.customerForm.decisionMakerName ? form.customerForm.decisionMakerName :'请选择'}}" data-type='decisionMaker' catchtap="openSingle" />
    <van-cell border="{{ true }}">
      <van-button custom-style="width:100%;" type="info" data-item="{{currentChoosedItem}}" size="small" bindtap="updateToChooseList">确定</van-button>
    </van-cell>
  </van-cell-group>
</van-popup>


<!-- 提交 -->
<dk-save-bottom flagTypeName="order-save-deal" disabledFlag="{{loadingButtonFlag}}"  totallength="{{numberFormat.toThousandCents(totallength)}}" item="{{item}}" bind:allClean="deal" bind:submit="submit"></dk-save-bottom>

<!-- 交货方式 -->
<dk-single-dropdown-item show="{{deliveryTypeFlag}}" id='deliveryType' typeName='deliveryType' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 客户来源 -->
<dk-single-dropdown-item show="{{customerSourceFlag}}" id='customerFrom' typeName='customerFrom' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 卫生间数 -->
<dk-single-dropdown-item show="{{numberToiletsFlag}}" id='toiletCount' typeName='toiletCount' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 装修类型 -->
<dk-single-dropdown-item show="{{decorationTypeFlag}}" id='fitupType' typeName='fitupType' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 房屋类型 -->
<dk-single-dropdown-item show="{{houseTypeFlag}}" id='houseType' typeName='houseType' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 装修风格 -->
<dk-single-dropdown-item show="{{decorationStyleFlag}}" id='fitupStyle' typeName='fitupStyle' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>
<!-- 年龄构成 -->
<dk-single-dropdown-item show="{{ageCompositionFlag}}" id='ageComposition' typeName='ageComposition' bind:muticommit='mutiSearch' bind:muticlose='muticlose'></dk-single-dropdown-item>