<script lang="ts" setup>
|
import { computed, ref } from 'vue';
|
|
import { useGo } from '@jnpf/hooks';
|
import { openWindow } from '@jnpf/utils';
|
|
import { APP_BACKEND_PREFIX, APP_PREFIX } from '#/utils/constants';
|
|
const props = defineProps({
|
latelyUseFlowList: {
|
default: () => [],
|
type: Array as any,
|
},
|
latelyUseMenuList: {
|
default: () => [],
|
type: Array as any,
|
},
|
commonUseFlowList: {
|
default: () => [],
|
type: Array as any,
|
},
|
commonUseMenuList: {
|
default: () => [],
|
type: Array as any,
|
},
|
flowEnabled: {
|
default: false,
|
type: Boolean,
|
},
|
});
|
|
const emit = defineEmits(['launch']);
|
const activeKey = ref('1');
|
const activeTabKey = ref('1');
|
const go = useGo();
|
|
const getList = computed(() => {
|
if (activeTabKey.value === '1') {
|
return activeKey.value === '1' ? props.latelyUseMenuList : props.latelyUseFlowList;
|
} else {
|
return activeKey.value === '1' ? props.commonUseMenuList : props.commonUseFlowList;
|
}
|
});
|
|
function openSystem(item) {
|
const { systemCode, urlAddress, isBackend } = item;
|
if (!urlAddress) return;
|
const url = urlAddress.startsWith('/') ? urlAddress : `/${urlAddress}`;
|
if (!systemCode || systemCode === 'mainSystem') {
|
go(url);
|
} else {
|
const fullUrl = `${window.location.origin}/${APP_PREFIX + (isBackend ? APP_BACKEND_PREFIX : '') + systemCode}${url}`;
|
openWindow(fullUrl);
|
}
|
}
|
function toggleActive(key) {
|
if (activeKey.value === key) return;
|
activeKey.value = key;
|
}
|
function toggleTabActive(key) {
|
if (activeTabKey.value === key) return;
|
activeTabKey.value = key;
|
}
|
function launch(id) {
|
emit('launch', id);
|
}
|
function handleClick(item) {
|
activeKey.value === '1' ? openSystem(item) : launch(item.id);
|
}
|
</script>
|
<template>
|
<div class="common-pane lately-pane dashboard-pane">
|
<div class="dashboard-header">
|
<div class="lately-tabs">
|
<span class="lately-tabs-item" :class="{ 'lately-tabs-item-active': activeTabKey == '1' }" @click="toggleTabActive('1')">最近使用</span>
|
<span class="lately-tabs-item" :class="{ 'lately-tabs-item-active': activeTabKey == '2' }" @click="toggleTabActive('2')">最近常用</span>
|
</div>
|
<div class="dashboard-header-tabs">
|
<span class="header-tabs-item" :class="{ 'header-tabs-item-active': activeKey == '1' }" @click="toggleActive('1')">应用功能</span>
|
<span class="header-tabs-item" :class="{ 'header-tabs-item-active': activeKey == '2' }" @click="toggleActive('2')" v-if="flowEnabled">发起审批</span>
|
</div>
|
</div>
|
<a-row class="common-list" :gutter="16">
|
<a-col class="common-item" v-for="(item, i) in getList" :key="i" :sm="24" :md="12" :lg="8" @click="handleClick(item)">
|
<i :class="item.icon" class="common-item-icon" :style="{ background: item.iconBackground || '#008cff' }"></i>
|
<div class="common-item-text">
|
<p class="common-item-title" :title="item.fullName">{{ item.fullName }}</p>
|
<p class="common-item-desc" :title="item.systemName">{{ item.systemName }}</p>
|
</div>
|
</a-col>
|
<a-col :span="24" v-if="!getList.length">
|
<jnpf-empty />
|
</a-col>
|
</a-row>
|
</div>
|
</template>
|