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
|
2025-06-19 03:46:52 +00:00
|
|
|
|
:source="FolderSource.TOOL"
|
2025-05-12 10:19:28 +00:00
|
|
|
|
:data="folderList"
|
|
|
|
|
|
:currentNodeKey="currentFolder?.id"
|
|
|
|
|
|
@handleNodeClick="folderClickHandel"
|
2025-06-20 19:14:59 +00:00
|
|
|
|
@refreshTree="refreshFolder"
|
2025-06-23 07:52:03 +00:00
|
|
|
|
:shareTitle="$t('views.system.share_tool')"
|
|
|
|
|
|
:showShared="permissionPrecise['is_share']()"
|
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-06-20 19:14:59 +00:00
|
|
|
|
<ContentContainer :header="currentFolder?.name">
|
2025-05-15 02:25:05 +00:00
|
|
|
|
<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"
|
|
|
|
|
|
>
|
2025-06-09 13:27:12 +00:00
|
|
|
|
<el-option :label="$t('common.creator')" value="create_user" />
|
2025-05-15 02:25:05 +00:00
|
|
|
|
|
2025-06-09 13:27:12 +00:00
|
|
|
|
<el-option :label="$t('views.model.modelForm.modeName.label')" value="name" />
|
2025-05-15 02:25:05 +00:00
|
|
|
|
</el-select>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-if="search_type === 'name'"
|
|
|
|
|
|
v-model="search_form.name"
|
|
|
|
|
|
@change="getList"
|
2025-05-27 11:06:47 +00:00
|
|
|
|
:placeholder="$t('common.searchBar.placeholder')"
|
2025-05-15 02:25:05 +00:00
|
|
|
|
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"
|
|
|
|
|
|
>
|
2025-06-09 13:27:12 +00:00
|
|
|
|
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.username" />
|
2025-05-15 02:25:05 +00:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</div>
|
2025-06-20 19:14:59 +00:00
|
|
|
|
<el-dropdown trigger="click" v-if="!isShared">
|
2025-06-18 13:39:39 +00:00
|
|
|
|
<el-button
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
class="ml-8"
|
|
|
|
|
|
v-hasPermission="[
|
|
|
|
|
|
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
2025-06-20 09:19:01 +00:00
|
|
|
|
RoleConst.USER.getWorkspaceRole,
|
2025-06-18 13:39:39 +00:00
|
|
|
|
PermissionConst.TOOL_CREATE.getWorkspacePermission,
|
|
|
|
|
|
]"
|
2025-06-18 12:22:33 +00:00
|
|
|
|
>
|
2025-06-17 03:03:18 +00:00
|
|
|
|
{{ $t('common.create') }}
|
|
|
|
|
|
<el-icon class="el-icon--right">
|
|
|
|
|
|
<arrow-down />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<template #dropdown>
|
|
|
|
|
|
<el-dropdown-menu class="create-dropdown">
|
|
|
|
|
|
<el-dropdown-item @click="openCreateDialog()">
|
|
|
|
|
|
<div class="flex align-center">
|
|
|
|
|
|
<el-avatar class="avatar-green" shape="square" :size="32">
|
|
|
|
|
|
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
<div class="pre-wrap ml-8">
|
|
|
|
|
|
<div class="lighter">空白创建</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-dropdown-item>
|
2025-06-18 13:39:39 +00:00
|
|
|
|
<el-upload
|
|
|
|
|
|
ref="elUploadRef"
|
|
|
|
|
|
:file-list="[]"
|
|
|
|
|
|
action="#"
|
|
|
|
|
|
multiple
|
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
|
:show-file-list="false"
|
|
|
|
|
|
:limit="1"
|
|
|
|
|
|
:on-change="(file: any, fileList: any) => importTool(file)"
|
|
|
|
|
|
class="import-button"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-dropdown-item class="w-full">
|
|
|
|
|
|
<div class="flex align-center w-full">
|
2025-06-17 03:03:18 +00:00
|
|
|
|
<el-avatar shape="square" class="mt-4" :size="36" style="background: none">
|
|
|
|
|
|
<img src="@/assets/icon_import.svg" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
<div class="pre-wrap ml-8">
|
|
|
|
|
|
<div class="lighter">{{ $t('common.importCreate') }}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-06-18 13:39:39 +00:00
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-upload>
|
2025-06-20 11:30:33 +00:00
|
|
|
|
<!-- TODO 从工具商店创建 -->
|
|
|
|
|
|
<!-- <el-dropdown-item @click="openToolStoreDialog()">
|
2025-06-20 09:47:58 +00:00
|
|
|
|
<div class="flex align-center">
|
|
|
|
|
|
<el-avatar class="avatar-green" shape="square" :size="32">
|
|
|
|
|
|
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
<div class="pre-wrap ml-8">
|
2025-06-20 19:14:59 +00:00
|
|
|
|
<div class="lighter">
|
|
|
|
|
|
{{ $t('views.tool.toolStore.createFromToolStore') }}
|
|
|
|
|
|
</div>
|
2025-06-20 09:47:58 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2025-06-20 11:30:33 +00:00
|
|
|
|
</el-dropdown-item> -->
|
2025-06-17 03:03:18 +00:00
|
|
|
|
<el-dropdown-item @click="openCreateFolder" divided>
|
|
|
|
|
|
<div class="flex align-center">
|
|
|
|
|
|
<AppIcon iconName="app-folder" style="font-size: 32px"></AppIcon>
|
|
|
|
|
|
<div class="pre-wrap ml-4">
|
|
|
|
|
|
<div class="lighter">
|
|
|
|
|
|
{{ $t('components.folder.addFolder') }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dropdown>
|
2025-05-15 02:25:05 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
2025-06-19 09:10:39 +00:00
|
|
|
|
<div
|
|
|
|
|
|
v-loading.fullscreen.lock="paginationConfig.current_page === 1 && loading"
|
|
|
|
|
|
style="max-height: calc(100vh - 140px)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<InfiniteScroll
|
|
|
|
|
|
:size="toolList.length"
|
|
|
|
|
|
:total="paginationConfig.total"
|
|
|
|
|
|
:page_size="paginationConfig.page_size"
|
|
|
|
|
|
v-model:current_page="paginationConfig.current_page"
|
|
|
|
|
|
@load="getList"
|
|
|
|
|
|
:loading="loading"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-row v-if="toolList.length > 0" :gutter="15">
|
|
|
|
|
|
<template v-for="(item, index) in toolList" :key="index">
|
|
|
|
|
|
<el-col
|
|
|
|
|
|
v-if="item.resource_type === 'folder'"
|
|
|
|
|
|
:xs="24"
|
|
|
|
|
|
:sm="12"
|
|
|
|
|
|
:md="12"
|
|
|
|
|
|
:lg="8"
|
|
|
|
|
|
:xl="6"
|
|
|
|
|
|
class="mb-16"
|
2025-05-15 10:21:38 +00:00
|
|
|
|
>
|
2025-06-19 09:10:39 +00:00
|
|
|
|
<CardBox
|
|
|
|
|
|
:title="item.name"
|
|
|
|
|
|
:description="item.desc || $t('common.noData')"
|
|
|
|
|
|
class="cursor"
|
|
|
|
|
|
@click="clickFolder(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<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.nick_name }}
|
|
|
|
|
|
</el-text>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</CardBox>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col v-else :xs="24" :sm="12" :md="12" :lg="8" :xl="6" class="mb-16">
|
|
|
|
|
|
<CardBox :title="item.name" :description="item.desc" class="cursor">
|
|
|
|
|
|
<template #icon>
|
|
|
|
|
|
<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">
|
|
|
|
|
|
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
|
|
|
|
|
</el-avatar>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #subTitle>
|
|
|
|
|
|
<el-text class="color-secondary lighter" size="small">
|
|
|
|
|
|
{{ $t('common.creator') }}: {{ item.nick_name }}
|
|
|
|
|
|
</el-text>
|
|
|
|
|
|
</template>
|
2025-06-20 19:14:59 +00:00
|
|
|
|
<template #tag>
|
|
|
|
|
|
<el-tag v-if="isShared" type="info" class="info-tag">
|
|
|
|
|
|
{{ t('views.system.shared') }}
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
</template>
|
2025-05-15 10:21:38 +00:00
|
|
|
|
|
2025-06-19 09:10:39 +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>
|
2025-06-20 19:14:59 +00:00
|
|
|
|
<div @click.stop v-if="!isShared">
|
2025-06-19 09:10:39 +00:00
|
|
|
|
<el-switch
|
|
|
|
|
|
v-model="item.is_active"
|
|
|
|
|
|
:before-change="() => changeState(item)"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
class="mr-4"
|
|
|
|
|
|
v-hasPermission="[
|
|
|
|
|
|
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
2025-06-20 09:19:01 +00:00
|
|
|
|
RoleConst.USER.getWorkspaceRole,
|
2025-06-19 09:10:39 +00:00
|
|
|
|
PermissionConst.TOOL_EDIT.getWorkspacePermission,
|
|
|
|
|
|
]"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<el-divider direction="vertical" />
|
|
|
|
|
|
<el-dropdown trigger="click">
|
|
|
|
|
|
<el-button text @click.stop>
|
|
|
|
|
|
<el-icon>
|
|
|
|
|
|
<MoreFilled />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<template #dropdown>
|
|
|
|
|
|
<el-dropdown-menu>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
v-if="
|
|
|
|
|
|
!item.template_id &&
|
|
|
|
|
|
hasPermission(
|
|
|
|
|
|
[
|
|
|
|
|
|
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
2025-06-20 09:19:01 +00:00
|
|
|
|
RoleConst.USER.getWorkspaceRole,
|
2025-06-23 07:52:03 +00:00
|
|
|
|
PermissionConst.TOOL_EDIT
|
|
|
|
|
|
.getWorkspacePermissionWorkspaceManageRole,
|
2025-06-19 09:10:39 +00:00
|
|
|
|
PermissionConst.TOOL_EDIT.getWorkspacePermission,
|
|
|
|
|
|
],
|
|
|
|
|
|
'OR',
|
|
|
|
|
|
)
|
|
|
|
|
|
"
|
|
|
|
|
|
@click.stop="openCreateDialog(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon>
|
|
|
|
|
|
<EditPen />
|
|
|
|
|
|
</el-icon>
|
|
|
|
|
|
{{ $t('common.edit') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
v-if="
|
|
|
|
|
|
!item.template_id &&
|
|
|
|
|
|
hasPermission(
|
|
|
|
|
|
[
|
|
|
|
|
|
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
2025-06-20 09:19:01 +00:00
|
|
|
|
RoleConst.USER.getWorkspaceRole,
|
2025-06-19 09:10:39 +00:00
|
|
|
|
PermissionConst.TOOL_EXPORT.getWorkspacePermission,
|
|
|
|
|
|
],
|
|
|
|
|
|
'OR',
|
|
|
|
|
|
)
|
|
|
|
|
|
"
|
|
|
|
|
|
@click.stop="copyTool(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-copy"></AppIcon>
|
|
|
|
|
|
{{ $t('common.copy') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
v-if="item.init_field_list?.length > 0"
|
|
|
|
|
|
@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 &&
|
|
|
|
|
|
hasPermission(
|
|
|
|
|
|
[
|
|
|
|
|
|
RoleConst.WORKSPACE_MANAGE.getWorkspaceRole,
|
2025-06-20 09:19:01 +00:00
|
|
|
|
RoleConst.USER.getWorkspaceRole,
|
2025-06-19 09:10:39 +00:00
|
|
|
|
PermissionConst.TOOL_EXPORT.getWorkspacePermission,
|
|
|
|
|
|
],
|
|
|
|
|
|
'OR',
|
|
|
|
|
|
)
|
|
|
|
|
|
"
|
|
|
|
|
|
@click.stop="exportTool(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-export"></AppIcon>
|
|
|
|
|
|
{{ $t('common.export') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
2025-06-23 07:52:03 +00:00
|
|
|
|
v-if="permissionPrecise.delete()"
|
2025-06-19 09:10:39 +00:00
|
|
|
|
divided
|
|
|
|
|
|
@click.stop="deleteTool(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon><Delete /></el-icon>
|
|
|
|
|
|
{{ $t('common.delete') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</CardBox>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
<el-empty :description="$t('common.noData')" v-else />
|
|
|
|
|
|
</InfiniteScroll>
|
2025-05-08 08:23:03 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</ContentContainer>
|
2025-06-09 13:27:12 +00:00
|
|
|
|
<InitParamDrawer ref="InitParamDrawerRef" @refresh="refresh" />
|
|
|
|
|
|
<ToolFormDrawer ref="ToolFormDrawerRef" @refresh="refresh" :title="ToolDrawertitle" />
|
2025-06-20 19:14:59 +00:00
|
|
|
|
<CreateFolderDialog ref="CreateFolderDialogRef" @refresh="refreshFolder" v-if="!isShared" />
|
2025-06-20 09:47:58 +00:00
|
|
|
|
<ToolStoreDialog ref="toolStoreDialogRef" @refresh="refresh" />
|
2025-05-08 08:23:03 +00:00
|
|
|
|
</LayoutContainer>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-06-09 13:27:12 +00:00
|
|
|
|
import { onMounted, ref, reactive, computed } from 'vue'
|
|
|
|
|
|
import { cloneDeep, get } from 'lodash'
|
2025-06-17 03:03:18 +00:00
|
|
|
|
import ToolApi from '@/api/tool/tool'
|
2025-05-08 08:23:03 +00:00
|
|
|
|
import useStore from '@/stores'
|
2025-05-15 10:21:38 +00:00
|
|
|
|
import InitParamDrawer from '@/views/tool/component/InitParamDrawer.vue'
|
2025-05-26 10:10:18 +00:00
|
|
|
|
import ToolFormDrawer from './ToolFormDrawer.vue'
|
2025-06-17 03:03:18 +00:00
|
|
|
|
import CreateFolderDialog from '@/components/folder-tree/CreateFolderDialog.vue'
|
2025-06-09 13:27:12 +00:00
|
|
|
|
import { t } from '@/locales'
|
|
|
|
|
|
import { isAppIcon } from '@/utils/common'
|
|
|
|
|
|
import { MsgSuccess, MsgConfirm, MsgError } from '@/utils/message'
|
2025-06-20 04:00:39 +00:00
|
|
|
|
import { EditionConst, PermissionConst, RoleConst } from '@/utils/permission/data'
|
2025-06-18 12:22:33 +00:00
|
|
|
|
import { hasPermission } from '@/utils/permission/index'
|
2025-06-19 03:46:52 +00:00
|
|
|
|
import { FolderSource } from '@/enums/common'
|
2025-06-20 04:00:39 +00:00
|
|
|
|
import { ComplexPermission } from '@/utils/permission/type'
|
2025-06-20 09:47:58 +00:00
|
|
|
|
import ToolStoreDialog from './component/ToolStoreDialog.vue'
|
2025-06-20 19:14:59 +00:00
|
|
|
|
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
|
2025-06-23 07:52:03 +00:00
|
|
|
|
import permissionMap from '@/permission'
|
|
|
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
const route = useRoute()
|
2025-06-09 13:27:12 +00:00
|
|
|
|
const { folder, user } = useStore()
|
2025-05-15 02:25:05 +00:00
|
|
|
|
|
2025-06-23 07:52:03 +00:00
|
|
|
|
const type = computed(() => {
|
|
|
|
|
|
if (route.path.includes('shared')) {
|
|
|
|
|
|
return 'systemShare'
|
|
|
|
|
|
} else if (route.path.includes('resource-management')) {
|
|
|
|
|
|
return 'systemManage'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return 'workspace'
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
const permissionPrecise = computed(() => {
|
|
|
|
|
|
return permissionMap['tool'][type.value]
|
|
|
|
|
|
})
|
|
|
|
|
|
|
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-12 10:19:28 +00:00
|
|
|
|
const currentFolder = ref<any>({})
|
2025-05-08 08:23:03 +00:00
|
|
|
|
|
2025-06-20 19:14:59 +00:00
|
|
|
|
const isShared = computed(() => {
|
|
|
|
|
|
return currentFolder.value.id === 'share'
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-05-15 02:25:05 +00:00
|
|
|
|
const search_type_change = () => {
|
2025-06-09 13:27:12 +00:00
|
|
|
|
search_form.value = { name: '', create_user: '' }
|
2025-05-15 02:25:05 +00:00
|
|
|
|
}
|
2025-05-22 10:38:06 +00:00
|
|
|
|
const ToolFormDrawerRef = ref()
|
|
|
|
|
|
const ToolDrawertitle = ref('')
|
2025-06-06 01:39:01 +00:00
|
|
|
|
|
2025-05-22 10:38:06 +00:00
|
|
|
|
function openCreateDialog(data?: any) {
|
|
|
|
|
|
// 有template_id的不允许编辑,是模板转换来的
|
|
|
|
|
|
if (data?.template_id) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
ToolDrawertitle.value = data ? t('views.tool.editTool') : t('views.tool.createTool')
|
|
|
|
|
|
if (data) {
|
2025-06-20 10:55:29 +00:00
|
|
|
|
ToolApi.getToolById(data?.id, changeStateloading).then((res) => {
|
2025-06-23 07:52:03 +00:00
|
|
|
|
ToolFormDrawerRef.value.open(res.data)
|
|
|
|
|
|
})
|
2025-05-22 10:38:06 +00:00
|
|
|
|
} 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-06-17 10:38:00 +00:00
|
|
|
|
folder_id: currentFolder.value?.id || user.getWorkspaceId(),
|
2025-06-05 08:27:54 +00:00
|
|
|
|
scope: 'WORKSPACE',
|
2025-05-08 08:23:03 +00:00
|
|
|
|
}
|
2025-06-20 19:14:59 +00:00
|
|
|
|
loadSharedApi('tool', isShared.value)
|
|
|
|
|
|
.getToolListPage(paginationConfig, params, loading)
|
|
|
|
|
|
.then((res: any) => {
|
|
|
|
|
|
paginationConfig.total = res.data?.total
|
|
|
|
|
|
toolList.value = [...toolList.value, ...res.data?.records]
|
|
|
|
|
|
})
|
2025-05-08 08:23:03 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-19 09:10:39 +00:00
|
|
|
|
function clickFolder(item: any) {
|
|
|
|
|
|
currentFolder.value.id = item.id
|
|
|
|
|
|
toolList.value = []
|
|
|
|
|
|
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-06-06 01:39:01 +00:00
|
|
|
|
ToolApi.putTool(row.id, obj, changeStateloading)
|
2025-05-22 10:38:06 +00:00
|
|
|
|
.then(() => {
|
|
|
|
|
|
return true
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
return false
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2025-06-06 01:39:01 +00:00
|
|
|
|
const res = await ToolApi.getToolById(row.id, changeStateloading)
|
2025-05-22 10:38:06 +00:00
|
|
|
|
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-06-06 01:39:01 +00:00
|
|
|
|
ToolApi.putTool(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-06-09 13:27:12 +00:00
|
|
|
|
function copyTool(row: any) {
|
|
|
|
|
|
ToolDrawertitle.value = t('views.tool.copyTool')
|
|
|
|
|
|
const obj = cloneDeep(row)
|
|
|
|
|
|
delete obj['id']
|
|
|
|
|
|
obj['name'] = obj['name'] + ` ${t('views.tool.form.title.copy')}`
|
|
|
|
|
|
ToolFormDrawerRef.value.open(obj)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function exportTool(row: any) {
|
|
|
|
|
|
ToolApi.exportTool(row.id, row.name, loading).catch((e: any) => {
|
|
|
|
|
|
if (e.response.status !== 403) {
|
|
|
|
|
|
e.response.data.text().then((res: string) => {
|
|
|
|
|
|
MsgError(`${t('views.application.tip.ExportError')}:${JSON.parse(res).message}`)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function deleteTool(row: any) {
|
|
|
|
|
|
MsgConfirm(
|
|
|
|
|
|
`${t('views.tool.delete.confirmTitle')}${row.name} ?`,
|
|
|
|
|
|
t('views.tool.delete.confirmMessage'),
|
|
|
|
|
|
{
|
|
|
|
|
|
confirmButtonText: t('common.confirm'),
|
|
|
|
|
|
cancelButtonText: t('common.cancel'),
|
2025-06-17 03:03:18 +00:00
|
|
|
|
confirmButtonClass: 'danger',
|
|
|
|
|
|
},
|
2025-06-09 13:27:12 +00:00
|
|
|
|
)
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
ToolApi.delTool(row.id, loading).then(() => {
|
|
|
|
|
|
const index = toolList.value.findIndex((v) => v.id === row.id)
|
|
|
|
|
|
toolList.value.splice(index, 1)
|
|
|
|
|
|
MsgSuccess(t('common.deleteSuccess'))
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function configInitParams(item: any) {
|
|
|
|
|
|
ToolApi.getToolById(item?.id, changeStateloading).then((res) => {
|
|
|
|
|
|
InitParamDrawerRef.value.open(res.data)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-20 09:47:58 +00:00
|
|
|
|
const toolStoreDialogRef = ref<InstanceType<typeof ToolStoreDialog>>()
|
|
|
|
|
|
function openToolStoreDialog() {
|
|
|
|
|
|
toolStoreDialogRef.value?.open()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-17 03:03:18 +00:00
|
|
|
|
const elUploadRef = ref()
|
|
|
|
|
|
function importTool(file: any) {
|
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
|
formData.append('file', file.raw, file.name)
|
|
|
|
|
|
elUploadRef.value.clearFiles()
|
|
|
|
|
|
ToolApi.postImportTool(formData, loading)
|
|
|
|
|
|
.then(async (res: any) => {
|
|
|
|
|
|
if (res?.data) {
|
|
|
|
|
|
toolList.value = []
|
|
|
|
|
|
getList()
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch((e: any) => {
|
|
|
|
|
|
if (e.code === 400) {
|
|
|
|
|
|
MsgConfirm(t('common.tip'), t('views.application.tip.professionalMessage'), {
|
|
|
|
|
|
cancelButtonText: t('common.confirm'),
|
|
|
|
|
|
confirmButtonText: t('common.professional'),
|
|
|
|
|
|
}).then(() => {
|
|
|
|
|
|
window.open('https://maxkb.cn/pricing.html', '_blank')
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-06-09 13:27:12 +00:00
|
|
|
|
|
2025-06-19 09:10:39 +00:00
|
|
|
|
// 文件夹相关
|
|
|
|
|
|
const CreateFolderDialogRef = ref()
|
|
|
|
|
|
function openCreateFolder() {
|
|
|
|
|
|
CreateFolderDialogRef.value.open(FolderSource.TOOL, currentFolder.value.id)
|
|
|
|
|
|
}
|
|
|
|
|
|
function getFolder(bool?: boolean) {
|
|
|
|
|
|
const params = {}
|
|
|
|
|
|
folder.asyncGetFolder(FolderSource.TOOL, params, loading).then((res: any) => {
|
|
|
|
|
|
folderList.value = res.data
|
|
|
|
|
|
if (bool) {
|
|
|
|
|
|
// 初始化刷新
|
|
|
|
|
|
currentFolder.value = res.data?.[0] || {}
|
|
|
|
|
|
}
|
|
|
|
|
|
getList()
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
function refreshFolder() {
|
|
|
|
|
|
toolList.value = []
|
2025-05-08 08:23:03 +00:00
|
|
|
|
getFolder()
|
2025-06-19 09:10:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function folderClickHandel(row: any) {
|
|
|
|
|
|
currentFolder.value = row
|
|
|
|
|
|
toolList.value = []
|
|
|
|
|
|
getList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
getFolder(true)
|
2025-05-08 08:23:03 +00:00
|
|
|
|
})
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|