|
@@ -98,7 +98,7 @@
|
|
|
<el-input type="textarea" v-model="form.need" readonly/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="附件" prop="imagePath">
|
|
|
- <el-button @click="downloadImage()" v-if=""></el-button>
|
|
|
+ <el-button @click="downloadSth(form.imagePath)" v-if="form.imagePath != null" type="info">下载附件</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<div slot="footer" class="dialog-footer">
|
|
@@ -110,7 +110,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listIssue, getIssue, delIssue, addIssue, updateIssue } from "@/api/zcustom/issue";
|
|
|
+import { addIssue, delIssue, downloadFile, getIssue, listIssue, updateIssue } from '@/api/zcustom/issue'
|
|
|
import { listProject } from '@/api/zcustom/project'
|
|
|
|
|
|
export default {
|
|
@@ -266,6 +266,24 @@ export default {
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
+
|
|
|
+ downloadSth(imagePath){
|
|
|
+ return downloadFile(imagePath).then(response => {
|
|
|
+ // 解析返回的文件流并触发下载
|
|
|
+ const blob = new Blob([response], { type: 'application/octet-stream' });
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.href = url;
|
|
|
+ // 设置下载文件名(从文件路径中提取文件名)
|
|
|
+ const fileName = imagePath.split('/').pop();
|
|
|
+ link.download = fileName; // 设置下载的文件名
|
|
|
+ link.click(); // 触发点击事件,下载文件
|
|
|
+ window.URL.revokeObjectURL(url); // 释放 URL 对象,防止内存泄漏
|
|
|
+ }).catch(error => {
|
|
|
+ console.error('文件下载失败:', error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
};
|
|
|
</script>
|