<template>
  <view>
    <uni-nav-bar
      fixed="true"
      statusBar="true"
      left-icon="back"
      title="转派"
      @clickLeft="back"
    >
      <template slot="right">
        <text class="btn-right" @click="submitReassign">确定</text>
      </template>
    </uni-nav-bar>
    <view class="cell-list">
      <radio-group @change="radioChange">
        <template v-for="(item, index) in employeeList">
          <label class="category_list">
            <view class="category_title">
              <view>
                <radio
                  :value="index + ''"
                  color="#157a2c"
                  :checked="index == current"
                />
              </view>
              <view class="lable-title">
                <label>{{ item.trueName }}</label>
              </view>
            </view>
          </label>
        </template>
      </radio-group>
    </view>
  </view>
</template>
<script>
let pageId = ''
export default {
  data () {
    return {
      employeeList: [
        {
          trueName: '张三',
          deptName: '设计部'
        },
        {
          trueName: '李四',
          deptName: '设计部'
        }
      ],
      current: -1,
      executorId: '',
      executorName: ''
    }
  },
  onLoad (option) {
    console.log(option)
    pageId = option.id
    //this.getList();
  },
  methods: {
    submitReassign () {
      if (!this.executorId) {
        uni.showToast({
          title: '请选择转派人员',
          icon: 'none'
        })
        return
      }
      let data = {
        executorId: this.executorId,
        executorName: this.executorName,
        id: pageId
      }
      //let data = "?id=" +pageId +"&executorName=" + this.executorName +"&executorId=" + this.executorId;

      this.back()
    },

    getList () {
      let data = {
        page: 1,
        size: 100
      }
      // post(this.apiUrl + "/main/user/list" ,data).then(res => {
      // 	console.log(res)
      // 	if (res.success) {
      // 		this.employeeList = res.data.items;
      // 	}
      // })
    },

    radioChange: function (e) {
      console.log(e)
      let value = Number(e.detail.value)
      console.log(value)
      let employeeList = this.employeeList
      this.executorId = employeeList[value].trueName
      this.executorName = employeeList[value].trueName
      // let index = parseInt(evt.detail.value)
      // this.bindTada = this.rkList[index]
    }
  }
}
</script>

<style scoped lang="scss">
.btn-right {
  position: absolute;
  right: 20rpx;
  height: 70rpx;
  line-height: 70rpx;
  border-radius: 10rpx;
  padding: 0 27rpx;
  font-size: 30rpx;
  color: $uni-color-success;
  background-color: $uni-color-success-opacity;
}

.category_list {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20rpx;
  border-bottom: 1rpx solid #eeecec;
  .category_title {
    width: 100%;
    height: 90rpx;
    line-height: 90rpx;
    display: flex;
    align-items: flex-start;
    .lable-title {
      margin-left: 10rpx;
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-right: 20rpx;
      font-size: 32rpx;
      color: $uni-text-color;
    }
  }
}
</style>
