<!--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.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}}" class="sg-input" bindinput="onChange" data-name="remark" placeholder="订单备注填写"></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-list sg-pad">
          <view class="sg-item sg-white-bg sg-pad sg-margin-bottom" wx:for="{{devices}}" wx:key="index"
            bindtap="switchSelect" data-index="{{index}}" data-can="{{item.status && item.status.key == 'free'}}">
            <view class="sg-top sg-flex sg-bottom-border sg-pad-bottom-sm sg-font-small sg-bold sg-space-between">
              <view class="sg-name sg-margin-right">设备名称：{{item.name}}</view>
              <view class="sg-status sg-flex sg-align-center">
                <view class="sg-dot" style="background: {{item.status ? item.status.color : ''}}"></view>
                <view class="sg-status-name">{{item.status ? item.status.name : ''}}</view>
              </view>
            </view>
            <view class="sg-body sg-font-xs sg-bottom-border sg-pad-bottom-sm">
              <view class="sg-item sg-margin-tb-sm sg-flex">
                <view class="sg-left-item">固定资产编号：{{item.number}}</view>
                <view class="sg-right-item">出厂日期：{{item.produce_date}}</view>
              </view>
              <view class="sg-item sg-margin-tb-sm sg-flex">
                <view class="sg-left-item">外形尺寸：{{item.shape}}</view>
                <view class="sg-right-item">采购原值：{{item.buy_origin}}</view>
              </view>
              <view class="sg-item sg-margin-tb-sm sg-flex">
                <view class="sg-left-item">规格型号：{{item.spec ? item.spec.name : ''}}</view>
                <view class="sg-right-item">生产厂家：{{item.manufacturer}}</view>
              </view>
            </view>
            <view class="sg-bottom sg-font-xs">
              <view class="sg-item sg-margin-tb-sm">目前在用工点：{{item.work_point ? item.work_point.name : '无'}}</view>
              <view class="sg-item sg-margin-tb-sm">
                借用时间：{{item.start_date ? item.start_date + '至' + item.end_date : '无'}}
              </view>
            </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='confirm' 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>
    <block wx:if="{{actionType == 'back'}}">
      <view class="sg-action sg-draft sg-pad sg-border-right sg-red-bg" bindtap="check" data-type='back'>归还</view>
      <view class="sg-action sg-pad sg-index-bg sg-green-bg" bindtap="check" data-type='checked'>续租</view>
    </block>
  </view>
  <van-dialog id="van-dialog" />
  <van-dialog show="{{ showPrice }}" use-slot title="修改价格" 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">设备单价</view>
        <input value="{{device_price}}" class="sg-input" bindinput="onChange" data-name="device_price"
          placeholder="请输入设备单价" type="number"></input>
      </view>
    </view>
  </van-dialog>
</view>