<!--
    上传文件的弹窗
-->

<template>
  <el-dialog
    title="上传文件"
    :visible.sync="dialog.uploadFiles"
    width="500px">
    <div class='max-height: 500px; overflow-y: auto;'>
      <upload-files
        :readOnly="read"
        :keysArr="keysArr"
        :firmDataType="firmDataType"
        @change="changeItem"
        max="2"
      />
    </div>
  </el-dialog>
</template>
<script>
import uploadFiles from "@/components/old-adm/ledger/components/lib/uploadFiles";

export default {
  components: {
    uploadFiles
  },
  props: {
    dialog: {
      type: Object,
      default: function () {
        return {
          uploadFiles: false
        };
      }
    },
    keysArr: {
      type: Array,
      default: function () {
        return []
      }
    },
    read: {
      type: Boolean,
      default: false
    },
    firmDataType: {
      type: String
    },
    infoType: {
      type: String
    },
    information: {
      type: Object
    }
  },
  data() {
    return {};
  },
  created() {
  },
  computed: {},
  mounted() {
  },
  methods: {
    changeItem(file) {
      if (this.firmDataType === 'dialog') {
        let info = this.infoType;
        switch (info) {
          case 'archive':
            this.information.archive.Archive = file
            this.$emit("changeFile", this.information, this.firmDataType)
            break
          case 'checkReport':
            this.information.checkReport.CheckReport = file
            this.$emit("changeFile", this.information, this.firmDataType)
            break
          case 'insuranceFile':
            this.information.insuranceFile.InsuranceFile = file
            this.$emit("changeFile", this.information, this.firmDataType)
            break;
          case 'infos.insuranceFile': //保险文件
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.archive': //设备文档
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.checkReport': //安装质检报告
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.maintainManual': //维修保养手册
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.approachingAcceptance': //进场验收单
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.acceptanceReport': //验收报告
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.operationManual': //操作说明书
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.originalCertificate': //原厂证明
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.testReport': //检测报告
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.productCertification': //产品合格证
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.installInstruction': //安装说明书
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.drawing': //设备图纸
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.installDrawing': //安装图纸
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.supplierContract': //供应合同
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.designIDGraph': //安装图纸
            this.$emit("changeFile", info, this.firmDataType, file)
            break
          case 'infos.fanCharacterCurve': //供应合同
            this.$emit("changeFile", info, this.firmDataType, file)
            break
        }
      } else {
        this.$emit("changeFile", file, this.firmDataType)
      }
    },
    deepCopy(obj) {
      return JSON.parse((JSON.stringify(obj)))
    }
  },
};
</script>
<style>
</style>
