<!--pages/create-order/index.wxml-->
<view class="sg-container">
  <view class="sg-tabs sg-flex sg-align-center sg-space-around">
    <block wx:for="{{tabs}}" wx:key="index">
      <view class="sg-tab sg-pad {{index == tabIndex ? 'sg-seleted' : 'sg-gray-color'}}" bindtap="switchTab"
        data-index="{{index}}">{{item}}</view>
    </block>
  </view>
  <view class="sg-order-box" wx:if="{{tabIndex == 0}}">
    <view class="sg-form">
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">项目名称</view>
        <view class="sg-input sg-gray-color">{{order.project ? order.project.name : ''}}</view>
      </view>
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">需求工点</view>
        <view class="sg-input sg-gray-color">{{order.work_point ? order.work_point.name : ''}}</view>
      </view>
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">租赁设备</view>
        <view class="sg-input sg-gray-color">{{device_total}}个</view>
      </view>
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">租赁总金额</view>
        <view class="sg-input sg-gray-color">￥{{order.money/100}}</view>
      </view>
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">填单人</view>
        <view class="sg-input sg-gray-color">{{order.user ? order.user.name : ''}}</view>
      </view>
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">创建时间</view>
        <view class="sg-input sg-gray-color">{{order.created_at}}</view>
      </view>
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">订单状态</view>
        <view class="sg-input sg-gray-color sg-bold" style="color:{{order.color}}">{{order.status}}</view>
      </view>
      <view class="sg-form-item sg-pad sg-top-border">
        <view class="sg-label">工作内容</view>
        <input value="{{remark}}" bindtap="viewRemark" class="sg-input" bindinput="onChange" data-name="remark" disabled="{{true}}"></input>
      </view>
    </view>
  </view>
  <van-calendar show="{{ showDate }}" bind:close="switchShowDate" bind:confirm="confirmDate" data-show="{{false}}"
    type="range" class="sg-calendar" />
  <view class="sg-device-box" wx:if="{{tabIndex == 1}}">
    <view class="sg-device-list sg-top-border">
      <block wx:if="{{devices.length <= 0}}">
        <view class="sg-center sg-pad">暂无设备</view>
      </block>
      <block wx:else>
        <view class="sg-item sg-pad sg-margin" wx:for="{{devices}}" wx:key="index" bindtap="selectDevice"
          data-index="{{index}}">
          <view class="sg-title sg-bold">{{index+1}}. {{item.device_type ? item.device_type.name : ''}} -
            {{item.device_name ? item.device_name.name : ''}} - {{item.spec ? item.spec.name : ''}}
          </view>
          <view class="sg-content sg-gray-color sg-font-small">
            <view class="sg-margin-tb-sm sg-flex sg-align-center sg-space-between">
              <view>租赁单价：￥{{item.price / 100}}</view>
              <view>租赁计数：{{item.quantity}}</view>
            </view>
            <view class="sg-margin-tb-sm">租赁方式：{{item.rent_type ? item.rent_type.name : ''}}</view>
            <view class="sg-margin-tb-sm">租赁时间：<text
                class="sg-rent-date sg-border">{{item.start_date ? (item.start_date + '至' + item.end_date) : ''}}</text>
            </view>
          </view>
          <view class="sg-footer sg-flex sg-align-center sg-space-between sg-margin-top-sm">
            <view class="sg-font-lg sg-bold">总金额：￥{{item.price * item.quantity / 100}}</view>
            <view class="sg-btn sg-index-bg sg-pad-sm sg-white" hidden="{{!changePrice}}" bindtap="switchShowPrice"
              data-item="{{item}}" data-show="{{true}}">{{role.level==2?'更改单价':'更改计数'}}</view>
          </view>
        </view>
      </block>
    </view>
  </view>
  <view class="sg-submit-box sg-fix-bottom sg-flex sg-align-center sg-center">
    <block wx:if="{{actionType == 'check'}}">
      <view class="sg-action sg-draft sg-pad sg-border-right sg-red-bg" bindtap="check" data-type='reject'>驳回申请</view>
      <view class="sg-action sg-pad sg-index-bg sg-green-bg" bindtap="check" data-type='checked'>通过审核</view>
    </block>
    <block wx:if="{{actionType == 'pass'}}">
      <view class="sg-action sg-draft sg-pad sg-border-right sg-index-bg sg-white sg-block" bindtap="check"
        data-type='pass' style="width: 100%">提交确认</view>
    </block>
    <block wx:if="{{actionType == 're-submit'}}">
      <view class="sg-action sg-draft sg-pad sg-border-right sg-index-bg sg-white sg-block" bindtap="check"
        data-type='re-submit' style="width: 100%">重新提交</view>
    </block>
  </view>
  <van-dialog id="van-dialog" />
  <van-dialog show="{{ showPrice }}" bind:cancel="closeshow" use-slot title="{{role.level==2?'更改单价':'更改计数'}}"
    show-cancel-button bind:confirm="changePrice" z-index="1">
    <view class="sg-box sg-pad">
      <view class="sg-form-item sg-pad-tb sg-top-border">
        <view class="sg-label">{{role.level==2?'租赁单价':'租赁计数'}}</view>
        <input value="{{device_quantity}}" class="sg-input" wx:if="{{role.level!=2}}" bindinput="onChange"
          data-name="device_quantity" placeholder="请输入租赁计数" type="number"></input>
        <input value="{{price}}" class="sg-input" wx:else bindinput="onChange" data-name="price"
          placeholder="请输入租赁单价" type="number"></input>
      </view>
    </view>
  </van-dialog>
</view>