Skip to content

Commit

Permalink
fix(tag):修复表格 tag 问题
Browse files Browse the repository at this point in the history
  • Loading branch information
besscroft committed Dec 7, 2023
1 parent 5d6ceda commit 512b727
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pages/admin/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ const updateShowHandle = async (val: number, id: number) => {
}
}
const isDiyType = (type: string) => {
return photosList.some(item => type === item.url.replace('/', ''));
}
const tagTitleHandle = (type: string) => {
return photosList.filter(item => type === item.url.replace('/', ''))?.title
}
onBeforeMount(async () => {
await dataHandle()
})
Expand All @@ -172,11 +180,8 @@ definePageMeta({
<el-table-column label="类型" prop="type">
<template #default="scope">
<el-tag v-if="scope.row.type === 'index'">首页精选</el-tag>
<el-tag
v-for="item in photosList"
:key="item.url"
v-else-if="scope.row.type === item.url.replace('/', '')">
{{ item.title }}
<el-tag v-else-if="isDiyType(scope.row.type)">
{{ tagTitleHandle(scope.row.type) || '错误类型' }}
</el-tag>
<el-tag v-else type="danger">错误类型</el-tag>
</template>
Expand Down

0 comments on commit 512b727

Please sign in to comment.