浏览代码

项目管理,权限,删除文件

MaiXinRong 6 月之前
父节点
当前提交
141a7a3216

+ 1 - 0
app/controller/file_controller.js

@@ -61,6 +61,7 @@ module.exports = app => {
                 renderData.categoryData = await ctx.service.category.getAllCategory(ctx.session.sessionProject.id);
                 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.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.canUpload = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.upload.value) >= 0;
+                renderData.canDelete = ctx.subProject.permission.file_permission.indexOf(ctx.service.subProjPermission.PermissionConst.file.delete.value) >= 0;
                 renderData.filingTypes = ctx.service.filing.analysisFilingType(renderData.filing);
                 renderData.filingTypes = ctx.service.filing.analysisFilingType(renderData.filing);
                 await this.layout('file/file.ejs', renderData, 'file/file_modal.ejs');
                 await this.layout('file/file.ejs', renderData, 'file/file_modal.ejs');
             } catch (err) {
             } catch (err) {

+ 1 - 1
app/public/js/file_detail.js

@@ -95,7 +95,7 @@ $(document).ready(function() {
             const editHtml = file.canEdit ? `<a href="javascript: void(0);" class="mr-1" name="edit-file" fid="${file.id}"><i class="fa fa-pencil fa-fw"></i></a>` : '';
             const editHtml = file.canEdit ? `<a href="javascript: void(0);" class="mr-1" name="edit-file" fid="${file.id}"><i class="fa fa-pencil fa-fw"></i></a>` : '';
             const viewHtml = file.viewpath ? `<a href="${file.viewpath}" class="mr-1" target="_blank"><i class="fa fa-eye fa-fw"></i></a>` : '';
             const viewHtml = file.viewpath ? `<a href="${file.viewpath}" class="mr-1" target="_blank"><i class="fa fa-eye fa-fw"></i></a>` : '';
             const downHtml = `<a href="javascript: void(0);" onclick="AliOss.downloadFile('${file.filepath}', '${file.filename + file.fileext}')" class="mr-1"><i class="fa fa-download fa-fw"></i></a>`;
             const downHtml = `<a href="javascript: void(0);" onclick="AliOss.downloadFile('${file.filepath}', '${file.filename + file.fileext}')" class="mr-1"><i class="fa fa-download fa-fw"></i></a>`;
-            const delHtml = file.canEdit ? `<a href="javascript: void(0);" class="mr-1 text-danger" name="del-file" fid="${file.id}"><i class="fa fa-trash-o fa-fw"></i></a>` : '';
+            const delHtml = file.canEdit || canDelete ? `<a href="javascript: void(0);" class="mr-1 text-danger" name="del-file" fid="${file.id}"><i class="fa fa-trash-o fa-fw"></i></a>` : '';
             return `<div class="d-flex justify-content-between align-items-center table-file"><div name="filename" fid="${file.id}">${file.filename}${file.fileext}</div><div class="btn-group-table" style="display: none;">${moveHtml}${editHtml}${viewHtml}${downHtml}${delHtml}</div></div>`;
             return `<div class="d-flex justify-content-between align-items-center table-file"><div name="filename" fid="${file.id}">${file.filename}${file.fileext}</div><div class="btn-group-table" style="display: none;">${moveHtml}${editHtml}${viewHtml}${downHtml}${delHtml}</div></div>`;
         }
         }
         _getEditFileNameHtml(file) {
         _getEditFileNameHtml(file) {

+ 13 - 0
app/public/js/sub_project.js

@@ -481,6 +481,10 @@ $(document).ready(function() {
             html.push(`<td><div class="custom-control custom-checkbox mb-2">
             html.push(`<td><div class="custom-control custom-checkbox mb-2">
                         <input type="checkbox" ptype="file" sptype="upload" id="fileupload${mem.uid}" uid="${mem.uid}" class="custom-control-input" ${(fileUpload ? 'checked' : '')}>
                         <input type="checkbox" ptype="file" sptype="upload" id="fileupload${mem.uid}" uid="${mem.uid}" class="custom-control-input" ${(fileUpload ? 'checked' : '')}>
                         <label class="custom-control-label" for="fileupload${mem.uid}"></label></div></td>`);
                         <label class="custom-control-label" for="fileupload${mem.uid}"></label></div></td>`);
+            const fileDelete = mem.file_permission.indexOf(permissionConst.file.delete.value) >= 0;
+            html.push(`<td><div class="custom-control custom-checkbox mb-2">
+                        <input type="checkbox" ptype="file" sptype="delete" id="filedelete${mem.uid}" uid="${mem.uid}" class="custom-control-input" ${(fileDelete ? 'checked' : '')}>
+                        <label class="custom-control-label" for="filedelete${mem.uid}"></label></div></td>`);
             const fileEdit = mem.file_permission.indexOf(permissionConst.file.filing.value) >= 0;
             const fileEdit = mem.file_permission.indexOf(permissionConst.file.filing.value) >= 0;
             html.push(`<td><div class="custom-control custom-checkbox mb-2">
             html.push(`<td><div class="custom-control custom-checkbox mb-2">
                         <input type="checkbox" ptype="file" sptype="filing" uid="${mem.uid}" id="fileedit${mem.uid}" class="custom-control-input" ${(fileEdit ? 'checked' : '')}>
                         <input type="checkbox" ptype="file" sptype="filing" uid="${mem.uid}" id="fileedit${mem.uid}" class="custom-control-input" ${(fileEdit ? 'checked' : '')}>
@@ -560,6 +564,12 @@ $(document).ready(function() {
                     mem.file_permission.push(parseInt(permissionConst.file.view.value));
                     mem.file_permission.push(parseInt(permissionConst.file.view.value));
                     $(`#fileview${id}`)[0].checked = true;
                     $(`#fileview${id}`)[0].checked = true;
                 }
                 }
+            } else if (pType === 'file' && spType === 'delete') {
+                mem.file_permission.push(parseInt(permissionConst.file.delete.value));
+                if (mem.file_permission.indexOf(permissionConst.file.view.value) < 0) {
+                    mem.file_permission.push(parseInt(permissionConst.file.view.value));
+                    $(`#fileview${id}`)[0].checked = true;
+                }
             } else if (pType === 'file' && spType === 'filing') {
             } else if (pType === 'file' && spType === 'filing') {
                 mem.file_permission.push(parseInt(permissionConst.file.filing.value));
                 mem.file_permission.push(parseInt(permissionConst.file.filing.value));
                 if (mem.file_permission.indexOf(permissionConst.file.view.value) < 0) {
                 if (mem.file_permission.indexOf(permissionConst.file.view.value) < 0) {
@@ -579,8 +589,11 @@ $(document).ready(function() {
                 mem.file_permission = [];
                 mem.file_permission = [];
                 $(`#fileupload${id}`)[0].checked = false;
                 $(`#fileupload${id}`)[0].checked = false;
                 $(`#fileedit${id}`)[0].checked = false;
                 $(`#fileedit${id}`)[0].checked = false;
+                $(`#filedelete${id}`)[0].checked = false;
             } else if (pType === 'file' && spType === 'upload') {
             } else if (pType === 'file' && spType === 'upload') {
                 mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.upload.value), 1);
                 mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.upload.value), 1);
+            } else if (pType === 'file' && spType === 'delete') {
+                mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.delete.value), 1);
             } else if (pType === 'file' && spType === 'filing') {
             } else if (pType === 'file' && spType === 'filing') {
                 mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.filing.value), 1);
                 mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.filing.value), 1);
             } else if (pType === 'manage' && spType === 'rela') {
             } else if (pType === 'manage' && spType === 'rela') {

+ 5 - 0
app/service/file.js

@@ -80,6 +80,11 @@ module.exports = app => {
 
 
             const fileDatas = await this.getAllDataByCondition({ where: { id: files } });
             const fileDatas = await this.getAllDataByCondition({ where: { id: files } });
             const filing = await this.ctx.service.filing.getDataById(fileDatas[0].filing_id);
             const filing = await this.ctx.service.filing.getDataById(fileDatas[0].filing_id);
+            if (this.ctx.subProject.permission.file_permission.indexOf(this.ctx.service.subProjPermission.PermissionConst.file.delete.value) < 0) {
+                for (const file of fileDatas) {
+                    if (file.user_id !== this.ctx.session.sessionUser.accountId) throw '无权删除文件';
+                }
+            }
             const result = {};
             const result = {};
 
 
             const conn = await this.db.beginTransaction();
             const conn = await this.db.beginTransaction();

+ 1 - 0
app/service/sub_proj_permission.js

@@ -29,6 +29,7 @@ module.exports = app => {
                 file: {
                 file: {
                     view: { title: '查看', value: 1 },
                     view: { title: '查看', value: 1 },
                     upload: { title: '上传/引用', value: 2 },
                     upload: { title: '上传/引用', value: 2 },
+                    delete: { title: '删除文件', value: 4 },
                     filing: { title: '文件类别编辑', value: 3 },
                     filing: { title: '文件类别编辑', value: 3 },
                 },
                 },
                 manage: {
                 manage: {

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

@@ -106,4 +106,5 @@
     const filing = JSON.parse(unescape('<%- escape(JSON.stringify(filing)) %>'));
     const filing = JSON.parse(unescape('<%- escape(JSON.stringify(filing)) %>'));
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
     const category = JSON.parse(unescape('<%- escape(JSON.stringify(categoryData)) %>'));
     const whiteList = JSON.parse('<%- JSON.stringify(ctx.app.config.multipart.whitelist) %>');
     const whiteList = JSON.parse('<%- JSON.stringify(ctx.app.config.multipart.whitelist) %>');
+    const canDelete = <%- canDelete %>;
 </script>
 </script>

+ 2 - 1
app/view/sub_proj/modal.ejs

@@ -154,7 +154,7 @@
                             <th rowspan="2" class="align-middle">成员名称</th>
                             <th rowspan="2" class="align-middle">成员名称</th>
                             <th rowspan="2" class="align-middle">职位</th>
                             <th rowspan="2" class="align-middle">职位</th>
                             <th colspan="2">动态投资</th>
                             <th colspan="2">动态投资</th>
-                            <th colspan="3">资料归集</th>
+                            <th colspan="4">资料归集</th>
                             <th rowspan="2" class="align-middle">关联标段</th>
                             <th rowspan="2" class="align-middle">关联标段</th>
                             <th rowspan="2" class="align-middle">移除</th>
                             <th rowspan="2" class="align-middle">移除</th>
                         </tr>
                         </tr>
@@ -163,6 +163,7 @@
                             <th>编辑</th>
                             <th>编辑</th>
                             <th>查看</th>
                             <th>查看</th>
                             <th>上传/引用</th>
                             <th>上传/引用</th>
+                            <th>删除文件</th>
                             <th>编辑分类</th>
                             <th>编辑分类</th>
                         </tr>
                         </tr>
                         </thead>
                         </thead>