【解决todo】AI 角色仓库,增加全部分类筛选

This commit is contained in:
cherishsince 2024-05-21 18:20:45 +08:00
parent 0803e33d1d
commit c06de8095e
2 changed files with 13 additions and 14 deletions

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="category-list"> <div class="category-list">
<div class="category" v-for="category in categoryList" :key="category"> <div class="category" v-for="(category) in categoryList" :key="category">
<el-button plain v-if="category !== active" @click="handleCategoryClick(category)">{{ category }}</el-button> <el-button plain round size="small" v-if="category !== active" @click="handleCategoryClick(category)">{{ category }}</el-button>
<el-button plain type="primary" v-else @click="handleCategoryClick(category)">{{ category }}</el-button> <el-button plain round size="small" v-else type="primary" @click="handleCategoryClick(category)">{{ category }}</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -17,7 +17,8 @@ defineProps({
}, },
active: { active: {
type: String, type: String,
required: false required: false,
default: '全部'
} }
}) })

View File

@ -83,7 +83,7 @@ const myRoleList = ref<ChatRoleVO[]>([]) // my 分页大小
const publicPageNo = ref<number>(1) // public const publicPageNo = ref<number>(1) // public
const publicPageSize = ref<number>(50) // public const publicPageSize = ref<number>(50) // public
const publicRoleList = ref<ChatRoleVO[]>([]) // public const publicRoleList = ref<ChatRoleVO[]>([]) // public
const activeCategory = ref<string>('') // const activeCategory = ref<string>('全部') //
const categoryList = ref<string[]>([]) // const categoryList = ref<string[]>([]) //
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
@ -101,14 +101,12 @@ const getMyRole = async (append?: boolean) => {
const params: ChatRolePageReqVO = { const params: ChatRolePageReqVO = {
pageNo: myPageNo.value, pageNo: myPageNo.value,
pageSize: myPageSize.value, pageSize: myPageSize.value,
category: activeCategory.value,
name: search.value, name: search.value,
publicStatus: false publicStatus: false
} }
const {total, list} = await ChatRoleApi.getMyPage(params) const {total, list} = await ChatRoleApi.getMyPage(params)
if (append) { if (append) {
myRoleList.value.push.apply(myRoleList.value, list) myRoleList.value.push.apply(myRoleList.value, list)
console.log('myRoleList.value.push', myRoleList.value)
} else { } else {
myRoleList.value = list myRoleList.value = list
} }
@ -119,7 +117,7 @@ const getPublicRole = async (append?: boolean) => {
const params: ChatRolePageReqVO = { const params: ChatRolePageReqVO = {
pageNo: publicPageNo.value, pageNo: publicPageNo.value,
pageSize: publicPageSize.value, pageSize: publicPageSize.value,
category: activeCategory.value, category: activeCategory.value === '全部' ? '' : activeCategory.value,
name: search.value, name: search.value,
publicStatus: true publicStatus: true
} }
@ -144,16 +142,16 @@ const getActiveTabsRole = async () => {
// //
const getRoleCategoryList = async () => { const getRoleCategoryList = async () => {
categoryList.value = await ChatRoleApi.getCategoryList() const res = await ChatRoleApi.getCategoryList()
const defaultRole = ['全部']
categoryList.value = [...defaultRole, ...res]
} }
// //
const handlerCategoryClick = async (category: string) => { const handlerCategoryClick = async (category: string) => {
if (activeCategory.value === category) { //
activeCategory.value = '' activeCategory.value = category
} else { //
activeCategory.value = category
}
await getActiveTabsRole() await getActiveTabsRole()
} }