| | |
| | | typeLabel(t) { return TYPE_LABELS[t] || t }, |
| | | downloadTemplate() { |
| | | if (!this.templateUrl) return |
| | | window.open('/api/templates/' + this.templateUrl) |
| | | const name = this.templateUrl.split('/').pop() |
| | | api.get('/templates/' + this.templateUrl, { responseType: 'blob' }) |
| | | .then(res => { |
| | | const blob = res instanceof Blob ? res : new Blob([res]) |
| | | const url = window.URL.createObjectURL(blob) |
| | | const a = document.createElement('a') |
| | | a.href = url |
| | | a.download = name |
| | | document.body.appendChild(a) |
| | | a.click() |
| | | window.URL.revokeObjectURL(url) |
| | | document.body.removeChild(a) |
| | | }) |
| | | .catch(() => this.$message.error('模板下载失败,请稍后重试')) |
| | | }, |
| | | onModuleChange(key) { |
| | | this.importType = this.moduleSel[key] || '' |