UnisKB/ui/src/views/application-workflow/component/NodeContent.vue

114 lines
3.7 KiB
Vue
Raw Normal View History

2025-07-03 11:34:36 +00:00
<template>
<div class="w-full">
<div v-if="data" class="flex align-center">
<AppIcon iconName="app-folder" style="font-size: 20px"></AppIcon>
2025-07-10 14:33:39 +00:00
<span
class="ml-8 ellipsis color-text-primary lighter"
style="max-width: 110px"
:title="data.name"
>
2025-07-03 11:34:36 +00:00
{{ data.name }}
</span>
</div>
<transition name="el-fade-in-linear">
2025-07-10 14:33:39 +00:00
<div
v-if="props.list?.length || (props.node?.expanded && toolList.length)"
class="list border-r-4 layout-bg flex-wrap"
@click.stop
>
2025-07-03 11:34:36 +00:00
<el-popover v-for="item in toolList" :key="item.id" placement="right" :width="280">
<template #reference>
2025-07-10 14:33:39 +00:00
<div
class="list-item flex align-center border border-r-6 p-8-12 cursor"
style="width: 39%"
@click.stop="emit('clickNodes', item)"
@mousedown.stop="emit('onmousedown', item)"
>
2025-07-04 07:27:32 +00:00
<LogoIcon v-if="item.resource_type === 'application'" height="32px" />
2025-07-10 14:33:39 +00:00
<el-avatar
v-else-if="isAppIcon(item?.icon)"
shape="square"
:size="32"
style="background: none"
>
<img :src="resetUrl(item?.icon)" alt="" />
2025-07-03 11:34:36 +00:00
</el-avatar>
<el-avatar v-else class="avatar-green" shape="square" :size="32">
2025-07-08 18:58:16 +00:00
<img src="@/assets/workflow/icon_tool.svg" style="width: 58%" alt="" />
2025-07-03 11:34:36 +00:00
</el-avatar>
2025-07-10 14:33:39 +00:00
<span class="ml-8 ellipsis" :title="item.name">{{ item.name }}</span>
2025-07-03 11:34:36 +00:00
</div>
</template>
<template #default>
2025-07-10 14:33:39 +00:00
<div class="flex-between">
2025-07-03 11:34:36 +00:00
<div class="flex align-center">
2025-07-04 07:27:32 +00:00
<LogoIcon v-if="item.resource_type === 'application'" height="32px" />
2025-07-10 14:33:39 +00:00
<el-avatar
v-else-if="isAppIcon(item?.icon)"
shape="square"
:size="32"
style="background: none"
>
<img :src="resetUrl(item?.icon)" alt="" />
2025-07-03 11:34:36 +00:00
</el-avatar>
<el-avatar v-else class="avatar-green" shape="square" :size="32">
2025-07-08 18:58:16 +00:00
<img src="@/assets/workflow/icon_tool.svg" style="width: 58%" alt="" />
2025-07-03 11:34:36 +00:00
</el-avatar>
2025-07-10 14:33:39 +00:00
<span class="medium ml-8 ellipsis" :title="item.name">{{ item.name }}</span>
2025-07-03 11:34:36 +00:00
</div>
<div v-if="item.type" class="status-tag" style="margin-left: auto">
<el-tag type="warning" v-if="isWorkFlow(item.type)" style="height: 22px">
{{ $t('views.application.workflow') }}
</el-tag>
<el-tag class="blue-tag" v-else style="height: 22px">
{{ $t('views.application.simple') }}
</el-tag>
</div>
</div>
2025-07-10 14:33:39 +00:00
<el-text type="info" size="small" class="mt-4">{{ item.desc }}</el-text>
2025-07-03 11:34:36 +00:00
</template>
</el-popover>
</div>
</transition>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
2025-07-10 14:33:39 +00:00
import { isAppIcon, resetUrl } from '@/utils/common'
2025-07-03 11:34:36 +00:00
import { isWorkFlow } from '@/utils/application'
const props = defineProps<{
data?: any
node?: any
list?: any[]
}>()
const emit = defineEmits<{
2025-07-10 14:33:39 +00:00
(e: 'clickNodes', item: any): void
(e: 'onmousedown', item: any): void
}>()
2025-07-03 11:34:36 +00:00
const toolList = computed(() => props.list ?? props.data?.cardList ?? [])
</script>
<style lang="scss" scoped>
.list {
cursor: default;
padding: 12px;
gap: 12px;
margin-top: 12px;
transform: translate(-16px, 0);
.list-item {
background-color: #ffffff;
&:hover {
border-color: var(--el-color-primary);
}
}
}
</style>