-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Expand file tree
/
Copy pathindex.vue
More file actions
146 lines (144 loc) · 4.28 KB
/
index.vue
File metadata and controls
146 lines (144 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<template>
<el-drawer
v-model="visible"
:title="$t('views.system.resourceMapping.title', '关联资源')"
size="60%"
:append-to-body="true"
>
<div class="flex-between mb-16">
<div class="flex-between complex-search">
<el-select class="complex-search__left" v-model="searchType" style="width: 100px">
<el-option
:label="$t('views.userManage.userForm.resourceName.label', '名称')"
value="resource_name"
/>
<el-option
:label="$t('views.userManage.userForm.user_name.label', '创建者')"
value="user_name"
/>
<el-option
:label="$t('views.userManage.userForm.source_type.label', '资源类型')"
value="source_type"
/>
</el-select>
<el-input
v-if="searchType === 'resource_name'"
v-model="query.resource_name"
:placeholder="$t('common.search')"
style="width: 220px"
clearable
@keyup.enter="pageResouceMapping()"
/>
<el-input
v-if="searchType === 'user_name'"
v-model="query.user_name"
:placeholder="$t('common.search')"
style="width: 220px"
clearable
@keyup.enter="pageResouceMapping()"
/>
<el-select
v-else-if="searchType === 'source_type'"
v-model="query.source_type"
@change="pageResouceMapping()"
filterable
clearable
multiple
:reserve-keyword="false"
collapse-tags
collapse-tags-tooltip
style="width: 220px"
>
<el-option label="应用" value="APPLICATION" />
<el-option label="知识库" value="KNOWLEDGE" />
</el-select>
</div>
</div>
<app-table
ref="multipleTableRef"
class="mt-16"
:data="tableData"
:pagination-config="paginationConfig"
@sizeChange="handleSizeChange"
@changePage="pageResouceMapping"
:maxTableHeight="200"
:row-key="(row: any) => row.id"
v-loading="loading"
>
<el-table-column prop="name" label="名称" min-width="120" show-overflow-tooltip />
<el-table-column prop="desc" min-width="120" show-overflow-tooltip label="描述" />
<el-table-column prop="source_type" min-width="120" show-overflow-tooltip label="资源类型" />
<el-table-column prop="username" min-width="120" show-overflow-tooltip label="创建者" />
</app-table>
</el-drawer>
</template>
<script setup lang="ts">
import { ref, reactive, computed } from 'vue'
import { useRoute } from 'vue-router'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
import useStore from '@/stores'
const route = useRoute()
const { user } = useStore()
const searchType = ref<string>('resource_name')
const query = ref<any>({
resource_name: '',
user_name: '',
source_type: '',
})
const loading = ref<boolean>(false)
const tableData = ref<Array<any>>()
const visible = ref<boolean>(false)
const paginationConfig = reactive({
current_page: 1,
page_size: 20,
total: 0,
})
const apiType = computed(() => {
if (route.path.includes('resource-management')) {
return 'systemManage'
} else {
return 'workspace'
}
})
const pageResouceMapping = () => {
const workspaceId = user.getWorkspaceId() || 'default'
const params: any = {}
if (query.value[searchType.value]) {
params[searchType.value] = query.value[searchType.value]
}
loadSharedApi({ type: 'resourceMapping', systemType: apiType.value })
.getResourceMapping(
workspaceId,
currentSource.value,
currentSourceId.value,
paginationConfig,
params,
loading,
)
.then((res: any) => {
tableData.value = res.data.records || []
paginationConfig.total = res.data.total || 0
})
}
function handleSizeChange() {
paginationConfig.current_page = 1
pageResouceMapping()
}
const currentSource = ref<string>()
const currentSourceId = ref<string>()
const open = (source: string, sourceId: string) => {
visible.value = true
currentSource.value = source
currentSourceId.value = sourceId
pageResouceMapping()
}
const close = () => {
visible.value = false
paginationConfig.current_page = 1
}
defineExpose({
open,
close,
})
</script>
<style lang="scss" scoped></style>