<template>
  <!-- 审核意见 -->
  <ul class="form-group">
    <!-- 标题 -->
    <dividerTitle :title="$t('approval.opinions')"></dividerTitle>
    <li>
      <el-row>
        <div>
          <el-form :size="'small'" style="padding-top: 10px;" ref="form" label-width="100px" :model="datas">
            <template>
              <el-row>
                <!-- 审核状态 -->
                <el-col :span="8">
                  <el-form-item :label="$t('approval.status')" prop="reviewStatus">
                    <el-input :disabled="readonly" v-model="datas.operateTypeName" :placeholder="$t('common.noForm')"></el-input>
                  </el-form-item>
                </el-col>
                <!-- 转派人 -->
                <el-col v-if="datas.reviewStatus == '4'" :span="8" gutter="2">
                  <el-form-item :label="$t('approval.transferrer')" prop="transferTargetId">
                    <el-input :disabled="readonly" v-model="datas.transferTargetName" :placeholder="$t('common.noForm')"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <!-- 审核意见 -->
                <el-col :span="8">
                  <el-form-item :label="$t('approval.opinions')" prop="reviewOpinion">
                    <el-input :disabled="readonly" v-model="datas.auditOpinionName" :placeholder="$t('common.noForm')"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <!-- 审核意见描述 -->
                <el-col>
                  <el-form-item :label="$t('approval.opinionsMemo')" prop="reviewOpinionMemo">
                    <el-input :disabled="readonly" v-model="datas.reviewOpinionMemo" :placeholder="$t('common.noForm')" type="textarea"
                              rows="3"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </template>
          </el-form>
        </div>
      </el-row>
    </li>
  </ul>
</template>
<script>
import * as format from '@/filters/index'
import dividerTitle from '@/components/element/assetpkgmgr/dividerTitle'

export default {
  components: {
    dividerTitle
  },
  props: {
    // 表单
    form: {
      type: Object
    },
    // 只读状态
    readonly: {
      type: Boolean
    }
  },
  data: function () {
    return {
      datas: {},
      // 审核状态字典
      operateTypeList: {
        '1': this.$t('approval.checking'),
        '2': this.$t('approval.adopt'),
        '3': this.$t('approval.reject'),
        '4': this.$t('approval.transfer')
      }
    }
  },
  methods: {
    getApprovalData: function () {
      let datas = this.form
      if (datas.taskStatus === '1') {
        this.$set(this.datas, 'operateTypeName', datas.taskName + '-' + this.$t('approval.draw'))
      } else {
        // 转义审核意见类型
        this.datas = this.UtilJs.cloneDeep(datas)
        this.datas.auditOpinionName = format.formatDict(datas.reviewOpinion, 'audit_opinion')
        // 转义审核状态类型
        this.datas.operateTypeName = datas.taskName + '-' + this.operateTypeList[datas.reviewStatus]
      }
      // console.log(this.datas)
    }
  },
  mounted () {
    this.getApprovalData()
  }
}
</script>
