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

组织架构添加权限控制

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