Browse Source

附件预览下载

MaiXinRong 2 years ago
parent
commit
83e779c9bb
1 changed files with 11 additions and 0 deletions
  1. 11 0
      app/public/js/payment_safe.js

+ 11 - 0
app/public/js/payment_safe.js

@@ -786,6 +786,17 @@ $(document).ready(function() {
     $('body').on('click', '[name=del-file]', function() {
        attObj.deleteAtt(parseInt(this.getAttribute('file_id')));
     });
+    $('body').on('click', 'a[file_id]', function() {
+        const file_id = parseInt(this.getAttribute('file_id'));
+        const file = attObj.atts.find(x => { return x.id === file_id; });
+        if (!file) return;
+
+        if (file.viewpath) {
+            window.open(file.viewpath, '_blank');
+        } else {
+            AliOss.downloadFile(file.filepath, `${file.filename}${file.fileext}`)
+        }
+    });
     $('.page-select').click(function() {
         const content = this.getAttribute('content');
         if (content === 'pre') {