<view>
  <view class="{{popupCx}}">
    <view class="flex-box flex-v-ce form-top" catchTap="openSelect" data-num="3">
      <view class="label isBt">奖扣对象</view>
      <view class="flex-1 font-flex-word userList">
        <block a:for="{{users}}">
          <text style="font-size:32rpx">{{item.name}},</text>
        </block>
      </view>
      <image mode="scaleToFill" src="../../../image/right.png" class="rightImg" />
    </view>
    <view a:for="{{items}}" a:for-index="index" key="{{index}}">
      <view class="flex-box flex-v-ce" style="padding-right:28rpx;">
        <view class="title flex-1">第({{index+1}})条</view>
        <view style="font-size:24rpx" data-index="{{index}}" class="blue" a:if="{{items.length>1}}" catchTap="deleteArr">删除</view>
      </view>
      <view class="inputs">
        <view class="flex-box flex-v-ce li border-bottom" style="padding:26rpx 28rpx;" data-index="{{index}}">
          <view class="label">指定规则</view>
          <view class="flex-1"></view>
          <switch onChange="switchChange" disabled="{{ruleOnoff}}" checked="{{item.checked}}" data-index="{{index}}" color="#26A2FF"></switch>
        </view>
        
        <view class="flex-box flex-v-ce li" a:if="{{item.checked}}" data-ruleId="{{item.item_id}}" data-index="{{index}}" 
          data-num="1" catchTap="openSelect">
          <view class="label isBt">选择规则</view>
          <view class="flex-1" a:if="{{item.selectRule}}">已选择1条</view>
          <view class="flex-1" a:else></view>
          <image mode="scaleToFill" src="../../../image/right.png" class="rightImg" />
        </view>
        <view class="flex-box flex-v-ce li" a:else data-ruleId="{{item.rule_id2}}" data-index="{{index}}" data-num="2" catchTap="openSelect">
          <view class="label isBt">选择分类</view>
          <view class="flex-1">{{item.rule_name}}</view>
          <image mode="scaleToFill" src="../../../image/right.png" class="rightImg" />
        </view>
        
        <view class="flex-box li" style="padding:15rpx 28rpx;" a:if="{{item.checked}}">
          <view class="label isBt" style="position: relative;top:8rpx;">积分</view>
          <text class="red" style="position: relative;top:8rpx;" a:if="{{item.isArrindex==true}}">+</text>
          <text class="green" a:else style="position: relative;top:8rpx;">-</text>
          <view class="flex-1">
            <view class="flex-box flex-v-ce">
              <view a:if="{{item.selectRule.range_type==1&&item.selectRule.min_point==item.selectRule.max_point}}" style="padding-left:10rpx; height:60rpx;line-height:60rpx;" 
                class="flex-1">{{item.point}}</view>
              <input a:else value="{{item.point}}" name="{{index}}" placeholder="0" type="number" onInput="bindKeyInput" 
                data-index="{{index}}" class="flex-1" />
              <view class="picker-box" data-index="{{index}}" catchTap="bindPickerChange" a:if="{{item.selectRule.range_type!=1}}">
                <view class="{{item.isArrindex==true? 'picker-right':'picker-left'}} yuan"></view>
                <view class="flex-box flex-v-ce">
                  <text class="red flex-1">奖</text>
                  <text class="green flex-1">扣</text>
                </view>
              </view>
            </view>
            <block a:if="{{item.selectRule}}">
              <view class="fontColorT input_text" a:if="{{item.selectRule.range_type==1&&item.selectRule.min_point==item.selectRule.max_point}}">固定：{{item.selectRule.min_point}} {{item.selectRule.pt_Obj[0].name}}</view>
              <view class="fontColorT input_text" a:else> 范围(可修改)：{{item.selectRule.min_point}}至{{item.selectRule.max_point}}
                <text>{{item.selectRule.pt_Obj[0].name}}</text></view>
            </block>
          </view>
        </view>
        
        <view class="flex-box li" style="padding:15rpx 28rpx;" a:else>
          <view class="label isBt" style="position: relative;top:8rpx;">积分</view>
          <text class="red" style="position: relative;top:8rpx;" a:if="{{item.isArrindex2==true}}">+</text>
          <text class="green" a:else style="position: relative;top:8rpx;">-</text>
          <view class="flex-1">
            <view class="flex-box flex-v-ce">
              <input value="{{item.point2}}" name="{{index}}" placeholder="0" type="number" onInput="bindKeyInput2" data-index="{{index}}" 
                class="flex-1" />
              <view class="picker-box" data-index="{{index}}" catchTap="bindPickerChange2">
                <view class="{{item.isArrindex2==true? 'picker-right':'picker-left'}} yuan"></view>
                <view class="flex-box flex-v-ce">
                  <text class="red flex-1">奖</text>
                  <text class="green flex-1">扣</text>
                </view>
              </view>
            </view>
          </view>
        </view>
        
        <view class="flex-box flex-v-ce li" catchTap="openDate" data-index="{{index}}">
          <view class="label isBt">发生时间</view>
          <view class="flex-1">{{item.event_time}}</view>
          <image mode="scaleToFill" src="../../../image/right.png" class="rightImg" />
        </view>
        <view class="flex-box flex-v-ce li" data-index="{{index}}" data-num="4" a:if="{{!isCreator}}" data-item="{{{id:item.reviewer_id,name:item.revieweName}}}" 
          catchTap="openSelect">
          <view class="label">递交审批</view>
          <view class="flex-1">{{item.revieweName}}</view>
          <image mode="scaleToFill" src="../../../image/right.png" class="rightImg" />
        </view>
        <view class="li">
          <textarea maxlength="100" value="{{item.remark}}" onInput="bindTextAreaBlur" placeholder="请输入事件内容" data-index="{{index}}"></textarea>
          <image mode="scaleToFill" src="../../../image/addImg.png" data-index="{{index}}" class="addImg" catchTap="openImg" />
        </view>
        <view style="background:#fff;padding:0 28rpx;" a:if="{{item.files[0]}}" class="flex-box flex-v-ce">
          <view a:for="{{item.files}}" key="index" a:for-item="imgs" a:for-index="imgIndex" style="position:relative">
            <text class="detele" data-itemIndx="{{index}}" data-index="{{imgIndex}}" catchTap="deteleImg">×</text>
            <image mode="scaleToFill" class="showImg" src="{{imgs}}" data-index="{{imgIndex}}" data-item="{{item.files}}" 
              catchTap="showImg" />
          </view>
        </view>
      </view>
    </view>
    <view class="add" catchTap="addArr">+  再加一条</view>
    <view class="btn-area" style="margin-top:28rpx;">
      <button type="default" loading="{{disabled}}" class="defBtn" disabled="{{disabled}}" catchTap="formSubmit">提交</button>
    </view>
  </view>
  <view class="box" animation="{{animationInfo}}">
    <select-rule defaultId="{{defaultRuleId}}" isGzType="{{isGzType}}" onConfirm="onSelectItem" onClose="onClose" a:if="{{isShowType=='1'}}" />
    <select-type defaultId="{{defaultRuleId}}" isGzType="{{isGzType}}" onConfirm="onSelectType" onClose="onClose" a:if="{{isShowType=='2'}}" />
    <select-section-staff isLeadership="{{true}}" isBoss="{{true}}" selectUser="{{users}}" onClose="onClose" onConfirm="onSelectUser" 
      a:if="{{isShowType=='3'}}" />
    <select-section-staff-two superior_list="{{superior_list}}" isLeadership="{{false}}" selectUser="{{reviewerObj}}" onClose="onClose" 
      onConfirm="onSelectUser2" a:if="{{isShowType=='4'}}" />
  </view>
  
  <!-- 结果弹窗 -->
  <view class="windows" a:if="{{isResult}}">
    <view class="windows-box" style="margin-top:15%">
      <view class="windows-title">处理结果</view>
      <block a:if="{{!isShowError}}">
        <view class="windows-content" style="padding:20rpx;">
          <progress percent="{{percentage}}" show-info stroke-width="10" />
          <view class="resultsBox">
            <view class="flex-box-ce results">
              <view style="width:60rpx;padding:0;text-align:center"></view>
              <view class="flex-1">奖扣对象</view>
              <view class="flex-2">事件内容</view>
              <view class="flex-1">积分</view>
              <view class="flex-2">处理结果</view>
            </view>
            <view a:for="{{results}}" class="flex-box-ce results">
              <view style="width:60rpx;padding:0;text-align:center">{{results.length-index}}</view>
              <view class="flex-1">{{item.target}}</view>
              <view class="flex-2" style="padding: 0.1rem 0.1rem;">{{item.task.msg.remark}}</view>
              <view class="flex-1">
                {{ item.point>0? '+'+item.point:item.point }}
                <text>{{ item.task.msg.pt_id==3? 'B分':'A分' }}</text>
              </view>
              <view class="green flex-2" a:if="{{item.status==1}}">
                <text a:if="{{item.msg=='奖扣成功'}}" class="green">{{ item.msg }}</text>
                <text a:else class="blue">{{ item.msg }}</text>
              </view>
              <view class="red flex-2" a:else>{{item.msg}}</view>
            </view>
          </view>
        </view>
        <view class="windows-btn flex-box flex-v-ce" a:if="{{results.length==resultList.length}}">
          <button type="default" class="flex-1" catchTap="closeTc">确定</button>
        </view>
      </block>
      <view a:else class="windows-content" style="padding:20rpx;">
        <view style="text-align: center;margin-bottom:20rpx" class="red">服务器繁忙，请稍后再试</view>
        <view class="windows-btn flex-box flex-v-ce">
          <button type="default" class="flex-1" catchTap="closeTc">确定</button>
        </view>
      </view>
    </view>
  </view>
  <!-- 错误弹窗 -->
  <view class="windows" a:if="{{isErrorShow}}">
    <view class="windows-box" style="margin-top:15%">
      <view class="windows-title red">网络连接中断,请检查网络再次提交</view>
      <view class="windows-content" style="padding:20rpx;">
        <view class="resultsBox">
          <view class="flex-box-ce results">
            <view style="width:60rpx;padding:0;text-align:center"></view>
            <view class="flex-1">奖扣对象</view>
            <view class="flex-1">分类</view>
            <view class="flex-1">规则</view>
            <view class="flex-2">事件内容</view>
            <view class="flex-1">积分</view>
          </view>
          <view a:for="{{errorList}}" class="flex-box-ce results">
            <view style="width:60rpx;padding:0;text-align:center">{{index+1}}</view>
            <view class="flex-1">{{item.name}}</view>
            <view class="flex-1">{{ item.rule_name||'--' }}</view>
            <view class="flex-1">{{ item.item_name||'--' }}</view>
            <view class="flex-2">{{item.remark}}</view>
            <view class="flex-1">
              {{ item.point>0? '+'+item.point:item.point }}
              <text>{{ item.task.msg.pt_id==3? 'B分':'A分' }}</text>
            </view>
          </view>
        </view>
      </view>
      <view class="windows-btn flex-box flex-v-ce">
        <button type="default" class="flex-1" catchTap="closeTc">取消</button>
        <button type="default" class="flex-1" catchTap="resubmit">再次提交</button>
      </view>
    </view>
  </view>
  
</view>