Commit 60a614be authored by 郭铭瑶's avatar 郭铭瑶 🤘

添加权限控制

parent e3589326
......@@ -2,7 +2,7 @@
"name": "huamu",
"version": "1.0.0",
"description": "花木街道数字孪生城市",
"author": "Guo",
"author": "GuoMingyao",
"private": true,
"scripts": {
"dev": "vite",
......
......@@ -96,6 +96,9 @@ const themeOverrides: GlobalThemeOverrides = {
colorSuccess: '#269D74',
iconColorSuccess: '#fff',
textColorSuccess: '#fff',
colorError: '#E59B00',
iconColorError: '#fff',
textColorError: '#fff',
},
Form: {
feedbackTextColorError: '#E59B00',
......
......@@ -16,27 +16,36 @@ interface Method {
export default {
async getAuth({ commit }: Method) {
if (process.env.NODE_ENV !== 'production') {
// 开发环境
commit('SET_AUTH', {
userid: 91541,
orgid: '000001',
// code: '001.001.031.014.205', // 最高权限
code: '001.001.031.014.205.002.001', //牡丹社区委员会
})
return
}
const userid: number | null = (await useFetchAuth())?.customer?.id || null
if (!userid) return
const orgIds: string[] =
const orgid: string =
(
await useFetchUser({
keys: '组织id',
q: `paths @ "userid" && string == "${userid}"`,
})
)?.['组织id'] || []
const authList: string[] = await Promise.all(
orgIds.map(
async (id) =>
(
await useFetchOrgAuth({
keys: '权限编码',
q: `paths @ "组织id" && string == "${id}"`,
})
)?.['权限编码'] || '',
),
)
commit('SET_AUTH', { userid, orgIds, authList })
)?.[0]?.['组织id']?.[0] || ''
const code: string =
(
await useFetchOrgAuth({
keys: '权限编码',
q: `paths @ "组织id" && string == "${orgid}"`,
})
)?.[0]?.['权限编码'] || ''
commit('SET_AUTH', { userid, orgid, code })
},
async getBasicInfo({ commit }: Method, query?: string) {
commit('SET_BASIC_INFO', {
......
export default {
showLoading: false,
auth: {
userid: null,
orgIds: [],
authList: [],
userid: 0,
orgid: '',
code: '',
},
showTag: true,
showBasicInfo: true,
......
......@@ -117,11 +117,11 @@ onMounted(() => {
async function getList(query?: string) {
const result = [...list.value]
result.forEach(async (item) => {
let q = `paths @ "标签类别" && string == "${item.title}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`
query && (q += `,${query}`)
const data = await useFetchActivity({
keys: '实际参与人数,出席率',
q: query
? `paths @ "标签类别" && string == "${item.title}",${query}`
: `paths @ "标签类别" && string == "${item.title}"`,
q,
})
const activityAmount = data.length || 0
let personAmount = 0
......
......@@ -123,8 +123,10 @@ const message = useMessage()
const activityList = ref([])
const fetchList = useDebounce(async (query?: string) => {
let q = `paths @ "党组织编号" && string @ "${store.state.auth.code}"`
query && (q += `,${query}`)
activityList.value =
(await useFetchActivity({ q: query }))?.map((item: any) => ({
(await useFetchActivity({ q }))?.map((item: any) => ({
id: item.id,
...item.extra,
})) || []
......@@ -253,7 +255,20 @@ const columns = [
)
},
},
{ title: '参与人数', key: '实际参与人数' },
{
title: '参与人数',
key: '实际参与人数',
render(row: any) {
return h(
'span',
{},
{
default: () =>
row['实际参与人数'] ? `${row['实际参与人数']}人` : '',
},
)
},
},
{
title: ' ',
key: 'actions',
......
......@@ -289,7 +289,7 @@ const getDetail = async (type: string, name: string) => {
switch (type) {
case 'organization':
res = await useFetchOrg({
q: `paths @ "标签" && string @ "${name}"`,
q: `paths @ "标签" && string @ "${name}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`,
})
break
case 'member':
......@@ -299,16 +299,16 @@ const getDetail = async (type: string, name: string) => {
dayjs().subtract(50, 'year').format('YYYY-MM-DD'),
]
res = await useFetchMember({
q: `paths @ "加入中共党组织日期" && string >= "${date[0]}",paths @ "加入中共党组织日期" && string <= "${date[1]}"`,
q: `paths @ "加入中共党组织日期" && string >= "${date[0]}",paths @ "加入中共党组织日期" && string <= "${date[1]}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`,
})
} else if (name === '党心暖我心') {
const date = dayjs().subtract(60, 'year').format('YYYY-MM-DD')
res = await useFetchMember({
q: `paths @ "加入中共党组织日期" && string <= "${date}"`,
q: `paths @ "加入中共党组织日期" && string <= "${date}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`,
})
} else {
res = await useFetchMember({
q: `paths @ "标签" && string @ "${name}"`,
q: `paths @ "标签" && string @ "${name}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`,
})
}
break
......
......@@ -184,10 +184,10 @@ const removeResult = () => {
const handleSearch = useDebounce(async function () {
isLoading.value = true
const orgs = await useFetchOrg({
q: `paths @ "党组织名称" && string @ "${searchKey.value}"`,
q: `paths @ "党组织名称" && string @ "${searchKey.value}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`,
})
const members = await useFetchMember({
q: `paths @ "姓名" && string @ "${searchKey.value}"`,
q: `paths @ "姓名" && string @ "${searchKey.value}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`,
})
resultData.value = {
organization: orgs,
......
......@@ -119,7 +119,7 @@
>
<n-grid :cols="24" :x-gap="12">
<n-form-item-gi :span="12" label="实际参与人数" path="count">
<p v-if="mode === 'view'">{{ memberData.count }}</p>
<p v-if="mode === 'view'">{{ memberData.count }}</p>
<n-input-number
v-else
v-model:value="memberData.count"
......@@ -135,7 +135,7 @@
label="不计入参与活动党员人数"
path="excludeCount"
>
<p v-if="mode === 'view'">{{ memberData.excludeCount }}</p>
<p v-if="mode === 'view'">{{ memberData.excludeCount }}</p>
<n-input-number
v-else
v-model:value="memberData.excludeCount"
......@@ -173,6 +173,7 @@
accept=".docx,.doc,.xlsx,.xls,.csv,.txt"
:on-change="(e) => onFileChange(e, 'memberData.attachment')"
:show-remove-button="mode !== 'view'"
@before-upload="beforeUpload"
>
<n-button v-if="mode !== 'view'"> 上传附件 </n-button>
</n-upload>
......@@ -193,6 +194,7 @@
:on-change="
(e) => onFileChange(e, 'memberData.attachmentPhoto')
"
@before-upload="beforeUpload"
@preview="handlePreview"
>
点击上传
......@@ -256,6 +258,7 @@
:on-change="
(e) => onFileChange(e, 'detailData.attachmentPhoto')
"
@before-upload="beforeUpload"
@preview="handlePreview"
>
点击上传
......@@ -277,6 +280,7 @@
list-type="image-card"
:show-remove-button="mode !== 'view'"
:on-change="(e) => onFileChange(e, 'detailData.photoList')"
@before-upload="beforeUpload"
@preview="handlePreview"
>
点击上传
......@@ -327,12 +331,15 @@ onMounted(async () => {
orgOptions.value = (
await useFetchOrg({
a: 'id,count',
keys: '党组织名称',
keys: '党组织名称,是否虚拟组织',
q: `paths @ "党组织编号" && string @ "${store.state.auth.code}"`,
})
)?.map((item: any) => ({
label: item['党组织名称'],
value: item['党组织名称'],
}))
)
?.filter((item: any) => !item['是否虚拟组织'])
?.map((item: any) => ({
label: item['党组织名称'],
value: item['党组织名称'],
}))
})
const show = computed(() => store.state.showNewActivityDrawer)
......@@ -592,6 +599,7 @@ const submit = () => {
活动照片: photoList?.map((item: any) => item.url) || [],
上海2000经度: location.value[0],
上海2000纬度: location.value[1],
党组织编号: orgCode.value,
出席率:
totalPerson.value === excludeCount
? 0
......@@ -654,6 +662,15 @@ function getPercent(val: number) {
return val
}
function beforeUpload(options: any) {
if (!options || !options.file) return false
if (options.file.file.size >= 20000000) {
message.error('不能上传超过20MB的文件')
return false
}
return true
}
async function onFileChange(options: any, type: string) {
console.log('change', options, type)
if (!options) return
......@@ -696,6 +713,8 @@ async function onFileChange(options: any, type: string) {
}
if (!options.file) return
if (options.file.file.size >= 20000000) return
const url = { url: await useAliOss(options.file.file) }
switch (type) {
......@@ -738,16 +757,18 @@ async function onFileChange(options: any, type: string) {
const totalPerson = ref(0)
const location = ref<number[]>([])
const orgCode = ref('')
async function getOrgInfo(name: string) {
if (!name) return
const res = (
await useFetchOrg({
keys: '党员数量,上海2000经度,上海2000纬度',
keys: '党员数量,上海2000经度,上海2000纬度,党组织编号',
q: `paths @ "党组织名称" && string == "${name}"`,
})
)?.[0]
totalPerson.value = res?.['党员数量'] || 0
location.value = [res?.['上海2000经度'] || 0, res?.['上海2000纬度'] || 0]
orgCode.value = res?.['党组织编号'] || ''
}
watch(
() => basicData.value.orgName,
......
......@@ -183,7 +183,7 @@ const handleSelect = (data: any) => {
<style lang="stylus" scoped>
@import '../../components/MyComponent/main.styl'
.search-modal
z-index 999
z-index 9999
border .01rem solid $light-gray
border-radius .03rem
background #fbfcfe
......
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