guoyuji
2024-05-06 06090881384d424ac4466fd8b8a43b307b8a63d4
添加用户权限列表
8个文件已修改
3个文件已添加
251 ■■■■■ 已修改文件
north-glass-erp/northglass-erp/src/router/index.js 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/sd/order/SelectOrder.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/system/role/RoleList.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/system/user/User.vue 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/views/system/user/UserList.vue 109 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/config/StpInterfaceImpl.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/controller/userInfo/UserInfoController.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/java/com/example/erp/service/userInfo/UserService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/src/main/resources/mapper/userInfo/User.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/target/classes/mapper/userInfo/User.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
north-glass-erp/northglass-erp/src/router/index.js
@@ -21,6 +21,25 @@
      name: 'main',
      component: () => import('../layout/MainErpView.vue'),
      children:[
          //user模块
        {
          path:'user',
          name: 'user',
          component: () => import('../views/system/user/User.vue'),
          children:[
            {
              path: 'userList',
              name: 'userList',
              component: () => import('../views/system/user/UserList.vue')
            },
            {
              name:'user',
              path: '',
              redirect:'/main/user/userList'
            }
          ]
        },
          //sd模块
        {
          path:'orderBasicData',
@@ -108,7 +127,7 @@
            },
            {
              path: '',
              redirect:'/main/order/SelectOrder'
              redirect:'/main/order/selectOrder'
            }
          ]
        },
north-glass-erp/northglass-erp/src/views/sd/order/SelectOrder.vue
@@ -314,7 +314,13 @@
        value-format="YYYY-MM-DD"
    />
    <el-button @click="changeDate" style="margin-top: -5px"  id="searchButton" type="primary" :icon="Search">{{ $t('basicData.search') }}</el-button>
    <el-button @click="changeDate"
               style="margin-top: -5px"
               id="searchButton"
               type="primary"
               :icon="Search">
      {{ $t('basicData.search') }}
    </el-button>
    <vxe-grid
        @filter-change="filterChanged"
        max-height="100%"
north-glass-erp/northglass-erp/src/views/system/role/RoleList.vue
New file
@@ -0,0 +1,11 @@
<script setup>
</script>
<template>
</template>
<style scoped>
</style>
north-glass-erp/northglass-erp/src/views/system/user/User.vue
New file
@@ -0,0 +1,61 @@
<script setup>
import {ArrowLeftBold, ArrowRight, Search} from "@element-plus/icons-vue"
import {useRouter,useRoute,onBeforeRouteUpdate} from "vue-router"
import {useI18n} from "vue-i18n"
const { t } = useI18n()
const router = useRouter()
const route = useRoute()
let indexFlag=$ref(1)
function changeRouter(index){
  indexFlag=index
}
</script>
<template>
  <div id="main-div">
    <div id="div-title">
      <el-breadcrumb :separator-icon="ArrowRight">
        <el-breadcrumb-item @click="changeRouter(1)" :class="indexFlag===1?'indexTag':''" :to="{ path: '/main/user/userList' }">用户首页</el-breadcrumb-item>
        <el-breadcrumb-item v-show="false" @click="changeRouter(2)" :class="indexFlag===2?'indexTag':''" :to="{ path: '/main/order/createOrder' }">{{$t('basicData.create')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div id="main-body">
      <router-view :key="route.fullPath" />
    </div>
  </div>
</template>
<style scoped>
#main-div{
  width: 99%;
  height: 100%;
}
#div-title{
  height: 2%;
  width: 100%;
}
#searchButton{
  margin-top: -5px;
  margin-left: 1rem;
}
#searchButton1{
//margin-left: 10rem;
}
/*main-body样式*/
#main-body{
  width: 100%;
  height: 95%;
  margin-top: 1%;
}
#select{
  margin-left:0.5rem;
}
:deep(.indexTag .el-breadcrumb__inner){
  color: #5CADFE !important;
}
</style>
north-glass-erp/northglass-erp/src/views/system/user/UserList.vue
New file
@@ -0,0 +1,109 @@
<script setup>
import {onBeforeMount, onMounted, reactive, ref} from "vue"
import {changeFilterEvent,filterChanged} from "@/hook"
import request from "@/utils/request"
import {useI18n} from "vue-i18n"
const { t } = useI18n()
const xGrid = ref()
const gridOptions = reactive({
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe:true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮
  id: 'userList',
  showFooter: false,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollY:{ enabled: true },//开启虚拟滚动
  showOverflow:true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },
  //表头参数
  columns:[
  ],
  //表头按钮
  toolbarConfig: {
    buttons: [
    ],
    zoom: true,
    custom: true
  },
})
onBeforeMount(()=>{
  let columns = [{title: t('basicData.operate'), width: 133, slots: { default: 'button_slot' }}]
  const columnName = {
    loginName: '用户ID',
    userName:'用户',
    address:'地址',
    phone:'电话',
    role:'角色',
    createTime:'创建时间'
  }
  for (let columnNameKey in columnName) {
    let column = {field: columnNameKey,
      title: columnName[columnNameKey],
      filters:[{ data: '' }],
      slots: { filter: 'filter' },
      sortable: true,
      filterMethod:filterChanged
    }
    columns.push(column)
  }
  gridOptions.columns = columns
})
onMounted(()=>{
  request.get('/userInfo/findAll').then(res=>{
    gridOptions.data = res.data
  })
})
</script>
<template>
  <div  style="width: 100%;height: 100% ;">
    <vxe-grid
        max-height="100%"
        class="mytable-scrollbar"
        ref="xGrid"
        v-bind="gridOptions"
    >
      <template #filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">
            <input type="type" v-model="option.data" @input="changeFilterEvent($event, option, $panel)"/>
          </div>
        </div>
      </template>
      <template #button_slot="{ row }">
        <el-button @click="getTableRow(row,'edit')" link type="primary" size="small">设置角色</el-button>
        <el-popconfirm @confirm="getTableRow(row,'delete')" :title="$t('searchOrder.deleteConfirm')">
          <template #reference>
            <el-button  link type="primary" size="small">{{ $t('basicData.delete') }}</el-button>
          </template>
        </el-popconfirm>
      </template>
    </vxe-grid>
  </div>
</template>
<style scoped>
</style>
north-glass-erp/src/main/java/com/example/erp/config/StpInterfaceImpl.java
@@ -14,7 +14,10 @@
 * @author kong
 * @since 2022-10-13
 */
@Component    // 打开此注解,保证此类被springboot扫描,即可完成sa-token的自定义权限验证扩展
// 打开此注解,保证此类被springboot扫描,即可完成sa-token的自定义权限验证扩展
@Component
public class StpInterfaceImpl implements StpInterface {
    private final PermissionRoleService permissionRoleService;
@@ -27,14 +30,6 @@
     */
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        // 本list仅做模拟,实际项目中要根据具体业务逻辑来查询权限
        /*List<String> list = new ArrayList<>();
        list.add("101");
        list.add("user.add");
        list.add("user.update");
        list.add("user.get");
        // list.add("user.delete");
        list.add("art.*");*/
        return permissionRoleService.getUserPermission(Integer.parseInt((String) loginId));
    }
north-glass-erp/src/main/java/com/example/erp/controller/userInfo/UserInfoController.java
@@ -6,10 +6,7 @@
import com.example.erp.common.Result;
import com.example.erp.controller.dto.UserDTO;
import com.example.erp.service.userInfo.UserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/userInfo")
@@ -36,14 +33,18 @@
    return Result.seccess(userService.isLogin()); }
    @SaCheckLogin
    @PostMapping("/userAdd")
    @PostMapping("/getTokenInfo")
    public Result userAdd() {
        return Result.seccess(StpUtil.getTokenInfo());
    }
    @PostMapping("/userDelete")
    @SaCheckPermission("user.delete")
    public Result userDelete() {
        return Result.seccess(123123);
    }
    @GetMapping("findAll")
    public Result findAll(){
        return Result.seccess(userService.findAll());
    }
}
north-glass-erp/src/main/java/com/example/erp/exception/GlobalExceptionHandle.java
@@ -22,6 +22,7 @@
        return Result.error(se.getCode(),se.getMessage());
    }
    // 拦截:无权限异常
    @ExceptionHandler(NotPermissionException.class)
    @ResponseBody
    public Result handlerException(NotPermissionException e) {
north-glass-erp/src/main/java/com/example/erp/service/userInfo/UserService.java
@@ -13,6 +13,8 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
@DS("user_info")
public class UserService {
@@ -70,7 +72,9 @@
        User user = userMapper.selectOne(new QueryWrapper<User>().
                eq("login_name", userDTO.getUserId()).eq("password", userDTO.getPass()));
        if(user!=null){
            //检查是让有登录,有登录直接退出
            StpUtil.logout(user.getId());
            //重新进行登录
            StpUtil.login(user.getId());
            userDTO.setPass(null);
            userDTO.setId(user.getId());
@@ -91,5 +95,13 @@
        StpUtil.logout();
        return true;
    }
    public List<User> findAll() {
        List<User> users = userMapper.findAll();
        users.forEach(user -> {
            user.setPassword(null);
        });
        return users;
    }
}
north-glass-erp/src/main/resources/mapper/userInfo/User.xml
@@ -6,6 +6,7 @@
    <select id="findAll">
        SELECT *
        FROM erp_user_info.user
        where state =1
    </select>
    <select id="findOne" >
north-glass-erp/target/classes/mapper/userInfo/User.xml
@@ -6,6 +6,7 @@
    <select id="findAll">
        SELECT *
        FROM erp_user_info.user
        where state =1
    </select>
    <select id="findOne" >