<!-- 前台导入wxmlUtil.wxs -->
<wxs src='/utils/wxmlUtil.wxs' module="wxmlUtil"></wxs>
<loading wx:if="{{loading}}"></loading>

<!-- 数据列表区 -->
<view wx:for="{{tableData}}" wx:for-item="item" wx:for-index="index" data-item="{{item}}" wx:key="index" class="main-class">
  <view class="main-foot-2" style="position: relative;">
    <view class="corner-view" style="padding:20rpx">
      <view style="display: flex;">
        <view class="corner-view-text font" style="width: 70%;">{{item.itemName}}</view>
        <view style="width: 30%;text-align: right;" data-index="{{index}}" data-item="{{item}}" catch:tap="collapseAndExpand">
          {{item.checked?$t["collapse"]:$t["expand"]}}
        </view>
      </view>
    </view>

    <view style="background-color: white;">
      <view wx:for="{{item.children}}" wx:for-item="item_" wx:if="{{item.checked}}" wx:for-index="index_"  wx:key="index_" style="display: flex;padding:10rpx">
        <!--文本框-->
        <van-field wx:if="{{item_.valueKind=='STR'}}" data-findex="{{index}}" data-index="{{index_}}" value="{{ item_.settingValue}}" border="{{ true }}" label-class="label-class" label="{{ item_.itemName}}" autosize readonly="{{!!item_.readonly}}" input-class="dk-cell-value-class" maxlength="{{item_.maxlength?item_.maxlength:50}}" bind:change="changeField">
        </van-field>
        <!--单选下拉-->
        <van-field wx:if="{{item_.valueKind=='S-CHOICE' }}" data-findex="{{index}}" label-class="label-class" data-index="{{index_}}" value="{{ item_.settingValue}}" label="{{item_.itemName}}" is-link catchtap="open" autosize border="{{ true }}" readonly="{{true}}" input-class="dk-cell-value-class">
        </van-field>
        <!--多选下拉-->
        <van-field wx:if="{{item_.valueKind=='M-CHOICE' }}" data-findex="{{index}}" label-class="label-class" data-index="{{index_}}" value="{{ item_.settingValue}}" label="{{item_.itemName}}" is-link catchtap="open" autosize border="{{ false }}" readonly="{{true}}" input-class="dk-cell-value-class" errorMessage="{{item.errMsg}}">
        </van-field>
        <!--switch-->
        <view class="dk-cell-value-class-switch" wx:if="{{item_.valueKind=='BOOL' }}">
          <view style="width: 80%;text-align: left;">{{ item_.itemName }}</view>
          <view style="width: 20%;text-align: right;">
            <van-switch bind:change="onChangeSwitch" data-findex="{{index}}" data-index="{{index_}}" active-color="#00A7B5" checked="{{ item_.settingValue == 'true' || item_.settingValue == true}}" size="18px"></van-switch>
          </view>

        </view>
        <!--数字类-->
        <van-field wx:if="{{item_.valueKind=='INT'|| item_.valueKind=='NUM'}}" type="{{item_.valueKind=='INT'?'number':'digit'}}" data-findex="{{index}}" data-index="{{index_}}" value="{{ item_.settingValue}}" border="{{ true }}" label-class="label-class" label="{{ item_.itemName}}" autosize input-class="dk-cell-value-class" maxlength="{{item_.maxlength?item_.maxlength:50}}" bind:change="changeField">
        </van-field>
      </view>
    </view>
  </view>
</view>

<!--  保存 -->
<view class="bottom-class">
  <van-button custom-class="save-button-class" disabled="{{loading}}" loading="{{loading}}" bind:click="save" type="default">保存
  </van-button>
</view>