<!--pages/AddTherapeuticRegimen/index.wxml-->
<view class="therapeuticRegimen">
  <view class="improt-file">
    <view class="upload-flow">
      <text class="iconfont icon-xiangji"></text>
      <view>拍照导入</view>
    </view>
  </view>
  <view class="therapeuticRegimen-item">
    <view class="title">用药周期</view>
    <view>
      <t-row gutter="12">
        <t-col span="12">
          <view class="input-example">
            <t-input placeholder="开始时间" bindtap="showPicker" value="{{start_date}}" data-mode="start_date" borderless="{{true}}" />
            <text class="tip">—</text>
          </view>

        </t-col>

        <t-col span="12">
          <view class="input-example">
            <t-input placeholder="结束时间" bindtap="showPicker" value="{{end_date}}" data-mode="end_date" borderless="{{true}}" />
          </view>
        </t-col>
      </t-row>
    </view>
  </view>
  <view class="yp-info" wx:for="{{detail}}" wx:key="index">
    <view class="title">
      <text>药品信息</text>
      <text class="iconfont icon-shanchu1" wx:if="{{detail.length > 1}}" data-index="{{index}}" bindtap="deleteItem"></text>
    </view>

    <view class="yp-item">
      <t-input bind:change="onInput" data-index="{{index}}" data-mode="name" label="药品名称" placeholder="请输入" align="right" value="{{item.name}}" />
      <t-input bind:change="onInput" data-index="{{index}}" data-mode="dose" label="单次用药剂量" placeholder="请输入" align="right" value="{{item.dose}}" />
      <!-- <t-input bind:change="onInput" data-index="{{index}}" data-mode="frequency" label="单次频次（每日次数）" placeholder="请输入" align="right" value="{{item.frequency}}" /> -->
      <t-cell class="{{item.frequency ? 'active':''}}" title="单次频次（每日次数）" arrow bind:click="showSelect" data-index="{{index}}" data-mode="frequency" data-list="{{frequencyList}}" note="{{item.frequency ? (frequencyList[item.frequency - 1].label) : '请选择'}}">
      </t-cell>

      <view class="day-time" wx:if="{{item.frequency}}">
        <t-row gutter="12">
          <t-col span="8">
            <view class="day-time-item" bindtap="showPickertime" data-mode="morning" >
           {{reminder.morning}}
            <text class="iconfont icon-bianji"></text>
          </view>
          </t-col>
          <t-col span="8" wx:if="{{item.frequency >= 2}}">
            <view class="day-time-item" bindtap="showPickertime" data-mode="noon">
            {{reminder.noon}}
              <text class="iconfont icon-bianji"></text>
            </view>
          
          </t-col>
          <t-col span="8" wx:if="{{item.frequency == 3}}">
            <view class="day-time-item" bindtap="showPickertime" data-mode="evening">
            {{reminder.evening}}
              <text class="iconfont icon-bianji"></text>
            </view>
            
          </t-col>
        </t-row>
      </view>

      <view class="administration-time">
        <view>饭前/饭后</view>
        <view class="radio-group">
          <t-radio-group bindchange="onRadioChange" data-index="{{index}}" default-value="饭后" borderless t-class="box" value="{{item.time}}">
            <t-radio block="{{false}}" label="饭前" value="饭前" />
            <t-radio block="{{false}}" label="饭后" value="饭后" />
          </t-radio-group>
        </view>
      </view>
    </view>
    <view class="add-btn-yp" wx:if="{{index == detail.length - 1}}" bindtap="addItem"><text class="iconfont icon-jiahao"></text>添加用药</view>
    <!-- <t-button class="add-btn" theme="primary" content="" block bindtap="addItem">+添加用药</t-button> -->
  </view>
  
  <t-button class="add-btn" theme="primary" content="" block bind:tap="saveData">保存</t-button>
  <t-date-time-picker 
  auto-close 
  bind:cancel="hidePicker" 
  bind:change="onPickerChange" 
  cancelBtn="取消" 
  confirmBtn="确认" 
  data-mode="birth" 
  defaultValue="{{timeData}}" 
  end="{{birthEnd}}" 
  filter="{{birthFilter}}" 
  format="YYYY-MM-DD" 
  mode="date" 
  popup-props="{{ { usingCustomNavbar: true } }}" 
  start="{{birthStart}}" 
  title="选择日期" value="{{timeData}}" visible="{{birthVisible}}" />

  <!-- 时分 -->
  <t-date-time-picker 
  title="选择时间" 
  visible="{{minuteVisible}}" 
  mode="{{['null', 'minute']}}" 
  start="{{startMinute}}" 
  value="{{minute}}" 
  defaultValue="{{timeData2}}" 
  format="HH:mm" 
  bindchange="onConfirm" 
  bindpick="onColumnChange" 
  bindcancel="hidePickerMinute" />

  <!-- 下拉选择 -->
<t-picker
  visible="{{selectVisible}}"
  value="{{selectValue}}"
  default-value="{{selectValue}}"
  cancelBtn="取消"
  confirmBtn="确认"
  bindchange="onSelectChange"
  bindcancel="onPickerCancel"
>
  <t-picker-item options="{{frequencyList}}"></t-picker-item>
</t-picker>
</view>