根据大屏页面需求,部门管理添加行政区划选择
This commit is contained in:
parent
77db14e9d3
commit
3c2987dc81
@ -0,0 +1,114 @@
|
||||
package com.inspur.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.inspur.common.annotation.Log;
|
||||
import com.inspur.common.core.controller.BaseController;
|
||||
import com.inspur.common.core.domain.AjaxResult;
|
||||
import com.inspur.common.enums.BusinessType;
|
||||
import com.inspur.system.domain.SysRegion;
|
||||
import com.inspur.system.service.ISysRegionService;
|
||||
import com.inspur.common.utils.poi.ExcelUtil;
|
||||
import com.inspur.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* 行政区划Controller
|
||||
*
|
||||
* @author zhanghan11
|
||||
* @date 2024-07-04
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/region")
|
||||
public class SysRegionController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysRegionService sysRegionService;
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:region:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysRegion sysRegion)
|
||||
{
|
||||
startPage();
|
||||
List<SysRegion> list = sysRegionService.selectSysRegionList(sysRegion);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:region:list')")
|
||||
@GetMapping("/listAll")
|
||||
public AjaxResult listAll(SysRegion sysRegion)
|
||||
{
|
||||
return AjaxResult.success(sysRegionService.selectSysRegionList(sysRegion));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出行政区划列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:region:export')")
|
||||
@Log(title = "行政区划", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, SysRegion sysRegion)
|
||||
{
|
||||
List<SysRegion> list = sysRegionService.selectSysRegionList(sysRegion);
|
||||
ExcelUtil<SysRegion> util = new ExcelUtil<SysRegion>(SysRegion.class);
|
||||
util.exportExcel(response, list, "行政区划数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行政区划详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:region:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
return AjaxResult.success(sysRegionService.selectSysRegionById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:region:add')")
|
||||
@Log(title = "行政区划", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody SysRegion sysRegion)
|
||||
{
|
||||
return toAjax(sysRegionService.insertSysRegion(sysRegion));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:region:edit')")
|
||||
@Log(title = "行政区划", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody SysRegion sysRegion)
|
||||
{
|
||||
return toAjax(sysRegionService.updateSysRegion(sysRegion));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除行政区划
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:region:remove')")
|
||||
@Log(title = "行政区划", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
return toAjax(sysRegionService.deleteSysRegionByIds(ids));
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ import com.inspur.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* 部门表 sys_dept
|
||||
*
|
||||
*
|
||||
* @author inspur
|
||||
*/
|
||||
public class SysDept extends BaseEntity
|
||||
@ -51,7 +51,10 @@ public class SysDept extends BaseEntity
|
||||
|
||||
/** 父部门名称 */
|
||||
private String parentName;
|
||||
|
||||
|
||||
/** 行政区划ID */
|
||||
private String regionId;
|
||||
|
||||
/** 子部门 */
|
||||
private List<SysDept> children = new ArrayList<SysDept>();
|
||||
|
||||
@ -181,6 +184,14 @@ public class SysDept extends BaseEntity
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getRegionId() {
|
||||
return regionId;
|
||||
}
|
||||
|
||||
public void setRegionId(String regionId) {
|
||||
this.regionId = regionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
@ -0,0 +1,107 @@
|
||||
package com.inspur.system.domain;
|
||||
|
||||
import com.inspur.common.annotation.Excel;
|
||||
import com.inspur.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 行政区划对象 sys_region
|
||||
*
|
||||
* @author zhanghan11
|
||||
* @date 2024-07-04
|
||||
*/
|
||||
public class SysRegion extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 主键 */
|
||||
private Long id;
|
||||
|
||||
/** 名称 */
|
||||
@Excel(name = "名称")
|
||||
private String name;
|
||||
|
||||
/** 父级ID */
|
||||
@Excel(name = "父级ID")
|
||||
private Long parentId;
|
||||
|
||||
/** 祖级列表 */
|
||||
@Excel(name = "祖级列表")
|
||||
private String ancestors;
|
||||
|
||||
/** 显示顺序 */
|
||||
@Excel(name = "显示顺序")
|
||||
private Integer orderNum;
|
||||
|
||||
/** 层级,1:省级,2:市级 */
|
||||
@Excel(name = "层级,1:省级,2:市级")
|
||||
private Integer level;
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
public void setParentId(Long parentId)
|
||||
{
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Long getParentId()
|
||||
{
|
||||
return parentId;
|
||||
}
|
||||
public void setAncestors(String ancestors)
|
||||
{
|
||||
this.ancestors = ancestors;
|
||||
}
|
||||
|
||||
public String getAncestors()
|
||||
{
|
||||
return ancestors;
|
||||
}
|
||||
public void setOrderNum(Integer orderNum)
|
||||
{
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public Integer getOrderNum()
|
||||
{
|
||||
return orderNum;
|
||||
}
|
||||
public void setLevel(Integer level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public Integer getLevel()
|
||||
{
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("name", getName())
|
||||
.append("parentId", getParentId())
|
||||
.append("ancestors", getAncestors())
|
||||
.append("orderNum", getOrderNum())
|
||||
.append("level", getLevel())
|
||||
.toString();
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.inspur.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.inspur.system.domain.SysRegion;
|
||||
|
||||
/**
|
||||
* 行政区划Mapper接口
|
||||
*
|
||||
* @author zhanghan11
|
||||
* @date 2024-07-04
|
||||
*/
|
||||
public interface SysRegionMapper
|
||||
{
|
||||
/**
|
||||
* 查询行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 行政区划
|
||||
*/
|
||||
public SysRegion selectSysRegionById(Long id);
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 行政区划集合
|
||||
*/
|
||||
public List<SysRegion> selectSysRegionList(SysRegion sysRegion);
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysRegion(SysRegion sysRegion);
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysRegion(SysRegion sysRegion);
|
||||
|
||||
/**
|
||||
* 删除行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRegionById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除行政区划
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRegionByIds(Long[] ids);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.inspur.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.inspur.system.domain.SysRegion;
|
||||
|
||||
/**
|
||||
* 行政区划Service接口
|
||||
*
|
||||
* @author zhanghan11
|
||||
* @date 2024-07-04
|
||||
*/
|
||||
public interface ISysRegionService
|
||||
{
|
||||
/**
|
||||
* 查询行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 行政区划
|
||||
*/
|
||||
public SysRegion selectSysRegionById(Long id);
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 行政区划集合
|
||||
*/
|
||||
public List<SysRegion> selectSysRegionList(SysRegion sysRegion);
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertSysRegion(SysRegion sysRegion);
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateSysRegion(SysRegion sysRegion);
|
||||
|
||||
/**
|
||||
* 批量删除行政区划
|
||||
*
|
||||
* @param ids 需要删除的行政区划主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRegionByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除行政区划信息
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteSysRegionById(Long id);
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.inspur.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.inspur.system.mapper.SysRegionMapper;
|
||||
import com.inspur.system.domain.SysRegion;
|
||||
import com.inspur.system.service.ISysRegionService;
|
||||
|
||||
/**
|
||||
* 行政区划Service业务层处理
|
||||
*
|
||||
* @author zhanghan11
|
||||
* @date 2024-07-04
|
||||
*/
|
||||
@Service
|
||||
public class SysRegionServiceImpl implements ISysRegionService
|
||||
{
|
||||
@Autowired
|
||||
private SysRegionMapper sysRegionMapper;
|
||||
|
||||
/**
|
||||
* 查询行政区划
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 行政区划
|
||||
*/
|
||||
@Override
|
||||
public SysRegion selectSysRegionById(Long id)
|
||||
{
|
||||
return sysRegionMapper.selectSysRegionById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询行政区划列表
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 行政区划
|
||||
*/
|
||||
@Override
|
||||
public List<SysRegion> selectSysRegionList(SysRegion sysRegion)
|
||||
{
|
||||
return sysRegionMapper.selectSysRegionList(sysRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增行政区划
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertSysRegion(SysRegion sysRegion)
|
||||
{
|
||||
return sysRegionMapper.insertSysRegion(sysRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改行政区划
|
||||
*
|
||||
* @param sysRegion 行政区划
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateSysRegion(SysRegion sysRegion)
|
||||
{
|
||||
return sysRegionMapper.updateSysRegion(sysRegion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除行政区划
|
||||
*
|
||||
* @param ids 需要删除的行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysRegionByIds(Long[] ids)
|
||||
{
|
||||
return sysRegionMapper.deleteSysRegionByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除行政区划信息
|
||||
*
|
||||
* @param id 行政区划主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteSysRegionById(Long id)
|
||||
{
|
||||
return sysRegionMapper.deleteSysRegionById(id);
|
||||
}
|
||||
}
|
@ -20,13 +20,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="regionId" column="region_id" />
|
||||
</resultMap>
|
||||
|
||||
|
||||
<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.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time,d.region_id
|
||||
from sys_dept d
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectDeptList" parameterType="SysDept" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where d.del_flag = '0'
|
||||
@ -46,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
${params.dataScope}
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectDeptListByRoleId" resultType="Long">
|
||||
select d.dept_id
|
||||
from sys_dept d
|
||||
@ -57,18 +58,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</if>
|
||||
order by d.parent_id, d.order_num
|
||||
</select>
|
||||
|
||||
|
||||
<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.phone, d.email, d.status,d.region_id,
|
||||
(select dept_name from sys_dept where dept_id = d.parent_id) parent_name
|
||||
from sys_dept d
|
||||
where d.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>
|
||||
|
||||
|
||||
<select id="hasChildByDeptId" parameterType="Long" resultType="int">
|
||||
select count(1) from sys_dept
|
||||
where del_flag = '0' and parent_id = #{deptId} limit 1
|
||||
@ -86,16 +87,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectChildrenDeptById" parameterType="Long" resultMap="SysDeptResult">
|
||||
select * from sys_dept where find_in_set(#{deptId}, ancestors)
|
||||
</select>
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
<select id="checkDeptNameUnique" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where dept_name=#{deptName} and parent_id = #{parentId} and del_flag = '0' limit 1
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertDept" parameterType="SysDept">
|
||||
insert into sys_dept(
|
||||
<if test="deptId != null and deptId != 0">dept_id,</if>
|
||||
@ -107,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="phone != null and phone != ''">phone,</if>
|
||||
<if test="email != null and email != ''">email,</if>
|
||||
<if test="status != null">status,</if>
|
||||
<if test="regionId != null">region_id,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
)values(
|
||||
@ -119,11 +121,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="phone != null and phone != ''">#{phone},</if>
|
||||
<if test="email != null and email != ''">#{email},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="regionId != null">#{regionId},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
|
||||
<update id="updateDept" parameterType="SysDept">
|
||||
update sys_dept
|
||||
<set>
|
||||
@ -135,12 +138,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="email != null">email = #{email},</if>
|
||||
<if test="status != null and status != ''">status = #{status},</if>
|
||||
<if test="regionId != null and regionId != ''">region_id = #{regionId},</if>
|
||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||
update_time = sysdate()
|
||||
</set>
|
||||
where dept_id = #{deptId}
|
||||
</update>
|
||||
|
||||
|
||||
<update id="updateDeptChildren" parameterType="java.util.List">
|
||||
update sys_dept set ancestors =
|
||||
<foreach collection="depts" item="item" index="index"
|
||||
@ -153,16 +157,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
#{item.deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
<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=")">
|
||||
#{deptId}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
<delete id="deleteDeptById" parameterType="Long">
|
||||
update sys_dept set del_flag = '2' where dept_id = #{deptId}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.inspur.system.mapper.SysRegionMapper">
|
||||
|
||||
<resultMap type="SysRegion" id="SysRegionResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="name" column="name" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="ancestors" column="ancestors" />
|
||||
<result property="orderNum" column="order_num" />
|
||||
<result property="level" column="level" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectSysRegionVo">
|
||||
select id, name, parent_id, ancestors, order_num, level from sys_region
|
||||
</sql>
|
||||
|
||||
<select id="selectSysRegionList" parameterType="SysRegion" resultMap="SysRegionResult">
|
||||
<include refid="selectSysRegionVo"/>
|
||||
<where>
|
||||
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
|
||||
<if test="parentId != null "> and parent_id = #{parentId}</if>
|
||||
<if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
|
||||
<if test="orderNum != null "> and order_num = #{orderNum}</if>
|
||||
<if test="level != null "> and level = #{level}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectSysRegionById" parameterType="Long" resultMap="SysRegionResult">
|
||||
<include refid="selectSysRegionVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertSysRegion" parameterType="SysRegion">
|
||||
insert into sys_region
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="name != null">name,</if>
|
||||
<if test="parentId != null">parent_id,</if>
|
||||
<if test="ancestors != null">ancestors,</if>
|
||||
<if test="orderNum != null">order_num,</if>
|
||||
<if test="level != null">level,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="name != null">#{name},</if>
|
||||
<if test="parentId != null">#{parentId},</if>
|
||||
<if test="ancestors != null">#{ancestors},</if>
|
||||
<if test="orderNum != null">#{orderNum},</if>
|
||||
<if test="level != null">#{level},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateSysRegion" parameterType="SysRegion">
|
||||
update sys_region
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="name != null">name = #{name},</if>
|
||||
<if test="parentId != null">parent_id = #{parentId},</if>
|
||||
<if test="ancestors != null">ancestors = #{ancestors},</if>
|
||||
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||
<if test="level != null">level = #{level},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteSysRegionById" parameterType="Long">
|
||||
delete from sys_region where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteSysRegionByIds" parameterType="String">
|
||||
delete from sys_region where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
53
zfipc-ui/src/api/system/region.js
Normal file
53
zfipc-ui/src/api/system/region.js
Normal file
@ -0,0 +1,53 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询行政区划列表
|
||||
export function listRegion(query) {
|
||||
return request({
|
||||
url: "/system/region/list",
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
// 查询行政区划树数据
|
||||
export function listRegionAll(query) {
|
||||
return request({
|
||||
url: "/system/region/listAll",
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
|
||||
// 查询行政区划详细
|
||||
export function getRegion(id) {
|
||||
return request({
|
||||
url: "/system/region/" + id,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
// 新增行政区划
|
||||
export function addRegion(data) {
|
||||
return request({
|
||||
url: "/system/region",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 修改行政区划
|
||||
export function updateRegion(data) {
|
||||
return request({
|
||||
url: "/system/region",
|
||||
method: "put",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除行政区划
|
||||
export function delRegion(id) {
|
||||
return request({
|
||||
url: "/system/region/" + id,
|
||||
method: "delete",
|
||||
});
|
||||
}
|
@ -1,7 +1,16 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
|
||||
<el-form-item label="部门名称" prop="deptName">
|
||||
<el-form
|
||||
:model="queryParams"
|
||||
ref="queryForm"
|
||||
size="small"
|
||||
:inline="true"
|
||||
v-show="showSearch"
|
||||
>
|
||||
<el-form-item
|
||||
label="部门名称"
|
||||
prop="deptName"
|
||||
>
|
||||
<el-input
|
||||
v-model="queryParams.deptName"
|
||||
placeholder="请输入部门名称"
|
||||
@ -9,8 +18,15 @@
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="部门状态" clearable>
|
||||
<el-form-item
|
||||
label="状态"
|
||||
prop="status"
|
||||
>
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="部门状态"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in dict.type.sys_normal_disable"
|
||||
:key="dict.value"
|
||||
@ -20,12 +36,24 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>搜索</el-button>
|
||||
<el-button
|
||||
icon="el-icon-refresh"
|
||||
size="mini"
|
||||
@click="resetQuery"
|
||||
>重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-row
|
||||
:gutter="10"
|
||||
class="mb8"
|
||||
>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
@ -45,7 +73,10 @@
|
||||
@click="toggleExpandAll"
|
||||
>展开/折叠</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
<right-toolbar
|
||||
:showSearch.sync="showSearch"
|
||||
@queryTable="getList"
|
||||
></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
@ -56,19 +87,43 @@
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
>
|
||||
<el-table-column prop="deptName" label="部门名称" width="260"></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="deptName"
|
||||
label="部门名称"
|
||||
width="260"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
prop="orderNum"
|
||||
label="排序"
|
||||
width="200"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
prop="status"
|
||||
label="状态"
|
||||
width="100"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
|
||||
<dict-tag
|
||||
:options="dict.type.sys_normal_disable"
|
||||
:value="scope.row.status"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" width="200">
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="200"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
@ -97,43 +152,98 @@
|
||||
</el-table>
|
||||
|
||||
<!-- 添加或修改部门对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-dialog
|
||||
:title="title"
|
||||
:visible.sync="open"
|
||||
width="600px"
|
||||
append-to-body
|
||||
>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-row>
|
||||
<el-col :span="24" v-if="form.parentId !== 0">
|
||||
<el-form-item label="上级部门" prop="parentId">
|
||||
<treeselect v-model="form.parentId" :options="deptOptions" :normalizer="normalizer" placeholder="选择上级部门" />
|
||||
<el-col
|
||||
:span="24"
|
||||
v-if="form.parentId !== 0"
|
||||
>
|
||||
<el-form-item
|
||||
label="上级部门"
|
||||
prop="parentId"
|
||||
>
|
||||
<treeselect
|
||||
v-model="form.parentId"
|
||||
:options="deptOptions"
|
||||
:normalizer="normalizer"
|
||||
placeholder="选择上级部门"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="部门名称" prop="deptName">
|
||||
<el-input v-model="form.deptName" placeholder="请输入部门名称" />
|
||||
<el-form-item
|
||||
label="部门名称"
|
||||
prop="deptName"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.deptName"
|
||||
placeholder="请输入部门名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="显示排序" prop="orderNum">
|
||||
<el-input-number v-model="form.orderNum" controls-position="right" :min="0" />
|
||||
<el-form-item
|
||||
label="显示排序"
|
||||
prop="orderNum"
|
||||
>
|
||||
<el-input-number
|
||||
v-model="form.orderNum"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="负责人" prop="leader">
|
||||
<el-input v-model="form.leader" placeholder="请输入负责人" maxlength="20" />
|
||||
<el-form-item
|
||||
label="负责人"
|
||||
prop="leader"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.leader"
|
||||
placeholder="请输入负责人"
|
||||
maxlength="20"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="联系电话" prop="phone">
|
||||
<el-input v-model="form.phone" placeholder="请输入联系电话" maxlength="11" />
|
||||
<el-form-item
|
||||
label="联系电话"
|
||||
prop="phone"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.phone"
|
||||
placeholder="请输入联系电话"
|
||||
maxlength="11"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="邮箱" prop="email">
|
||||
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
|
||||
<el-form-item
|
||||
label="邮箱"
|
||||
prop="email"
|
||||
>
|
||||
<el-input
|
||||
v-model="form.email"
|
||||
placeholder="请输入邮箱"
|
||||
maxlength="50"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@ -148,9 +258,35 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col
|
||||
:span="24"
|
||||
v-if="form.parentId !== 0"
|
||||
>
|
||||
<el-form-item
|
||||
label="行政区划"
|
||||
prop="regionId"
|
||||
>
|
||||
<treeselect
|
||||
:key="form.parentId"
|
||||
v-model="form.regionId"
|
||||
:options="regionOptions"
|
||||
:normalizer="normalizerRegion"
|
||||
:disable-branch-nodes="true"
|
||||
placeholder="选择行政区划"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<div
|
||||
slot="footer"
|
||||
class="dialog-footer"
|
||||
>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="submitForm"
|
||||
>确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
@ -158,13 +294,21 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild } from "@/api/system/dept";
|
||||
import {
|
||||
listDept,
|
||||
getDept,
|
||||
delDept,
|
||||
addDept,
|
||||
updateDept,
|
||||
listDeptExcludeChild,
|
||||
} from "@/api/system/dept";
|
||||
import { listRegionAll } from "@/api/system/region";
|
||||
import Treeselect from "@riophae/vue-treeselect";
|
||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
||||
|
||||
export default {
|
||||
name: "Dept",
|
||||
dicts: ['sys_normal_disable'],
|
||||
dicts: ["sys_normal_disable"],
|
||||
components: { Treeselect },
|
||||
data() {
|
||||
return {
|
||||
@ -176,6 +320,8 @@ export default {
|
||||
deptList: [],
|
||||
// 部门树选项
|
||||
deptOptions: [],
|
||||
// 行政区划选项
|
||||
regionOptions: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
@ -187,36 +333,36 @@ export default {
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
deptName: undefined,
|
||||
status: undefined
|
||||
status: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
parentId: [
|
||||
{ required: true, message: "上级部门不能为空", trigger: "blur" }
|
||||
{ required: true, message: "上级部门不能为空", trigger: "blur" },
|
||||
],
|
||||
deptName: [
|
||||
{ required: true, message: "部门名称不能为空", trigger: "blur" }
|
||||
{ required: true, message: "部门名称不能为空", trigger: "blur" },
|
||||
],
|
||||
orderNum: [
|
||||
{ required: true, message: "显示排序不能为空", trigger: "blur" }
|
||||
{ required: true, message: "显示排序不能为空", trigger: "blur" },
|
||||
],
|
||||
email: [
|
||||
{
|
||||
type: "email",
|
||||
message: "请输入正确的邮箱地址",
|
||||
trigger: ["blur", "change"]
|
||||
}
|
||||
trigger: ["blur", "change"],
|
||||
},
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
||||
message: "请输入正确的手机号码",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
}
|
||||
trigger: "blur",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@ -226,7 +372,7 @@ export default {
|
||||
/** 查询部门列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listDept(this.queryParams).then(response => {
|
||||
listDept(this.queryParams).then((response) => {
|
||||
this.deptList = this.handleTree(response.data, "deptId");
|
||||
this.loading = false;
|
||||
});
|
||||
@ -239,7 +385,18 @@ export default {
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.deptName,
|
||||
children: node.children
|
||||
children: node.children,
|
||||
};
|
||||
},
|
||||
/** 转换行政区划数据结构 */
|
||||
normalizerRegion(node) {
|
||||
if (node.children && !node.children.length) {
|
||||
delete node.children;
|
||||
}
|
||||
return {
|
||||
id: node.id,
|
||||
label: node.name,
|
||||
children: node.children,
|
||||
};
|
||||
},
|
||||
// 取消按钮
|
||||
@ -257,7 +414,7 @@ export default {
|
||||
leader: undefined,
|
||||
phone: undefined,
|
||||
email: undefined,
|
||||
status: "0"
|
||||
status: "0",
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
@ -278,9 +435,12 @@ export default {
|
||||
}
|
||||
this.open = true;
|
||||
this.title = "添加部门";
|
||||
listDept().then(response => {
|
||||
listDept().then((response) => {
|
||||
this.deptOptions = this.handleTree(response.data, "deptId");
|
||||
});
|
||||
listRegionAll().then((response) => {
|
||||
this.regionOptions = this.handleTree(response.data, "id");
|
||||
});
|
||||
},
|
||||
/** 展开/折叠操作 */
|
||||
toggleExpandAll() {
|
||||
@ -293,31 +453,38 @@ export default {
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
getDept(row.deptId).then(response => {
|
||||
getDept(row.deptId).then((response) => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改部门";
|
||||
listDeptExcludeChild(row.deptId).then(response => {
|
||||
listRegionAll().then((response) => {
|
||||
this.regionOptions = this.handleTree(response.data, "id");
|
||||
});
|
||||
listDeptExcludeChild(row.deptId).then((response) => {
|
||||
this.deptOptions = this.handleTree(response.data, "deptId");
|
||||
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: [],
|
||||
};
|
||||
this.deptOptions.push(noResultsOptions);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm: function() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.deptId != undefined) {
|
||||
updateDept(this.form).then(response => {
|
||||
updateDept(this.form).then((response) => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
addDept(this.form).then(response => {
|
||||
addDept(this.form).then((response) => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
@ -328,13 +495,17 @@ export default {
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
this.$modal.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?').then(function() {
|
||||
return delDept(row.deptId);
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
this.$modal
|
||||
.confirm('是否确认删除名称为"' + row.deptName + '"的数据项?')
|
||||
.then(function () {
|
||||
return delDept(row.deptId);
|
||||
})
|
||||
.then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
})
|
||||
.catch(() => {});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user