角色页面添加角色使用用途

This commit is contained in:
sk1551 2020-04-18 10:20:05 +08:00
parent fb937034a7
commit b1addfbebd
6 changed files with 162 additions and 65 deletions

View File

@ -173,6 +173,15 @@
>{{dict.dictLabel}}</el-radio> >{{dict.dictLabel}}</el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="用途">
<el-radio-group v-model="form.purpose">
<el-radio
v-for="dict in purposeOptions"
:key="dict.dictValue"
:label="dict.dictValue"
>{{dict.dictLabel}}</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="菜单权限"> <el-form-item label="菜单权限">
<el-tree <el-tree
:data="menuOptions" :data="menuOptions"
@ -233,9 +242,24 @@
</template> </template>
<script> <script>
import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from "@/api/system/role"; import {
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu"; listRole,
import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept"; getRole,
delRole,
addRole,
updateRole,
exportRole,
dataScope,
changeRoleStatus
} from "@/api/system/role";
import {
treeselect as menuTreeselect,
roleMenuTreeselect
} from "@/api/system/menu";
import {
treeselect as deptTreeselect,
roleDeptTreeselect
} from "@/api/system/dept";
export default { export default {
name: "Role", name: "Role",
@ -263,6 +287,8 @@ export default {
dateRange: [], dateRange: [],
// //
statusOptions: [], statusOptions: [],
//
purposeOptions: [],
// //
dataScopeOptions: [ dataScopeOptions: [
{ {
@ -296,7 +322,8 @@ export default {
pageSize: 10, pageSize: 10,
roleName: undefined, roleName: undefined,
roleKey: undefined, roleKey: undefined,
status: undefined status: undefined,
purpose: undefined
}, },
// //
form: {}, form: {},
@ -323,6 +350,9 @@ export default {
this.getDicts("sys_normal_disable").then(response => { this.getDicts("sys_normal_disable").then(response => {
this.statusOptions = response.data; this.statusOptions = response.data;
}); });
this.getDicts("sys_purpose").then(response => {
this.purposeOptions = response.data;
});
}, },
methods: { methods: {
/** 查询角色列表 */ /** 查询角色列表 */
@ -383,15 +413,22 @@ export default {
// //
handleStatusChange(row) { handleStatusChange(row) {
let text = row.status === "0" ? "启用" : "停用"; let text = row.status === "0" ? "启用" : "停用";
this.$confirm('确认要"' + text + '""' + row.roleName + '"角色吗?', "警告", { this.$confirm(
'确认要"' + text + '""' + row.roleName + '"角色吗?',
"警告",
{
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }
)
.then(function() {
return changeRoleStatus(row.roleId, row.status); return changeRoleStatus(row.roleId, row.status);
}).then(() => { })
.then(() => {
this.msgSuccess(text + "成功"); this.msgSuccess(text + "成功");
}).catch(function() { })
.catch(function() {
row.status = row.status === "0" ? "1" : "0"; row.status = row.status === "0" ? "1" : "0";
}); });
}, },
@ -418,7 +455,8 @@ export default {
status: "0", status: "0",
menuIds: [], menuIds: [],
deptIds: [], deptIds: [],
remark: undefined remark: undefined,
purpose: "1"
}; };
this.resetForm("form"); this.resetForm("form");
}, },
@ -435,9 +473,9 @@ export default {
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
this.ids = selection.map(item => item.roleId) this.ids = selection.map(item => item.roleId);
this.single = selection.length!=1 this.single = selection.length != 1;
this.multiple = !selection.length this.multiple = !selection.length;
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
@ -449,7 +487,7 @@ export default {
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();
const roleId = row.roleId || this.ids const roleId = row.roleId || this.ids;
this.$nextTick(() => { this.$nextTick(() => {
this.getRoleMenuTreeselect(roleId); this.getRoleMenuTreeselect(roleId);
}); });
@ -519,29 +557,39 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const roleIds = row.roleId || this.ids; const roleIds = row.roleId || this.ids;
this.$confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?', "警告", { this.$confirm(
'是否确认删除角色编号为"' + roleIds + '"的数据项?',
"警告",
{
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { }
)
.then(function() {
return delRole(roleIds); return delRole(roleIds);
}).then(() => { })
.then(() => {
this.getList(); this.getList();
this.msgSuccess("删除成功"); this.msgSuccess("删除成功");
}).catch(function() {}); })
.catch(function() {});
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
const queryParams = this.queryParams; const queryParams = this.queryParams;
this.$confirm('是否确认导出所有角色数据项?', "警告", { this.$confirm("是否确认导出所有角色数据项?", "警告", {
confirmButtonText: "确定", confirmButtonText: "确定",
cancelButtonText: "取消", cancelButtonText: "取消",
type: "warning" type: "warning"
}).then(function() { })
.then(function() {
return exportRole(queryParams); return exportRole(queryParams);
}).then(response => { })
.then(response => {
this.download(response.msg); this.download(response.msg);
}).catch(function() {}); })
.catch(function() {});
} }
} }
}; };

View File

@ -103,7 +103,7 @@ public class BySchoolController extends BaseController
{ {
//从school表中取出当前最大的ID值 并且将其赋值给dept中的ordernumber //从school表中取出当前最大的ID值 并且将其赋值给dept中的ordernumber
String maxId = jdbcTemplate.queryForObject(String.format("select MAX(id) from by_school"),String.class); String maxId = jdbcTemplate.queryForObject(String.format("select MAX(id) from by_school"),String.class);
//生成32位UUID
String uuid = getUUID32(); String uuid = getUUID32();
//将UUID赋值给xxdm //将UUID赋值给xxdm
@ -114,12 +114,19 @@ public class BySchoolController extends BaseController
//创建dept实例 并且向要添加的dept中设置各个参数 //创建dept实例 并且向要添加的dept中设置各个参数
SysDept dept = new SysDept(); SysDept dept = new SysDept();
if (maxId != "0")
{
dept.setOrderNum(maxId);
System.out.println("------------" + maxId);
}else
{
dept.setOrderNum("6");
}
dept.setSchoolId(bySchool.getXxdm()); dept.setSchoolId(bySchool.getXxdm());
dept.setCreateBy(SecurityUtils.getUsername()); dept.setCreateBy(SecurityUtils.getUsername());
dept.setParentId(200L); dept.setParentId(200L);
dept.setAncestors("0,100,200"); dept.setAncestors("0,100,200");
dept.setDeptName(bySchool.getSchoolName()); dept.setDeptName(bySchool.getSchoolName());
dept.setOrderNum(maxId);
dept.setPhone(bySchool.getTel()); dept.setPhone(bySchool.getTel());
dept.setLeader(SecurityUtils.getUsername()); dept.setLeader(SecurityUtils.getUsername());
//插入数据 //插入数据
@ -136,6 +143,16 @@ public class BySchoolController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody BySchool bySchool) public AjaxResult edit(@RequestBody BySchool bySchool)
{ {
//创建dept实例 并且向要添加的dept中设置各个参数
SysDept dept = new SysDept();
//设置schoolID为xxdm
dept.setSchoolId(bySchool.getXxdm());
//通过selectdeptlist来获取deptid
dept.setDeptId(deptService.selectDeptList(dept).get(0).getDeptId());
dept.setStatus(bySchool.getStatus());
deptService.updateDept(dept);
return toAjax(bySchoolService.updateBySchool(bySchool)); return toAjax(bySchoolService.updateBySchool(bySchool));
} }
@ -152,10 +169,12 @@ public class BySchoolController extends BaseController
{ {
//循环找出school表的id //循环找出school表的id
Long bySchId = ids[i]; Long bySchId = ids[i];
//用school表ID获取xxdm的值 //用school表ID获取xxdm的值
//将值赋给dept中的schoolID //将值赋给dept中的schoolID
SysDept dept = new SysDept(); SysDept dept = new SysDept();
dept.setSchoolId(bySchoolService.selectBySchoolById(bySchId).getXxdm()); dept.setSchoolId(bySchoolService.selectBySchoolById(bySchId).getXxdm());
//通过dept表的schoolID来找出dept的List //通过dept表的schoolID来找出dept的List
deptService.deleteDeptById(deptService.selectDeptList(dept).get(0).getDeptId()); deptService.deleteDeptById(deptService.selectDeptList(dept).get(0).getDeptId());
} }

View File

@ -88,9 +88,9 @@ public class BySchool extends BaseEntity
@Excel(name = "紧急联系电话") @Excel(name = "紧急联系电话")
private String emTel; private String emTel;
/** 状态0试用1开通2停用,3禁用) */ /** 状态0正常1停用) */
@Excel(name = "状态", readConverterExp = "0=试用1开通2停用,3禁") @Excel(name = "状态", readConverterExp = "0=正常1停")
private Long status; private String status;
/** 幼儿园规模 */ /** 幼儿园规模 */
@Excel(name = "幼儿园规模") @Excel(name = "幼儿园规模")
@ -140,6 +140,12 @@ public class BySchool extends BaseEntity
@Excel(name = "当前学期") @Excel(name = "当前学期")
private String dqxq; private String dqxq;
/** 删除标志0代表存在 2代表删除 */
private String isDel;
//部门 //部门
private SysDept dept; private SysDept dept;
@ -295,12 +301,12 @@ public class BySchool extends BaseEntity
{ {
return emTel; return emTel;
} }
public void setStatus(Long status) public void setStatus(String status)
{ {
this.status = status; this.status = status;
} }
public Long getStatus() public String getStatus()
{ {
return status; return status;
} }
@ -421,7 +427,13 @@ public class BySchool extends BaseEntity
this.xxdm = xxdm; this.xxdm = xxdm;
} }
public String getIsDel() {
return isDel;
}
public void setIsDel(String isDel) {
this.isDel = isDel;
}
@Override @Override
public String toString() { public String toString() {
@ -459,6 +471,7 @@ public class BySchool extends BaseEntity
.append("dqxn", getDqxn()) .append("dqxn", getDqxn())
.append("dqxq", getDqxq()) .append("dqxq", getDqxq())
.append("dept", getDept()) .append("dept", getDept())
.append("isDel",getIsDel())
.toString(); .toString();
} }

View File

@ -53,6 +53,9 @@ public class SysRole extends BaseEntity
/** 部门组(数据权限) */ /** 部门组(数据权限) */
private Long[] deptIds; private Long[] deptIds;
/** 角色用途 */
private String purpose;
public SysRole() public SysRole()
{ {
@ -192,6 +195,15 @@ public class SysRole extends BaseEntity
.append("updateBy", getUpdateBy()) .append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("remark", getRemark()) .append("remark", getRemark())
.append("purpose", getPurpose())
.toString(); .toString();
} }
public String getPurpose() {
return purpose;
}
public void setPurpose(String purpose) {
this.purpose = purpose;
}
} }

View File

@ -37,45 +37,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="openDeadline" column="open_deadline" /> <result property="openDeadline" column="open_deadline" />
<result property="dqxn" column="dqxn" /> <result property="dqxn" column="dqxn" />
<result property="dqxq" column="dqxq" /> <result property="dqxq" column="dqxq" />
<result property="isDel" column="is_del" />
</resultMap> </resultMap>
<sql id="selectBySchoolVo"> <sql id="selectBySchoolVo">
select id, xxdm, school_name, name_short, type, parent_id, province, provincename, regionid, regionname, area, areaname, address, mastername, tel, em_man, em_tel, status, scale, create_time, create_user, approval_user, approval_time, remark, location, is_demonstr, businesslicenseimg, open_book, fee_status, open_deadline, dqxn, dqxq from by_school select id, xxdm, school_name, name_short, type, parent_id, province, provincename, regionid, regionname, area, areaname, address, mastername, tel, em_man, em_tel, status, scale, create_time, create_user, approval_user, approval_time, remark, location, is_demonstr, businesslicenseimg, open_book, fee_status, open_deadline, dqxn, dqxq, is_del from by_school
</sql> </sql>
<select id="selectBySchoolList" parameterType="BySchool" resultMap="BySchoolResult"> <select id="selectBySchoolList" parameterType="BySchool" resultMap="BySchoolResult">
<include refid="selectBySchoolVo"/> <include refid="selectBySchoolVo"/>
<where> where is_del = '0'
<if test="xxdm != null and xxdm != ''"> and xxdm like concat('%', #{xxdm}, '%')</if> <if test="xxdm != null and xxdm != ''"> and xxdm like concat('%', #{xxdm}, '%')</if>
<if test="schoolName != null and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if> <if test="schoolName != null and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
<if test="nameShort != null and nameShort != ''"> and name_short = #{nameShort}</if> <if test="nameShort != null and nameShort != ''"> and name_short = #{nameShort}</if>
<if test="type != null "> and type = #{type}</if> <if test="type != null "> and type = #{type}</if>
<if test="parentId != null "> and parent_id = #{parentId}</if> <if test="parentId != null "> and parent_id = #{parentId}</if>
<if test="province != null and province != ''"> and province = #{province}</if> <if test="province != null and province != ''"> and province = #{province}</if>
<if test="provincename != null and provincename != ''"> and provincename like concat('%', #{provincename}, '%')</if> <if test="provincename != null and provincename != ''"> and provincename like concat('%', #{provincename}, '%')</if>
<if test="regionid != null and regionid != ''"> and regionid = #{regionid}</if> <if test="regionid != null and regionid != ''"> and regionid = #{regionid}</if>
<if test="regionname != null and regionname != ''"> and regionname like concat('%', #{regionname}, '%')</if> <if test="regionname != null and regionname != ''"> and regionname like concat('%', #{regionname}, '%')</if>
<if test="area != null and area != ''"> and area = #{area}</if> <if test="area != null and area != ''"> and area = #{area}</if>
<if test="areaname != null and areaname != ''"> and areaname like concat('%', #{areaname}, '%')</if> <if test="areaname != null and areaname != ''"> and areaname like concat('%', #{areaname}, '%')</if>
<if test="address != null and address != ''"> and address = #{address}</if> <if test="address != null and address != ''"> and address = #{address}</if>
<if test="mastername != null and mastername != ''"> and mastername like concat('%', #{mastername}, '%')</if> <if test="mastername != null and mastername != ''"> and mastername like concat('%', #{mastername}, '%')</if>
<if test="tel != null and tel != ''"> and tel = #{tel}</if> <if test="tel != null and tel != ''"> and tel = #{tel}</if>
<if test="emMan != null and emMan != ''"> and em_man = #{emMan}</if> <if test="emMan != null and emMan != ''"> and em_man = #{emMan}</if>
<if test="emTel != null and emTel != ''"> and em_tel = #{emTel}</if> <if test="emTel != null and emTel != ''"> and em_tel = #{emTel}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
<if test="scale != null "> and scale = #{scale}</if> <if test="scale != null "> and scale = #{scale}</if>
<if test="createUser != null "> and create_user = #{createUser}</if> <if test="createUser != null "> and create_user = #{createUser}</if>
<if test="approvalUser != null "> and approval_user = #{approvalUser}</if> <if test="approvalUser != null "> and approval_user = #{approvalUser}</if>
<if test="approvalTime != null "> and approval_time = #{approvalTime}</if> <if test="approvalTime != null "> and approval_time = #{approvalTime}</if>
<if test="location != null and location != ''"> and location = #{location}</if> <if test="location != null and location != ''"> and location = #{location}</if>
<if test="isDemonstr != null "> and is_demonstr = #{isDemonstr}</if> <if test="isDemonstr != null "> and is_demonstr = #{isDemonstr}</if>
<if test="businesslicenseimg != null and businesslicenseimg != ''"> and businesslicenseimg = #{businesslicenseimg}</if> <if test="businesslicenseimg != null and businesslicenseimg != ''"> and businesslicenseimg = #{businesslicenseimg}</if>
<if test="openBook != null "> and open_book = #{openBook}</if> <if test="openBook != null "> and open_book = #{openBook}</if>
<if test="feeStatus != null "> and fee_status = #{feeStatus}</if> <if test="feeStatus != null "> and fee_status = #{feeStatus}</if>
<if test="openDeadline != null "> and open_deadline = #{openDeadline}</if> <if test="openDeadline != null "> and open_deadline = #{openDeadline}</if>
<if test="dqxn != null and dqxn != ''"> and dqxn = #{dqxn}</if> <if test="dqxn != null and dqxn != ''"> and dqxn = #{dqxn}</if>
<if test="dqxq != null and dqxq != ''"> and dqxq = #{dqxq}</if> <if test="dqxq != null and dqxq != ''"> and dqxq = #{dqxq}</if>
</where>
</select> </select>
<select id="selectBySchoolById" parameterType="Long" resultMap="BySchoolResult"> <select id="selectBySchoolById" parameterType="Long" resultMap="BySchoolResult">
@ -196,7 +197,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteBySchoolByIds" parameterType="String"> <delete id="deleteBySchoolByIds" parameterType="String">
delete from by_school where id in update by_school set is_del = '2' where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>

View File

@ -17,11 +17,12 @@ 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" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="purpose" column="purpose" />
</resultMap> </resultMap>
<sql id="selectRoleVo"> <sql id="selectRoleVo">
select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, select distinct r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope,
r.status, r.del_flag, r.create_time, r.remark r.status, r.del_flag, r.create_time, r.remark, r.purpose
from sys_role r from sys_role r
left join sys_user_role ur on ur.role_id = r.role_id left join sys_user_role ur on ur.role_id = r.role_id
left join sys_user u on u.user_id = ur.user_id left join sys_user u on u.user_id = ur.user_id
@ -96,6 +97,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dataScope != null and dataScope != ''">data_scope,</if> <if test="dataScope != null and dataScope != ''">data_scope,</if>
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="remark != null and remark != ''">remark,</if> <if test="remark != null and remark != ''">remark,</if>
<if test="purpose != null and purpose != ''">purpose,</if>
<if test="createBy != null and createBy != ''">create_by,</if> <if test="createBy != null and createBy != ''">create_by,</if>
create_time create_time
)values( )values(
@ -106,6 +108,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="dataScope != null and dataScope != ''">#{dataScope},</if> <if test="dataScope != null and dataScope != ''">#{dataScope},</if>
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="remark != null and remark != ''">#{remark},</if> <if test="remark != null and remark != ''">#{remark},</if>
<if test="purpose != null and purpose != ''">#{purpose},</if>
<if test="createBy != null and createBy != ''">#{createBy},</if> <if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate() sysdate()
) )
@ -119,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if> <if test="roleSort != null and roleSort != ''">role_sort = #{roleSort},</if>
<if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if> <if test="dataScope != null and dataScope != ''">data_scope = #{dataScope},</if>
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="purpose != null and purpose != ''">purpose = #{purpose},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
update_time = sysdate() update_time = sysdate()