dev_xd
姜玉琦 2024-09-17 23:38:52 +08:00
parent 286e8abc0a
commit cf9af39a16
8 changed files with 130 additions and 38 deletions

View File

@ -69,6 +69,7 @@ public class TokenController
user.setActiveComId(Convert.toLong(proData.get("comId")));
user.setActiveProjectId(Convert.toLong(proData.get("id")));
user.setActiveProjectName(Convert.toStr(proData.get("projectName")));
loginUser.setSysUser(user);
loginUser.setProjectId(Convert.toLong(proData.get("id")));
loginUser.setProjectName(Convert.toStr(proData.get("projectName")));
loginUser.setProjectDeptId(Convert.toLong(proData.get("comId")));
@ -98,6 +99,36 @@ public class TokenController
return R.fail();
}
/**
*
* @return
*/
@GetMapping("/cancelProject")
public R<?> cancelProject(HttpServletRequest request)
{
LoginUser loginUser = tokenService.getLoginUser(request);
if(SecurityUtils.isAdmin(loginUser.getUserid())){
SysUser user = loginUser.getSysUser();
user.setActiveComId(null);
user.setActiveProjectId(null);
user.setActiveProjectName(null);
loginUser.setSysUser(user);
loginUser.setProjectId(null);
loginUser.setProjectName(null);
loginUser.setProjectDeptId(null);
}else{
SysUser user = loginUser.getSysUser();
user.setActiveProjectId(null);
user.setActiveProjectName(null);
loginUser.setSysUser(user);
loginUser.setProjectId(null);
loginUser.setProjectName(null);
}
// 刷新令牌有效期
tokenService.refreshToken(loginUser);
return R.ok();
}
@DeleteMapping("logout")
public R<?> logout(HttpServletRequest request)
{

View File

@ -9,9 +9,6 @@ public class ProDept extends BaseEntity
/** 部门ID */
private Long deptId;
/** 公司编号 */
private Long comId;
/** 父部门ID */
private Long parentId;
@ -50,14 +47,6 @@ public class ProDept extends BaseEntity
this.deptId = deptId;
}
public Long getComId() {
return comId;
}
public void setComId(Long comId) {
this.comId = comId;
}
public Long getParentId() {
return parentId;
}

View File

@ -253,7 +253,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<insert id="insertDept" parameterType="ProDept" useGeneratedKeys="true" keyProperty="id">
<insert id="insertDept" parameterType="ProDept" useGeneratedKeys="true" keyProperty="deptId">
insert into sys_dept(
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
@ -265,8 +265,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if>
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
@ -280,11 +278,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<update id="updateDept" parameterType="ProDept">
update sys_dept
<set>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="deptShortName != null and deptShortName != ''">dept_short_name = #{deptShortName},</if>
<if test="deptCode != null and deptCode != ''">dept_code = #{deptCode},</if>
<if test="deptType != null and deptType != ''">dept_type = #{deptType},</if>
<if test="deptInfos != null and deptInfos != ''">dept_infos = #{deptInfos},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate()
</set>
where dept_id = #{deptId}
</update>
</mapper>

View File

@ -3,6 +3,7 @@ package com.yanzhu.system.service.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.yanzhu.common.datascope.annotation.DataScope;
@ -219,7 +220,13 @@ public class SysDeptServiceImpl implements ISysDeptService
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
dept.setComId(info.getComId());
int res = deptMapper.insertDept(dept);
if(Objects.equals(dept.getDeptType(),"2") && Objects.isNull(info.getComId())){
dept.setComId(dept.getDeptId());
deptMapper.updateDept(dept);
}
return res;
}
/**

View File

@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="SysDept" id="SysDeptResult">
<id property="deptId" column="dept_id" />
<result property="comId" column="com_id" />
<result property="parentId" column="parent_id" />
<result property="ancestors" column="ancestors" />
<result property="deptName" column="dept_name" />
@ -27,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_short_name, d.dept_code, d.dept_type, d.dept_infos, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
select d.dept_id, d.com_id, d.parent_id, d.ancestors, d.dept_name, d.dept_short_name, d.dept_code, d.dept_type, d.dept_infos, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
</sql>
@ -81,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDeptVo"/>
where dept_id = #{deptId}
</select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select>
@ -106,6 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertDept" parameterType="SysDept">
insert into sys_dept(
<if test="comId != null and comId != 0">com_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
@ -122,6 +124,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createBy != null and createBy != ''">create_by,</if>
create_time
)values(
<if test="comId != null and comId != 0">#{comId},</if>
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
@ -143,6 +146,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<update id="updateDept" parameterType="SysDept">
update sys_dept
<set>
<if test="comId != null and comId != 0">com_id = #{comId},</if>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>

View File

@ -40,6 +40,14 @@ export function switchProject(proId) {
})
}
// 取消项目登录
export function cancelProject() {
return request({
url: '/auth/cancelProject',
method: 'get'
})
}
// 获取用户详细信息
export function getInfo() {
return request({

View File

@ -16,6 +16,7 @@
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery"></el-button>
<el-button icon="Refresh" @click="resetQuery"></el-button>
<el-button v-if="userStore.currentProId && isAdmin" type="danger" icon="CircleClose" @click="circleClose"></el-button>
</el-form-item>
</el-form>
@ -48,6 +49,11 @@
v-model:limit="queryParams.pageSize"
@pagination="getProjectList"
/>
<template #footer>
<div class="dialog-footer">
<el-button @click="cancel"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
@ -55,10 +61,9 @@
<script setup name="CurrentProject">
import { OfficeBuilding } from '@element-plus/icons-vue'
import { findMyProjectList } from "@/api/publics";
import { switchProject } from '@/api/login'
import { switchProject, cancelProject } from '@/api/login'
import { changeDefaultProject } from "@/api/manage/proProjectInfoUsers";
const { proxy } = getCurrentInstance();
import useUserStore from '@/store/modules/user'
@ -110,11 +115,6 @@ function resetQuery() {
handleQuery();
}
/** 提交按钮 */
function submitForm() {
}
/** 改变默认项目 */
function changeDefault(proId) {
if(isAdmin.value){
@ -134,6 +134,15 @@ function changeDefault(proId) {
}
}
/** 取消切换项目 */
function circleClose() {
cancelProject().then(res =>{
if(res.code==200){
window.location.reload();
}
})
}
/** 显示项目列表 */
function showProList() {
getProjectList();
@ -158,9 +167,8 @@ initPage();
padding-bottom: 50px;
.pagination-container{
margin-top: 0px;
padding-bottom: 30px !important;
.el-pagination{
margin-right: 50px;
margin-right: 22px;
}
}
}

View File

@ -10,8 +10,8 @@
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="部门状态" clearable style="width: 200px">
<el-form-item label="部门状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择部门状态" clearable style="width: 200px">
<el-option
v-for="dict in sys_normal_disable"
:key="dict.value"
@ -56,14 +56,14 @@
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
<el-table-column prop="deptShortName" label="部门简称"></el-table-column>
<el-table-column prop="sys_dept_type" label="部门类型">
<el-table-column prop="deptShortName" label="部门简称" align="center"/>
<el-table-column prop="sys_dept_type" label="部门类型" align="center">
<template #default="scope">
<dict-tag :options="sys_dept_type" :value="scope.row.deptType" />
</template>
</el-table-column>
<el-table-column prop="orderNum" label="排序" width="100"></el-table-column>
<el-table-column prop="status" label="状态" width="100">
<el-table-column prop="orderNum" align="center" label="排序" width="100"></el-table-column>
<el-table-column prop="status" align="center" label="部门状态" width="100">
<template #default="scope">
<dict-tag :options="sys_normal_disable" :value="scope.row.status" />
</template>
@ -75,9 +75,11 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']"></el-button>
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']"></el-button>
<el-button v-if="scope.row.parentId != 0" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']"></el-button>
<div v-if="scope.row.deptType!='4'">
<el-button v-if="scope.row.deptId!=scope.row.comId || (isAdmin && scope.row.deptId==scope.row.comId)" link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:dept:edit']"></el-button>
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['system:dept:add']"></el-button>
<el-button v-if="scope.row.parentId != 0 && scope.row.deptId!=scope.row.comId" link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:dept:remove']"></el-button>
</div>
</template>
</el-table-column>
</el-table>
@ -105,10 +107,22 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="部门类型" prop="deptType">
<el-form-item v-if="isAdmin" label="部门类型" prop="deptType">
<el-select v-model="form.deptType" placeholder="请选择部门类型" style="width: 100%">
<el-option
v-for="dict in sys_dept_type"
v-show="dict.value!='4'"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="!isAdmin" label="部门类型" prop="deptType">
<el-select v-model="form.deptType" placeholder="请选择部门类型" style="width: 100%">
<el-option
v-for="dict in sys_dept_type"
v-show="dict.value!='4' && dict.value!='2'"
:key="dict.value"
:label="dict.label"
:value="dict.value"
@ -169,7 +183,11 @@ import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild }
const { proxy } = getCurrentInstance();
const { sys_dept_type, sys_normal_disable } = proxy.useDict("sys_dept_type", "sys_normal_disable");
import useUserStore from '@/store/modules/user'
const userStore = useUserStore()
const isAdmin = ref(false);
const deptList = ref([]);
const open = ref(false);
const loading = ref(true);
@ -300,5 +318,17 @@ function handleDelete(row) {
}).catch(() => {});
}
/** 初始化页面 */
function initPage() {
let roles = userStore.roles;
if(roles.includes("admin")){
isAdmin.value = true;
}else{
isAdmin.value = false;
}
}
initPage();
getList();
</script>