<import src="detail.skeleton.wxml" />
<template is="skeleton" wx:if="{{loading}}" />

<view class="intr">
    <view class="num">
        {{detail.sonum}}
    </view>
    <view class="tags">
        <text wx:if="{{detail.brandname}}" style="background-color: #0079FE;">{{detail.brandname}}</text>
        <text wx:if="{{detail.tradefield}}" style="background-color: #4BD863;">{{detail.tradefield}}</text>
        <!-- <text wx:if="{{detail.status=='新建' && detail.type=='项目订单'}}" style="background-color: #4BD863;" bindtap="setBraned">设置品牌/领域</text> -->
    </view>
    <view class="exp" wx:if="{{detail.type=='项目订单'}}">关联项目：{{detail.projectname || '暂无'}}</view>
    <view class="exp">订单类型：{{detail.type}}</view>
    <view class="exp">订单状态：{{detail.status}}</view>
    <view class="exp">单据日期：{{detail.billdate || '暂无'}}</view>
    <view class="exp">创建日期：{{detail.createdate}}</view>
    <view class="exp">核销状态：{{detail.writeoffstatus}}</view>
    <view class="exp">开票状态：{{detail.invoicestatus}}</view>
    <van-button custom-class='copy' bindtap="copyItem">一键复制订单</van-button>
</view>

<navigator url="#" class="box location" bindtap="selectConsignee">
    <van-icon custom-class='icon' name="location" />
    <view class="content">
        <view class="name">
            {{detail.contacts.name || '暂无'}}<text>{{detail.contacts.phonenumber}}</text>
        </view>
        <view class="address">
            {{detail.contacts.address}}
        </view>
    </view>
    <view class="iconfont icon-dibu-bianji" />
</navigator>

<navigator url="#" class="box location" bindtap="selectFinance">
    <view class="content">
        <view class="name">
            开票单位
        </view>
        <view class="address">
            {{detail.finance.enterprisename || '暂无'}}
        </view>
    </view>
    <view class="iconfont icon-dibu-bianji" />
</navigator>

<view class="box pay">
    <view class="title">
        支付信息
    </view>
    <navigator url="#" class="row" bindtap="selectAgent">
        <view class="label">结算人</view>
        <view style="font-size: 28rpx;">
            {{detail.pay_enterprisename || '暂无'}}
            <van-icon name="arrow" />
        </view>
    </navigator>

    <view class="row">
        <view class="label">支付账户</view>
        <view style="font-size: 28rpx;">
            {{detail.accountclass.accountname || '暂无'}}
        </view>
    </view>

    <block wx:if="{{order_rebate_used==1 && (detail.type=='标准订单'||detail.type=='特殊订单')}}">
        <navigator url="#" class="row" style="font-size: 0;" bindtap="changeRebateUsed">
            <view class="label">是否使用返利金（余额：{{detail.rebatebalance}}）</view>
            <checkbox disabled="{{detail.status!='新建'}}" checked="{{detail.rebate_used==1}}" color='var(--assist)' />
        </navigator>
        <view class="row" wx:if="{{detail.rebate_used==1}}">
            <view class="label">返利金支付(最多订单金额{{detail.order_rebate_userate}}%)</view>
            <input disabled="{{detail.status!='新建'}}" bindtap="isEdit" type="digit" class="remarks" placeholder-class='placeholder' value="{{detail.rebateamount}}" placeholder="使用金额" bindblur="setRebate_amount" />
        </view>
    </block>
</view>

<view class="box" style="padding: 10rpx 30rpx;">
    <view class="row">
        <view class="label">订单备注</view>
        <textarea disabled="{{detail.status!='新建'}}" bindtap="isEdit" class="remarks" placeholder-class='placeholder' bindblur="changeRemarks" value="{{detail.remarks}}" auto-height placeholder="订单备注" />
    </view>
    <navigator url="#" class="row" style="font-size: 0;">
        <view class="label">是否需要回签单</view>
        <checkbox disabled="{{detail.status!='新建'}}" bindtap="isEdit" checked="{{true}}" color='var(--assist)' />
    </navigator>
</view>

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

<Yl_FunTabs list='{{tabsList}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
    <Product slot='产品明细' id='Product' disabled="{{detail.status!='新建'}}" />
    <Yl_Attachment slot='附件' id='Yl_Attachment' ownertable="sa_order" ownerid="{{detail.sa_orderid}}" disabled="{{detail.status!='新建'}}" />
    <Progress slot='订单进度' id='Progress' />
</Yl_FunTabs>

<view style="height: 130rpx;" />
<view class="footer">
    <view class="count">
        ￥{{detail.amount}}元
    </view>
    <view class="but-box">
        <van-button custom-class='but delete' wx:if="{{detail.status=='新建'}}" bind:click="deleteItem">删除订单</van-button>
        <van-button custom-class='but' wx:if="{{detail.status=='新建'}}" bind:click="submit">提交订单</van-button>
        <van-button custom-class='but' wx:if="{{detail.status=='交期待确认'}}" bind:click="notarize">确认交期</van-button>
    </view>
</view>