
// @description:工具制作混入
// @author: tangQing
// @date: 2023-01-05
import upload from '@comp/common/updownload/upload'
import Cookies from 'js-cookie'
/* api*/
import { upLoadFileUrl } from '@/api/common/uploadCenter'
import downloadFile from '@comp/common/updownload/downloadFile'
import { getFileDetail } from '@/api/common/uploadCenter'
export const toolMakeMixins = {
  components: {
    upload,
    downloadFile
  },
  data() {
    return {
      upLoadFileUrl: upLoadFileUrl,
      importHeaders: {}, // cookie信息
      principalList: [],
      principalListOther: [],
      uploadKey: '0',
      uploadKeyOther: '1',
      firstAttachment: {}
      // isUpLoadDatOther: false // 是否显示二次上传文件
    }
  },
  created() {
    this.importHeaders['X-AUTH-TOKEN'] = Cookies.get('X-AUTH-TOKEN')
  },
  methods: {
    // 展示首次文件
    getMakeFile(bizId, fileType) {
      var params = {
        bizId: bizId,
        fileType: fileType
      }
      getFileDetail(params).then(response => {
        if (response.data.length) {
          this.firstAttachment = response.data
          // this.isUpLoadDatOther = true
        }
      }).catch(() => {
      })
    },
    uploadBefore(ev) {
      this.tenderStageTimeRule().then(() => {
      }).catch(() => {
        ev.stopPropagation()
      })
    },
    refresh() {
      // 刷新
      this.principalList = []
      this.principalListOther = []
      this.uploadKey = Math.ceil(Math.random() * 100)
      this.uploadKeyOther = Math.ceil(Math.random() * 1000)
    },
    // 附件上传
    principalFile(file, fileList) {
      this.principalList = fileList
    },
    principalFileOther(file, fileList) {
      this.principalListOther = fileList
    }

  }
}
