<!--components/dynamicForm/index.wxml-->

  <view class="form-box">
    <block wx:for="{{formData}}" wx:key="id">
      <!-- input输入框 -->
      <view class="form-row ipt-row " wx:if="{{item.type==='input'}}">
        <view class="form-lable {{item.isRequired?'required':'' +''}}">{{item.lable}}</view>
        <view style="width:100%">
          <input wx:if="{{!item.disabled}}" class="field {{item.disabled?'disabled':''}}"
            type="{{inputMap[item.id].original.inputType || 'text'}}" maxlength="{{item.maxLength || -1}}"
            bindinput="onInput" id="{{item.id}}" value="{{item.defaultValue || ''}}"
            disabled="{{item.disabled}}" placeholder="{{inputMap[item.id].placeholder || '请填写内容'}}" />
          <view class="field disabled" wx:else>{{item.defaultValue || ''}}</view>
          <view class="error-info" wx:if="{{inputMap[item.id].error}}">{{inputMap[item.id].error}}</view>
        </view>
      </view>
      <!-- picker选择器 -->
      <view class="form-row flex-start" wx:elif="{{item.type==='picker'}}">
        <view class="form-lable {{item.isRequired?'required':''}}">{{item.lable}}</view>
        <view style="width:100%">
          <view wx:if="{{!item.disabled}}" class="picker-row {{item.disabled?'disabled':''}}">
            <picker class="field" range="{{item.range}}" disabled="{{item.disabled}}" id="{{item.id}}" value="{{pickerMap[item.id].idx}}"
              range-key="name" bindchange="onPickerChange">
              {{pickerMap[item.id].hasChoose?item.range[pickerMap[item.id].idx].name:'请选择'}}
            </picker>
            <van-icon class="row-icon" name="arrow"></van-icon>
          </view>
          <view class="field disabled" wx:else>{{pickerMap[item.id].hasChoose?item.range[pickerMap[item.id].idx].name:''}}</view>
          <view class="error-info" wx:if="{{pickerMap[item.id].error}}">{{pickerMap[item.id].error}}</view>
        </view>
      </view>
      <!-- 日期选择器 -->
      <view class="form-row flex-start " wx:elif="{{item.type==='date'}}">
        <view class="form-lable {{item.isRequired?'required':''}}">{{item.lable}}</view>
        <view style="width:100%">
          <view class="picker-row">
            <view class="field {{item.disabled?'disabled':''}}" bindtap="datePickerShow" data-disabled="{{item.disabled}}" data-id="{{item.id}}">{{dateMap[item.id].hasChoose?(dateMap[item.id].config.endDate?dateMap[item.id].startDate+' ~ ' + dateMap[item.id].endDate: dateMap[item.id].startDate):'请选择'}}</view>
            <time-picker pickerShow="{{dateMap[item.id].show}}" id="{{item.id}}" wx:if="{{!isPickerRender}}" bind:hidePicker="datePickerHide"
              bind:setPickerTime="setPickerTime" config="{{dateMap[item.id].original.config}}"></time-picker>
            <van-icon class="row-icon" name="arrow"></van-icon>
          </view>
          <view class="error-info" wx:if="{{dateMap[item.id].error}}">{{dateMap[item.id].error}}</view>
        </view>
      </view>
      <!-- 文本框 -->
      <view class="textarea-box" wx:elif="{{item.type==='textarea'}}">
        <view class="flex mb-24">
          <view class="area-lable {{item.isRequired?'required':''}}">{{item.lable}}</view>
          <view class="error-info" wx:if="{{inputMap[item.id].error}}">{{inputMap[item.id].error}}</view>
        </view>
        <view class="text-area {{item.disabled?'disabled':''}}">
          <textarea style="width:100%" value="{{item.defaultValue || ''}}" disabled="{{item.disabled}}" placeholder="{{inputMap[item.id].placeholder || '请填写内容'}}"
            id="{{item.id}}" bindinput="onInput" auto-height="{{true}}" maxlength="{{item.maxLength || -1}}" name=""
            cols="30" rows="10"></textarea>
          <view wx:if="{{item.maxLength}}" class="text-num">{{inputMap[item.id].value.length||0}}/{{item.maxLength}}
          </view>
        </view>
      </view>
      <!-- 文件上传 -->
      <view class="img-box" wx:elif="{{item.type==='file'}}">
        <!-- <view class="area-lable mb-24 {{item.isRequired?'required':''}}">{{item.lable}}</view> -->
        <view class="flex mb-24">
          <view class="area-lable {{item.isRequired?'required':''}}">{{item.lable}}</view>
          <view class="error-info" wx:if="{{fileMap[item.id].error}}">{{fileMap[item.id].error}}</view>
        </view>
        <van-uploader file-list="{{ fileMap[item.id].list }}" preview-size="196rpx" max-count="{{fileMap[item.id].original.maxCount || 9}}"
          disabled="{{fileMap[item.id].original.disabled || false}}" accept="{{fileMap[item.id].original.accept || 'image'}}" id="{{item.id}}" multiple image-fit="aspectFill"
          bind:after-read="onFileRead" bind:delete="onFileDelete" />
      </view>
    </block>
  </view>
  <button wx:if="{{showSubmitBtn}}" class='form-btn' bindtap="formSubmit">提交</button>
