浏览代码

公共空间和部门空间处理。

wukai 2 年之前
父节点
当前提交
d2c2e62237

+ 67 - 15
lzga-modules/lzga-doc/src/main/java/com/jjt/doc/controller/DocDirController.java

@@ -15,6 +15,7 @@ import com.jjt.doc.enums.DocOfType;
 import com.jjt.doc.service.IDocGroupService;
 import com.jjt.doc.service.IDocSpaceService;
 import com.jjt.system.api.RemoteConfigService;
+import com.jjt.system.api.domain.SysUser;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
@@ -83,17 +84,7 @@ public class DocDirController extends BaseController {
         } else {
             docSpace = spaceList.get(0);
         }
-        //2.查询顶层目录,如果没有则创建
-        DocDir docDir = new DocDir();
-        docDir.setSpaceId(docSpace.getSpaceId());
-        List<DocDir> list = docDirService.selectDocDirList(docDir);
-        if (list.size() == 0) {
-            docDir.setDirName(docSpace.getSpaceName());
-            docDir.setParentId(0L);
-            docDirService.insertDocDir(docDir);
-
-            list = docDirService.selectDocDirList(docDir);
-        }
+        List<DocDir> list = topDir(docSpace.getSpaceId(), docSpace.getSpaceName());
         return success(list);
     }
 
@@ -119,18 +110,79 @@ public class DocDirController extends BaseController {
         } else {
             docSpace = spaceList.get(0);
         }
+        List<DocDir> list = topDir(docSpace.getSpaceId(), docSpace.getSpaceName());
+        return success(list);
+    }
+
+    /**
+     * 查询部门空间的目录
+     */
+    @GetMapping("/list/dept")
+    public AjaxResult deptList() {
+        //1.先查询分组空间,如果没有则创建
+        DocSpace docSpace = new DocSpace();
+        SysUser sysUser = SecurityUtils.getLoginUser().getSysUser();
+        docSpace.setOwner(sysUser.getDeptId());
+        docSpace.setSpaceType(DocOfType.DEPT.getValue());
+        List<DocSpace> spaceList = docSpaceService.selectDocSpaceList(docSpace);
+        if (spaceList.size() == 0) {
+            //初始化分组空间
+            docSpace.setSpaceName("\"" + sysUser.getDept().getDeptName() + "\"的部门空间");
+            R<String> defaultCap = remoteConfigService.selectConfigByKey("dept.default.cap", SecurityConstants.INNER);
+            BigDecimal cap = new BigDecimal(defaultCap.getMsg());
+            docSpace.setSpaceCap(cap);
+            docSpace.setCreateBy(SecurityUtils.getUsername());
+            docSpaceService.insertDocSpace(docSpace);
+        } else {
+            docSpace = spaceList.get(0);
+        }
+
+        List<DocDir> list = topDir(docSpace.getSpaceId(), docSpace.getSpaceName());
+        return success(list);
+    }
+
+    /**
+     * 查询公共空间的目录
+     */
+    @GetMapping("/list/public")
+    public AjaxResult publicList() {
+        //1.先查询分组空间,如果没有则创建
+        DocSpace docSpace = new DocSpace();
+        docSpace.setOwner(0L);
+        docSpace.setSpaceType(DocOfType.PUBLIC.getValue());
+        List<DocSpace> spaceList = docSpaceService.selectDocSpaceList(docSpace);
+        if (spaceList.size() == 0) {
+            //初始化分组空间
+            docSpace.setSpaceName("\"公共文档\"空间");
+            docSpace.setCreateBy(SecurityUtils.getUsername());
+            docSpaceService.insertDocSpace(docSpace);
+        } else {
+            docSpace = spaceList.get(0);
+        }
+
+        List<DocDir> list = topDir(docSpace.getSpaceId(), docSpace.getSpaceName());
+        return success(list);
+    }
+
+    /**
+     * 查询顶层目录,如果没有则创建
+     *
+     * @param spaceId   空间ID
+     * @param spaceName 空间名称
+     * @return
+     */
+    private List<DocDir> topDir(Long spaceId, String spaceName) {
         //2.查询顶层目录,如果没有则创建
         DocDir docDir = new DocDir();
-        docDir.setSpaceId(docSpace.getSpaceId());
+        docDir.setSpaceId(spaceId);
         List<DocDir> list = docDirService.selectDocDirList(docDir);
         if (list.size() == 0) {
-            docDir.setDirName(docSpace.getSpaceName());
+            docDir.setDirName(spaceName);
             docDir.setParentId(0L);
             docDirService.insertDocDir(docDir);
-
             list = docDirService.selectDocDirList(docDir);
         }
-        return success(list);
+        return list;
     }
 
     /**

+ 13 - 1
lzga-modules/lzga-doc/src/main/java/com/jjt/doc/controller/DocGroupController.java

@@ -42,7 +42,6 @@ public class DocGroupController extends BaseController {
     /**
      * 查询分组列表
      */
-//    @RequiresPermissions("doc:group:select")
     @GetMapping("/select")
     public TableDataInfo select(DocGroup docGroup) {
         startPage();
@@ -52,6 +51,19 @@ public class DocGroupController extends BaseController {
     }
 
     /**
+     * 查询分组列表
+     */
+    @GetMapping("/selectDoc")
+    public TableDataInfo selectDoc(DocGroup docGroup) {
+        startPage();
+        docGroup.setGroupManager(SecurityUtils.getUserId());
+        //传1则表示 分组成员的查询
+        docGroup.setSearchValue("1");
+        List<DocGroup> list = docGroupService.getGroupByUid(docGroup);
+        return getDataTable(list);
+    }
+
+    /**
      * 导出分组列表
      */
     @RequiresPermissions("doc:group:export")

+ 13 - 51
lzga-modules/lzga-doc/src/main/java/com/jjt/doc/controller/DocSpaceController.java

@@ -78,42 +78,7 @@ public class DocSpaceController extends BaseController {
         DocSpace docSpace = new DocSpace();
         docSpace.setOwner(uid);
         docSpace.setSpaceType(DocOfType.PERSONAL.getValue());
-        List<DocSpace> list = docSpaceService.selectDocSpaceList(docSpace);
-        docSpace = list.get(0);
-        //查询是否有已申请扩容未审批的记录
-        DocSpaceExpand expand = new DocSpaceExpand();
-        expand.setSpaceId(docSpace.getSpaceId());
-        expand.setExpandStatus("1");
-        List expandList = expandService.selectDocSpaceExpandList(expand);
-        if (expandList.size() > 0) {
-            docSpace.setIsApply("1");
-        } else {
-            docSpace.setIsApply("0");
-        }
-        return success(docSpace);
-    }
-
-    /**
-     * 获取公共存储空间信息
-     */
-    @GetMapping(value = "/public")
-    public AjaxResult getPublicSpace() {
-        Long uid = SecurityUtils.getUserId();
-        DocSpace docSpace = new DocSpace();
-        docSpace.setOwner(uid);
-        docSpace.setSpaceType(DocOfType.PUBLIC.getValue());
-        List<DocSpace> list = docSpaceService.selectDocSpaceList(docSpace);
-        docSpace = list.get(0);
-        //查询是否有已申请扩容未审批的记录
-        DocSpaceExpand expand = new DocSpaceExpand();
-        expand.setSpaceId(docSpace.getSpaceId());
-        expand.setExpandStatus("1");
-        List expandList = expandService.selectDocSpaceExpandList(expand);
-        if (expandList.size() > 0) {
-            docSpace.setIsApply("1");
-        } else {
-            docSpace.setIsApply("0");
-        }
+        process(docSpace);
         return success(docSpace);
     }
 
@@ -122,22 +87,11 @@ public class DocSpaceController extends BaseController {
      */
     @GetMapping(value = "/dept")
     public AjaxResult getDeptSpace() {
-        Long uid = SecurityUtils.getUserId();
+        Long uid = SecurityUtils.getLoginUser().getSysUser().getDeptId();
         DocSpace docSpace = new DocSpace();
         docSpace.setOwner(uid);
         docSpace.setSpaceType(DocOfType.DEPT.getValue());
-        List<DocSpace> list = docSpaceService.selectDocSpaceList(docSpace);
-        docSpace = list.get(0);
-        //查询是否有已申请扩容未审批的记录
-        DocSpaceExpand expand = new DocSpaceExpand();
-        expand.setSpaceId(docSpace.getSpaceId());
-        expand.setExpandStatus("1");
-        List expandList = expandService.selectDocSpaceExpandList(expand);
-        if (expandList.size() > 0) {
-            docSpace.setIsApply("1");
-        } else {
-            docSpace.setIsApply("0");
-        }
+        process(docSpace);
         return success(docSpace);
     }
 
@@ -146,10 +100,19 @@ public class DocSpaceController extends BaseController {
      */
     @GetMapping(value = "/group/{groupId}")
     public AjaxResult getGroupSpace(Long groupId) {
-        Long uid = SecurityUtils.getUserId();
         DocSpace docSpace = new DocSpace();
         docSpace.setOwner(groupId);
         docSpace.setSpaceType(DocOfType.GROUP.getValue());
+        process(docSpace);
+        return success(docSpace);
+    }
+
+    /**
+     * 公共方法处理空间信息
+     *
+     * @param docSpace
+     */
+    private void process(DocSpace docSpace) {
         List<DocSpace> list = docSpaceService.selectDocSpaceList(docSpace);
         docSpace = list.get(0);
         //查询是否有已申请扩容未审批的记录
@@ -162,7 +125,6 @@ public class DocSpaceController extends BaseController {
         } else {
             docSpace.setIsApply("0");
         }
-        return success(docSpace);
     }
 
     /**

+ 7 - 1
lzga-modules/lzga-doc/src/main/resources/mapper/doc/DocGroupMapper.xml

@@ -52,7 +52,13 @@
     <select id="getGroupByUid" parameterType="DocGroup" resultType="com.jjt.doc.domain.DocGroup">
         <include refid="selectDocGroupVo"/>
         <where>
-            is_del!='1' and GROUP_MANAGER = #{groupManager}
+            is_del!='1'
+            <choose>
+                <when test="searchValue!=null and searchValue=='1'">and (GROUP_MANAGER = #{groupManager} or group_id in
+                    (select group_id from doc_group_user where user_id=#{groupManager}))
+                </when>
+                <otherwise>and GROUP_MANAGER = #{groupManager}</otherwise>
+            </choose>
             <if test="groupManagerName != null  and groupManagerName != ''">and GROUP_MANAGER_NAME like concat('%',
                 #{groupManagerName}, '%')
             </if>

+ 10 - 1
lzga-ui/src/api/doc/group.js

@@ -17,6 +17,15 @@ export function selectGroup(query) {
   })
 }
 
+// 查询分组列表
+export function selectGroupDoc(query) {
+  return request({
+    url: '/doc/group/selectDoc',
+    method: 'get',
+    params: query
+  })
+}
+
 // 查询分组详细
 export function getGroup(groupId) {
   return request({
@@ -49,4 +58,4 @@ export function delGroup(groupId) {
     url: '/doc/group/' + groupId,
     method: 'delete'
   })
-}
+}

+ 0 - 7
lzga-ui/src/api/doc/space.js

@@ -50,13 +50,6 @@ export function getPersonalSpace() {
     method: 'get'
   })
 }
-// 查询公共存储空间
-export function getPublicSpace() {
-  return request({
-    url: '/doc/space/public',
-    method: 'get'
-  })
-}
 // 查询部门存储空间
 export function getDeptSpace() {
   return request({

+ 14 - 0
lzga-ui/src/router/index.js

@@ -335,6 +335,20 @@ export const dynamicRoutes = [{
     }
   }]
 }, {
+  path: '/doc/group-doc/',
+  component: Layout,
+  hidden: true,
+  permissions: ['doc:groupDoc'],
+  children: [{
+    path: 'doc/:groupId(\\d+)',
+    component: () => import('@/views/doc/info/groupDoc'),
+    name: 'GroupSpace',
+    meta: {
+      title: '分组文档',
+      activeMenu: '/doc/groupDoc'
+    }
+  }]
+}, {
   path: '/doc/share-user/',
   component: Layout,
   hidden: true,

+ 71 - 13
lzga-ui/src/views/doc/dir/deptSpace.vue

@@ -2,8 +2,8 @@
   <div class="app-container">
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
-          v-hasPermi="['doc:dir:add']">新增</el-button>
+        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['doc:dir:add']"
+          v-hasRole="['dept.manager']">新增</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button>
@@ -17,15 +17,22 @@
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
-            v-hasPermi="['doc:dir:add']">新增</el-button>
+            v-hasPermi="['doc:dir:add']" v-hasRole="['dept.manager']">新增</el-button>
           <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-edit"
-            @click="handleUpdate(scope.row)" v-hasPermi="['doc:dir:edit']">修改</el-button>
+            @click="handleUpdate(scope.row)" v-hasPermi="['doc:dir:edit']" v-hasRole="['dept.manager']">修改</el-button>
           <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-delete"
-            @click="handleDelete(scope.row)" v-hasPermi="['doc:dir:remove']">删除</el-button>
+            @click="handleDelete(scope.row)" v-hasPermi="['doc:dir:remove']"
+            v-hasRole="['dept.manager']">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
-
+    <!-- 个人空间相关信息 -->
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        总容量:{{spaceData.spaceCap}} GB 已使用容量:{{spaceData.usedCap}} GB 可用容量:{{spaceData.avlCap}} GB
+        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleExpand">扩容申请</el-button>
+      </el-col>
+    </el-row>
     <!-- 添加或修改目录信息对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
@@ -44,6 +51,22 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+    <!-- 扩容申请对话框 -->
+    <el-dialog :title="title" :visible.sync="openSpace" width="500px" append-to-body>
+      <el-form ref="formSpace" :model="formSpace" :rules="rulesSpace" label-width="80px">
+        <el-form-item label="扩充容量" prop="expandCap">
+          <el-input-number v-model="formSpace.expandCap" placeholder="扩充容量"></el-input-number><label>GB</label>
+        </el-form-item>
+        <el-form-item label="申请理由" prop="remark">
+          <el-input v-model="formSpace.remark" type="textarea" rows="5" placeholder="请输入申请理由" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFormSpace">确 定</el-button>
+        <el-button @click="cancelSpace">取 消</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -54,11 +77,11 @@
     delDir,
     addDir,
     updateDir,
-    personalList
+    deptList
   } from "@/api/doc/dir";
 
   import {
-    getPersonalSpace
+    getDeptSpace
   } from "@/api/doc/space";
 
   import {
@@ -73,7 +96,7 @@
   import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 
   export default {
-    name: "Dir",
+    name: "DeptSpace",
     components: {
       Treeselect
     },
@@ -136,13 +159,13 @@
     },
     created() {
       this.getList();
-      this.spaceInfo();
+      // this.spaceInfo();
     },
     methods: {
       /** 查询个人空间相关信息 */
       spaceInfo() {
         this.loading = true;
-        getPersonalSpace().then(response => {
+        getDeptSpace().then(response => {
           this.spaceData = response.data;
           this.loading = false;
         });
@@ -150,9 +173,13 @@
       /** 查询目录信息列表 */
       getList() {
         this.loading = true;
-        personalList().then(response => {
+        deptList().then(response => {
           this.dirList = this.handleTree(response.data, "dirId");
           this.loading = false;
+          getDeptSpace().then(response => {
+            this.spaceData = response.data;
+            this.loading = false;
+          });
         });
       },
       /** 转换目录信息数据结构 */
@@ -213,7 +240,26 @@
         }
         this.open = true;
         this.title = "添加目录信息";
-        personalList().then(response => {
+        deptList().then(response => {
+          this.form.spaceId = response.data[0].spaceId;
+          this.dirOptions = this.handleTree(response.data, "dirId");
+        });
+      },
+      /** 扩容申请 */
+      handleExpand(row) {
+        this.formSpace.currentCap = this.spaceData.spaceCap;
+        this.formSpace.spaceId = this.spaceData.spaceId;
+        this.formSpace.spaceName = this.spaceData.spaceName;
+        this.reset();
+        // this.getTreeselect();
+        if (row != null && row.dirId) {
+          this.form.parentId = row.dirId;
+          // } else {
+          // 	this.form.parentId = 0;
+        }
+        this.openSpace = true;
+        this.title = "扩容申请";
+        deptList().then(response => {
           this.form.spaceId = response.data[0].spaceId;
           this.dirOptions = this.handleTree(response.data, "dirId");
         });
@@ -261,6 +307,18 @@
           }
         });
       },
+      /** 提交按钮 */
+      submitFormSpace() {
+        console.log(this.formSpace);
+        this.$refs["formSpace"].validate(valid => {
+          if (valid) {
+            addExpand(this.formSpace).then(response => {
+              this.$modal.msgSuccess("扩容申请提交成功");
+              this.openSpace = false;
+            });
+          }
+        });
+      },
       /** 删除按钮操作 */
       handleDelete(row) {
         this.$modal.confirm('是否确认删除目录信息编号为"' + row.dirId + '"的数据项?').then(function() {

+ 3 - 2
lzga-ui/src/views/doc/dir/groupSpace.vue

@@ -164,7 +164,6 @@
         this.queryParams.groupId = groupId;
         this.getList();
       }
-      this.spaceInfo();
     },
     methods: {
       /** 查询个人空间相关信息 */
@@ -181,6 +180,8 @@
         groupList(this.queryParams.groupId).then(response => {
           this.dirList = this.handleTree(response.data, "dirId");
           this.loading = false;
+          //放这里,避免没创建空间时报错
+          this.spaceInfo();
         });
       },
       /** 转换目录信息数据结构 */
@@ -331,4 +332,4 @@
       }
     }
   };
-</script>
+</script>

+ 10 - 44
lzga-ui/src/views/doc/dir/publicSpace.vue

@@ -2,8 +2,8 @@
   <div class="app-container">
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
-          v-hasPermi="['doc:dir:add']">新增</el-button>
+        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['doc:dir:add']"
+          v-hasRole="['public.manager']">新增</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button>
@@ -17,15 +17,15 @@
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
-            v-hasPermi="['doc:dir:add']">新增</el-button>
+            v-hasPermi="['doc:dir:add']" v-hasRole="['public.manager']">新增</el-button>
           <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-edit"
-            @click="handleUpdate(scope.row)" v-hasPermi="['doc:dir:edit']">修改</el-button>
+            @click="handleUpdate(scope.row)" v-hasPermi="['doc:dir:edit']" v-hasRole="['public.manager']">修改</el-button>
           <el-button v-if="scope.row.parentId != 0" size="mini" type="text" icon="el-icon-delete"
-            @click="handleDelete(scope.row)" v-hasPermi="['doc:dir:remove']">删除</el-button>
+            @click="handleDelete(scope.row)" v-hasPermi="['doc:dir:remove']"
+            v-hasRole="['public.manager']">删除</el-button>
         </template>
       </el-table-column>
     </el-table>
-
     <!-- 添加或修改目录信息对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
@@ -54,26 +54,14 @@
     delDir,
     addDir,
     updateDir,
-    personalList
+    publicList
   } from "@/api/doc/dir";
 
-  import {
-    getPersonalSpace
-  } from "@/api/doc/space";
-
-  import {
-    listExpand,
-    getExpand,
-    delExpand,
-    addExpand,
-    updateExpand
-  } from "@/api/doc/expand";
-
   import Treeselect from "@riophae/vue-treeselect";
   import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 
   export default {
-    name: "Dir",
+    name: "DeptSpace",
     components: {
       Treeselect
     },
@@ -118,39 +106,17 @@
             message: "上级目录不能为空",
             trigger: "blur"
           }],
-        },
-        // 表单校验
-        rulesSpace: {
-          expandCap: [{
-            required: true,
-            message: "扩容容量不能为空",
-            trigger: "blur"
-          }],
-          remark: [{
-            required: true,
-            message: "申请理由不能为空",
-            trigger: "blur"
-          }],
         }
       };
     },
     created() {
       this.getList();
-      this.spaceInfo();
     },
     methods: {
-      /** 查询个人空间相关信息 */
-      spaceInfo() {
-        this.loading = true;
-        getPersonalSpace().then(response => {
-          this.spaceData = response.data;
-          this.loading = false;
-        });
-      },
       /** 查询目录信息列表 */
       getList() {
         this.loading = true;
-        personalList().then(response => {
+        publicList().then(response => {
           this.dirList = this.handleTree(response.data, "dirId");
           this.loading = false;
         });
@@ -213,7 +179,7 @@
         }
         this.open = true;
         this.title = "添加目录信息";
-        personalList().then(response => {
+        publicList().then(response => {
           this.form.spaceId = response.data[0].spaceId;
           this.dirOptions = this.handleTree(response.data, "dirId");
         });