{"remainingRequest":"D:\\jenkins\\workspace\\xypm-web\\node_modules\\vue-loader\\lib\\index.js??vue-loader-options!D:\\jenkins\\workspace\\xypm-web\\src\\components\\ImportExportData\\ImportData\\ImportData.vue?vue&type=script&lang=js&","dependencies":[{"path":"D:\\jenkins\\workspace\\xypm-web\\src\\components\\ImportExportData\\ImportData\\ImportData.vue","mtime":1675214576355},{"path":"D:\\jenkins\\workspace\\xypm-web\\node_modules\\babel-loader\\lib\\index.js","mtime":315532800000},{"path":"D:\\jenkins\\workspace\\xypm-web\\node_modules\\cache-loader\\dist\\cjs.js","mtime":499162500000},{"path":"D:\\jenkins\\workspace\\xypm-web\\node_modules\\vue-loader\\lib\\index.js","mtime":499162500000}],"contextDependencies":[],"result":["//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\r\nconst DataTemplateSetting = () =>\r\n  import('@/components/ImportExportData/DataTemplateSetting')\r\nimport portal from '@/api/portal'\r\nexport default {\r\n  name: 'ImportData',\r\n  components: {\r\n    DataTemplateSetting\r\n  },\r\n  props: {\r\n    // 页面组件别名\r\n    bizCode: {\r\n      type: String,\r\n      default: '',\r\n      required: true\r\n    },\r\n    // 模板文件名称\r\n    tempFiles: {\r\n      type: String,\r\n      default: '',\r\n      required: true\r\n    },\r\n    originAPIOptions: {\r\n      type: Object,\r\n      default: () => {},\r\n      required: true\r\n    },\r\n    dataBaseOptions: {\r\n      type: Object,\r\n      default: () => {},\r\n      required: true\r\n    }\r\n  },\r\n  computed: {\r\n    uploadHeaders: function(mapState) {\r\n      return {\r\n        Authorization:\r\n          this.$store.state.login.currentUser &&\r\n          'Bearer ' + this.$store.state.login.currentUser.token\r\n      }\r\n    },\r\n    importUrl: function() {\r\n      return (\r\n        window.context[this.originAPIOptions.moduleRoot] +\r\n        '/config/excel/v1/upload' +\r\n        // this.originAPIOptions.url +\r\n        '?export=import&tempId=' +\r\n        this.bizCode\r\n      )\r\n    }\r\n  },\r\n  data() {\r\n    return {\r\n      dialogShow: false,\r\n      noTemp: false, // 是否有模板\r\n      downLoading: false,\r\n      uploading: false,\r\n      tempId: ''\r\n    }\r\n  },\r\n\r\n  mounted() {},\r\n  methods: {\r\n    cancel() {\r\n      this.$refs.upload.clearFiles()\r\n      this.dialogShow = false\r\n      this.tempId = ''\r\n      this.noTemp = false\r\n      this.downLoading = false\r\n    },\r\n    checkTemp() {\r\n      let data = this.qs.stringify({\r\n        type: 2,\r\n        bizCode: this.bizCode\r\n      })\r\n      portal.checkTemp(data).then(res => {\r\n        if (res) {\r\n          this.noTemp = false\r\n          this.tempId = res.excelTemp.id\r\n        } else {\r\n          this.noTemp = true\r\n          this.tempId = ''\r\n        }\r\n      })\r\n    },\r\n    openDialog() {\r\n      this.dialogShow = true\r\n      this.checkTemp()\r\n    },\r\n    downloadTemp() {\r\n      this.downLoading = true\r\n      let params = {\r\n        originAPIOptions: this.originAPIOptions,\r\n        bizCode: this.bizCode\r\n      }\r\n      console.log(params, 'params')\r\n      portal.downloadTemp(params).then(res => {\r\n        const content = res\r\n        const blob = new Blob([content])\r\n        const fileName = `${this.tempFiles}.xls`\r\n        const elink = document.createElement('a')\r\n        elink.download = fileName\r\n        elink.style.display = 'none'\r\n        elink.href = URL.createObjectURL(blob)\r\n        document.body.appendChild(elink)\r\n        elink.click()\r\n        URL.revokeObjectURL(elink.href) // 释放URL 对象\r\n        document.body.removeChild(elink)\r\n        this.downLoading = false\r\n      })\r\n    },\r\n    setTemp() {\r\n      this.$refs.DataTemplate.openDialog(this.tempId)\r\n    },\r\n    beforeUpload(file) {\r\n      if (!file.name.endsWith('.xlsx') && !file.name.endsWith('.xls')) {\r\n        this.$message.warning('只能导入Excel文件!')\r\n        return false\r\n      }\r\n      this.uploading = true\r\n    },\r\n    //导入\r\n    onExceed(file) {\r\n      this.$message.warning('只能选择一个Excel文件!')\r\n    },\r\n    handleUploadResult(response, file, fileList) {\r\n      this.uploading = false\r\n      if (response.state) {\r\n        this.$message.success(response.message)\r\n        this.$emit('reload')\r\n      } else {\r\n        this.$message.error(response.message + '：' + response.value)\r\n      }\r\n    },\r\n    submitImport() {\r\n      if (\r\n        !this.$refs.upload.uploadFiles ||\r\n        this.$refs.upload.uploadFiles.length == 0\r\n      ) {\r\n        this.$message.warning('请选择要导入的数据文件!')\r\n        return false\r\n      }\r\n      this.$refs.upload.submit()\r\n    }\r\n  }\r\n}\r\n",null]}