소스 검색

资料归集,文件个数

MaiXinRong 1 년 전
부모
커밋
156a265f3d
4개의 변경된 파일12개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 0
      app/controller/file_controller.js
  2. 3 0
      app/public/js/file_list.js
  3. 5 0
      app/service/filing.js
  4. 1 1
      app/view/file/index.ejs

+ 3 - 0
app/controller/file_controller.js

@@ -31,6 +31,9 @@ module.exports = app => {
                     auditConst,
                 };
                 renderData.projectList = await ctx.service.subProject.getFileProject(ctx.session.sessionProject.id, ctx.session.sessionUser.accountId, ctx.session.sessionUser.is_admin);
+                for (const p of renderData.projectList) {
+                    if (!p.is_folder) p.file_count = await this.service.filing.sumFileCount(p.id);
+                }
                 renderData.tenderList = await ctx.service.tender.getList4Select('stage');
                 renderData.categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
                 await this.layout('file/index.ejs', renderData, 'file/modal.ejs');

+ 3 - 0
app/public/js/file_list.js

@@ -26,6 +26,7 @@ $(document).ready(() => {
 
         const Utils = {
             getRowTdHtml: function (node, tree) {
+                console.log(node);
                 const html = [];
                 // 名称
                 html.push('<td width="20%" class="in-' + node.tree_level + '">');
@@ -40,6 +41,8 @@ $(document).ready(() => {
                     html.push(`<a href="/sp/${node.id}/file" name="name" id="${node.id}">`, node.name, '</a>');
                 }
                 html.push('</td>');
+                // 文件个数
+                html.push(`<td class="text-center">${ node.file_count || ''}</td>`);
                 // 管理单位
                 html.push(`<td class="text-center">${node.management}</td>`);
                 // 创建时间

+ 5 - 0
app/service/filing.js

@@ -217,6 +217,11 @@ module.exports = app => {
             await this.db.updateRows(this.tableName, updateData);
             return { update: updateData };
         }
+
+        async sumFileCount(spid) {
+            const result = await this.db.queryOne(`SELECT SUM(file_count) AS file_count FROM ${this.tableName} WHERE spid = '${spid}' and is_deleted = 0`);
+            return result.file_count;
+        }
     }
 
     return Filing;

+ 1 - 1
app/view/file/index.ejs

@@ -15,7 +15,7 @@
                 </div>
                 <% } else { %>
                 <table class="table table-hover table-bordered">
-                    <tr class="text-center"><th style="min-width: 200px">项目名称</th><th>管理单位</th><th>创建时间</th><th>操作</th></tr>
+                    <tr class="text-center"><th style="min-width: 200px">项目名称</th><th>文件个数</th><th>管理单位</th><th>创建时间</th><th>操作</th></tr>
                     <tbody id="projectList">
                     </tbody>
                 </table>