2025-05-08 08:23:03 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<LayoutContainer class="tool-manage">
|
|
|
|
|
|
<template #left>
|
2025-05-13 08:19:21 +00:00
|
|
|
|
<h4 class="p-16 pb-0">{{ $t('views.tool.title') }}</h4>
|
2025-05-12 10:19:28 +00:00
|
|
|
|
<folder-tree
|
|
|
|
|
|
:data="folderList"
|
|
|
|
|
|
:currentNodeKey="currentFolder?.id"
|
|
|
|
|
|
@handleNodeClick="folderClickHandel"
|
2025-05-15 02:25:05 +00:00
|
|
|
|
class="p-8"
|
2025-05-12 10:19:28 +00:00
|
|
|
|
/>
|
2025-05-08 08:23:03 +00:00
|
|
|
|
</template>
|
2025-05-15 02:25:05 +00:00
|
|
|
|
<ContentContainer :header="currentFolder?.name">
|
|
|
|
|
|
<template #search>
|
|
|
|
|
|
<div class="flex">
|
|
|
|
|
|
<div class="flex-between complex-search">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
class="complex-search__left"
|
|
|
|
|
|
v-model="search_type"
|
|
|
|
|
|
style="width: 120px"
|
|
|
|
|
|
@change="search_type_change"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option :label="$t('common.creator')" value="create_user" />
|
|
|
|
|
|
|
|
|
|
|
|
<el-option :label="$t('views.model.modelForm.modeName.label')" value="name" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-if="search_type === 'name'"
|
|
|
|
|
|
v-model="search_form.name"
|
|
|
|
|
|
@change="getList"
|
|
|
|
|
|
:placeholder="$t('views.model.searchBar.placeholder')"
|
|
|
|
|
|
style="width: 220px"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
v-else-if="search_type === 'create_user'"
|
|
|
|
|
|
v-model="search_form.create_user"
|
|
|
|
|
|
@change="getList"
|
|
|
|
|
|
clearable
|
|
|
|
|
|
style="width: 220px"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.username" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- <el-button class="ml-16" type="primary" @click="openCreateModel(active_provider)">
|
|
|
|
|
|
{{ $t('views.model.addModel') }}</el-button
|
|
|
|
|
|
> -->
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2025-05-08 08:23:03 +00:00
|
|
|
|
<div>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
<el-row v-if="toolFolderList.length > 0 || toolList.length > 0" :gutter="15">
|
|
|
|
|
|
<template v-for="(item, index) in toolFolderList" :key="index">
|
|
|
|
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6" class="mb-16">
|
|
|
|
|
|
<CardBox
|
|
|
|
|
|
:title="item.name"
|
|
|
|
|
|
:description="item.desc || $t('common.noData')"
|
|
|
|
|
|
class="cursor"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #icon>
|
|
|
|
|
|
<el-avatar shape="square" :size="32" style="background: none">
|
|
|
|
|
|
<AppIcon iconName="app-folder" style="font-size: 32px"></AppIcon>
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #subTitle>
|
|
|
|
|
|
<el-text class="color-secondary lighter" size="small">
|
|
|
|
|
|
{{ $t('common.creator') }}: {{ item.username }}
|
|
|
|
|
|
</el-text>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</CardBox>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2025-05-08 08:23:03 +00:00
|
|
|
|
<template v-for="(item, index) in toolList" :key="index">
|
|
|
|
|
|
<el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="6" class="mb-16">
|
|
|
|
|
|
<CardBox :title="item.name" :description="item.desc" class="cursor">
|
|
|
|
|
|
<template #icon>
|
2025-05-26 10:10:18 +00:00
|
|
|
|
<el-avatar
|
|
|
|
|
|
v-if="isAppIcon(item?.icon)"
|
|
|
|
|
|
shape="square"
|
|
|
|
|
|
:size="32"
|
|
|
|
|
|
style="background: none"
|
|
|
|
|
|
class="mr-8"
|
|
|
|
|
|
>
|
|
|
|
|
|
<img :src="item?.icon" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
<el-avatar v-else class="avatar-green" shape="square" :size="32">
|
2025-05-12 10:19:28 +00:00
|
|
|
|
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
2025-05-08 08:23:03 +00:00
|
|
|
|
</el-avatar>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #subTitle>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
<el-text class="color-secondary lighter" size="small">
|
|
|
|
|
|
{{ $t('common.creator') }}: {{ item.username }}
|
2025-05-08 08:23:03 +00:00
|
|
|
|
</el-text>
|
|
|
|
|
|
</template>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<div v-if="item.is_active" class="flex align-center">
|
|
|
|
|
|
<el-icon class="color-success mr-8" style="font-size: 16px"
|
|
|
|
|
|
><SuccessFilled
|
|
|
|
|
|
/></el-icon>
|
|
|
|
|
|
<span class="color-secondary">
|
|
|
|
|
|
{{ $t('common.status.enabled') }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-else class="flex align-center">
|
|
|
|
|
|
<AppIcon iconName="app-disabled" class="color-secondary mr-8"></AppIcon>
|
|
|
|
|
|
<span class="color-secondary">
|
|
|
|
|
|
{{ $t('common.status.disabled') }}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #mouseEnter>
|
|
|
|
|
|
<div @click.stop>
|
|
|
|
|
|
<el-switch
|
|
|
|
|
|
v-model="item.is_active"
|
|
|
|
|
|
:before-change="() => changeState(item)"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
class="mr-4"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-divider direction="vertical" />
|
|
|
|
|
|
<el-dropdown trigger="click">
|
|
|
|
|
|
<el-button text @click.stop>
|
|
|
|
|
|
<el-icon><MoreFilled /></el-icon>
|
|
|
|
|
|
</el-button>
|
2025-05-22 10:38:06 +00:00
|
|
|
|
<template #dropdown>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
<el-dropdown-menu>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
v-if="!item.template_id"
|
2025-05-22 10:38:06 +00:00
|
|
|
|
:disabled="!canEdit(item)"
|
2025-05-15 10:21:38 +00:00
|
|
|
|
@click.stop="openCreateDialog(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon><EditPen /></el-icon>
|
|
|
|
|
|
{{ $t('common.edit') }}
|
|
|
|
|
|
</el-dropdown-item>
|
2025-05-22 10:38:06 +00:00
|
|
|
|
<!-- <el-dropdown-item
|
|
|
|
|
|
:disabled="!canEdit(item)"
|
2025-05-15 10:21:38 +00:00
|
|
|
|
v-if="!item.template_id"
|
2025-05-22 10:38:06 +00:00
|
|
|
|
@click.stop="copytool(item)"
|
2025-05-15 10:21:38 +00:00
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-copy"></AppIcon>
|
|
|
|
|
|
{{ $t('common.copy') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
v-if="item.init_field_list?.length > 0"
|
2025-05-22 10:38:06 +00:00
|
|
|
|
:disabled="!canEdit(item)"
|
2025-05-15 10:21:38 +00:00
|
|
|
|
@click.stop="configInitParams(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-operation" class="mr-4"></AppIcon>
|
|
|
|
|
|
{{ $t('common.param.initParam') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
v-if="!item.template_id"
|
2025-05-22 10:38:06 +00:00
|
|
|
|
:disabled="!canEdit(item)"
|
|
|
|
|
|
@click.stop="exporttool(item)"
|
2025-05-15 10:21:38 +00:00
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-export"></AppIcon>
|
|
|
|
|
|
{{ $t('common.export') }}
|
|
|
|
|
|
</el-dropdown-item>
|
2025-05-22 10:38:06 +00:00
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
:disabled="!canEdit(item)"
|
|
|
|
|
|
divided
|
|
|
|
|
|
@click.stop="deletetool(item)"
|
|
|
|
|
|
>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
<el-icon><Delete /></el-icon>
|
|
|
|
|
|
{{ $t('common.delete') }}
|
2025-05-22 10:38:06 +00:00
|
|
|
|
</el-dropdown-item> -->
|
2025-05-15 10:21:38 +00:00
|
|
|
|
</el-dropdown-menu>
|
2025-05-22 10:38:06 +00:00
|
|
|
|
</template>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-05-08 08:23:03 +00:00
|
|
|
|
</CardBox>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-empty :description="$t('common.noData')" v-else />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</ContentContainer>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
<InitParamDrawer ref="InitParamDrawerRef" @refresh="refresh" />
|
2025-05-22 10:38:06 +00:00
|
|
|
|
<ToolFormDrawer ref="ToolFormDrawerRef" @refresh="refresh" :title="ToolDrawertitle" />
|
2025-05-08 08:23:03 +00:00
|
|
|
|
</LayoutContainer>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
import { onMounted, ref, reactive, computed } from 'vue'
|
|
|
|
|
|
import ToolApi from '@/api/tool/tool'
|
|
|
|
|
|
import useStore from '@/stores'
|
2025-05-15 10:21:38 +00:00
|
|
|
|
import { MsgConfirm } from '@/utils/message'
|
|
|
|
|
|
import InitParamDrawer from '@/views/tool/component/InitParamDrawer.vue'
|
2025-05-26 10:10:18 +00:00
|
|
|
|
import ToolFormDrawer from './ToolFormDrawer.vue'
|
2025-05-08 08:23:03 +00:00
|
|
|
|
import { t } from '@/locales'
|
2025-05-26 10:10:18 +00:00
|
|
|
|
import { isAppIcon } from '@/utils/common'
|
2025-05-08 08:23:03 +00:00
|
|
|
|
|
2025-05-22 10:38:06 +00:00
|
|
|
|
const { folder, user } = useStore()
|
2025-05-15 02:25:05 +00:00
|
|
|
|
|
2025-05-15 10:21:38 +00:00
|
|
|
|
const InitParamDrawerRef = ref()
|
2025-05-15 02:25:05 +00:00
|
|
|
|
const search_type = ref('name')
|
|
|
|
|
|
const search_form = ref<{
|
|
|
|
|
|
name: string
|
|
|
|
|
|
create_user: string
|
|
|
|
|
|
}>({
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
create_user: '',
|
|
|
|
|
|
})
|
|
|
|
|
|
const user_options = ref<any[]>([])
|
|
|
|
|
|
|
2025-05-08 08:23:03 +00:00
|
|
|
|
const loading = ref(false)
|
2025-05-15 10:21:38 +00:00
|
|
|
|
const changeStateloading = ref(false)
|
2025-05-08 08:23:03 +00:00
|
|
|
|
const paginationConfig = reactive({
|
|
|
|
|
|
current_page: 1,
|
|
|
|
|
|
page_size: 30,
|
|
|
|
|
|
total: 0,
|
|
|
|
|
|
})
|
2025-05-12 10:28:58 +00:00
|
|
|
|
|
2025-05-09 06:42:51 +00:00
|
|
|
|
const folderList = ref<any[]>([])
|
2025-05-08 08:23:03 +00:00
|
|
|
|
const toolList = ref<any[]>([])
|
2025-05-15 10:21:38 +00:00
|
|
|
|
const toolFolderList = ref<any[]>([])
|
2025-05-12 10:19:28 +00:00
|
|
|
|
const currentFolder = ref<any>({})
|
2025-05-08 08:23:03 +00:00
|
|
|
|
|
2025-05-15 02:25:05 +00:00
|
|
|
|
const search_type_change = () => {
|
|
|
|
|
|
search_form.value = { name: '', create_user: '' }
|
|
|
|
|
|
}
|
2025-05-22 10:38:06 +00:00
|
|
|
|
const canEdit = (row: any) => {
|
|
|
|
|
|
return user.userInfo?.id === row?.user_id
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ToolFormDrawerRef = ref()
|
|
|
|
|
|
const ToolDrawertitle = ref('')
|
|
|
|
|
|
function openCreateDialog(data?: any) {
|
|
|
|
|
|
// 有template_id的不允许编辑,是模板转换来的
|
|
|
|
|
|
if (data?.template_id) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
ToolDrawertitle.value = data ? t('views.tool.editTool') : t('views.tool.createTool')
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
if (data?.permission_type !== 'PUBLIC' || canEdit(data)) {
|
|
|
|
|
|
ToolApi.getToolById('default', data?.id, changeStateloading).then((res) => {
|
|
|
|
|
|
ToolFormDrawerRef.value.open(res.data)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ToolFormDrawerRef.value.open(data)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-05-15 02:25:05 +00:00
|
|
|
|
|
2025-05-08 08:23:03 +00:00
|
|
|
|
function getList() {
|
|
|
|
|
|
const params = {
|
2025-05-12 10:19:28 +00:00
|
|
|
|
folder_id: currentFolder.value?.id || 'root',
|
2025-05-08 08:23:03 +00:00
|
|
|
|
tool_type: 'CUSTOM',
|
|
|
|
|
|
}
|
|
|
|
|
|
ToolApi.getToolList('default', paginationConfig, params, loading).then((res) => {
|
2025-05-15 10:21:38 +00:00
|
|
|
|
toolFolderList.value = res.data?.folders
|
|
|
|
|
|
paginationConfig.total = res.data?.tools.total
|
|
|
|
|
|
toolList.value = [...toolList.value, ...res.data?.tools.records]
|
2025-05-08 08:23:03 +00:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getFolder() {
|
|
|
|
|
|
const params = {}
|
2025-05-09 06:42:51 +00:00
|
|
|
|
folder.asynGetFolder('default', 'TOOL', params, loading).then((res: any) => {
|
|
|
|
|
|
folderList.value = res.data
|
2025-05-12 10:19:28 +00:00
|
|
|
|
currentFolder.value = res.data?.[0] || {}
|
|
|
|
|
|
getList()
|
2025-05-08 08:23:03 +00:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-15 10:21:38 +00:00
|
|
|
|
async function changeState(row: any) {
|
2025-05-22 10:38:06 +00:00
|
|
|
|
if (row.is_active) {
|
|
|
|
|
|
MsgConfirm(
|
|
|
|
|
|
`${t('views.tool.disabled.confirmTitle')}${row.name} ?`,
|
|
|
|
|
|
t('views.tool.disabled.confirmMessage'),
|
|
|
|
|
|
{
|
|
|
|
|
|
confirmButtonText: t('common.status.disable'),
|
|
|
|
|
|
confirmButtonClass: 'danger',
|
|
|
|
|
|
},
|
|
|
|
|
|
).then(() => {
|
|
|
|
|
|
const obj = {
|
|
|
|
|
|
is_active: !row.is_active,
|
|
|
|
|
|
}
|
2025-05-26 10:10:18 +00:00
|
|
|
|
ToolApi.putTool('default', row.id, obj, changeStateloading)
|
2025-05-22 10:38:06 +00:00
|
|
|
|
.then(() => {
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
return false
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const res = await ToolApi.getToolById('default', row.id, changeStateloading)
|
|
|
|
|
|
if (
|
|
|
|
|
|
!res.data.init_params &&
|
|
|
|
|
|
res.data.init_field_list &&
|
|
|
|
|
|
res.data.init_field_list.length > 0 &&
|
|
|
|
|
|
res.data.init_field_list.filter((item: any) => item.default_value && item.show_default_value)
|
|
|
|
|
|
.length !== res.data.init_field_list.length
|
|
|
|
|
|
) {
|
|
|
|
|
|
InitParamDrawerRef.value.open(res.data, !row.is_active)
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
const obj = {
|
|
|
|
|
|
is_active: !row.is_active,
|
|
|
|
|
|
}
|
2025-05-26 10:10:18 +00:00
|
|
|
|
ToolApi.putTool('default', row.id, obj, changeStateloading)
|
2025-05-22 10:38:06 +00:00
|
|
|
|
.then(() => {
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
return false
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-05-15 10:21:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function refresh(data: any) {
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
const index = toolList.value.findIndex((v) => v.id === data.id)
|
|
|
|
|
|
// if (user.userInfo && data.user_id === user.userInfo.id) {
|
|
|
|
|
|
// data.username = user.userInfo.username
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// data.username = userOptions.value.find((v) => v.value === data.user_id)?.label
|
|
|
|
|
|
// }
|
|
|
|
|
|
toolList.value.splice(index, 1, data)
|
|
|
|
|
|
}
|
|
|
|
|
|
paginationConfig.total = 0
|
|
|
|
|
|
paginationConfig.current_page = 1
|
|
|
|
|
|
toolList.value = []
|
|
|
|
|
|
getList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-13 08:19:21 +00:00
|
|
|
|
function folderClickHandel(row: any) {
|
|
|
|
|
|
// currentFolder.value = row
|
|
|
|
|
|
// toolList.value = []
|
|
|
|
|
|
// getList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-08 08:23:03 +00:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
getFolder()
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|