UnisKB/ui/src/views/application/ApplicationAccess.vue

167 lines
4.8 KiB
Vue
Raw Normal View History

2025-06-03 08:08:49 +00:00
<template>
<div class="p-16-24">
<h4 class="mb-16">{{ $t('views.application.applicationAccess.title') }}</h4>
<el-row :gutter="16">
<el-col
:xs="24"
:sm="24"
:md="12"
:lg="12"
:xl="12"
class="mb-16"
v-for="(item, index) in platforms"
:key="index"
>
2025-06-13 06:05:23 +00:00
<el-card shadow="hover" class="border-none cursor">
2025-06-03 08:08:49 +00:00
<div class="flex-between">
<div class="flex align-center ml-8 mr-8">
2025-07-30 11:36:37 +00:00
<img :src="item.logoSrc" alt="" class="icon" />
2025-06-03 08:08:49 +00:00
<div class="ml-12">
<h5 class="mb-4">{{ item.name }}</h5>
<el-text type="info" style="font-size: 12px">{{ item.description }}</el-text>
</div>
</div>
<div>
<el-switch
size="small"
v-model="item.isActive"
@change="changeStatus(item.key, item.isActive)"
:disabled="!item.exists"
2025-06-25 09:18:47 +00:00
v-if="permissionPrecise.access_edit(id)"
2025-06-03 08:08:49 +00:00
/>
<el-divider direction="vertical" />
2025-07-30 11:36:37 +00:00
<el-button
class="mr-4"
@click="openDrawer(item.key)"
2025-06-25 09:18:47 +00:00
v-if="permissionPrecise.access_edit(id)"
2025-07-30 11:36:37 +00:00
>{{ $t('views.application.applicationAccess.setting') }}</el-button
>
2025-06-03 08:08:49 +00:00
</div>
</div>
</el-card>
</el-col>
</el-row>
<AccessSettingDrawer ref="AccessSettingDrawerRef" @refresh="refresh" />
</div>
</template>
<script setup lang="ts">
2025-06-25 09:18:47 +00:00
import { reactive, ref, onMounted, computed } from 'vue'
2025-06-03 08:08:49 +00:00
import AccessSettingDrawer from './component/AccessSettingDrawer.vue'
import { MsgSuccess } from '@/utils/message'
import { useRoute } from 'vue-router'
import { t } from '@/locales'
2025-06-25 09:18:47 +00:00
import permissionMap from '@/permission'
2025-07-30 11:36:37 +00:00
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
2025-06-25 09:18:47 +00:00
const route = useRoute()
2025-07-30 11:36:37 +00:00
const apiType = computed(() => {
if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
2025-06-25 09:18:47 +00:00
return 'workspace'
2025-07-30 11:36:37 +00:00
}
2025-06-25 09:18:47 +00:00
})
const permissionPrecise = computed(() => {
return permissionMap['application'][apiType.value]
})
2025-06-03 08:08:49 +00:00
// 平台数据
const platforms = reactive([
{
key: 'wecomBot',
logoSrc: new URL(`../../assets/logo/logo_wechat-bot.svg`, import.meta.url).href,
name: t('views.application.applicationAccess.wecomBot'),
description: t('views.application.applicationAccess.wecomBotTip'),
isActive: false,
exists: false,
},
2025-06-03 08:08:49 +00:00
{
key: 'wecom',
2025-06-11 13:02:26 +00:00
logoSrc: new URL(`../../assets/logo/logo_wechat-work.svg`, import.meta.url).href,
2025-06-03 08:08:49 +00:00
name: t('views.application.applicationAccess.wecom'),
description: t('views.application.applicationAccess.wecomTip'),
isActive: false,
2025-06-10 09:57:33 +00:00
exists: false,
2025-06-03 08:08:49 +00:00
},
{
key: 'dingtalk',
2025-06-11 13:02:26 +00:00
logoSrc: new URL(`../../assets/logo/logo_dingtalk.svg`, import.meta.url).href,
2025-06-03 08:08:49 +00:00
name: t('views.application.applicationAccess.dingtalk'),
description: t('views.application.applicationAccess.dingtalkTip'),
isActive: false,
2025-06-10 09:57:33 +00:00
exists: false,
2025-06-03 08:08:49 +00:00
},
{
key: 'wechat',
2025-06-11 13:02:26 +00:00
logoSrc: new URL(`../../assets/logo/logo_wechat.svg`, import.meta.url).href,
2025-06-03 08:08:49 +00:00
name: t('views.application.applicationAccess.wechat'),
description: t('views.application.applicationAccess.wechatTip'),
isActive: false,
2025-06-10 09:57:33 +00:00
exists: false,
2025-06-03 08:08:49 +00:00
},
{
2025-07-01 03:35:25 +00:00
key: 'lark',
2025-06-11 13:02:26 +00:00
logoSrc: new URL(`../../assets/logo/logo_lark.svg`, import.meta.url).href,
2025-06-03 08:08:49 +00:00
name: t('views.application.applicationAccess.lark'),
description: t('views.application.applicationAccess.larkTip'),
isActive: false,
2025-06-10 09:57:33 +00:00
exists: false,
2025-06-03 08:08:49 +00:00
},
{
key: 'slack',
2025-06-11 13:02:26 +00:00
logoSrc: new URL(`../../assets/logo/logo_slack.svg`, import.meta.url).href,
2025-06-03 08:08:49 +00:00
name: t('views.application.applicationAccess.slack'),
description: t('views.application.applicationAccess.slackTip'),
isActive: false,
2025-06-10 09:57:33 +00:00
exists: false,
},
2025-06-03 08:08:49 +00:00
])
const AccessSettingDrawerRef = ref()
const loading = ref(false)
const {
2025-06-10 09:57:33 +00:00
params: { id },
2025-06-03 08:08:49 +00:00
} = route as any
function openDrawer(key: string) {
AccessSettingDrawerRef.value.open(id, key)
}
function refresh() {
getPlatformStatus()
}
function getPlatformStatus() {
loading.value = true
2025-07-30 11:36:37 +00:00
loadSharedApi({ type: 'application', systemType: apiType.value })
.getPlatformStatus(id)
.then((res: any) => {
platforms.forEach((platform) => {
platform.isActive = res.data[platform.key][1]
platform.exists = res.data[platform.key][0]
})
loading.value = false
2025-06-20 09:13:01 +00:00
})
2025-06-03 08:08:49 +00:00
}
function changeStatus(type: string, value: boolean) {
const data = {
type: type,
2025-06-10 09:57:33 +00:00
status: value,
2025-06-03 08:08:49 +00:00
}
2025-07-30 11:36:37 +00:00
loadSharedApi({ type: 'application', systemType: apiType.value })
.updatePlatformStatus(id, data)
.then(() => {
MsgSuccess(t('common.saveSuccess'))
})
2025-06-03 08:08:49 +00:00
}
onMounted(() => {
2025-07-01 03:35:25 +00:00
getPlatformStatus()
2025-06-03 08:08:49 +00:00
})
</script>
2025-06-10 09:57:33 +00:00
<style lang="scss" scoped></style>