浏览代码

奖罚金,预览

MaiXinRong 2 年之前
父节点
当前提交
f37b4a6817
共有 3 个文件被更改,包括 17 次插入2 次删除
  1. 4 1
      app/controller/stage_extra_controller.js
  2. 6 1
      app/public/js/se_bonus.js
  3. 7 0
      app/service/stage_bonus.js

+ 4 - 1
app/controller/stage_extra_controller.js

@@ -355,8 +355,11 @@ module.exports = app => {
                     ]
                 });
                 for (const pf of bonus.proof_file) {
-                    delete pf.filepath;
                     pf.username = (await ctx.service.projectAccount.getAccountInfoById(pf.uid)).name;
+                    if (ctx.helper.canPreview(pf.fileext)){
+                        pf.viewpath = pf.filepath.substr(3, pf.filepath.length - 3);
+                    }
+                    delete pf.filepath;
                 }
                 ctx.body = {err: 0, msg: '', data: bonus.proof_file};
             } catch (error) {

+ 6 - 1
app/public/js/se_bonus.js

@@ -148,7 +148,12 @@ $(document).ready(() => {
             if (files !== null && files !== undefined) {
                 for (const [i, f] of files.entries()) {
                     html.push('<tr>');
-                    html.push('<td style="width: 200px">', f.filename + f.fileext, '</td>');
+                    if (f.viewpath) {
+                        html.push(`<td style="width: 200px"><a href="${f.viewpath}" target="_blank">${f.filename}${f.fileext}</a></td>`);
+                        //html.push(`<td style="width: 200px"><a href="download/file?b_id=${id}&index=${i}&view=1" target="_blank">${f.filename}${f.fileext}</a></td>`);
+                    } else {
+                        html.push(`<td style="width: 200px"><a href="download/file?b_id=${id}&index=${i}" title="下载">${f.filename}${f.fileext}</a></td>`);
+                    }
                     html.push('<td>', f.username, '</td>');
                     html.push('<td>', f.in_time, '</td>');
                     html.push('<td>');

+ 7 - 0
app/service/stage_bonus.js

@@ -23,11 +23,17 @@ module.exports = app => {
         }
 
         _parseData(data) {
+            const helper = this.ctx.helper;
             if (!data) return;
             const datas = data instanceof Array ? data : [data];
             for (const d of datas) {
                 if (d.proof_file) {
                     d.proof_file = JSON.parse(d.proof_file);
+                    d.proof_file.forEach(f => {
+                        if (helper.canPreview(f.fileext)){
+                            f.viewpath = f.filepath.substr(3, f.filepath.length - 3);
+                        }
+                    });
                 } else {
                     d.proof_file = [];
                 }
@@ -143,6 +149,7 @@ module.exports = app => {
             }
             if (uDatas.length > 0) {
                 await this.db.updateRows(this.tableName, uDatas);
+                this._parseData(uDatas);
                 return uDatas;
             } else {
                 return [];