<template>
  <div>
    <Title title="企业资质" />
    <Preview :dataList="enterpriseQualification" />
    <Title title="审批意见" />
    <u--textarea
      v-model="textareaValue"
      placeholder="请输入内容"
      count
      height="105"
      @blur="handleBlur"
      :disabled="isDetail"
    />
    <Title title="审批记录" />
    <Steps :data="approvalRecordList" />
  </div>
</template>

<script>
import Steps from 'pages/component/Steps'
import { selectFile } from '@/api/project'
import { filterInput } from '@/utils/regular'

export default {
  props: {
    isDetail: {
      type: Boolean,
      default: false
    },
    isLeave: {
      type: Boolean,
      default: false
    },
    isSubcontractor: {
      type: Boolean,
      default: false
    },
    params: {
      type: Object,
      default: () => {}
    },
    approvalRecordList: {
      type: Array,
      default: () => []
    }
  },
  components: { Steps },
  data() {
    return {
      // 企业资质
      enterpriseQualification: [],
      // 其他材料
      otherMaterials: [],
      // 离场原因
      leaveValue: '',
      // 审批意见
      textareaValue: ''
    }
  },
  mounted() {
    console.log('🚀 ~ mounted ~ this.classification:', this.classification)
    console.log('isSubcontractor', this.approvalRecordList)
    console.log('企业资质->> props', this.params)
    if (this.isSubcontractor) {
    }
    this.getUnitQualification()
  },
  methods: {
    handleBlur() {
      console.log('审批意见', this.textareaValue)
      this.textareaValue = filterInput(this.textareaValue)
      this.$emit('handleOpinion', { enterpriseQualification: this.textareaValue })
    },
    // 获取单位资质
    getUnitQualification() {
      const params = {
        proId: this.params.proId,
        uuid: this.params.uuid,
        subUuid: this.params.subUuid,
        supUuid: this.params.supUuid,
        taskId: this.params.taskId,
        consUuid: this.params.consUuid,
        classification: this.isSubcontractor ? '3' : '2',
        fromType: '1',
        informationType: '1'
      }
      console.log('🚀 ~ getEnterpriseQualification ~ params:', params)
      selectFile(params).then(res => {
        console.log('单位资质', res)
        if (res.data && res.data.length > 0) {
          this.enterpriseQualification = res.data
        } else {
          this.enterpriseQualification = []
        }
        console.log('🚀 ~ selectFile ~ this.enterpriseQualification:', this.enterpriseQualification)
      })
    }
  }
}
</script>

<style lang="scss" scoped></style>
