UnisKB/ui/src/views/system-resource-management/ApplicationResourceIndex.vue

331 lines
11 KiB
Vue
Raw Normal View History

2025-06-26 13:33:09 +00:00
<template>
<div class="p-16-24">
<el-breadcrumb separator-icon="ArrowRight">
<el-breadcrumb-item>{{ t('views.system.resource_management.label') }}</el-breadcrumb-item>
<el-breadcrumb-item>
<h5 class="ml-4 color-text-primary">{{ t('views.application.title') }}</h5>
</el-breadcrumb-item>
</el-breadcrumb>
<el-card class="mt-16">
<div class="flex-between mb-16">
<div class="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"/>
2025-06-26 13:33:09 +00:00
<el-option :label="$t('common.name')" value="name"/>
2025-06-26 13:33:09 +00:00
</el-select>
<el-input
v-if="search_type === 'name'"
v-model="search_form.name"
@change="getList"
:placeholder="$t('common.searchBar.placeholder')"
style="width: 220px"
clearable
/>
<el-select
v-else-if="search_type === 'create_user'"
v-model="search_form.create_user"
@change="getList"
clearable
filterable
2025-06-26 13:33:09 +00:00
style="width: 220px"
>
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.nick_name"/>
2025-06-26 13:33:09 +00:00
</el-select>
</div>
</div>
<app-table
:data="applicationList"
2025-06-26 13:33:09 +00:00
:pagination-config="paginationConfig"
@sizeChange="getList"
@changePage="getList"
>
<!-- <el-table-column type="selection" width="55" /> -->
<el-table-column width="220" :label="$t('common.name')">
<template #default="scope">
<div class="table-name flex align-center">
<el-icon size="24" class="mr-8">
<el-avatar
v-if="isAppIcon(scope.row?.icon)"
shape="square"
:size="24"
style="background: none"
class="mr-8"
>
<img :src="resetUrl(scope.row?.icon)" alt=""/>
2025-06-26 13:33:09 +00:00
</el-avatar>
<el-avatar v-else class="avatar-green" shape="square" :size="24">
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt=""/>
2025-06-26 13:33:09 +00:00
</el-avatar>
</el-icon>
{{ scope.row.name }}
</div>
</template>
</el-table-column>
<el-table-column
prop="tool_type"
:label="$t('views.system.resource_management.type')"
width="160"
2025-06-26 13:33:09 +00:00
>
<template #default="scope">
<el-tag type="warning" v-if="isWorkFlow(scope.row.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>
</template>
</el-table-column>
<el-table-column
width="150"
prop="is_publish"
:label="$t('common.status.label')"
show-overflow-tooltip
>
<template #header>
<div>
<span>{{ $t('common.status.label') }}</span>
<el-popover :width="200" trigger="click" :visible="statusVisible">
<template #reference>
<el-button
style="margin-top: -2px"
:type="statusArr && statusArr.length > 0 ? 'primary' : ''"
link
@click="statusVisible = !statusVisible"
>
<el-icon>
<Filter/>
</el-icon>
</el-button>
</template>
<div class="filter">
<div class="form-item mb-16">
<div @click.stop>
<el-scrollbar height="300" style="margin: 0 0 0 10px">
<el-checkbox-group
v-model="statusArr"
style="display: flex; flex-direction: column"
>
<el-checkbox
v-for="item in statusOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-checkbox-group>
</el-scrollbar>
</div>
</div>
</div>
<div class="text-right">
<el-button size="small" @click="filterStatusChange('clear')"
>{{ $t('common.clear') }}
</el-button>
<el-button type="primary" @click="filterStatusChange" size="small"
>{{ $t('common.confirm') }}
</el-button>
</div>
</el-popover>
</div>
</template>
<template #default="scope">
<div v-if="scope.row.is_publish" class="flex align-center">
<el-icon class="color-success mr-8" style="font-size: 16px">
<SuccessFilled/>
</el-icon>
<span class="color-secondary">
{{ $t('views.application.status.published') }}
</span>
</div>
<div v-else class="flex align-center">
<AppIcon iconName="app-disabled" class="color-secondary mr-8"></AppIcon>
<span class="color-secondary">
{{ $t('views.application.status.unpublished') }}
</span>
</div>
2025-06-26 13:33:09 +00:00
</template>
</el-table-column>
<el-table-column
v-if="user.isEE()"
width="150"
prop="workspace_name"
:label="$t('views.workspace.title')"
show-overflow-tooltip
>
<template #header>
<div>
<span>{{ $t('views.workspace.title') }}</span>
<el-popover :width="200" trigger="click" :visible="workspaceVisible">
<template #reference>
<el-button
style="margin-top: -2px"
:type="workspaceArr && workspaceArr.length > 0 ? 'primary' : ''"
link
@click="workspaceVisible = !workspaceVisible"
>
<el-icon>
<Filter/>
2025-06-26 13:33:09 +00:00
</el-icon>
</el-button>
</template>
<div class="filter">
<div class="form-item mb-16">
<div @click.stop>
<el-scrollbar height="300" style="margin: 0 0 0 10px">
<el-checkbox-group
v-model="workspaceArr"
style="display: flex; flex-direction: column"
>
<el-checkbox
v-for="item in workspaceOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-checkbox-group>
</el-scrollbar>
</div>
</div>
</div>
<div class="text-right">
<el-button size="small" @click="filterWorkspaceChange('clear')"
>{{ $t('common.clear') }}
2025-06-26 13:33:09 +00:00
</el-button>
<el-button type="primary" @click="filterWorkspaceChange" size="small"
>{{ $t('common.confirm') }}
2025-06-26 13:33:09 +00:00
</el-button>
</div>
</el-popover>
</div>
</template>
</el-table-column>
<el-table-column prop="nick_name" :label="$t('common.creator')" show-overflow-tooltip
width="120"/>
<el-table-column :label="$t('views.application.publishTime')" width="120">
<template #default="{ row }">
{{ datetimeFormat(row.update_time) }}
</template>
</el-table-column>
<el-table-column :label="$t('views.document.table.updateTime')" width="120">
2025-06-26 13:33:09 +00:00
<template #default="{ row }">
{{ datetimeFormat(row.update_time) }}
</template>
</el-table-column>
<el-table-column :label="$t('common.createTime')" width="120">
2025-06-26 13:33:09 +00:00
<template #default="{ row }">
{{ datetimeFormat(row.create_time) }}
</template>
</el-table-column>
</app-table>
</el-card>
</div>
</template>
<script lang="ts" setup>
import {onMounted, ref, reactive, computed} from 'vue'
import ApplicationResourceApi from '@/api/system-resource-management/application'
import {t} from '@/locales'
import {isAppIcon, resetUrl} from '@/utils/common'
2025-06-26 13:33:09 +00:00
import useStore from '@/stores'
import {datetimeFormat} from '@/utils/time'
2025-07-02 01:56:42 +00:00
import {loadPermissionApi} from "@/utils/dynamics-api/permission-api.ts";
import {isWorkFlow} from "@/utils/application.ts";
import UserApi from "@/api/user/user.ts";
2025-06-26 13:33:09 +00:00
const {user} = useStore()
2025-06-26 13:33:09 +00:00
const search_type = ref('name')
const search_form = ref<any>({
name: '',
create_user: '',
})
const user_options = ref<any[]>([])
const loading = ref(false)
const changeStateloading = ref(false)
const applicationList = ref<any[]>([])
2025-06-26 13:33:09 +00:00
const paginationConfig = reactive({
current_page: 1,
page_size: 30,
total: 0,
})
const workspaceOptions = ref<any[]>([])
const workspaceVisible = ref(false)
const workspaceArr = ref<any[]>([])
const statusVisible = ref(false)
const statusArr = ref<any[]>([])
const statusOptions = ref<any[]>([{
label: t('views.application.status.published'),
value: true,
}, {
label: t('views.application.status.unpublished'),
value: false,
}])
2025-06-26 13:33:09 +00:00
function filterWorkspaceChange(val: string) {
if (val === 'clear') {
workspaceArr.value = []
}
getList()
workspaceVisible.value = false
}
function filterStatusChange(val: string) {
if (val === 'clear') {
statusArr.value = []
}
getList()
statusVisible.value = false
}
2025-06-26 13:33:09 +00:00
async function getWorkspaceList() {
if (user.isEE()) {
2025-07-02 01:56:42 +00:00
const res = await loadPermissionApi('workspace').getSystemWorkspaceList(loading)
2025-06-26 13:33:09 +00:00
workspaceOptions.value = res.data.map((item: any) => ({
label: item.name,
value: item.id,
}))
}
}
2025-06-26 13:33:09 +00:00
const search_type_change = () => {
search_form.value = {name: '', create_user: ''}
2025-06-26 13:33:09 +00:00
}
function getList() {
const params: any = {}
if (search_form.value[search_type.value]) {
params[search_type.value] = search_form.value[search_type.value]
2025-06-26 13:33:09 +00:00
}
if (workspaceArr.value.length > 0) {
params['workspace_ids'] = JSON.stringify(workspaceArr.value)
}
if (statusArr.value.length > 0) {
params['status'] = JSON.stringify(statusArr.value)
}
ApplicationResourceApi.getApplication(paginationConfig, params, loading).then((res: any) => {
2025-06-26 13:33:09 +00:00
paginationConfig.total = res.data?.total
applicationList.value = res.data?.records
2025-06-26 13:33:09 +00:00
})
}
onMounted(() => {
getWorkspaceList()
getList()
UserApi.getAllMemberList('').then((res: any) => {
user_options.value = res.data
})
2025-06-26 13:33:09 +00:00
})
</script>
<style lang="scss" scoped></style>