2024-08-15 09:17:25 +00:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="function-lib-list-container p-24" style="padding-top: 16px">
|
2025-03-17 06:04:25 +00:00
|
|
|
|
<el-tabs v-model="functionType">
|
2025-03-10 08:07:20 +00:00
|
|
|
|
<el-tab-pane :label="$t('views.functionLib.title')" name="PUBLIC"></el-tab-pane>
|
|
|
|
|
|
<el-tab-pane :label="$t('views.functionLib.internalTitle')" name="INTERNAL"></el-tab-pane>
|
|
|
|
|
|
</el-tabs>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
<div class="flex-between mb-16">
|
2025-03-10 08:07:20 +00:00
|
|
|
|
<h4></h4>
|
2024-11-05 03:52:56 +00:00
|
|
|
|
<div class="flex-between">
|
2024-11-19 09:05:09 +00:00
|
|
|
|
<el-select
|
2025-03-24 09:33:35 +00:00
|
|
|
|
v-if="functionType === 'PUBLIC'"
|
2024-11-19 09:05:09 +00:00
|
|
|
|
v-model="selectUserId"
|
|
|
|
|
|
class="mr-12"
|
|
|
|
|
|
style="max-width: 240px; width: 150px"
|
|
|
|
|
|
@change="searchHandle"
|
|
|
|
|
|
>
|
2024-11-05 03:52:56 +00:00
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in userOptions"
|
|
|
|
|
|
:key="item.value"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
:value="item.value"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model="searchValue"
|
|
|
|
|
|
@change="searchHandle"
|
2025-01-13 03:15:51 +00:00
|
|
|
|
:placeholder="$t('views.functionLib.searchBar.placeholder')"
|
2024-11-05 03:52:56 +00:00
|
|
|
|
prefix-icon="Search"
|
|
|
|
|
|
class="w-240"
|
2024-11-19 09:05:09 +00:00
|
|
|
|
style="max-width: 240px"
|
2024-11-05 03:52:56 +00:00
|
|
|
|
clearable
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
</div>
|
2024-09-18 02:34:49 +00:00
|
|
|
|
<div
|
|
|
|
|
|
v-loading.fullscreen.lock="
|
|
|
|
|
|
(paginationConfig.current_page === 1 && loading) || changeStateloading
|
|
|
|
|
|
"
|
|
|
|
|
|
>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
<InfiniteScroll
|
|
|
|
|
|
:size="functionLibList.length"
|
|
|
|
|
|
:total="paginationConfig.total"
|
|
|
|
|
|
:page_size="paginationConfig.page_size"
|
|
|
|
|
|
v-model:current_page="paginationConfig.current_page"
|
|
|
|
|
|
@load="getList"
|
|
|
|
|
|
:loading="loading"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-row :gutter="15">
|
2025-03-17 06:04:25 +00:00
|
|
|
|
<el-col
|
|
|
|
|
|
:xs="24"
|
|
|
|
|
|
:sm="12"
|
|
|
|
|
|
:md="8"
|
|
|
|
|
|
:lg="6"
|
|
|
|
|
|
:xl="6"
|
|
|
|
|
|
class="mb-16"
|
|
|
|
|
|
v-if="functionType === 'PUBLIC'"
|
|
|
|
|
|
>
|
2025-02-14 09:40:51 +00:00
|
|
|
|
<el-card shadow="hover" class="application-card-add" style="--el-card-padding: 8px">
|
2025-02-25 07:45:45 +00:00
|
|
|
|
<div class="card-add-button flex align-center cursor p-8" @click="openCreateDialog()">
|
2025-02-14 09:40:51 +00:00
|
|
|
|
<AppIcon iconName="app-add-application" class="mr-8"></AppIcon>
|
|
|
|
|
|
{{ $t('views.functionLib.createFunction') }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<el-divider style="margin: 8px 0" />
|
|
|
|
|
|
<el-upload
|
|
|
|
|
|
ref="elUploadRef"
|
|
|
|
|
|
:file-list="[]"
|
|
|
|
|
|
action="#"
|
|
|
|
|
|
multiple
|
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
|
:show-file-list="false"
|
|
|
|
|
|
:limit="1"
|
|
|
|
|
|
:on-change="(file: any, fileList: any) => importFunctionLib(file)"
|
|
|
|
|
|
class="card-add-button"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="flex align-center cursor p-8">
|
|
|
|
|
|
<AppIcon iconName="app-import" class="mr-8"></AppIcon>
|
|
|
|
|
|
{{ $t('views.functionLib.importFunction') }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-upload>
|
|
|
|
|
|
</el-card>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col
|
|
|
|
|
|
:xs="24"
|
|
|
|
|
|
:sm="12"
|
|
|
|
|
|
:md="8"
|
|
|
|
|
|
:lg="6"
|
2024-12-02 07:35:42 +00:00
|
|
|
|
:xl="6"
|
2024-08-15 09:17:25 +00:00
|
|
|
|
v-for="(item, index) in functionLibList"
|
|
|
|
|
|
:key="index"
|
|
|
|
|
|
class="mb-16"
|
|
|
|
|
|
>
|
|
|
|
|
|
<CardBox
|
2025-03-10 08:07:20 +00:00
|
|
|
|
v-if="functionType === 'PUBLIC'"
|
2024-08-15 09:17:25 +00:00
|
|
|
|
:title="item.name"
|
|
|
|
|
|
:description="item.desc"
|
2024-09-24 02:38:20 +00:00
|
|
|
|
class="function-lib-card"
|
2024-08-15 09:17:25 +00:00
|
|
|
|
@click="openCreateDialog(item)"
|
2024-09-25 09:30:02 +00:00
|
|
|
|
:class="item.permission_type === 'PUBLIC' && !canEdit(item) ? '' : 'cursor'"
|
2024-08-15 09:17:25 +00:00
|
|
|
|
>
|
|
|
|
|
|
<template #icon>
|
2025-03-10 08:07:20 +00:00
|
|
|
|
<AppAvatar
|
|
|
|
|
|
v-if="isAppIcon(item?.icon)"
|
|
|
|
|
|
shape="square"
|
|
|
|
|
|
:size="32"
|
|
|
|
|
|
style="background: none"
|
|
|
|
|
|
class="mr-8"
|
|
|
|
|
|
>
|
|
|
|
|
|
<img :src="getImageUrl(item?.icon)" alt="" />
|
2024-08-15 09:17:25 +00:00
|
|
|
|
</AppAvatar>
|
2025-03-10 08:07:20 +00:00
|
|
|
|
<AppAvatar
|
|
|
|
|
|
v-else-if="item?.name"
|
|
|
|
|
|
:name="item?.name"
|
|
|
|
|
|
pinyinColor
|
|
|
|
|
|
shape="square"
|
|
|
|
|
|
:size="32"
|
|
|
|
|
|
class="mr-8"
|
|
|
|
|
|
/>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
</template>
|
2024-11-05 11:13:34 +00:00
|
|
|
|
<template #subTitle>
|
2025-03-24 09:40:14 +00:00
|
|
|
|
<el-text class="color-secondary" size="small">
|
2024-11-05 11:13:34 +00:00
|
|
|
|
<auto-tooltip :content="item.username">
|
2025-01-13 03:15:51 +00:00
|
|
|
|
{{ $t('common.creator') }}: {{ item.username }}
|
2024-11-05 11:13:34 +00:00
|
|
|
|
</auto-tooltip>
|
|
|
|
|
|
</el-text>
|
|
|
|
|
|
</template>
|
2024-09-18 02:34:49 +00:00
|
|
|
|
<div class="status-button">
|
2024-11-05 03:52:56 +00:00
|
|
|
|
<el-tag
|
|
|
|
|
|
class="info-tag"
|
|
|
|
|
|
v-if="item.permission_type === 'PUBLIC'"
|
|
|
|
|
|
style="height: 22px"
|
2025-01-13 03:15:51 +00:00
|
|
|
|
>
|
|
|
|
|
|
{{ $t('common.public') }}</el-tag
|
2024-11-05 03:52:56 +00:00
|
|
|
|
>
|
|
|
|
|
|
<el-tag
|
|
|
|
|
|
class="danger-tag"
|
|
|
|
|
|
v-else-if="item.permission_type === 'PRIVATE'"
|
|
|
|
|
|
style="height: 22px"
|
2025-01-13 03:15:51 +00:00
|
|
|
|
>
|
|
|
|
|
|
{{ $t('common.private') }}</el-tag
|
2024-09-18 02:34:49 +00:00
|
|
|
|
>
|
|
|
|
|
|
</div>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
<template #footer>
|
2024-09-18 02:34:49 +00:00
|
|
|
|
<div class="footer-content flex-between">
|
2025-03-17 06:04:25 +00:00
|
|
|
|
<div>
|
|
|
|
|
|
<span v-if="item.template_id"> {{ $t('common.author') }}: MaxKB</span>
|
|
|
|
|
|
</div>
|
2024-09-18 02:34:49 +00:00
|
|
|
|
<div @click.stop>
|
|
|
|
|
|
<el-switch
|
2024-09-25 07:23:19 +00:00
|
|
|
|
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
2024-09-18 02:34:49 +00:00
|
|
|
|
v-model="item.is_active"
|
|
|
|
|
|
@change="changeState($event, item)"
|
|
|
|
|
|
size="small"
|
2025-03-17 06:04:25 +00:00
|
|
|
|
class="mr-4"
|
2024-09-18 02:34:49 +00:00
|
|
|
|
/>
|
2025-03-10 03:12:49 +00:00
|
|
|
|
<el-dropdown trigger="click">
|
|
|
|
|
|
<el-button text @click.stop>
|
|
|
|
|
|
<el-icon><MoreFilled /></el-icon>
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
<template #dropdown>
|
|
|
|
|
|
<el-dropdown-menu>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
2025-03-10 08:07:20 +00:00
|
|
|
|
v-if="!item.template_id"
|
2025-03-10 03:12:49 +00:00
|
|
|
|
@click.stop="copyFunctionLib(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-copy"></AppIcon>
|
2025-03-17 06:04:25 +00:00
|
|
|
|
{{ $t('common.copy') }}
|
2025-03-10 03:12:49 +00:00
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
|
|
|
|
|
@click.stop="configInitParams(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-operation" class="mr-4"></AppIcon>
|
|
|
|
|
|
{{ $t('common.param.initParam') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
|
|
|
|
|
@click.stop="configPermission(item)"
|
|
|
|
|
|
>
|
2025-03-17 06:04:25 +00:00
|
|
|
|
<el-icon><User /></el-icon>
|
2025-03-10 03:12:49 +00:00
|
|
|
|
{{ $t('views.functionLib.functionForm.form.permission_type.label') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
2025-03-10 08:07:20 +00:00
|
|
|
|
v-if="!item.template_id"
|
2025-03-10 03:12:49 +00:00
|
|
|
|
@click.stop="exportFunctionLib(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<AppIcon iconName="app-export"></AppIcon>
|
2025-03-17 06:04:25 +00:00
|
|
|
|
{{ $t('common.export') }}
|
2025-03-10 03:12:49 +00:00
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item
|
|
|
|
|
|
:disabled="item.permission_type === 'PUBLIC' && !canEdit(item)"
|
|
|
|
|
|
@click.stop="deleteFunctionLib(item)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-icon><Delete /></el-icon>
|
|
|
|
|
|
{{ $t('common.delete') }}
|
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-dropdown>
|
2024-09-18 02:34:49 +00:00
|
|
|
|
</div>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</CardBox>
|
2025-03-10 08:07:20 +00:00
|
|
|
|
<CardBox
|
|
|
|
|
|
v-if="functionType === 'INTERNAL'"
|
|
|
|
|
|
:title="item.name"
|
|
|
|
|
|
:description="item.desc"
|
|
|
|
|
|
class="function-lib-card"
|
|
|
|
|
|
@click="openDescDrawer(item)"
|
|
|
|
|
|
:class="item.permission_type === 'PUBLIC' && !canEdit(item) ? '' : 'cursor'"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template #icon>
|
|
|
|
|
|
<AppAvatar
|
|
|
|
|
|
v-if="isAppIcon(item?.icon)"
|
|
|
|
|
|
shape="square"
|
|
|
|
|
|
:size="32"
|
|
|
|
|
|
style="background: none"
|
|
|
|
|
|
class="mr-8"
|
|
|
|
|
|
>
|
|
|
|
|
|
<img :src="getImageUrl(item?.icon)" alt="" />
|
|
|
|
|
|
</AppAvatar>
|
|
|
|
|
|
<AppAvatar
|
|
|
|
|
|
v-else-if="item?.name"
|
|
|
|
|
|
:name="item?.name"
|
|
|
|
|
|
pinyinColor
|
|
|
|
|
|
shape="square"
|
|
|
|
|
|
:size="32"
|
|
|
|
|
|
class="mr-8"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<div class="status-button">
|
2025-03-19 04:00:57 +00:00
|
|
|
|
|
2025-03-10 08:07:20 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<div class="footer-content flex-between">
|
|
|
|
|
|
<div>{{ $t('common.author') }}: MaxKB</div>
|
2025-03-19 04:00:57 +00:00
|
|
|
|
<div @click.stop>
|
2025-03-17 06:04:25 +00:00
|
|
|
|
<el-button type="primary" link @click="addInternalFunction(item)">
|
2025-03-10 08:07:20 +00:00
|
|
|
|
{{ $t('common.add') }}
|
|
|
|
|
|
</el-button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</CardBox>
|
2024-08-15 09:17:25 +00:00
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
</InfiniteScroll>
|
|
|
|
|
|
</div>
|
2024-08-21 09:25:16 +00:00
|
|
|
|
<FunctionFormDrawer ref="FunctionFormDrawerRef" @refresh="refresh" :title="title" />
|
2025-03-10 03:12:49 +00:00
|
|
|
|
<PermissionDialog ref="PermissionDialogRef" @refresh="refresh" />
|
2025-03-19 04:00:57 +00:00
|
|
|
|
<AddInternalFunctionDialog ref="AddInternalFunctionDialogRef" @refresh="confirmAddInternalFunction" />
|
2025-03-10 03:12:49 +00:00
|
|
|
|
<InitParamDrawer ref="InitParamDrawerRef" @refresh="refresh" />
|
2025-03-10 08:07:20 +00:00
|
|
|
|
<component :is="internalDescComponent" ref="internalDescRef" />
|
2024-08-15 09:17:25 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
2025-03-10 08:07:20 +00:00
|
|
|
|
import { ref, onMounted, reactive, watch, nextTick } from 'vue'
|
2024-08-21 07:36:42 +00:00
|
|
|
|
import { cloneDeep } from 'lodash'
|
2024-08-15 09:17:25 +00:00
|
|
|
|
import functionLibApi from '@/api/function-lib'
|
|
|
|
|
|
import FunctionFormDrawer from './component/FunctionFormDrawer.vue'
|
2025-02-14 09:40:51 +00:00
|
|
|
|
import { MsgSuccess, MsgConfirm, MsgError } from '@/utils/message'
|
2024-09-25 07:23:19 +00:00
|
|
|
|
import useStore from '@/stores'
|
2024-11-05 03:52:56 +00:00
|
|
|
|
import applicationApi from '@/api/application'
|
2025-01-13 03:15:51 +00:00
|
|
|
|
import { t } from '@/locales'
|
2025-03-10 03:12:49 +00:00
|
|
|
|
import PermissionDialog from '@/views/function-lib/component/PermissionDialog.vue'
|
|
|
|
|
|
import InitParamDrawer from '@/views/function-lib/component/InitParamDrawer.vue'
|
2025-03-10 08:07:20 +00:00
|
|
|
|
import { isAppIcon } from '@/utils/application'
|
|
|
|
|
|
import InfiniteScroll from '@/components/infinite-scroll/index.vue'
|
|
|
|
|
|
import CardBox from '@/components/card-box/index.vue'
|
|
|
|
|
|
import type { Dict } from '@/api/type/common'
|
2025-03-19 04:00:57 +00:00
|
|
|
|
import AddInternalFunctionDialog from '@/views/function-lib/component/AddInternalFunctionDialog.vue'
|
2025-03-10 08:07:20 +00:00
|
|
|
|
|
|
|
|
|
|
const internalIcons: Dict<any> = import.meta.glob('@/assets/fx/*/*.png', { eager: true })
|
|
|
|
|
|
let internalDesc: Dict<any> = import.meta.glob('@/assets/fx/*/index.vue', { eager: true })
|
|
|
|
|
|
const internalDescRef = ref()
|
|
|
|
|
|
const internalDescComponent = ref()
|
|
|
|
|
|
|
2024-09-25 07:23:19 +00:00
|
|
|
|
const { user } = useStore()
|
|
|
|
|
|
|
2024-08-15 09:17:25 +00:00
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
const FunctionFormDrawerRef = ref()
|
2025-03-10 03:12:49 +00:00
|
|
|
|
const PermissionDialogRef = ref()
|
2025-03-19 04:00:57 +00:00
|
|
|
|
const AddInternalFunctionDialogRef = ref()
|
2025-03-10 03:12:49 +00:00
|
|
|
|
const InitParamDrawerRef = ref()
|
2024-08-15 09:17:25 +00:00
|
|
|
|
|
|
|
|
|
|
const functionLibList = ref<any[]>([])
|
|
|
|
|
|
|
|
|
|
|
|
const paginationConfig = reactive({
|
|
|
|
|
|
current_page: 1,
|
2024-12-11 06:13:13 +00:00
|
|
|
|
page_size: 30,
|
2024-08-15 09:17:25 +00:00
|
|
|
|
total: 0
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const searchValue = ref('')
|
2024-08-21 09:25:16 +00:00
|
|
|
|
const title = ref('')
|
2024-09-18 02:34:49 +00:00
|
|
|
|
const changeStateloading = ref(false)
|
2024-08-15 09:17:25 +00:00
|
|
|
|
|
2024-11-05 03:52:56 +00:00
|
|
|
|
interface UserOption {
|
|
|
|
|
|
label: string
|
|
|
|
|
|
value: string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const userOptions = ref<UserOption[]>([])
|
|
|
|
|
|
|
|
|
|
|
|
const selectUserId = ref('all')
|
2025-02-14 09:40:51 +00:00
|
|
|
|
const elUploadRef = ref<any>()
|
2024-11-05 03:52:56 +00:00
|
|
|
|
|
2025-03-10 08:07:20 +00:00
|
|
|
|
const functionType = ref('PUBLIC')
|
|
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
|
functionType,
|
|
|
|
|
|
(val) => {
|
|
|
|
|
|
paginationConfig.total = 0
|
|
|
|
|
|
paginationConfig.current_page = 1
|
|
|
|
|
|
functionLibList.value = []
|
|
|
|
|
|
getList()
|
|
|
|
|
|
},
|
|
|
|
|
|
{ immediate: true }
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2024-09-25 07:23:19 +00:00
|
|
|
|
const canEdit = (row: any) => {
|
2024-09-25 16:03:16 +00:00
|
|
|
|
return user.userInfo?.id === row?.user_id
|
2024-09-25 07:23:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-15 09:17:25 +00:00
|
|
|
|
function openCreateDialog(data?: any) {
|
2025-03-10 08:07:20 +00:00
|
|
|
|
// 有template_id的不允许编辑,是模板转换来的
|
|
|
|
|
|
if (data?.template_id) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
// console.log(data)
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title.value = data ? t('views.functionLib.editFunction') : t('views.functionLib.createFunction')
|
2024-09-25 16:03:16 +00:00
|
|
|
|
if (data) {
|
|
|
|
|
|
if (data?.permission_type !== 'PUBLIC' || canEdit(data)) {
|
2025-03-10 08:07:20 +00:00
|
|
|
|
functionLibApi.getFunctionLibById(data?.id, changeStateloading).then((res) => {
|
|
|
|
|
|
FunctionFormDrawerRef.value.open(res.data)
|
|
|
|
|
|
})
|
2024-09-25 16:03:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
} else {
|
2024-09-24 02:38:20 +00:00
|
|
|
|
FunctionFormDrawerRef.value.open(data)
|
|
|
|
|
|
}
|
2024-08-15 09:17:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-10 08:07:20 +00:00
|
|
|
|
function getImageUrl(name: string) {
|
|
|
|
|
|
if (name.startsWith('/src/assets/fx/')) {
|
2025-03-17 06:04:25 +00:00
|
|
|
|
return internalIcons[name]?.default
|
2025-03-10 08:07:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
return name
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function openDescDrawer(row: any) {
|
|
|
|
|
|
const index = row.icon.replace('icon.png', 'index.vue')
|
|
|
|
|
|
internalDescComponent.value = internalDesc[index].default
|
2025-03-17 06:04:25 +00:00
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
internalDescRef.value?.open(row)
|
2025-03-10 08:07:20 +00:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addInternalFunction(data?: any) {
|
2025-03-19 04:00:57 +00:00
|
|
|
|
AddInternalFunctionDialogRef.value.open(data)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function confirmAddInternalFunction(data?: any) {
|
|
|
|
|
|
functionLibApi.addInternalFunction(data.id, {name: data.name}, changeStateloading).then((res) => {
|
2025-03-17 06:04:25 +00:00
|
|
|
|
MsgSuccess(t('common.submitSuccess'))
|
|
|
|
|
|
searchHandle()
|
|
|
|
|
|
})
|
2025-03-10 08:07:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-15 09:17:25 +00:00
|
|
|
|
function searchHandle() {
|
2024-11-05 03:52:56 +00:00
|
|
|
|
if (user.userInfo) {
|
|
|
|
|
|
localStorage.setItem(user.userInfo.id + 'function', selectUserId.value)
|
|
|
|
|
|
}
|
2024-08-15 09:17:25 +00:00
|
|
|
|
paginationConfig.total = 0
|
|
|
|
|
|
paginationConfig.current_page = 1
|
|
|
|
|
|
functionLibList.value = []
|
|
|
|
|
|
getList()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-10 08:07:20 +00:00
|
|
|
|
async function changeState(bool: Boolean, row: any) {
|
2024-09-18 02:34:49 +00:00
|
|
|
|
if (!bool) {
|
|
|
|
|
|
MsgConfirm(
|
2025-01-13 03:15:51 +00:00
|
|
|
|
`${t('views.functionLib.disabled.confirmTitle')}${row.name} ?`,
|
|
|
|
|
|
t('views.functionLib.disabled.confirmMessage'),
|
2024-09-18 02:34:49 +00:00
|
|
|
|
{
|
2025-01-13 03:15:51 +00:00
|
|
|
|
confirmButtonText: t('views.functionLib.setting.disabled'),
|
2024-09-18 02:34:49 +00:00
|
|
|
|
confirmButtonClass: 'danger'
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
const obj = {
|
|
|
|
|
|
is_active: bool
|
|
|
|
|
|
}
|
|
|
|
|
|
functionLibApi.putFunctionLib(row.id, obj, changeStateloading).then((res) => {})
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {
|
|
|
|
|
|
row.is_active = true
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2025-03-10 08:07:20 +00:00
|
|
|
|
const res = await functionLibApi.getFunctionLibById(row.id, changeStateloading)
|
|
|
|
|
|
if (!res.data.init_params && res.data.init_field_list && res.data.init_field_list.length > 0) {
|
|
|
|
|
|
InitParamDrawerRef.value.open(res.data)
|
|
|
|
|
|
row.is_active = false
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2024-09-18 02:34:49 +00:00
|
|
|
|
const obj = {
|
|
|
|
|
|
is_active: bool
|
|
|
|
|
|
}
|
|
|
|
|
|
functionLibApi.putFunctionLib(row.id, obj, changeStateloading).then((res) => {})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-15 09:17:25 +00:00
|
|
|
|
function deleteFunctionLib(row: any) {
|
2024-08-21 06:54:26 +00:00
|
|
|
|
MsgConfirm(
|
2025-01-13 03:15:51 +00:00
|
|
|
|
`${t('views.functionLib.delete.confirmTitle')}${row.name} ?`,
|
|
|
|
|
|
t('views.functionLib.delete.confirmMessage'),
|
2024-08-21 06:54:26 +00:00
|
|
|
|
{
|
2025-03-05 02:56:04 +00:00
|
|
|
|
confirmButtonText: t('common.confirm'),
|
2025-01-13 03:15:51 +00:00
|
|
|
|
cancelButtonText: t('common.cancel'),
|
2024-08-21 06:54:26 +00:00
|
|
|
|
confirmButtonClass: 'danger'
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
.then(() => {
|
|
|
|
|
|
functionLibApi.delFunctionLib(row.id, loading).then(() => {
|
|
|
|
|
|
const index = functionLibList.value.findIndex((v) => v.id === row.id)
|
|
|
|
|
|
functionLibList.value.splice(index, 1)
|
2025-01-13 03:15:51 +00:00
|
|
|
|
MsgSuccess(t('common.deleteSuccess'))
|
2024-08-21 06:54:26 +00:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(() => {})
|
2024-08-15 09:17:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-15 11:00:56 +00:00
|
|
|
|
function copyFunctionLib(row: any) {
|
2025-01-13 03:15:51 +00:00
|
|
|
|
title.value = t('views.functionLib.copyFunction')
|
2024-08-21 07:36:42 +00:00
|
|
|
|
const obj = cloneDeep(row)
|
|
|
|
|
|
delete obj['id']
|
2025-01-13 03:15:51 +00:00
|
|
|
|
obj['name'] = obj['name'] + ` ${t('views.functionLib.functionForm.title.copy')}`
|
2024-08-21 09:25:16 +00:00
|
|
|
|
FunctionFormDrawerRef.value.open(obj)
|
2024-08-15 11:00:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-14 09:40:51 +00:00
|
|
|
|
function exportFunctionLib(row: any) {
|
2025-03-17 06:04:25 +00:00
|
|
|
|
functionLibApi.exportFunctionLib(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}`)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2025-02-14 09:40:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-10 03:12:49 +00:00
|
|
|
|
function configPermission(item: any) {
|
|
|
|
|
|
PermissionDialogRef.value.open(item)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function configInitParams(item: any) {
|
2025-03-10 08:07:20 +00:00
|
|
|
|
functionLibApi.getFunctionLibById(item?.id, changeStateloading).then((res) => {
|
|
|
|
|
|
InitParamDrawerRef.value.open(res.data)
|
|
|
|
|
|
})
|
2025-03-10 03:12:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-14 09:40:51 +00:00
|
|
|
|
function importFunctionLib(file: any) {
|
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
|
formData.append('file', file.raw, file.name)
|
|
|
|
|
|
elUploadRef.value.clearFiles()
|
|
|
|
|
|
functionLibApi
|
|
|
|
|
|
.importFunctionLib(formData, loading)
|
|
|
|
|
|
.then(async (res: any) => {
|
|
|
|
|
|
if (res?.data) {
|
|
|
|
|
|
searchHandle()
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.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')
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-15 09:17:25 +00:00
|
|
|
|
function getList() {
|
2024-11-05 03:52:56 +00:00
|
|
|
|
const params = {
|
|
|
|
|
|
...(searchValue.value && { name: searchValue.value }),
|
2025-03-10 08:07:20 +00:00
|
|
|
|
...(functionType.value && { function_type: functionType.value }),
|
2024-11-05 03:52:56 +00:00
|
|
|
|
...(selectUserId.value &&
|
|
|
|
|
|
selectUserId.value !== 'all' && { select_user_id: selectUserId.value })
|
|
|
|
|
|
}
|
|
|
|
|
|
functionLibApi.getFunctionLib(paginationConfig, params, loading).then((res: any) => {
|
|
|
|
|
|
res.data.records.forEach((item: any) => {
|
|
|
|
|
|
if (user.userInfo && item.user_id === user.userInfo.id) {
|
|
|
|
|
|
item.username = user.userInfo.username
|
|
|
|
|
|
} else {
|
|
|
|
|
|
item.username = userOptions.value.find((v) => v.value === item.user_id)?.label
|
|
|
|
|
|
}
|
2024-08-15 09:17:25 +00:00
|
|
|
|
})
|
2024-11-05 03:52:56 +00:00
|
|
|
|
functionLibList.value = [...functionLibList.value, ...res.data.records]
|
|
|
|
|
|
paginationConfig.total = res.data.total
|
|
|
|
|
|
})
|
2024-08-15 09:17:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function refresh(data: any) {
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
const index = functionLibList.value.findIndex((v) => v.id === data.id)
|
2025-02-06 08:40:15 +00:00
|
|
|
|
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
|
|
|
|
|
|
}
|
2024-08-15 09:17:25 +00:00
|
|
|
|
functionLibList.value.splice(index, 1, data)
|
|
|
|
|
|
}
|
2025-03-10 08:07:20 +00:00
|
|
|
|
paginationConfig.total = 0
|
|
|
|
|
|
paginationConfig.current_page = 1
|
|
|
|
|
|
functionLibList.value = []
|
|
|
|
|
|
getList()
|
2024-08-15 09:17:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-11-05 03:52:56 +00:00
|
|
|
|
function getUserList() {
|
|
|
|
|
|
applicationApi.getUserList('FUNCTION', loading).then((res) => {
|
|
|
|
|
|
if (res.data) {
|
|
|
|
|
|
userOptions.value = res.data.map((item: any) => {
|
|
|
|
|
|
return {
|
|
|
|
|
|
label: item.username,
|
|
|
|
|
|
value: item.id
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (user.userInfo) {
|
|
|
|
|
|
const selectUserIdValue = localStorage.getItem(user.userInfo.id + 'function')
|
|
|
|
|
|
if (selectUserIdValue && userOptions.value.find((v) => v.value === selectUserIdValue)) {
|
|
|
|
|
|
selectUserId.value = selectUserIdValue
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-03-10 08:07:20 +00:00
|
|
|
|
// getList()
|
2024-11-05 03:52:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-15 09:17:25 +00:00
|
|
|
|
onMounted(() => {
|
2024-11-05 03:52:56 +00:00
|
|
|
|
getUserList()
|
2024-08-15 09:17:25 +00:00
|
|
|
|
})
|
|
|
|
|
|
</script>
|
2024-09-18 02:34:49 +00:00
|
|
|
|
<style lang="scss" scoped>
|
2025-02-14 09:40:51 +00:00
|
|
|
|
.application-card-add {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
min-height: var(--card-min-height);
|
|
|
|
|
|
border: 1px dashed var(--el-border-color);
|
|
|
|
|
|
background: var(--el-disabled-bg-color);
|
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
border: 1px solid var(--el-card-bg-color);
|
|
|
|
|
|
background-color: var(--el-card-bg-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.card-add-button {
|
|
|
|
|
|
&:hover {
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
background: var(--app-text-color-light-1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
:deep(.el-upload) {
|
|
|
|
|
|
display: block;
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
color: var(--el-text-color-regular);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.application-card {
|
|
|
|
|
|
.status-tag {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
right: 16px;
|
|
|
|
|
|
top: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-09-18 02:34:49 +00:00
|
|
|
|
.function-lib-list-container {
|
|
|
|
|
|
.status-button {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
right: 12px;
|
2024-11-05 11:13:34 +00:00
|
|
|
|
top: 15px;
|
2024-09-18 02:34:49 +00:00
|
|
|
|
height: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|