<!--pages/add-inner-device/index.wxml-->
<view class="sg-container">
  <view class="sg-search-box sg-fix-top">
    <view class="sg-search-box sg-flex sg-align-center">
      <van-dropdown-menu active-color="#5992fd">
        <van-dropdown-item value="{{ name }}" options="{{ names }}" bind:change="onChange"/>
      </van-dropdown-menu>
      <van-search value="{{ number }}" placeholder="请输入规格型号模糊查询" class="sg-flex-grow" bind:change="onsearch" data-name="number"
        left-icon="false" bind:search="search" use-right-icon-slot>
        <van-icon name="search" bind:tap="search" class="sg-index-color sg-icon"  slot="right-icon"></van-icon>
      </van-search>
    </view>
  </view>
  <view class="sg-list sg-pad">
    <inner-device-card wx:for="{{list}}" wx:key="index" index="{{index}}" item="{{item}}" showChecked="{{true}}"
      bind:checked="switchSelect"></inner-device-card>
  </view>
  <van-dialog show="{{ showAdded }}" use-slot title="已添加设备" confirm-button-color="#5693FC" show-cancel-button
    bind:confirm="switchShowAdded" z-index="200" data-show="{{false}}" bind:cancel="cancel">
    <view class="sg-added-list">
      <view class="sg-item sg-pad sg-bottom-border sg-flex sg-align-center sg-space-between" wx:for="{{add_devices}}"
        wx:key="index">
        <view class="sg-left">
          <view class="sg-name sg-font-small">{{item.inner_name ? item.inner_name + ' - ' : ''}}{{item.spec_name}}
          </view>
          <view class="sg-dates sg-font-xs sg-gray-color">
            {{item.start_date ? item.start_date + '至' + item.end_date : ''}}</view>
        </view>
        <view class="sg-right sg-white sg-pad-sm"
          style="text-align:center;background-color: #737477;color:#fff;border-radius: 20rpx;font-size:24rpx;width:80rpx"
          bindtap="deleteDevice" data-index="{{index}}">删除</view>
      </view>
    </view>
  </van-dialog>
  <van-calendar show="{{ showDate }}" bind:close="switchShowDate" bind:confirm="confirmDate" data-show="{{false}}"
    type="range" class="sg-calendar" default-date="{{default_dates}}" color="#5992fd" />
  <view class="sg-submit-box sg-fix-bottom sg-flex sg-align-center sg-center">
    <!-- <view class="sg-action sg-pad sg-white-bg" bindtap="switchShowAdded" data-show="{{true}}">已添加({{add_devices.length}})</view> -->
    <!-- <view class="sg-action sg-draft sg-pad sg-border-right sg-green-bg sg-white" bindtap="complete">完成</view> -->
    <view class="sg-action sg-draft sg-pad sg-border-right sg-index-bg sg-white" style="width:100%"
      bindtap="switchShowDate" data-show="{{true}}" data-type='draft'>立即添加</view>
  </view>
</view>