<template>
  <div>
    <Title title="安全协议书" />
    <Preview :dataList="securityAgreement" />
    <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 {
      // 安全协议书
      securityAgreement: [],
      // 离场原因
      leaveValue: '',
      // 审批意见
      textareaValue: ''
    }
  },
  mounted() {
    if (this.isSubcontractor) {
    } else {
    }
    this.getSecurityAgreement()
  },
  methods: {
    handleBlur() {
      console.log('审批意见', this.textareaValue)
      this.textareaValue = filterInput(this.textareaValue)
      this.$emit('handleOpinion', { SecurityAgreement: this.textareaValue })
    },
    // 获取安全协议书
    async getSecurityAgreement() {
      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: '2'
      }
      // console.log('🚀 ~ getSecurityAgreement ~ params:', params)
      const res = await selectFile(params)
      console.log('安全协议书', res)
      if (res.data && res.data.length > 0) {
        this.securityAgreement = res.data
      }
    }
  }
}
</script>

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