Commit 9791d78c authored by 郭铭瑶's avatar 郭铭瑶 🤘

组织架构添加权限控制

parent 60a614be
......@@ -21,8 +21,15 @@ export default {
commit('SET_AUTH', {
userid: 91541,
orgid: '000001',
// code: '001.001.031.014.205', // 最高权限
code: '001.001.031.014.205.002.001', //牡丹社区委员会
code: '001.001.031.014.205', // 最高权限
// code: '001.001.031.014.205.001', // 行政党组
// code: '001.001.031.014.205.002', // 社区党委
// code: '001.001.031.014.205.002.001', //牡丹社区委员会
// code: '001.001.031.014.205.002.001.601', // 牡丹第一居民区总支部委员会
// code: '001.001.031.014.205.002.007', // 杉杉控股
// code: '001.001.031.014.205.002.804', // 钦洋投资管理中心总支委员会
// code: '001.001.031.014.205.003', // 机关事业单位
// code: '001.001.031.014.205.003.701', // 机关第一支部委员会
})
return
}
......
......@@ -6,8 +6,9 @@
>
<div id="struct-modal">
<n-layout class="layout" has-sider>
<n-layout-sider width="25%" class="side-menu">
<n-layout-sider v-if="!onlyOne" width="25%" class="side-menu">
<h2
v-if="code === '001.001.031.014.205'"
:class="{ on: curKey === 'default' }"
@click.prevent="
() => {
......@@ -39,15 +40,6 @@
collapsed-mode="width"
class="sub"
>
<!-- <p
v-for="item in subList"
:key="item.key"
:class="{ on: subKey === item.key }"
:title="item.label"
@click.prevent="setSub(item)"
>
{{ item.label }}
</p> -->
<n-menu
:on-update:value="toSetSub"
class="sub-menu"
......@@ -189,6 +181,58 @@
</div>
</div>
</div>
<div v-else-if="curKey === '4'" class="card">
<div class="flex">
<div class="col">
<div class="row">
<span>
{{
curMenu['等级'] === '党总支'
? '党总支书记'
: '党委书记'
}}
</span>
<p>{{ curMenu['书记'] }}</p>
</div>
<div class="row">
<span>党组织地址</span>
<p>{{ curMenu['党组织地址'] }}</p>
</div>
<div class="row">
<span>党员数量</span>
<p>
{{
curMenu['党员数量']
? curMenu['党员数量'] + ' 位'
: '无'
}}
</p>
</div>
</div>
<div class="col">
<div class="row">
<span>
{{
curMenu['等级'] === '党总支'
? '党总支委员'
: '党委成员'
}}
</span>
<p>{{ curMenu['委员'] }}</p>
</div>
<div class="row">
<span>党组织联系方式</span>
<p>
{{
curMenu['联系方式_座机'] ||
curMenu['联系方式_手机'] ||
'无'
}}
</p>
</div>
</div>
</div>
</div>
<div
v-else-if="
curKey.split('-').length === 3 && curMenu && curMenu._hasSub
......@@ -198,7 +242,13 @@
<div class="flex">
<div class="col">
<div class="row">
<span>党委书记</span>
<span>
{{
curSubMenu['等级'] === '党总支'
? '党总支书记'
: '党委书记'
}}
</span>
<p>{{ curSubMenu['书记'] }}</p>
</div>
<div class="row">
......@@ -218,7 +268,13 @@
</div>
<div class="col">
<div class="row">
<span>党委成员</span>
<span>
{{
curSubMenu['等级'] === '党总支'
? '党总支委员'
: '党委成员'
}}
</span>
<p>{{ curSubMenu['委员'] }}</p>
</div>
<div class="row">
......@@ -236,10 +292,13 @@
</div>
<template
v-else-if="
((curKey.startsWith('2') || curKey.startsWith('3')) &&
((curKey.startsWith('2') ||
curKey.startsWith('3') ||
curKey.startsWith('4')) &&
curKey.split('-').length === 2) ||
(curKey.split('-').length === 3 &&
(!curMenu || !curMenu._hasSub))
(!curMenu || !curMenu._hasSub)) ||
onlyOne
"
>
<div class="card">
......@@ -329,6 +388,8 @@ import { useFetchOrg, useFetchMember } from '@/hooks/useFetch'
import { organization } from '@/util/tags'
import useExportFile from '@/hooks/useExportFile'
const code = computed(() => store.state.auth.code)
const show = computed(() => store.state.showStructModal)
const close = () => {
store.commit('SET_STRUCT_MODAL', false)
......@@ -337,12 +398,26 @@ const close = () => {
clear()
}
function clear() {
if (onlyOne.value) return
subKey.value = null
curSubMenu.value = {}
expandedKeys.value = []
subExpandedKeys.value = []
initCurMenu()
}
function initCurMenu() {
if (code.value === '001.001.031.014.205') {
curMenu.value = { label: '中共浦东新区花木街道工作委员会', key: 'default' }
curKey.value = 'default'
} else {
curMenu.value = {
label: menus.value?.[0]?.label,
key: menus.value?.[0]?.key,
...menus.value?.[0],
}
curKey.value = curMenu.value.key
}
}
function renderIcon() {
......@@ -355,125 +430,115 @@ const communityParty = ref<any>({}) // 社区党委
const belongToInstitution = ref<any[]>([])
const belongToCommunityParty = ref<any[]>([])
onMounted(async () => {
defaultData.value = (
await useFetchOrg({
q: 'paths @ "党组织名称" && string == "中共上海市浦东新区花木街道工作委员会"',
})
)?.[0]?.extra
administration.value = (
await useFetchOrg({
q: 'paths @ "党组织名称" && string == "行政党组"',
})
)?.[0]?.extra
institution.value = (
await useFetchOrg({
q: 'paths @ "党组织名称" && string == "中共花木街道机关事业单位总支部委员会"',
})
)?.[0]?.extra
communityParty.value = (
await useFetchOrg({
q: 'paths @ "党组织名称" && string == "社区党委"',
})
)?.[0]?.extra
const onlyOne = ref(false)
belongToInstitution.value = (
await useFetchOrg({
q: 'paths @ "上级党组织名称" && string == "中共花木街道机关事业单位总支部委员会"',
onMounted(async () => {
const orgList = await useFetchOrg({
q: `paths @ "党组织编号" && string @ "${code.value}"`,
})
)?.map((item: any, i: number) => {
const data = item.extra
return {
...data,
label: data['党组织名称'].replace('中共浦东新区花木街道', ''),
key: '2-' + (i + 1),
if (orgList.length === 1) {
onlyOne.value = true
curMenu.value = {
label: orgList[0].extra['党组织名称'],
key: 'one',
...orgList[0].extra,
}
})
belongToCommunityParty.value = (
await useFetchOrg({
q: 'paths @ "上级党组织名称" && string == "社区党委"',
})
)?.map((item: any, i: number) => {
const data = item.extra
return {
...data,
label: data['党组织名称'].replace('中共花木街道', '').replace('中共', ''),
key: '3-' + (i + 1),
curKey.value = 'one'
return
}
})
const data = belongToCommunityParty.value
const bigSixChildren: any[] = []
const twoNewChildren: any[] = []
const datasource = data.filter((item: any) => item['是否虚拟组织']) || []
data.forEach((item: any) => {
if (item['是否虚拟组织']) return
if (item['类别'] === '居民区') {
bigSixChildren.push(item)
} else if (item['类别'] === '两新') {
twoNewChildren.push(item)
} else {
datasource.push(item)
if (code.value === '001.001.031.014.205.003') {
// 机关事业单位党总支
await setInstitution()
menus.value = [
{
label: '机关事业单位党总支',
key: '2',
icon: renderIcon(),
children: belongToInstitution.value,
...institution.value,
},
]
initCurMenu()
return
}
})
const bigSix = datasource.find((e: any) =>
e['党组织名称']?.includes('六大社区党委'),
)
const twoNew = datasource.find((e: any) => e['党组织名称']?.includes('两新'))
bigSix.children = await Promise.all(
bigSixChildren.map(async (e: any, i: number) => {
const children = await checkHasChildren(e)
const result = {
...e,
label: e['党组织名称'].replace('中共花木街道', '').replace('中共', ''),
key: bigSix.key + '-' + (i + 1),
if (code.value === '001.001.031.014.205.002') {
// 社区党委
await setCommunityParty()
menus.value = [
{
label: '社区党委',
key: '3',
icon: renderIcon(),
children: belongToCommunityParty.value,
...communityParty.value,
},
]
initCurMenu()
return
}
if (code.value !== '001.001.031.014.205') {
const cur = (
await useFetchOrg({
q: `paths @ "党组织编号" && string == "${code.value}"`,
})
)?.[0]?.extra
const children = await checkHasChildren(cur)
let result = []
if (children && children.length > 0) {
result._hasSub = true
result.subList = children.map((child: any, index: number) => ({
...child,
label: child['党组织名称']
result = await Promise.all(
children.map(async (child: any, index: number) => {
child.label = child['党组织名称']
.replace('中共花木街道', '')
.replace('中共', '')
.replace('浦东新区花木街道', '')
.replace('中共', ''),
key: result.key + '-' + (index + 1),
child.key = `4-${index + 1}`
const grandson = await checkHasChildren(child)
if (grandson && grandson.length > 0) {
child.children = grandson.map((son: any, i: number) => ({
key: `${child.key}-${i + 1}`,
label: son['党组织名称']
.replace('中共花木街道', '')
.replace('中共', '')
.replace('浦东新区花木街道', ''),
...son,
}))
}
return result
return child
}),
)
twoNew.children = await Promise.all(
twoNewChildren.map(async (e: any, i: number) => {
const children = await checkHasChildren(e)
const result = {
...e,
label: e['党组织名称'].replace('中共花木街道', '').replace('中共', ''),
key: twoNew.key + '-' + (i + 1),
}
if (children && children.length > 0) {
result._hasSub = true
result.subList = children.map((child: any, index: number) => ({
...child,
label: child['党组织名称']
.replace('浦东新区花木街道', '')
.replace('中共', ''),
key: result.key + '-' + (index + 1),
}))
menus.value = [
{
label: cur['党组织名称']
.replace('中共花木街道', '')
.replace('中共', '')
.replace('浦东新区花木街道', ''),
key: '4',
icon: renderIcon(),
children: result || [],
...cur,
},
]
initCurMenu()
return
}
return result
}),
)
belongToCommunityParty.value = datasource
})
async function checkHasChildren(data: any) {
return (
defaultData.value = (
await useFetchOrg({
q: `paths @ "上级党组织名称" && string == "${data['党组织名称']}"`,
q: 'paths @ "党组织名称" && string == "中共上海市浦东新区花木街道工作委员会"',
})
)?.map((e: any) => e.extra)
}
const menus = computed(() => [
)?.[0]?.extra
administration.value = (
await useFetchOrg({
q: 'paths @ "党组织名称" && string == "行政党组"',
})
)?.[0]?.extra
await setInstitution()
await setCommunityParty()
menus.value = [
{ label: '行政党组', key: '1', icon: renderIcon() },
{
label: '机关事业单位党总支',
......@@ -487,7 +552,20 @@ const menus = computed(() => [
icon: renderIcon(),
children: belongToCommunityParty.value,
},
])
]
initCurMenu()
})
async function checkHasChildren(data: any) {
if (!data) return []
return (
await useFetchOrg({
q: `paths @ "上级党组织名称" && string == "${data['党组织名称']}"`,
})
)?.map((e: any) => e.extra)
}
const menus = ref<any[]>([])
const subList = ref<any[]>([])
......@@ -496,7 +574,11 @@ const handleExpand = (val: string[]) => {
if (expandedKeys.value.length === 0 || val.length === 0) {
expandedKeys.value = val
} else if (val[val.length - 1].startsWith(expandedKeys.value[0])) {
if (val.length >= 3) {
expandedKeys.value = [val[0], val[val.length - 1]]
} else {
expandedKeys.value = val
}
} else {
expandedKeys.value = [val[val.length - 1]]
}
......@@ -504,11 +586,16 @@ const handleExpand = (val: string[]) => {
expandedKeys.value = []
subExpandedKeys.value = []
subKey.value = null
curMenu.value = { label: '中共浦东新区花木街道工作委员会', key: 'default' }
curKey.value = 'default'
initCurMenu()
return
}
if (expandedKeys.value.length === 0) return
if (expandedKeys.value[0] === '4' && expandedKeys.value.length === 2) {
const key = expandedKeys.value[expandedKeys.value.length - 1]
curMenu.value = menus.value[0].children.find((e: any) => e.key === key)
curKey.value = curMenu.value?.key
return
}
curKey.value = expandedKeys.value[0]
const cur = menus.value.find((e) => e.key === curKey.value)
subKey.value = null
......@@ -519,12 +606,9 @@ const handleExpand = (val: string[]) => {
}
}
const curKey = ref<string | null>('default')
const curKey = ref<string | null>('')
const subKey = ref<string | null>(null)
const curMenu = ref<any>({
label: '中共浦东新区花木街道工作委员会',
key: 'default',
})
const curMenu = ref<any>({})
const curSubMenu = ref<any>({})
const setCurKey = (val: string, item: any) => {
curKey.value = val
......@@ -613,6 +697,108 @@ const pagination = {
const exportList = () => {
useExportFile(tableList.value, '姓名', `${curMenu.value.label}党员详表`)
}
async function setInstitution() {
institution.value = (
await useFetchOrg({
q: 'paths @ "党组织名称" && string == "中共花木街道机关事业单位总支部委员会"',
})
)?.[0]?.extra
belongToInstitution.value = (
await useFetchOrg({
q: 'paths @ "上级党组织名称" && string == "中共花木街道机关事业单位总支部委员会"',
})
)?.map((item: any, i: number) => {
const data = item.extra
return {
...data,
label: data['党组织名称'].replace('中共浦东新区花木街道', ''),
key: '2-' + (i + 1),
}
})
}
async function setCommunityParty() {
communityParty.value = (
await useFetchOrg({
q: 'paths @ "党组织名称" && string == "社区党委"',
})
)?.[0]?.extra
belongToCommunityParty.value = (
await useFetchOrg({
q: 'paths @ "上级党组织名称" && string == "社区党委"',
})
)?.map((item: any, i: number) => {
const data = item.extra
return {
...data,
label: data['党组织名称'].replace('中共花木街道', '').replace('中共', ''),
key: '3-' + (i + 1),
}
})
const data = belongToCommunityParty.value
const bigSixChildren: any[] = []
const twoNewChildren: any[] = []
const datasource = data.filter((item: any) => item['是否虚拟组织']) || []
data.forEach((item: any) => {
if (item['是否虚拟组织']) return
if (item['类别'] === '居民区') {
bigSixChildren.push(item)
} else if (item['类别'] === '两新') {
twoNewChildren.push(item)
} else {
datasource.push(item)
}
})
const bigSix = datasource.find((e: any) =>
e['党组织名称']?.includes('六大社区党委'),
)
const twoNew = datasource.find((e: any) => e['党组织名称']?.includes('两新'))
bigSix.children = await Promise.all(
bigSixChildren.map(async (e: any, i: number) => {
const children = await checkHasChildren(e)
const result = {
...e,
label: e['党组织名称'].replace('中共花木街道', '').replace('中共', ''),
key: bigSix.key + '-' + (i + 1),
}
if (children && children.length > 0) {
result._hasSub = true
result.subList = children.map((child: any, index: number) => ({
...child,
label: child['党组织名称']
.replace('浦东新区花木街道', '')
.replace('中共', ''),
key: result.key + '-' + (index + 1),
}))
}
return result
}),
)
twoNew.children = await Promise.all(
twoNewChildren.map(async (e: any, i: number) => {
const children = await checkHasChildren(e)
const result = {
...e,
label: e['党组织名称'].replace('中共花木街道', '').replace('中共', ''),
key: twoNew.key + '-' + (i + 1),
}
if (children && children.length > 0) {
result._hasSub = true
result.subList = children.map((child: any, index: number) => ({
...child,
label: child['党组织名称']
.replace('浦东新区花木街道', '')
.replace('中共', ''),
key: result.key + '-' + (index + 1),
}))
}
return result
}),
)
belongToCommunityParty.value = datasource
}
</script>
<style lang="stylus" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment