<!-- pages/AddTherapeuticRegimen/index.wxml -->
<view class="therapeuticRegimen">
  <view class="improt-file">
    <view wx:if="{{!imageFile}}" class="upload-flow" bind:tap="handleUpload">
      <text class="iconfont icon-xiangji"></text>
      <view>拍照导入</view>
    </view>
    <view wx:else class="report-image" data-mode="imageFile" bind:tap="handleImagePreview">
      <image class="image" src="{{imageFile}}" mode=""></image>
      <view class="delete-btn" catchtap="handleDelete">
        <text class="iconfont icon-x"></text>
      </view>
    </view>
  </view>
  <view class="therapeuticRegimen-item">
    <view class="title">
      <text class="title-text">用药周期</text>
    </view>
    <view>
      <t-row gutter="12">
        <t-col span="12">
          <view class="input-example">
            <t-input placeholder="开始时间" readonly 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="结束时间" readonly 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 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-cell class="info-edit__cell" title="药品名称">
        <t-input bind:change="onInput" data-index="{{index}}" data-mode="name" align="right" borderless placeholder="请输入" slot="note" value="{{item.name}}" />
      </t-cell>
      <!-- <t-cell label="药品名称">
        <t-input bind:change="onInput" data-index="{{index}}" data-mode="name" placeholder="请输入" align="right" value="{{item.name}}" />

      </t-cell> -->
      <t-cell class="info-edit__cell" title="单次用药剂量">
        <t-input bind:change="onInput" data-index="{{index}}" data-mode="dose" align="right" borderless placeholder="请输入" slot="note" value="{{item.dose}}" />
      </t-cell>
      <!-- <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="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>
  <view class="day-time">
    <view class="day-title">
      用药提醒
    </view>
    <t-row gutter="12">
      <t-col span="8">
        <text>早</text>
        <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">
        <text>中</text>
        <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">
        <text>晚</text>
        <view class="day-time-item" bindtap="showPickertime" data-mode="evening">
          {{reminder.evening}}
          <text class="iconfont icon-bianji"></text>
        </view>
      </t-col>
    </t-row>
  </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>
  <t-image-viewer usingCustomNavbar deleteBtn="{{false}}" closeBtn="{{true}}" showIndex="{{false}}" initial-index="{{imageIndex}}" visible="{{imageVisible}}" images="{{imageList}}" bind:change="onChange" bind:delete="onDelete" bind:close="onClose"></t-image-viewer>
</view>