<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;">{{language[detail.brandname]||detail.brandname}}</text>
		<text wx:if="{{detail.tradefield}}" style="background-color: #4BD863;">{{language[detail.tradefield]||detail.tradefield}}</text>
		<!-- <text wx:if="{{detail.status=='新建' && detail.type=='项目订单'}}" style="background-color: #4BD863;" bindtap="setBraned">设置品牌/领域</text> -->
	</view>
	<view class="exp" wx:if="{{userrole!='经销商'}}">{{language['企业']||'企业'}}：{{detail.enterprisename || ' --'}}</view>
	<view class="exp" wx:if="{{detail.type=='项目订单'}}">{{language['关联项目']||'关联项目'}}：{{detail.projectname || language['暂无']||'暂无'}}</view>
	<view class="exp">{{language['订单类型']||'订单类型'}}：{{language[detail.type]||detail.type}}</view>
	<view class="exp">{{language['订单状态']||'订单状态'}}：<text style="color:{{sColors[detail.status]}};">{{language[detail.status]||detail.status}}</text></view>
	<view class="exp">{{language['单据日期']||'单据日期'}}：{{detail.billdate || language['暂无']||'暂无'}}</view>
	<view class="exp">{{language['创建日期']||'创建日期'}}：{{detail.createdate}}</view>
	<view class="exp" wx:if="{{siteid=='HY'}}">{{language['备货状态']||'备货状态'}}：<text style="color:{{sColors[detail.goodsstatus]}};">{{language[detail.goodsstatus]||detail.goodsstatus}}</text></view>
	<view class="exp">{{language['核销状态']||'核销状态'}}：<text style="color:{{sColors[detail.writeoffstatus]}};">{{language[detail.writeoffstatus]||detail.writeoffstatus}}</text></view>
	<view class="exp">{{language['开票状态']||'开票状态'}}：<text style="color:{{sColors[detail.invoicestatus]}};">{{language[detail.invoicestatus]||detail.invoicestatus}}</text></view>
	<van-button custom-class='copy' bindtap="copyItem">{{language['一键复制订单']||'一键复制订单'}}</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 || language['暂无']||'暂无'}}<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">
			{{language['开票单位']||'开票单位'}}
		</view>
		<view class="address">
			{{detail.finance.enterprisename || language['暂无']||'暂无'}}
		</view>
	</view>
	<view class="iconfont icon-dibu-bianji" />
</navigator>

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

	<view class="row">
		<view class="label">{{language['支付账户']||'支付账户'}}</view>
		<view style="font-size: 28rpx; text-align: right;">
			{{language[account.name]||account.name}}
			<text style="font-size: 22rpx;">{{account.text}}</text>
		</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">{{language['是否使用返利金（余额']||'是否使用返利金（余额'}}：{{detail.rebatebalance}}）</view>
			<checkbox disabled="{{detail.status!='新建'}}" checked="{{detail.rebate_used==1}}" color='var(--assist)' />
		</navigator>
		<block wx:if="{{detail.rebate_used==1}}">
			<view class="row">
				<view class="label">{{language['返利金支付']||'返利金支付'}}({{language['最多订单金额']||'最多订单金额'}}{{detail.order_rebate_userate}})</view>
				<input disabled="{{detail.status!='新建'}}" bindtap="isEdit" type="digit" class="remarks" placeholder-class='placeholder' value="{{detail.rebateamount}}" placeholder="{{language['使用金额']||'使用金额'}}" bindblur="setRebate_amount" />
			</view>
			<view class="row">
				<view class="label" style="font-size: 28rpx;">{{language['支付合计']||'支付合计'}}：{{detail.amount}}（{{language[detail.accountclass.accountname]||detail.accountclass.accountname}}）+ {{detail.rebateamount}}（{{language['返利金']||'返利金'}}）</view>
			</view>
		</block>
	</block>
</view>

<view class="box" style="padding: 10rpx 30rpx;">
	<picker mode="selector" range='{{saletypeList}}' disabled="{{detail.status!='新建' ||detail.type=='特殊订单'}}" range-key='show' bindchange='setSaletype'>
		<navigator url="#" class="row" bindtap="selectSaletype">
			<view class="label">{{language['销售分类']||'销售分类'}}</view>
			<view style="font-size: 28rpx;">
				{{detail.saletype ? detail.saletype +'-'+ detail.saletyperemarks:language['前往设置']|| '前往设置'}}
				<van-icon name="arrow" />
			</view>
		</navigator>
	</picker>
	<view class="row" wx:if="{{detail.type=='标准订单'}}">
		<view class="label">{{language['项目备注']||'项目备注'}}</view>
		<textarea disabled="{{detail.status!='新建'||detail.type=='特殊订单'}}" bindtap="isEdit" class="remarks" placeholder-class='placeholder' bindblur="changeRemarks" data-name="projectnote" value="{{detail.projectnote}}" auto-height placeholder="{{language['项目备注']||'项目备注'}}" />
	</view>
	<view class="row">
		<view class="label">{{language['订单备注']||'订单备注'}}</view>
		<textarea disabled="{{detail.status!='新建'||detail.type=='特殊订单'}}" bindtap="isEdit" class="remarks" placeholder-class='placeholder' bindblur="changeRemarks" data-name="remarks" value="{{detail.remarks}}" auto-height placeholder="{{language['订单备注']||'订单备注'}}" />
	</view>
	<view class="row">
		<view class="label">{{language['回签单']||'回签单'}}</view>
		<van-radio-group direction='horizontal' disabled="{{detail.status!='新建'||detail.type=='特殊订单'}}" value="{{ detail.signbackstatus }}" bind:change="changeSignbackstatus">
			<van-radio icon-size='14px' custom-class='label-class' name="不需要">{{language['不需要']||'不需要'}}</van-radio>
			<van-radio icon-size='14px' custom-class='label-class' name="纸质件">{{language['纸质件']||'纸质件'}}</van-radio>
			<van-radio icon-size='14px' custom-class='label-class' name="扫描件">{{language['扫描件']||'扫描件'}}</van-radio>
		</van-radio-group>
	</view>
</view>
<view style="height: 20rpx;" />
<Yl_FunTabs list='{{tabsList}}' active='{{tabsActive}}' bind:onChenge="tabsChange">
	<Product slot='产品明细' id='Product' disabled="{{detail.status!='新建'||detail.type=='特殊订单'}}" />
	<Yl_Attachment slot='附件' id='Yl_Attachment' ownertable="sa_order" ownerid="{{detail.sa_orderid}}" disabled="{{detail.status!='新建'}}" />
	<Progress slot='订单进度' id='Progress' />
	<Invoice slot='发票' id='Invoice' apiId='20221229154102' />
</Yl_FunTabs>

<van-dialog show="{{ showMYModel }}" bind:close="dialogOnClose" bind:confirm='stepperSubmit' use-slot title="{{language['提示']||'提示'}}" confirmButtonText="{{language['确定']||'确定'}}" cancelButtonText="{{language['取消']||'取消'}}" confirm-button-color='#3774F6' show-cancel-button confirm-button-open-type="getUserInfo" zIndex="99999999">
	<view class="dialog-box">
		<view style="margin-top: 20rpx;">
			{{language['是否确认提交订单']||'是否确认提交订单'}}？
		</view>
		<view style="margin:20rpx 0;">
			<text style="color: #FF3B30;margin-right: 6rpx;">*</text>{{language['发货提醒天数']||'发货提醒天数'}}
		</view>
		<van-stepper value="{{ reminddays }}" input-class='dialog-input-class' min="0" bind:change="stepperChange" />
		<view style="margin-top: 20rpx;font-size: 24rpx;">
			{{language['用于提醒订单负责人待发货信息，若值为0则不提醒'] || '用于提醒订单负责人待发货信息，若值为0则不提醒'}}
		</view>
	</view>
</van-dialog>
<view style="height: 130rpx;" />
<view class="footer">
	<view class="price">
		<view class="count">
			{{defaultamount}}{{language['元']||'元'}}
		</view>
		<view>
			{{language[logistics]||logistics}}
		</view>
	</view>
	<view class="but-box">
		<block wx:if="{{detail.status=='预提交'}}">
			<van-button wx:if="{{isSure}}" custom-class='but' bind:click="confirmSubmit">{{language['确认提交']||'确认提交'}}</van-button>
			<van-button wx:if="{{isRecall}}" custom-class='but' color='#FF9933' bind:click="recall">{{language['撤回']||'撤回'}}</van-button>
		</block>
		<block wx:else>
			<block wx:if="{{isDelete}}">
				<van-button custom-class='but delete' wx:if="{{detail.status=='新建'&&detail.type!='特殊订单'}}" bind:click="deleteItem">{{language['删除订单']||'删除订单'}}</van-button>
			</block>
			<block wx:if="{{isSubmit}}">
				<van-button custom-class='but' wx:if="{{detail.status=='新建'}}" bind:click="submit">{{language['提交订单']||'提交订单'}}</van-button>
			</block>
			<block wx:if="{{fixATime}}">
				<van-button custom-class='but' wx:if="{{detail.status=='交期待确认'}}" bind:click="notarize">{{language['确认交期']||'确认交期'}}</van-button>
			</block>
		</block>
	</view>
</view>