Browse Source

管理分类,显示授权信息

MaiXinRong 5 tháng trước cách đây
mục cha
commit
dd74af51c1
2 tập tin đã thay đổi với 16 bổ sung2 xóa
  1. 10 1
      app/controller/file_controller.js
  2. 6 1
      app/public/js/filing_manage.js

+ 10 - 1
app/controller/file_controller.js

@@ -80,7 +80,6 @@ module.exports = app => {
                 ctx.ajaxErrorBody(err, '获取授权用户数据错误');
             }
         }
-
         async saveFilingTypePermission(ctx) {
             try {
                 const data = JSON.parse(ctx.request.body.data);
@@ -507,6 +506,16 @@ module.exports = app => {
                     jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.file.manage),
                 };
                 renderData.filingData = await ctx.service.filing.getValidFiling(ctx.params.id, ctx.subProject.permission.filing_type);
+                const permissionData = await ctx.service.subProjPermission.getFilingType(ctx.subProject.id);
+                permissionData.forEach(x => { x.filing_type = x.filing_type.split(','); });
+                renderData.filingData.forEach(x => {
+                    if (!x.is_fixed) {
+                        x.permission_count = 0;
+                    } else {
+                        const rela = permissionData.filter(y => { return y.filing_type.indexOf(x.filing_type + '') >= 0; });
+                        x.permission_count = rela.length;
+                    }
+                });
                 await this.layout('file/manage.ejs', renderData, 'file/manage_modal.ejs');
             } catch (err) {
                 ctx.log(err);

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

@@ -246,6 +246,7 @@ $(document).ready(function() {
                 cols: [
                     { title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 250, formatter: '@', readOnly: true, cellType: 'tree' },
                     { title: '文件数', colSpan: '1', rowSpan: '1', field: 'file_count', hAlign: 1, width: 50, readOnly: true },
+                    { title: '授权', colSpan: '1', rowSpan: '1', field: 'permission_count', hAlign: 1, width: 50, readOnly: true },
                     { title: '固定', colSpan: '1', rowSpan: '1', field: 'is_fixed', hAlign: 1, width: 50, cellType: 'checkbox' },
                     { title: '提示', colSpan: '1', rowSpan: '1', field: 'tips', hAlign: 0, width: 280, formatter: '@', wordWrap: 1 },
                 ],
@@ -337,6 +338,9 @@ $(document).ready(function() {
                 if (node.file_count > 0 && node.is_fixed !== node.org_is_fixed) {
                     throw `【${node.name}】下已存在文件,不可修改是否为固定节点`;
                 }
+                if (node.permission_count > 0 && node.is_fixed !== node.org_is_fixed) {
+                    throw `【${node.name}】下已授权给用户,不可修改是否为固定节点`;
+                }
             }
             const sftIndex = [];
             const getNewSft = function () {
@@ -347,7 +351,7 @@ $(document).ready(function() {
                 return i;
             };
             for (const node of this.checkTree.nodes) {
-                if (node.file_count) {
+                if (node.file_count || node.permission_count) {
                     node.new_filing_type = node.filing_type;
                 } else if (node.is_fixed) {
                     node.new_filing_type = getNewSft();
@@ -391,6 +395,7 @@ $(document).ready(function() {
                     filing_type: node.filing_type,
                     tips: node.tips,
                     file_count: node.file_count,
+                    permission_count: node.permission_count,
                 });
             }
             return data;