Skip to content

Commit ee87efd

Browse files
wxg0103liuruibin
authored andcommitted
refactor: optimize user options fetching and improve select component integration
1 parent cbee83c commit ee87efd

4 files changed

Lines changed: 127 additions & 84 deletions

File tree

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

Lines changed: 54 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
style="width: 120px"
1616
@change="search_type_change"
1717
>
18-
<el-option :label="$t('common.creator')" value="create_user" />
18+
<el-option :label="$t('common.creator')" value="create_user"/>
1919

20-
<el-option :label="$t('common.name')" value="name" />
21-
<el-option :label="$t('common.type')" value="type" />
20+
<el-option :label="$t('common.name')" value="name"/>
21+
<el-option :label="$t('common.type')" value="type"/>
2222
</el-select>
2323
<el-input
2424
v-if="search_type === 'name'"
@@ -34,9 +34,11 @@
3434
@change="getList"
3535
clearable
3636
filterable
37+
remote
38+
:remote-method="getUserList"
3739
style="width: 220px"
3840
>
39-
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.nick_name" />
41+
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.nick_name"/>
4042
</el-select>
4143
<el-select
4244
v-else-if="search_type === 'type'"
@@ -46,7 +48,7 @@
4648
filterable
4749
style="width: 220px"
4850
>
49-
<el-option v-for="u in type_options" :key="u.id" :value="u.value" :label="u.label" />
51+
<el-option v-for="u in type_options" :key="u.id" :value="u.value" :label="u.label"/>
5052
</el-select>
5153
</div>
5254
</div>
@@ -63,7 +65,7 @@
6365
<template #default="{ row }">
6466
<el-space :size="8">
6567
<el-avatar shape="square" :size="24" style="background: none">
66-
<img :src="resetUrl(row?.icon)" alt="" />
68+
<img :src="resetUrl(row?.icon)" alt=""/>
6769
</el-avatar>
6870
<span class="ellipsis" style="max-width: 160px">
6971
{{ row.name }}
@@ -100,7 +102,7 @@
100102
@click="statusVisible = !statusVisible"
101103
>
102104
<el-icon>
103-
<Filter />
105+
<Filter/>
104106
</el-icon>
105107
</el-button>
106108
</template>
@@ -123,10 +125,10 @@
123125
</div>
124126
<div class="text-right">
125127
<el-button size="small" @click="filterStatusChange('clear')"
126-
>{{ $t('common.clear') }}
128+
>{{ $t('common.clear') }}
127129
</el-button>
128130
<el-button type="primary" @click="filterStatusChange" size="small"
129-
>{{ $t('common.confirm') }}
131+
>{{ $t('common.confirm') }}
130132
</el-button>
131133
</div>
132134
</el-popover>
@@ -135,7 +137,7 @@
135137
<template #default="scope">
136138
<div v-if="scope.row.is_publish" class="flex align-center">
137139
<el-icon class="color-success mr-8" style="font-size: 16px">
138-
<SuccessFilled />
140+
<SuccessFilled/>
139141
</el-icon>
140142
<span class="color-text-primary">
141143
{{ $t('common.status.published') }}
@@ -173,7 +175,7 @@
173175
@click="workspaceVisible = !workspaceVisible"
174176
>
175177
<el-icon>
176-
<Filter />
178+
<Filter/>
177179
</el-icon>
178180
</el-button>
179181
</template>
@@ -199,24 +201,24 @@
199201
/>
200202
</el-checkbox-group>
201203
</el-scrollbar>
202-
<el-empty v-else :description="$t('common.noData')" />
204+
<el-empty v-else :description="$t('common.noData')"/>
203205
</div>
204206
</div>
205207
</div>
206208
<div class="text-right">
207209
<el-button size="small" @click="filterWorkspaceChange('clear')"
208-
>{{ $t('common.clear') }}
210+
>{{ $t('common.clear') }}
209211
</el-button>
210212
<el-button type="primary" @click="filterWorkspaceChange" size="small"
211-
>{{ $t('common.confirm') }}
213+
>{{ $t('common.confirm') }}
212214
</el-button>
213215
</div>
214216
</el-popover>
215217
</div>
216218
</template>
217219
</el-table-column>
218220

219-
<el-table-column prop="nick_name" :label="$t('common.creator')" show-overflow-tooltip />
221+
<el-table-column prop="nick_name" :label="$t('common.creator')" show-overflow-tooltip/>
220222
<el-table-column :label="$t('views.application.publishTime')" width="180">
221223
<template #default="{ row }">
222224
{{ datetimeFormat(row.update_time) }}
@@ -323,25 +325,25 @@
323325
</template>
324326

325327
<script lang="ts" setup>
326-
import { onMounted, ref, reactive, computed, watch } from 'vue'
327-
import { useRouter, useRoute } from 'vue-router'
328+
import {onMounted, ref, reactive, computed, watch} from 'vue'
329+
import {useRouter, useRoute} from 'vue-router'
328330
import ApplicationResourceApi from '@/api/system-resource-management/application'
329331
import ResourceAuthorizationDrawer from '@/components/resource-authorization-drawer/index.vue'
330-
import { t } from '@/locales'
331-
import { isAppIcon, resetUrl } from '@/utils/common'
332+
import {t} from '@/locales'
333+
import {isAppIcon, resetUrl} from '@/utils/common'
332334
import ResourceTriggerDrawer from '@/views/trigger/ResourceTriggerDrawer.vue'
333335
import useStore from '@/stores'
334-
import { datetimeFormat } from '@/utils/time'
335-
import { loadPermissionApi } from '@/utils/dynamics-api/permission-api.ts'
336-
import { isWorkFlow } from '@/utils/application.ts'
336+
import {datetimeFormat} from '@/utils/time'
337+
import {loadPermissionApi} from '@/utils/dynamics-api/permission-api.ts'
338+
import {isWorkFlow} from '@/utils/application.ts'
337339
import UserApi from '@/api/user/user.ts'
338340
import permissionMap from '@/permission'
339-
import { MsgSuccess, MsgConfirm, MsgError } from '@/utils/message'
340-
import { SourceTypeEnum } from '@/enums/common'
341+
import {MsgSuccess, MsgConfirm, MsgError} from '@/utils/message'
342+
import {SourceTypeEnum} from '@/enums/common'
341343
342344
const router = useRouter()
343345
const route = useRoute()
344-
const { user, application } = useStore()
346+
const {user, application} = useStore()
345347
346348
const permissionPrecise = computed(() => {
347349
return permissionMap['application']['systemManage']
@@ -385,20 +387,20 @@ function toChat(row: any) {
385387
.map((v: any) => {
386388
apiInputParams.value = v.properties.api_input_field_list
387389
? v.properties.api_input_field_list.map((v: any) => {
388-
return {
389-
name: v.variable,
390-
value: v.default_value,
391-
}
392-
})
390+
return {
391+
name: v.variable,
392+
value: v.default_value,
393+
}
394+
})
393395
: v.properties.input_field_list
394396
? v.properties.input_field_list
395-
.filter((v: any) => v.assignment_method === 'api_input')
396-
.map((v: any) => {
397-
return {
398-
name: v.variable,
399-
value: v.default_value,
400-
}
401-
})
397+
.filter((v: any) => v.assignment_method === 'api_input')
398+
.map((v: any) => {
399+
return {
400+
name: v.variable,
401+
value: v.default_value,
402+
}
403+
})
402404
: []
403405
})
404406
const apiParams = mapToUrlParams(apiInputParams.value)
@@ -438,7 +440,8 @@ function deleteApplication(row: any) {
438440
MsgSuccess(t('common.deleteSuccess'))
439441
})
440442
})
441-
.catch(() => {})
443+
.catch(() => {
444+
})
442445
}
443446
444447
const exportApplication = (application: any) => {
@@ -505,7 +508,7 @@ watch(
505508
v.label.toLowerCase().includes(filterText.value.toLowerCase()),
506509
)
507510
},
508-
{ immediate: true },
511+
{immediate: true},
509512
)
510513
511514
function filterWorkspaceChange(val: string) {
@@ -536,7 +539,7 @@ async function getWorkspaceList() {
536539
}
537540
538541
const search_type_change = () => {
539-
search_form.value = { name: '', create_user: '', type: '' }
542+
search_form.value = {name: '', create_user: '', type: ''}
540543
}
541544
542545
function getList() {
@@ -556,13 +559,21 @@ function getList() {
556559
})
557560
}
558561
562+
function getUserList(query: string) {
563+
UserApi.getAllMemberList(query ? {nick_name: query} : '')
564+
.then((res: any) => {
565+
user_options.value = res.data || []
566+
})
567+
.catch(() => {
568+
user_options.value = []
569+
})
570+
}
571+
559572
onMounted(() => {
560573
getWorkspaceList()
561574
getList()
562575
563-
UserApi.getAllMemberList('').then((res: any) => {
564-
user_options.value = res.data
565-
})
576+
getUserList('')
566577
})
567578
</script>
568579

0 commit comments

Comments
 (0)