<!--pages/create-project-role/index.wxml-->
<view class="sg-container">
  <view class="sg-search-box sg-shadow" wx:if="{{type == 'create'}}">
    <van-icon name="search" class="sg-index-color sg-search-icon" />
    <input class="sg-search-input" placeholder="搜索成员的姓名或绑定手机号" bindblur="blur" bindinput="updateInput"
      data-name="keyword" value="{{keyword}}"></input>
    <van-icon name="close" class="sg-search-icon" bind:click="clear" />
  </view>
  <view class="sg-user-box">
    <view class="sg-user-list sg-margin-tb">
      <view class=" sg-pad sg-margin-top-sm" style="background: white;" wx:for="{{users}}" wx:key="index">
        <view class="sg-flex sg-align-center" style="flex-direction: column;padding-bottom:25rpx;border-bottom:1rpx solid #000">
          <image class="sg-big-avatar" style="margin:0" src="{{item.avatar}}"></image>
          <view class="sg-name" style="margin-top:15rpx">{{item.name}}</view>
          <view class="sg-phone sg-gray-color sg-font-small" style="margin-top:15rpx">{{ item.phone }}</view>
        </view>
        <view class="sg-right sg-flex-grow">
          <view class="sg-project-role sg-gray-color sg-font-small sg-flex sg-align-center sg-space-between sg-margin-tb-sm">
            <view class="sg-project" style="color:blue">所属项目</view>
            <view class="sg-role" style="color:blue">项目角色</view>
          </view>
          <view
            class="sg-project-role sg-gray-color sg-font-small sg-flex sg-align-center sg-space-between sg-margin-tb-sm"
            wx:for="{{item.project_users}}" wx:for-item="i_item" wx:for-key="i_index" wx:key="i_index">
            <view class="sg-project">{{ i_item.project_name }}</view>
            <view class="sg-role">{{ i_item.role_name }}</view>
          </view>
        </view>
      </view>
    </view>
  </view>
  <view class="sg-pick-box">
    <view class="sg-pick-item sg-pad">
      <view class="sg-pick-name">{{type!='edit'?'将他添加到：':'当前所属项目：'}}</view>
      <picker bindchange="bindPickerChange" disabled="{{type=='edit'}}" value="{{projectIndex}}" range="{{projects}}" range-key="name"
        data-name="projectIndex">
        <view class="picker sg-gray-color">
          {{projectIndex >= 0 ? projects[projectIndex].name : '请选择添加项目'}}
        </view>
      </picker>
    </view>
    <view class="sg-pick-item sg-pad sg-margin-top-sm">
      <view class="sg-pick-name">他的角色：</view>
      <picker bindchange="bindPickerChange" value="{{roleIndex}}" range="{{roles}}" range-key="name"
        data-name="roleIndex">
        <view class="picker sg-gray-color">
          {{roleIndex >= 0 ? roles[roleIndex].name : '请选择角色'}}
        </view>
      </picker>
    </view>
  </view>
  <view class="sg-bottom-submit-box sg-pad sg-center" bindtap="submit">{{ type == 'create' ? '立即添加' : '保存修改' }}</view>
</view>