| | |
| | | import request from "@/utils/request" |
| | | import {useRouter,useRoute} from "vue-router" |
| | | import {useI18n} from "vue-i18n" |
| | | import i18n from "@/lang/index" |
| | | const lang = i18n.global.locale.value |
| | | import {ElMessage, ElMessageBox} from "element-plus" |
| | | const { t } = useI18n() |
| | | const router = useRouter() |
| | | const route = useRoute() |
| | | const dialogVisible = ref(false) |
| | | let selectValue = ref(null) |
| | | let options = ref([]) |
| | | let selectValue = ref([null,null]) |
| | | let options = ref(null) |
| | | let checkId = ref(null) |
| | | |
| | | |
| | | const xGrid = ref() |
| | | const gridOptions = reactive({ |
| | |
| | | customConfig: { |
| | | storage: true |
| | | }, |
| | | checkboxConfig: { |
| | | checkField:'checked', |
| | | }, |
| | | editConfig: { |
| | | trigger: 'click', |
| | | mode: 'row', |
| | |
| | | |
| | | let columnsP = [ |
| | | { type: 'seq', width: 60 }, |
| | | { type: 'checkbox', width: 50 } |
| | | { type: 'checkbox', |
| | | width: 50 , |
| | | field:"checked", |
| | | |
| | | } |
| | | ] |
| | | const columnNameP = { |
| | | id: 'ID', |
| | |
| | | }) |
| | | |
| | | onMounted(()=>{ |
| | | request.get('/role/findAll').then(res=>{ |
| | | request.get(`/role/findAll`).then(res=>{ |
| | | gridOptions.data = res.data |
| | | }) |
| | | request.post('/permission/getPermissionList').then(res=>{ |
| | | request.post(`/permission/getPermissionList/${lang}`).then(res=>{ |
| | | options.value = res.data |
| | | }) |
| | | }) |
| | |
| | | switch (type) { |
| | | case 'edit': { |
| | | dialogVisible.value = true |
| | | checkId.value = row.id |
| | | break |
| | | } |
| | | } |
| | | } |
| | | |
| | | const getPermissionList = () => { |
| | | request.post(`/permission/getPermission/${2}`).then(res=>{ |
| | | permissionOptions.data = res.data |
| | | request.post(`/permission/getPermission/${checkId.value}/${lang}`,selectValue.value).then(res=>{ |
| | | pGrid.value.reloadData(res.data) |
| | | }) |
| | | } |
| | | |
| | | const selectChange = ()=>{ |
| | | console.log(selectValue.value) |
| | | getPermissionList() |
| | | } |
| | | |
| | | </script> |
| | |
| | | |
| | | import com.example.erp.common.Result; |
| | | import com.example.erp.service.userInfo.PermissionBasicService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/permission") |
| | |
| | | this.permissionBasicService = permissionBasicService; |
| | | } |
| | | |
| | | @PostMapping("getPermission/{userId}") |
| | | public Result getPermission(@PathVariable Integer userId){ |
| | | return Result.seccess(permissionBasicService.getPermission(userId)); |
| | | @PostMapping("getPermission/{userId}/{lang}") |
| | | public Result getPermission(@PathVariable Integer userId,@PathVariable String lang, @RequestBody List<Integer> selectPageId){ |
| | | return Result.seccess(permissionBasicService.getPermission(userId,lang,selectPageId)); |
| | | } |
| | | |
| | | @PostMapping("getPermissionList") |
| | | public Result getPermission(){ |
| | | return Result.seccess(permissionBasicService.getPermissionList()); |
| | | @PostMapping("getPermissionList/{lang}") |
| | | public Result getPermission(@PathVariable String lang){ |
| | | return Result.seccess(permissionBasicService.getPermissionList(lang)); |
| | | } |
| | | } |
| | |
| | | package com.example.erp.entity.userInfo; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import lombok.Data; |
| | | |
| | |
| | | private String page; |
| | | private String permission; |
| | | private String state; |
| | | @TableField(select = false,exist = false) |
| | | private Boolean checked; |
| | | } |
| | |
| | | private Integer menuID; |
| | | private String itemName; |
| | | private String url; |
| | | private String menu; |
| | | private String languageType; |
| | | private Integer state; |
| | | private Integer listSort; |
| | |
| | | |
| | | @Mapper |
| | | public interface PermissionBasicMapper extends BaseMapper<PermissionBasic> { |
| | | List<PermissionBasic> getPermission(Integer userId); |
| | | List<PermissionBasic> getPermission(Integer userId, String lang, Integer id); |
| | | |
| | | List<PermissionBasic> selectOneLevel(); |
| | | List<PermissionBasic> selectOneLevel(String lang); |
| | | |
| | | List<Map<String,Object>> selectTowLevel(String menu); |
| | | } |
| | |
| | | package com.example.erp.service.userInfo; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.example.erp.entity.userInfo.PermissionBasic; |
| | | import com.example.erp.mapper.userInfo.PermissionBasicMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | this.permissionBasicMapper = permissionBasicMapper; |
| | | } |
| | | |
| | | public List<PermissionBasic> getPermission(Integer userId) { |
| | | return permissionBasicMapper.getPermission(userId); |
| | | public List<PermissionBasic> getPermission(Integer userId, String lang, List<Integer> selectPageId) { |
| | | return permissionBasicMapper.getPermission(userId,lang, selectPageId.get(1)); |
| | | } |
| | | |
| | | public Object getPermissionList() { |
| | | List<PermissionBasic> getOne = permissionBasicMapper.selectOneLevel(); |
| | | public Object getPermissionList(String lang) { |
| | | List<PermissionBasic> getOne = permissionBasicMapper.selectOneLevel(lang); |
| | | List<Map<String,Object>> ListOne = new ArrayList<>(); |
| | | |
| | | for(PermissionBasic permissionBasic : getOne){ |
| | |
| | | CASE |
| | | WHEN b.id IS NULL THEN 0 |
| | | ELSE 1 |
| | | END |
| | | END as 'checked' |
| | | from permission_basic as a |
| | | left join permission_role as b |
| | | on a.id = b.permission_id |
| | |
| | | left join user as d |
| | | on c.user_id = d.id |
| | | and d.id = #{userId} |
| | | where a.id!=1 and a.state=1 |
| | | where |
| | | a.id!=1 |
| | | and a.state=1 |
| | | <if test="id != null and id != ''"> |
| | | and a.page = (select page from permission_basic where id = #{id}) |
| | | </if> |
| | | |
| | | group by a.id |
| | | </select> |
| | | |
| | | <select id="selectOneLevel"> |
| | | select * |
| | | from permission_basic |
| | | where id!=1 and state=1 |
| | | group by menu |
| | | select a.id, |
| | | <if test="lang=='zh'"> |
| | | b.itemName as menu |
| | | </if> |
| | | <if test="lang=='en'"> |
| | | a.menu |
| | | </if> |
| | | |
| | | from permission_basic as a |
| | | left join sys_menu_item as b |
| | | on a.menu = b.menu |
| | | where a.id!=1 and a.state=1 |
| | | group by a.menu |
| | | |
| | | </select> |
| | | |