This commit is contained in:
Vinjor 2025-11-24 11:31:19 +08:00
commit a3e8c72163
4 changed files with 93 additions and 23 deletions

View File

@ -37,6 +37,9 @@ public class SysDept extends BaseEntity
/** 负责人 */ /** 负责人 */
private String leader; private String leader;
/** 负责人id */
private Long leaderId;
/** 联系电话 */ /** 联系电话 */
private String phone; private String phone;
@ -118,6 +121,16 @@ public class SysDept extends BaseEntity
this.leader = leader; this.leader = leader;
} }
public Long getLeaderId()
{
return leaderId;
}
public void setLeaderId(Long leaderId)
{
this.leaderId = leaderId;
}
@Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符") @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
public String getPhone() public String getPhone()
{ {
@ -190,6 +203,7 @@ public class SysDept extends BaseEntity
.append("deptName", getDeptName()) .append("deptName", getDeptName())
.append("orderNum", getOrderNum()) .append("orderNum", getOrderNum())
.append("leader", getLeader()) .append("leader", getLeader())
.append("leaderId", getLeaderId())
.append("phone", getPhone()) .append("phone", getPhone())
.append("email", getEmail()) .append("email", getEmail())
.append("status", getStatus()) .append("status", getStatus())

View File

@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="deptName" column="dept_name" /> <result property="deptName" column="dept_name" />
<result property="orderNum" column="order_num" /> <result property="orderNum" column="order_num" />
<result property="leader" column="leader" /> <result property="leader" column="leader" />
<result property="leaderId" column="leader_id" />
<result property="phone" column="phone" /> <result property="phone" column="phone" />
<result property="email" column="email" /> <result property="email" column="email" />
<result property="status" column="status" /> <result property="status" column="status" />
@ -21,14 +22,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time" />
</resultMap> </resultMap>
<sql id="selectDeptVo"> <sql id="selectDeptVo">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, 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.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader,d.leader_id, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d from sys_dept d
</sql> </sql>
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult"> <select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, u.nick_name as leader,d.leader_id, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time
from sys_dept d
left join sys_user u on d.leader_id = u.user_id
where d.del_flag = '0' where d.del_flag = '0'
<if test="deptId != null and deptId != 0"> <if test="deptId != null and deptId != 0">
AND dept_id = #{deptId} AND dept_id = #{deptId}
@ -46,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
${params.dataScope} ${params.dataScope}
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
<select id="selectDeptListByRoleId" resultType="Long"> <select id="selectDeptListByRoleId" resultType="Long">
select d.dept_id select d.dept_id
from sys_dept d from sys_dept d
@ -57,36 +60,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
order by d.parent_id, d.order_num order by d.parent_id, d.order_num
</select> </select>
<select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult"> <select id="selectDeptById" parameterType="Long" resultMap="SysDeptResult">
select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader,d.leader_id, d.phone, d.email, d.status,
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name (select dept_name from sys_dept where dept_id = d.parent_id) parent_name
from sys_dept d from sys_dept d
where d.dept_id = #{deptId} where d.dept_id = #{deptId}
</select> </select>
<select id="checkDeptExistUser" parameterType="Long" resultType="int"> <select id="checkDeptExistUser" parameterType="Long" resultType="int">
select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0' select count(1) from sys_user where dept_id = #{deptId} and del_flag = '0'
</select> </select>
<select id="hasChildByDeptId" parameterType="Long" resultType="int"> <select id="hasChildByDeptId" parameterType="Long" resultType="int">
select count(1) from sys_dept select count(1) from sys_dept
where del_flag = '0' and parent_id = #{deptId} limit 1 where del_flag = '0' and parent_id = #{deptId} limit 1
</select> </select>
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult"> <select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
select * from sys_dept where find_in_set(#{deptId}, ancestors) select * from sys_dept where find_in_set(#{deptId}, ancestors)
</select> </select>
<select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int"> <select id="selectNormalChildrenDeptById" parameterType="Long" resultType="int">
select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors) select count(*) from sys_dept where status = 0 and del_flag = '0' and find_in_set(#{deptId}, ancestors)
</select> </select>
<select id="checkDeptNameUnique" resultMap="SysDeptResult"> <select id="checkDeptNameUnique" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1 where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
</select> </select>
<insert id="insertDept" parameterType="SysDept"> <insert id="insertDept" parameterType="SysDept">
insert into sys_dept( insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if> <if test="deptId != null and deptId != 0">dept_id,</if>
@ -95,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null and ancestors != ''">ancestors,</if> <if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if> <if test="orderNum != null">order_num,</if>
<if test="leader != null and leader != ''">leader,</if> <if test="leader != null and leader != ''">leader,</if>
<if test="leaderId != null and leaderId != ''">leader_id,</if>
<if test="phone != null and phone != ''">phone,</if> <if test="phone != null and phone != ''">phone,</if>
<if test="email != null and email != ''">email,</if> <if test="email != null and email != ''">email,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
@ -107,6 +111,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null and ancestors != ''">#{ancestors},</if> <if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if> <if test="orderNum != null">#{orderNum},</if>
<if test="leader != null and leader != ''">#{leader},</if> <if test="leader != null and leader != ''">#{leader},</if>
<if test="leaderId != null and leaderId != ''">#{leaderId},</if>
<if test="phone != null and phone != ''">#{phone},</if> <if test="phone != null and phone != ''">#{phone},</if>
<if test="email != null and email != ''">#{email},</if> <if test="email != null and email != ''">#{email},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
@ -114,7 +119,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
sysdate() sysdate()
) )
</insert> </insert>
<update id="updateDept" parameterType="SysDept"> <update id="updateDept" parameterType="SysDept">
update sys_dept update sys_dept
<set> <set>
@ -123,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if> <if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if> <if test="orderNum != null">order_num = #{orderNum},</if>
<if test="leader != null">leader = #{leader},</if> <if test="leader != null">leader = #{leader},</if>
<if test="leaderId != null">leader_id = #{leaderId},</if>
<if test="phone != null">phone = #{phone},</if> <if test="phone != null">phone = #{phone},</if>
<if test="email != null">email = #{email},</if> <if test="email != null">email = #{email},</if>
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
@ -131,7 +137,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</set> </set>
where dept_id = #{deptId} where dept_id = #{deptId}
</update> </update>
<update id="updateDeptChildren" parameterType="java.util.List"> <update id="updateDeptChildren" parameterType="java.util.List">
update sys_dept set ancestors = update sys_dept set ancestors =
<foreach collection="depts" item="item" index="index" <foreach collection="depts" item="item" index="index"
@ -144,14 +150,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{item.deptId} #{item.deptId}
</foreach> </foreach>
</update> </update>
<update id="updateDeptStatusNormal" parameterType="Long"> <update id="updateDeptStatusNormal" parameterType="Long">
update sys_dept set status = '0' where dept_id in update sys_dept set status = '0' where dept_id in
<foreach collection="array" item="deptId" open="(" separator="," close=")"> <foreach collection="array" item="deptId" open="(" separator="," close=")">
#{deptId} #{deptId}
</foreach> </foreach>
</update> </update>
<delete id="deleteDeptById" parameterType="Long"> <delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '2' where dept_id = #{deptId} update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete> </delete>

View File

@ -366,7 +366,6 @@ export default {
} }
listCountry(queryParams).then(response => { listCountry(queryParams).then(response => {
this.countryList = response.data.records; this.countryList = response.data.records;
this.total = response.data.total;
this.countryLoading = false; this.countryLoading = false;
}); });
} else { } else {

View File

@ -57,6 +57,7 @@
:tree-props="{children: 'children', hasChildren: 'hasChildren'}" :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
> >
<el-table-column prop="deptName" label="部门名称" width="260"></el-table-column> <el-table-column prop="deptName" label="部门名称" width="260"></el-table-column>
<el-table-column prop="leader" label="部门负责人" width="260"></el-table-column>
<el-table-column prop="orderNum" label="排序" width="200"></el-table-column> <el-table-column prop="orderNum" label="排序" width="200"></el-table-column>
<el-table-column prop="status" label="状态" width="100"> <el-table-column prop="status" label="状态" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
@ -120,8 +121,22 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="负责人" prop="leader"> <el-form-item label="负责人" prop="leaderId">
<el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" /> <el-select style="width: 100%"
filterable
remote
v-model="form.leaderId"
placeholder="请选择部门负责人"
:remote-method="remoteMethod"
:loading="userLoading"
clearable>
<el-option
v-for="item in userList"
:key="item.userId"
:label="item.nickName+'('+item.userName+')'"
:value="item.userId"
/>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -161,7 +176,7 @@
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept"; import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { listUser } from "@/api/system/user";
export default { export default {
name: "Dept", name: "Dept",
dicts: ['sys_normal_disable'], dicts: ['sys_normal_disable'],
@ -189,6 +204,11 @@ export default {
deptName: undefined, deptName: undefined,
status: undefined status: undefined
}, },
//
userList: [],
userLoading: false,
// //
form: {}, form: {},
// //
@ -199,6 +219,9 @@ export default {
deptName: [ deptName: [
{ required: true, message: "部门名称不能为空", trigger: "blur" } { required: true, message: "部门名称不能为空", trigger: "blur" }
], ],
leaderId:[
{ required: true, message: "部门负责人不能为空", trigger: "blur" }
],
orderNum: [ orderNum: [
{ required: true, message: "显示排序不能为空", trigger: "blur" } { required: true, message: "显示排序不能为空", trigger: "blur" }
], ],
@ -223,6 +246,31 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
/**选中负责人*/
leaderChange(row){
},
/** 搜索用户 */
remoteMethod(query,userId){
if (query !== ''){
this.userLoading = true;
const queryParams = {
pageNum: 1,
pageSize: 10,
userName: query,
userId: userId
}
listUser(queryParams).then(res => {
this.userList = res.rows;
this.userLoading = false;
})
} else {
this.userList = []
}
},
/** 查询部门列表 */ /** 查询部门列表 */
getList() { getList() {
this.loading = true; this.loading = true;
@ -254,7 +302,7 @@ export default {
parentId: undefined, parentId: undefined,
deptName: undefined, deptName: undefined,
orderNum: undefined, orderNum: undefined,
leader: undefined, leaderId: undefined,
phone: undefined, phone: undefined,
email: undefined, email: undefined,
status: "0" status: "0"
@ -295,9 +343,11 @@ export default {
this.reset(); this.reset();
getDept(row.deptId).then(response => { getDept(row.deptId).then(response => {
this.form = response.data; this.form = response.data;
this.remoteMethod(null,this.form.leaderId)
this.open = true; this.open = true;
this.title = "修改部门"; this.title = "修改部门";
listDeptExcludeChild(row.deptId).then(response => { listDeptExcludeChild(row.deptId).then(response => {
console.log(response.data,'ssssssssssss')
this.deptOptions = this.handleTree(response.data, "deptId"); this.deptOptions = this.handleTree(response.data, "deptId");
if (this.deptOptions.length == 0) { if (this.deptOptions.length == 0) {
const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] }; const noResultsOptions = { deptId: this.form.parentId, deptName: this.form.parentName, children: [] };
@ -309,6 +359,7 @@ export default {
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
console.log(this.form,'修改内容')
if (valid) { if (valid) {
if (this.form.deptId != undefined) { if (this.form.deptId != undefined) {
updateDept(this.form).then(response => { updateDept(this.form).then(response => {