Browse Source

设置权限

qin_v20
herenshan112 7 months ago
parent
commit
cace8b1fff
  1. 178
      src/views/hr/orgUserRole/org.vue

178
src/views/hr/orgUserRole/org.vue

@ -3,33 +3,35 @@
@ 时间: 2024-05-24 13:36:49
@ 备注: 只有行政组织的选项列
-->
<script lang='ts' setup>
import { Search,ArrowRight } from '@element-plus/icons-vue' //
import { userOrgRole,crumb } from '@/api/hr/search/types'
<script lang="ts" setup>
import { Search, ArrowRight } from "@element-plus/icons-vue"; //
import { userOrgRole, crumb } from "@/api/hr/search/types";
import { gainSunOrgAndUser,searchOrgUser } from '@/api/hr/people/index'
import { gainSunOrgAndUser, searchOrgUser } from "@/api/hr/people/index";
const props = defineProps({
pickList: {
type: Object,
default() {
return {}
}
return {};
},
},
orgTrue: {
type: Number,
default:1
}
})
default: 1,
},
});
const emits = defineEmits(["update:pickList", "updataPickLog"]);
const loading = ref(false)
const crumbList = ref<crumb[]>([]) //
const listAry = ref<userOrgRole[]>([]) //
const pickLists = ref<userOrgRole[]>([]) //
const loading = ref(false);
const crumbList = ref<crumb[]>([]); //
const listAry = ref<userOrgRole[]>([]); //
const pickLists = ref<userOrgRole[]>([]); //
const circleUrl = ref('https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png')
const circleUrl = ref(
"https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
);
/**
@ 作者: 秦东
@ -38,11 +40,11 @@ const circleUrl = ref('https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726
*/
const pickList = computed({
get() {
return props.pickList
return props.pickList;
},
set(val: any) {
emits('update:pickList', val)
}
emits("update:pickList", val);
},
});
/**
@ 作者: 秦东
@ -53,40 +55,39 @@ const dataLoading = (orgId?:string) => {
loading.value = true;
gainSunOrgAndUser({ id: orgId })
.then((data) => {
crumbList.value = data.data.orgList
listAry.value = data.data.orgUserList
crumbList.value = data.data.orgList;
listAry.value = data.data.orgUserList;
})
.finally(() => {
loading.value = false;
if (pickLists.value.length > 0) {
listAry.value.forEach((item: userOrgRole) => {
let isTrue = true
let isTrue = true;
pickLists.value.forEach((itemVal: userOrgRole) => {
if (item.id == itemVal.id) {
item.isPick = 1;
isTrue = false;
}
})
});
if (isTrue) {
item.isPick = 2;
}
})
}
})
});
}
});
};
//
onMounted(() => {
if (props.pickList.value.length > 0) {
pickLists.value = props.pickList.value
pickLists.value = props.pickList.value;
nextTick(() => {
dataLoading()
})
dataLoading();
});
} else {
dataLoading()
dataLoading();
}
})
});
/**
@ 作者: 秦东
@ 时间: 2024-05-24 15:04:01
@ -94,57 +95,61 @@ onMounted(()=>{
*/
const pickCont = (val: userOrgRole) => {
if (val.isPick != 1) {
val.isPick = 1
val.isPick = 1;
if (pickLists.value.length > 0) {
let isTrue = true
let isTrue = true;
pickLists.value.forEach((item: userOrgRole) => {
if (item.id == val.id) {
isTrue = false;
}
})
});
if (isTrue) {
pickLists.value.push(val)
pickLists.value.push(val);
}
} else {
pickLists.value.push(val)
pickLists.value.push(val);
}
} else {
val.isPick = 2
val.isPick = 2;
if (pickLists.value.length > 0) {
pickLists.value.forEach((item: userOrgRole, index: number) => {
if (item.id == val.id) {
pickLists.value.splice(index,1)
pickLists.value.splice(index, 1);
}
})
});
}
}
// emits('update:pickList', pickLists)
// console.log("-------->",pickLists.value)
emits('updataPickLog', pickLists.value)
}
emits("updataPickLog", pickLists.value);
};
/**
@ 作者: 秦东
@ 时间: 2024-05-24 15:25:58
@ 功能: 监听已选择的选项
*/
watch(() => props.pickList, (val:userOrgRole[])=>{
watch(
() => props.pickList,
(val: userOrgRole[]) => {
// console.log("-------->",val)
pickLists.value = val
pickLists.value = val;
listAry.value.forEach((item) => {
let isTrue = true
let isTrue = true;
val.forEach((itemVal: userOrgRole) => {
if (item.id == itemVal.id) {
item.isPick = 1;
isTrue = false;
}
})
});
if (isTrue) {
item.isPick = 2;
}
})
},{
deep: true
})
});
},
{
deep: true,
}
);
/**
@ 作者: 秦东
@ 时间: 2024-05-24 15:43:27
@ -152,53 +157,78 @@ watch(() => props.pickList, (val:userOrgRole[])=>{
*/
const pickSunCont = (orgId?: string) => {
// console.log("-------->",orgId)
dataLoading(orgId)
}
dataLoading(orgId);
};
/**
@ 作者: 秦东
@ 时间: 2024-05-27 15:14:57
@ 功能: 搜索组织和人员
*/
const searchOrgUs = (val: any) => {
searchOrgUser({name:val})
.then((data) =>{
searchOrgUser({ name: val }).then((data) => {
// console.log("",data)
listAry.value = data.data.orgUserList
listAry.value = data.data.orgUserList;
// console.log("",listRoleAry)
})
}
});
};
defineExpose({
searchOrgUs
})
searchOrgUs,
});
</script>
<template>
<div>
<el-breadcrumb v-loading="loading" :separator-icon="ArrowRight" class="mianbaoxue">
<el-breadcrumb-item @click="pickSunCont()">首页</el-breadcrumb-item>
<el-breadcrumb-item v-for="item in crumbList" :key="item.id" @click="pickSunCont(item.id)">{{ item.title }}</el-breadcrumb-item>
<el-breadcrumb-item
v-for="item in crumbList"
:key="item.id"
@click="pickSunCont(item.id)"
>{{ item.title }}</el-breadcrumb-item
>
</el-breadcrumb>
<el-scrollbar v-loading="loading" class="contentBox">
<ul>
<li v-for="item in listAry" :key="item.id" :class="item.isPick==1?'active':''">
<li
v-for="item in listAry"
:key="item.id"
:class="item.isPick == 1 ? 'active' : ''"
>
<el-space v-if="orgTrue != 1 && item.types != 2" wrap @click="pickCont(item)">
<i v-if="item.isPick==1" class="fa fa-check-square-o"></i><i v-else class="fa fa-square-o"></i>
<i v-if="item.isPick == 1" class="fa fa-check-square-o"></i
><i v-else class="fa fa-square-o"></i>
<svg-icon v-if="item.types == 2" icon-class="fenZhu" :size="20" />
<svg-icon v-if="item.types == 3" icon-class="tasp" :size="20" />
<el-avatar v-if="item.types==1" shape="square" :size="20" :src="circleUrl" />
<el-avatar
v-if="item.types == 1"
shape="square"
:size="20"
:src="circleUrl"
/>
<el-text>{{ item.title }}</el-text>
</el-space>
<el-space v-if="orgTrue != 1 && item.types == 2" wrap>
<i class="fa fa-minus-square-o"></i>
<svg-icon v-if="item.types == 2" icon-class="fenZhu" :size="20" />
<svg-icon v-if="item.types == 3" icon-class="tasp" :size="20" />
<el-avatar v-if="item.types==1" shape="square" :size="20" :src="circleUrl" />
<el-avatar
v-if="item.types == 1"
shape="square"
:size="20"
:src="circleUrl"
/>
<el-text>{{ item.title }}</el-text>
</el-space>
<el-space v-if="orgTrue == 1" wrap @click="pickCont(item)">
<i v-if="item.isPick==1" class="fa fa-check-square-o"></i><i v-else class="fa fa-square-o"></i>
<i v-if="item.isPick == 1" class="fa fa-check-square-o"></i
><i v-else class="fa fa-square-o"></i>
<svg-icon v-if="item.types == 2" icon-class="fenZhu" :size="20" />
<svg-icon v-if="item.types == 3" icon-class="tasp" :size="20" />
<el-avatar v-if="item.types==1" shape="square" :size="20" :src="circleUrl" />
<el-avatar
v-if="item.types == 1"
shape="square"
:size="20"
:src="circleUrl"
/>
<el-text>{{ item.title }}</el-text>
</el-space>
<div v-if="item.types == 2" class="contentLiLeft">
@ -210,7 +240,7 @@ defineExpose({
</el-scrollbar>
</div>
</template>
<style lang='scss' scoped>
<style lang="scss" scoped>
.mianbaoxue {
display: flex;
white-space: nowrap;
@ -233,18 +263,18 @@ defineExpose({
}
}
li:hover {
background-color: #EBEEF5;
color: #409EFF;
background-color: #ebeef5;
color: #409eff;
.el-text {
color: #409EFF;
color: #409eff;
}
}
li.active {
background-color: #EBEDF0;
color: #409EFF;
background-color: #ebedf0;
color: #409eff;
.el-text {
color: #409EFF;
color: #409eff;
}
}
}
@ -267,10 +297,10 @@ defineExpose({
}
}
li:hover {
background-color: #F56C6C;
color: #FFFFFF;
background-color: #f56c6c;
color: #ffffff;
.el-text {
color: #FFFFFF;
color: #ffffff;
}
}
}

Loading…
Cancel
Save