<template>
  <div class="ls-apploval">

    <div class="ls-row">
      <div class="row-header title">
        <span class="icon iconfont icon-shenpi1"></span>
        <span>审批意见</span>
      </div>
    </div>

    <div v-if="processStatus.length"
         class="radio-wrap">
      <van-radio-group v-model="param.result"
                       v-for="(item, index) in processStatus"
                       :key="index">
        <van-radio icon-size="25px"
                   :name="item.vaule">{{ item.key }}</van-radio>
      </van-radio-group>
    </div>

    <div class="turn-user"
         v-if="param.result==='change'">
      <label>转办人</label>
      <aws-org ref="awsOrgRef"
               :init-active-ids="activeTaskIds"
               :init-users-select="usersTaskSelect"
               :only-one="true"
               @orgClose="turnUserInfo"></aws-org>
    </div>

    <div class="text-content">
      <van-field v-model="param.content"
                 rows="5"
                 autosize
                 class="textarea"
                 type="textarea"
                 maxlength="300"
                 placeholder="请输入"
                 show-word-limit />
    </div>

  </div>
</template>

<script>
import { Toast } from 'vant'
export default {
  name: 'ls-apploval',
  mounted () {
    this.$nextTick(() => {

    })
  },
  created () { },
  data () {
    return {
      activeTaskIds: [], // 部门
      usersTaskSelect: [], // 用户
      baseInfo: {},
      detailStatus: {},
      processStatus: [
      ],
      param: {
        dictList: [],
        handle: false,
        buttion: false,
        busId: '',
        moduleId: '',
        busStatus: '',
        content: '',
        createTime: '',
        creater: '',
        result: '',
        reviewerType: '',
        status: 'Y',
        titleInfo: '处理信息',
        taskUserId: '',
        taskUserName: ''
      }
    }
  },
  methods: {
    // 根据业务ID及模块ID获取操作动作及是否显示等信息
    getOperReviewer (value) {
      var that = this
      that.param.busId = value.busId
      that.param.moduleId = value.moduleId
      this.$axios.post({
        domain: 'crmUrl',
        url: 'reviewer.getOperReviewer',
        data: that.param,
        requestType: 'body',
        showLoad: false,
        success: function (res) {

          that.baseInfo = res.data || {}
          if (that.baseInfo.dictList != null) {
            that.param.handle = true
            that.processStatus = that.baseInfo.dictList
          }
          if (value.moduleId != 3104) {
            that.param.handle = res.data.buttion
          }
          that.param.buttion = that.baseInfo.buttion // 要根据这个状态传递到父组件去判断
          that.$emit('send', that.param)
        },
        error: function (res) {
          Toast.fail(res.body.msg || res.msg)
        }
      })
    },
    // 转办人
    turnUserInfo (users) {
      if (users != null && users.length > 0) {
        this.param.taskUserId = users[0].uid
        this.param.taskUserName = users[0].name
      }
    }
  }
}
</script>

<style type="text/css" scoped lang="scss">
.ls-apploval {
  background-color: #fff;
  margin-top: 10px;
  padding-bottom: 20px;

  .radio-wrap {
    display: flex;
    padding: 25px 20px 10px;

    .van-radio-group {
      margin-right: 25px;
    }
    .van-radio {
      overflow: visible;
    }
  }

  .textarea {
    border: none;
  }
  .turn-user {
    display: flex;
    align-items: center;
    padding-left: 20px;
    padding-top: 10px;
  }
}
</style>
