|
|
@@ -90,13 +90,7 @@ module.exports = app => {
|
|
|
' WHERE leg.id = att.lid AND pa.id = att.uid AND att.id = ? ORDER BY att.in_time DESC';
|
|
|
const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.ctx.service.ledger.tableName, id];
|
|
|
const result = await this.db.queryOne(sql, sqlParam);
|
|
|
- result.orginpath = this.ctx.app.config.fujianOssPath + result.filepath;
|
|
|
- if (!ctx.helper.canPreview(result.fileext)) {
|
|
|
- result.filepath = `/tender/${ctx.tender.id}/ledger/download/file/${result.id}`;
|
|
|
- } else {
|
|
|
- // result.filepath = result.filepath.replace(/^app|\/app/, '');
|
|
|
- result.filepath = this.ctx.app.config.fujianOssPath + result.filepath;
|
|
|
- }
|
|
|
+ this._analysisAtt(result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -149,17 +143,23 @@ module.exports = app => {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ _analysisAtt(data) {
|
|
|
+ const datas = data instanceof Array ? data : [data];
|
|
|
+ for (const r of datas) {
|
|
|
+ r.orginpath = this.ctx.app.config.fujianOssPath + r.filepath;
|
|
|
+ r.filepath = this.ctx.app.config.fujianOssPath + r.filepath;
|
|
|
+ r.viewpath = this.ctx.helper.getPreviewPath(r.fileext, r.filepath);
|
|
|
+ r.in_time = this.ctx.moment(r.in_time * 1000).format('YYYY-MM-DD');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
async getViewDataByFid(id) {
|
|
|
const sql = 'SELECT att.id, att.lid, att.uid, att.filepath, att.filename, att.fileext, att.filesize, att.extra_upload, att.remark, att.in_time,' +
|
|
|
' pa.name as `username`' +
|
|
|
' FROM ' + this.tableName + ' att Left Join ' + this.ctx.service.projectAccount.tableName + ' pa On pa.id = att.uid' +
|
|
|
' WHERE att.id = ?';
|
|
|
const result = await this.db.query(sql, [id]);
|
|
|
- for (const r of result) {
|
|
|
- r.filepath = this.ctx.app.config.fujianOssPath + r.filepath;
|
|
|
- if (this.ctx.helper.canPreview(r.fileext)) r.viewpath = r.filepath;
|
|
|
- r.in_time = this.ctx.moment(r.in_time * 1000).format('YYYY-MM-DD');
|
|
|
- }
|
|
|
+ this._analysisAtt(result);
|
|
|
return result[0];
|
|
|
}
|
|
|
|
|
|
@@ -169,11 +169,7 @@ module.exports = app => {
|
|
|
' FROM ' + this.tableName + ' att Left Join ' + this.ctx.service.projectAccount.tableName + ' pa On pa.id = att.uid' +
|
|
|
' WHERE att.tid = ? AND att.settle_id = ? ORDER BY att.id DESC';
|
|
|
const result = await this.db.query(sql, [tid, settle_id]);
|
|
|
- for (const r of result) {
|
|
|
- r.filepath = this.ctx.app.config.fujianOssPath + r.filepath;
|
|
|
- if (this.ctx.helper.canPreview(r.fileext)) r.viewpath = r.filepath;
|
|
|
- r.in_time = this.ctx.moment(r.in_time * 1000).format('YYYY-MM-DD');
|
|
|
- }
|
|
|
+ this._analysisAtt(result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -183,11 +179,7 @@ module.exports = app => {
|
|
|
' FROM ' + this.tableName + ' att Left Join ' + this.ctx.service.projectAccount.tableName + ' pa On pa.id = att.uid' +
|
|
|
' WHERE att.tid = ? AND att.revise_id = ? ORDER BY att.id DESC';
|
|
|
const result = await this.db.query(sql, [tid, rid]);
|
|
|
- for (const r of result) {
|
|
|
- r.filepath = this.ctx.app.config.fujianOssPath + r.filepath;
|
|
|
- if (this.ctx.helper.canPreview(r.fileext)) r.viewpath = r.filepath;
|
|
|
- r.in_time = this.ctx.moment(r.in_time * 1000).format('YYYY-MM-DD');
|
|
|
- }
|
|
|
+ this._analysisAtt(result);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -195,13 +187,9 @@ module.exports = app => {
|
|
|
const sql = 'SELECT att.id, att.lid, att.uid, att.filepath, att.filename, att.fileext, att.filesize, att.extra_upload, att.remark, att.in_time,' +
|
|
|
' pa.name as `username`' +
|
|
|
' FROM ' + this.tableName + ' att Left Join ' + this.ctx.service.projectAccount.tableName + ' pa On pa.id = att.uid' +
|
|
|
- ' WHERE att.tid = ? AND att.revising = 0 ORDER BY att.id DESC';
|
|
|
+ ' WHERE att.tid = ? AND att.revising = 0 AND att.settle_id = -1 ORDER BY att.id DESC';
|
|
|
const result = await this.db.query(sql, [tid]);
|
|
|
- for (const r of result) {
|
|
|
- r.filepath = this.ctx.app.config.fujianOssPath + r.filepath;
|
|
|
- if (this.ctx.helper.canPreview(r.fileext)) r.viewpath = r.filepath;
|
|
|
- r.in_time = this.ctx.moment(r.in_time * 1000).format('YYYY-MM-DD');
|
|
|
- }
|
|
|
+ this._analysisAtt(result);
|
|
|
return result;
|
|
|
}
|
|
|
}
|