Jelajahi Sumber

资料归集,授权分类问题

MaiXinRong 1 tahun lalu
induk
melakukan
d7bc91f44f
2 mengubah file dengan 18 tambahan dan 3 penghapusan
  1. 1 1
      app/controller/file_controller.js
  2. 17 2
      app/service/filing.js

+ 1 - 1
app/controller/file_controller.js

@@ -53,7 +53,7 @@ module.exports = app => {
                 renderData.categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
                 renderData.canFiling = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.filing.value) >= 0;
                 renderData.canUpload = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.upload.value) >= 0;
-                renderData.filingTypes = ctx.service.filing.filingType;
+                renderData.filingTypes = ctx.service.filing.analysisFilingType(renderData.filing);
                 await this.layout('file/file.ejs', renderData, 'file/file_modal.ejs');
             } catch (err) {
                 ctx.log(err);

+ 17 - 2
app/service/filing.js

@@ -36,13 +36,29 @@ module.exports = app => {
         constructor(ctx) {
             super(ctx);
             this.tableName = 'filing';
-            this.filingType = filingType;
         }
 
         get allFilingType () {
             return filingType.map(x => { return x.value });
         }
 
+        analysisFilingType(filing) {
+            const curFilingType = filing.filter(f => {
+                return f.tree_level === 1;
+            });
+            curFilingType.sort((x, y) => {
+                return x.tree_order - y.tree_order;
+            });
+            return curFilingType.map(f => {
+                return { value: f.filing_type, name: f.name }
+            });
+        }
+
+        async getFilingType(spid) {
+            const filing = await ctx.service.filing.getValidFiling(ctx.params.id, ctx.subProject.permission.filing_type);
+            return this.analysisFilingType(filing);
+        }
+
         async initFiling(spid, templateId, transaction) {
             const count = await this.count({ spid });
             if (count > 0) return;
@@ -76,7 +92,6 @@ module.exports = app => {
             return await this.getAllDataByCondition({ where: condition });
         }
 
-
         async getPosterityData(id){
             const result = [];
             let cur = await this.getAllDataByCondition({ where: { tree_pid: id } });