diff --git a/ruoyi-admin/src/main/resources/templates/system/checkReport/detail.html b/ruoyi-admin/src/main/resources/templates/system/checkReport/detail.html
index 800d7d3..85ac868 100644
--- a/ruoyi-admin/src/main/resources/templates/system/checkReport/detail.html
+++ b/ruoyi-admin/src/main/resources/templates/system/checkReport/detail.html
@@ -188,6 +188,7 @@
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-remove="handleRemove(scope.row)"
+ :on-preview="handlePreview"
>
上传文件
@@ -346,6 +347,36 @@
handleExceed(){
$.modal.msgWarning('超出个数限制,最多只能上传一个文件!');
},
+ handlePreview(file){
+ $.ajax({
+ url: '/common/download/resource?resource=' + file.url,
+ type: 'GET',
+ xhrFields: {
+ responseType: 'blob'
+ },
+ success: function (data, status, xhr) {
+ let contentType = xhr.getResponseHeader('Content-Type');
+ let filename = file.name;
+ if (navigator.msSaveBlob) {
+ // 兼容 IE
+ navigator.msSaveBlob(data, filename);
+ } else {
+ let blob = new Blob([data], { type: contentType });
+ let url = URL.createObjectURL(blob);
+ let a = document.createElement('a');
+ a.href = url;
+ a.download = filename;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ }
+ },
+ error: function (xhr, status, error) {
+ console.error('下载文件失败:', error);
+ }
+ });
+ },
validateEndTime(rule, value, callback) {
// if (value && this.postForm.checkStartTime && new Date(value).getTime() < new Date(this.postForm.checkStartTime).getTime()) {
// callback(new Error('结束日期不能早于开始日期'));
diff --git a/ruoyi-admin/src/main/resources/templates/system/checkReport/edit.html b/ruoyi-admin/src/main/resources/templates/system/checkReport/edit.html
index bbad92d..d2d8ca6 100644
--- a/ruoyi-admin/src/main/resources/templates/system/checkReport/edit.html
+++ b/ruoyi-admin/src/main/resources/templates/system/checkReport/edit.html
@@ -185,6 +185,7 @@
:on-error="handleUploadError"
:on-exceed="handleExceed"
:on-remove="handleRemove(scope.row)"
+ :on-preview="handlePreview"
>
上传文件
@@ -357,6 +358,36 @@
handleExceed(){
$.modal.msgWarning('超出个数限制,最多只能上传一个文件!');
},
+ handlePreview(file){
+ $.ajax({
+ url: '/common/download/resource?resource=' + file.url,
+ type: 'GET',
+ xhrFields: {
+ responseType: 'blob'
+ },
+ success: function (data, status, xhr) {
+ let contentType = xhr.getResponseHeader('Content-Type');
+ let filename = file.name;
+ if (navigator.msSaveBlob) {
+ // 兼容 IE
+ navigator.msSaveBlob(data, filename);
+ } else {
+ let blob = new Blob([data], { type: contentType });
+ let url = URL.createObjectURL(blob);
+ let a = document.createElement('a');
+ a.href = url;
+ a.download = filename;
+ document.body.appendChild(a);
+ a.click();
+ document.body.removeChild(a);
+ URL.revokeObjectURL(url);
+ }
+ },
+ error: function (xhr, status, error) {
+ console.error('下载文件失败:', error);
+ }
+ });
+ },
validateEndTime(rule, value, callback) {
// if (value && this.postForm.checkStartTime && new Date(value).getTime() < new Date(this.postForm.checkStartTime).getTime()) {
// callback(new Error('结束日期不能早于开始日期'));