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

添加权限控制

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