Browse Source

提交权限配置

power_master^2
herenshan112 4 days ago
parent
commit
7a2b48374b
  1. 12
      src/api/system/roleapi/power.ts
  2. 99
      src/layout/components/myconst/editmypassword.vue
  3. 307
      src/utils/CheckPassword.ts
  4. 10
      src/views/system/monitor/online/index.vue
  5. 42
      src/views/system/monitor/online/roleConfig/setRolePeople.vue

12
src/api/system/roleapi/power.ts

@ -47,3 +47,15 @@ export function addNewPeople(data?: getSystemPower){
data:data
});
}
/**
@ 作者: 秦东
@ 时间: 2025-11-28 10:24:09
@ 功能: 编辑自己登陆密码
*/
export function editMyPwd(data?: getSystemPower){
return request({
url: '/systemapi/hr/editMyPwd',
method: 'post',
data:data
});
}

99
src/layout/components/myconst/editmypassword.vue

@ -4,14 +4,64 @@
@ 备注: 修改密码
-->
<script lang='ts' setup>
import { editMyPwd } from '@/api/system/roleapi/power'
import { checkPwdRule,level } from '@/utils/CheckPassword'
const props = defineProps({
editPasswordIsShow:{
type:Boolean,
default:false
}
});
const rulePowwerFormRef = ref()
const emits = defineEmits(["update:editPasswordIsShow"]); //
const addLoading = ref(false)
const saveData = ref({
oldPassword:"",
newPassword:"",
confirmPassword:""
})
const rules = ref<any>({
oldPassword: [{ required: true, message: '请输入旧密码', trigger: 'blur' }],
newPassword: [{required: true,
validator: (rule: any, value: any, callback: any) => {
if (!value) {
callback(new Error('请确认密码'));
return;
}
const result: string = checkPwdRule(value);
if(result !== "校验通过"){
callback(new Error(result));
return;
}
callback();
// const res: string = level(value);
// callback('success');
// console.log("",rule)
},
trigger: ['blur']
}],
confirmPassword: [{required: true,
validator: (rule: any, value: any, callback: any) => {
if (!value) {
callback(new Error('请确认密码'));
return;
}
const result: string = checkPwdRule(value);
if(result !== "校验通过"){
callback(new Error(result));
return;
}
if (value !== saveData.value.newPassword) {
callback(new Error('两次输入密码不一致!'));
} else {
callback();
}
},
trigger: ['blur']
}],
});
/**
* 弹窗显示控制
*/
@ -42,6 +92,35 @@ const addLoading = ref(false)
*/
const submitEditPwdForm = ()=>{
addLoading.value = true
rulePowwerFormRef.value.validate((valid: any) => {
if (valid) {
//
// console.log(':', saveData.value);
//
editMyPwd(saveData.value).then(( data:any ) =>{
// console.log(':',data);
if(data.code == 0){
//
//
editMyPwdBoxClose()
//
ElMessage.success('密码修改成功');
}else{
//
//
ElMessage.error(data.msg);
}
addLoading.value = false
}).finally(() => {
addLoading.value = false
})
} else {
//
console.log('表单验证不通过');
addLoading.value = false
}
});
}
/**
* 初始化数据
@ -57,7 +136,25 @@ function initData(){
width="30%"
custom-class="dialog_box"
:before-close="editMyPwdBoxClose"
>
>
<el-form
ref="rulePowwerFormRef"
style="width: 100%"
:model="saveData"
:rules="rules"
label-width="auto"
>
<el-form-item label="原始密码" prop="oldPassword">
<el-input v-model="saveData.oldPassword" type="password" autocomplete="off" placeholder="请输入原始密码" clearable show-password />
</el-form-item>
<el-form-item label="新密码" prop="newPassword">
<el-input v-model="saveData.newPassword" type="password" autocomplete="off" placeholder="请输入新密码" clearable show-password />
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="saveData.confirmPassword" type="password" autocomplete="off" placeholder="请确认新密码" clearable show-password />
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" :loading="addLoading" @click="submitEditPwdForm" > </el-button>

307
src/utils/CheckPassword.ts

@ -0,0 +1,307 @@
/**
*
*/
const REG_NUMBER:string = ".*\\d+.*";
/**
*
*/
const REG_UPPERCASE:string = ".*[A-Z]+.*";
/**
*
*/
const REG_LOWERCASE:string = ".*[a-z]+.*";
/**
* (~!@#$%^&*()_+|<>,.?/:;'[]{}\)
*/
const REG_SYMBOL:string = ".*[~!@#$%^&*()_+|<>,.?/:;'\\[\\]{}\"]+.*";
/**
* ()
* shift键盘字符表
*/
const CHAR_TABLE1:string[][] = [
['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\0'],
['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\\'],
['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '\0', '\0'],
['z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', '\0', '\0', '\0']];
/**
* shift键盘的字符表
*/
const CHAR_TABLE2:string[][] = [
['!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '\0'],
['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '{', '}', '|'],
['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ':', '"', '\0', '\0'],
['z', 'x', 'c', 'v', 'b', 'n', 'm', '<', '>', '?', '\0', '\0', '\0']];
/**
*
* @param password
* @param username
*/
export const checkPasswordRule = (password:string,username:string) => {
if (password === '' || password.length < 8 || password.length > 32) {
// console.log("长度小于8,或大于32");
return "密码长度应大于8小于32";
} if (password.indexOf(username) !== -1) {
// console.log("包含用户名");
return "请勿包含用户名";
}
if (isContinuousChar(password)) {
// console.log("包含3个及以上相同或字典连续字符");
return "请勿包含3个及以上相同或连续的字符";
}
if (isKeyBoardContinuousChar(password)) {
// console.log("包含3个及以上键盘连续字符");
return "请勿包含3个及以上键盘连续字符";
}
let i:number = 0;
if (password.match(REG_NUMBER)) i++;
if (password.match(REG_LOWERCASE)) i++;
if (password.match(REG_UPPERCASE)) i++;
if (password.match(REG_SYMBOL)) i++;
if (i < 2) {
// console.log(("数字、小写字母、大写字母、特殊字符,至少包含两种"));
return "数字、小写字母、大写字母、特殊字符,至少包含两种";
}
// console.log(i);
return "校验通过";
}
/**
* 3
*/
const isContinuousChar = (password:string) => {
let chars: string[] = password.split('')
let charCode: number[] = [];
for (let i = 0; i < chars.length - 2; i++) {
charCode[i] = chars[i].charCodeAt(0)
}
for (let i = 0; i < charCode.length - 2; i++) {
let n1 = charCode[i];
let n2 = charCode[i + 1];
let n3 = charCode[i + 2];
// 判断重复字符
if (n1 == n2 && n1 == n3) {
return true;
}
// 判断连续字符: 正序 + 倒序
if ((n1 + 1 == n2 && n1 + 2 == n3) || (n1 - 1 == n2 && n1 - 2 == n3)) {
return true;
}
}
return false;
}
/**
* 3
* @param password
*/
const isKeyBoardContinuousChar = (password:string) => {
if (password === '') {
return false;
}
//考虑大小写,都转换成小写字母
let lpStrChars: string[] = password.toLowerCase().split('')
// 获取字符串长度
let nStrLen: number = lpStrChars.length;
// 定义位置数组:row - 行,col - column 列
const pRowCharPos:number[] = new Array(nStrLen).fill('')
const pColCharPos: number[] = new Array(nStrLen).fill('')
for (let i = 0; i < nStrLen; i++) {
let chLower: string = lpStrChars[i];
pColCharPos[i] = -1;
// 检索在表1中的位置,构建位置数组
for (let nRowTable1Idx = 0; nRowTable1Idx < 4; nRowTable1Idx++) {
for (let nColTable1Idx = 0; nColTable1Idx < 13; nColTable1Idx++) {
if (chLower == CHAR_TABLE1[nRowTable1Idx][nColTable1Idx]) {
pRowCharPos[i] = nRowTable1Idx;
pColCharPos[i] = nColTable1Idx;
}
}
}
// 在表1中没找到,到表二中去找,找到则continue
if (pColCharPos[i] >= 0) {
continue;
}
// 检索在表2中的位置,构建位置数组
for (let nRowTable2Idx = 0; nRowTable2Idx < 4; nRowTable2Idx++) {
for (let nColTable2Idx = 0; nColTable2Idx < 13; nColTable2Idx++) {
if (chLower == CHAR_TABLE2[nRowTable2Idx][nColTable2Idx]) {
pRowCharPos[i] = nRowTable2Idx;
pColCharPos[i] = nColTable2Idx;
}
}
}
}
// 匹配坐标连线
for (let j = 1; j <= nStrLen - 2; j++) {
//同一行
if (pRowCharPos[j - 1] == pRowCharPos[j] && pRowCharPos[j] == pRowCharPos[j + 1]) {
// 键盘行正向连续(asd)或者键盘行反向连续(dsa)
if ((pColCharPos[j - 1] + 1 == pColCharPos[j] && pColCharPos[j] + 1 == pColCharPos[j + 1]) ||
(pColCharPos[j + 1] + 1 == pColCharPos[j] && pColCharPos[j] + 1 == pColCharPos[j - 1])) {
return true;
}
}
//同一列
if (pColCharPos[j - 1] == pColCharPos[j] && pColCharPos[j] == pColCharPos[j + 1]) {
//键盘列连续(qaz)或者键盘列反向连续(zaq)
if ((pRowCharPos[j - 1] + 1 == pRowCharPos[j] && pRowCharPos[j] + 1 == pRowCharPos[j + 1]) ||
(pRowCharPos[j - 1] - 1 == pRowCharPos[j] && pRowCharPos[j] - 1 == pRowCharPos[j + 1])) {
return true;
}
}
}
return false;
}
/**
*
*/
/**
*
* @param str
*/
const length = (str:string) => {
if(str.length<5){
return 5;
}else if(str.length<8){
return 10;
}else{
return 25;
}
}
/**
*
* @param str
*/
const letters = (str: string) => {
let count1=0,count2=0;
for(let i=0;i<str.length;i++){
if(str.charAt(i)>='a'&&str.charAt(i)<='z'){
count1++;
}
if(str.charAt(i)>='A'&&str.charAt(i)<='Z'){
count2++;
}
}
if(count1==0 && count2==0){
return 0;
}
if(count1!=0 && count2!=0){
return 20;
}
return 10;
}
/**
*
* @param str
*/
const numbers = (str: string) => {
let count=0;
for(let i=0;i<str.length;i++){
if(str.charAt(i)>='0'&&str.charAt(i)<='9'){
count++;
}
}
if(count==0){
return 0;
}
if(count==1){
return 10;
}
return 20;
}
/**
*
* @param str
*/
const symbols = (str: string) => {
let count=0;
for(let i=0;i<str.length;i++){
if(str.charCodeAt(i)>=0x21 && str.charCodeAt(i)<=0x2F ||
str.charCodeAt(i)>=0x3A && str.charCodeAt(i)<=0x40 ||
str.charCodeAt(i)>=0x5B && str.charCodeAt(i)<=0x60 ||
str.charCodeAt(i)>=0x7B && str.charCodeAt(i)<=0x7E ){
count++;
}
}
if(count==0){
return 0;
}
if(count==1){
return 10;
}
return 25;
}
/**
*
* @param str
*/
const rewards = (str: string) => {
let letter=letters(str);//字母
let number=numbers(str);//数字
let symbol=symbols(str);//符号
if(letter>0 && number>0 && symbol==0){//字母和数字
return 2;
}
if(letter==10 && number>0 && symbol>0){//字母、数字和符号
return 3;
}
if(letter==20 && number>0 && symbol>0){//大小写字母、数字和符号
return 5;
}
return 0;
}
/**
*
* @param str
*/
export const level = (str: string) => {
let lengths=length(str);//长度
let letter=letters(str);//字母
let number=numbers(str);//数字
let symbol=symbols(str);//符号
let reward=rewards(str);//奖励
let sum=lengths+letter+number+symbol+reward;
console.log(sum);
if(sum>=80){
return "非常强";//非常安全
}else if(sum>=60){
return "强";//非常强
}else if(sum>=40){
return "一般";//一般
}else if(sum>=25){
return "弱";//弱
}else{
return "非常弱";//非常弱
}
}
export const checkPwdRule = (password:string) => {
if (password === '' || password.length < 8 || password.length > 32) {
// console.log("长度小于8,或大于32");
return "密码长度应大于8小于32";
}
if (isContinuousChar(password)) {
// console.log("包含3个及以上相同或字典连续字符");
return "请勿包含3个及以上相同或连续的字符";
}
if (isKeyBoardContinuousChar(password)) {
// console.log("包含3个及以上键盘连续字符");
return "请勿包含3个及以上键盘连续字符";
}
let i:number = 0;
if (password.match(REG_NUMBER)) i++;
if (password.match(REG_LOWERCASE)) i++;
if (password.match(REG_UPPERCASE)) i++;
if (password.match(REG_SYMBOL)) i++;
if (i < 2) {
// console.log(("数字、小写字母、大写字母、特殊字符,至少包含两种"));
return "数字、小写字母、大写字母、特殊字符,至少包含两种";
}
// console.log(i);
return "校验通过";
}

10
src/views/system/monitor/online/index.vue

@ -344,6 +344,8 @@ const getAppTableList = (number:boolean) => {
watch(()=>systemPower.value.appSystem,(val:string)=>{
if(val=="app"){
getAppList();
}else{
getSystemPowerSub()
}
systemPower.value.isPick = false
},{
@ -488,6 +490,8 @@ const pickUser = (item:any) =>{
console.log("选择用户陪权--111111->",item)
item.isPick = true
systemPower.value.roleId = item.id.toString()
// systemPower.value.powerType="user"
console.log("选择用户陪权--2222->",userPowerList)
if(userPowerList.value.list && Array.isArray(userPowerList.value.list)){
userPowerList.value.list.forEach((items:any)=>{
// console.log("--111111->",items.id)
@ -496,6 +500,7 @@ const pickUser = (item:any) =>{
}
})
}
getSystemPowerSub()
}
/**
@ 作者: 秦东
@ -642,7 +647,7 @@ onMounted(()=>{
</template>
</el-tree-v2>
</el-tab-pane>
<el-tab-pane label="个人" name="person">
<el-tab-pane label="用户" name="person">
<div class="searchBox">
<el-input v-model="searchUserQuery.name" placeholder="请输入要查找的人" :suffix-icon="Search" @input="onQueryChangedOrgUser" clearable />
</div>
@ -768,8 +773,7 @@ onMounted(()=>{
<td valign="top">
<el-scrollbar class="tab_pane_box">
<ul class="appListBox">
<li v-for="item in appList" :key="item" @click="pickAppList(item)" :class="{'active':item.isPick}"
>
<li v-for="item in appList" :key="item" @click="pickAppList(item)" :class="{'active':item.isPick}">
<el-checkbox @click.stop="pickAppTableList(item)" v-model="item.pickAll" :value="item.pickAll" :disabled="!item.isPick" ></el-checkbox>
{{ item.name }}
</li>

42
src/views/system/monitor/online/roleConfig/setRolePeople.vue

@ -31,13 +31,26 @@ const props = defineProps({
})
const userLoading = ref(false)
const emit = defineEmits(['update:show'])
const isShow = computed(() => {
if(props.show){
getPowerPageUserSub()
getPickUser()
// const isShowsdf = computed(() => {
// if(props.show){
// getPowerPageUserSub()
// // getPickUser()
// }
// return props.show
// })
const isShowsdf = computed({
get(){
console.log("------------------->",props.show)
return props.show
},
set(val){
emit('update:show', val)
}
return props.show
})
const roleInfo = computed(() => {
return props.roleInfo
})
@ -81,6 +94,9 @@ const closeDialog = () => {
userPowerList.value =
pickUserKey.value=[]
userPowerListPick.value=[]
userPage.page = 1
userPage.name = ''
userPage.orgId = ''
}
/**
@ 作者: 秦东
@ -164,13 +180,27 @@ const saveRolePeople = () => {
}
})
}
watch(() => props.show, (newVal) => {
if(newVal){
getPowerPageUserSub()
getPickUser()
}
},{
immediate: true
})
watch(() => userPage.name, (newVal) => {
getPowerPageUserSub()
},{
immediate: true
})
onMounted(() => {
getPowerPageUserSub()
getPickUser()
})
</script>
<template>
<el-dialog
v-model="isShow"
v-model="isShowsdf"
:title="`编辑<<${roleInfo.label}>>角色使用人`"
width="800"
destroy-on-close

Loading…
Cancel
Save