Browse Source

spss,暂存数据,调整

MaiXinRong 4 days ago
parent
commit
8230fb74ca
2 changed files with 10 additions and 6 deletions
  1. 1 2
      app/lib/rm/spss.js
  2. 9 4
      app/service/spss_stash.js

+ 1 - 2
app/lib/rm/spss.js

@@ -15,8 +15,7 @@ class reportMemorySpss {
     }
 
     async _loadTypeData(type) {
-        // if (!this[type]) this[type] = await this.ctx.service.spssStash.getLatestSpssStash(this.ctx.subProject.id, type);
-        if (!this[type]) this[type] = await this.ctx.service.spssStash.getLatestSpssStash(this.ctx.subProject.id, type, this.ctx.session.sessionUser.accountId);
+        if (!this[type]) this[type] = await this.ctx.service.spssStash.getLatestSpssStash(this.ctx.subProject.id, type);
     }
 
     async getTypeTender(type) {

+ 9 - 4
app/service/spss_stash.js

@@ -8,7 +8,8 @@
  * @version
  */
 
-const maxStashCount = 5;
+const maxStashCount = 3;
+const filterSelf = true;
 
 module.exports = app => {
 
@@ -25,9 +26,13 @@ module.exports = app => {
             this.tableName = 'spss_stash';
         }
 
+        getCondition(spid, spss_type) {
+            return filterSelf ? { spid, spss_type, user_id: this.ctx.session.sessionUser.accountId} : { spid, spss_type };
+        }
+
         async getSpssStashList(spid, spssType) {
             const result = await this.getAllDataByCondition({
-                where: { spid, spss_type: spssType },
+                where: this.getCondition(spid, spssType),
                 columns: [ 'id', 'user_id', 'user_name', 'create_time' ],
                 orders: [['create_time', 'desc']],
             });
@@ -46,9 +51,9 @@ module.exports = app => {
             return data;
         }
 
-        async getLatestSpssStash(spid, type, user_id) {
+        async getLatestSpssStash(spid, type) {
             const data = await this.getAllDataByCondition({
-                where: { spid, spss_type: type, user_id },
+                where: this.getCondition(spid, type),
                 orders: [['create_time', 'desc']],
                 limit: 1,
                 offset: 0,