<template>
  <app-sign
    @sign-success="signSuccess"
    :selectdata = "selectdata"
    :file-path="filePath"
    :blobid="selectdata.f_process_id"
    :defname="selectdata.defname"
    :type="title"
    @sign-clean="signClean"
    :isclean="mark === 0 ? true : false"
    :issign="mark === 0 ? true : false"
  ></app-sign>
</template>
<script>
import {HttpResetClass} from 'vue-client'
import Vue from "vue";

export default {
  title: '签字流程签字通用组件',
  props: {
    selectdata: {
      type: Object
    },
    mark: {
      type: Number,
      default: 0
    },
    title: {
      type: String
    }
  },
  data () {
    return {
    }
  },
  ready () {
  },
  methods: {
    signClean () {
      if (this.title === '检测单位签字') {
        this.selectdata.f_check_sign = null
      }
      if (this.title === '安装单位签字') {
        this.selectdata.f_build_sign = null
      }
      if (this.title === '土建单位签字') {
        this.selectdata.f_engineering_sign = null
      }
      if (this.title === '监理单位签字') {
        this.selectdata.f_supervisor_sign = null
      }
      if (this.title === '建设单位签字') {
        this.selectdata.f_construct_sign = null
      }
    },
    signSuccess (fileUrl) {
      console.log('==============签字回调==================')
      console.log(fileUrl)
      if (this.title === '检测单位签字') {
        this.selectdata.f_check_sign = fileUrl
      }
      if (this.title === '安装单位签字') {
        this.selectdata.f_build_sign = fileUrl
      }
      if (this.title === '土建单位签字') {
        this.selectdata.f_engineering_sign = fileUrl
      }
      if (this.title === '监理单位签字') {
        this.selectdata.f_supervisor_sign = fileUrl
      }
      if (this.title === '建设单位签字') {
        this.selectdata.f_construct_sign = fileUrl
      }
    }
  },
  events: {
  },
  computed: {
    filePath () {
      if (this.title === '检测单位签字') {
        return this.selectdata.f_check_sign
      }
      if (this.title === '安装单位签字') {
        return this.selectdata.f_build_sign
      }
      if (this.title === '土建单位签字') {
        return this.selectdata.f_engineering_sign
      }
      if (this.title === '监理单位签字') {
        return this.selectdata.f_supervisor_sign
      }
      if (this.title === '建设单位签字') {
        return this.selectdata.f_construct_sign
      }
      return ''
    }
  },
  watch: {
  }
}
</script>
<style scoped lang="less">
</style>
