增加角色列
This commit is contained in:
parent
877d7c035b
commit
c0d6371c35
@ -14,6 +14,17 @@
|
|||||||
row-key="userid"
|
row-key="userid"
|
||||||
>
|
>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="column.key === 'roles'">
|
||||||
|
<a-space>
|
||||||
|
<a-tag
|
||||||
|
v-for="role in record.roles"
|
||||||
|
:key="role"
|
||||||
|
:color="getRoleColor(role)"
|
||||||
|
>
|
||||||
|
{{ getRoleName(role) }}
|
||||||
|
</a-tag>
|
||||||
|
</a-space>
|
||||||
|
</template>
|
||||||
<template v-if="column.key === 'phone'">
|
<template v-if="column.key === 'phone'">
|
||||||
{{ formatPhone(record.phone) }}
|
{{ formatPhone(record.phone) }}
|
||||||
</template>
|
</template>
|
||||||
@ -28,13 +39,14 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { defineComponent, ref, onMounted } from 'vue'
|
import { defineComponent, ref, onMounted } from 'vue'
|
||||||
import { message } from 'ant-design-vue'
|
import { message, Tag } from 'ant-design-vue'
|
||||||
import { getUserList } from '@/api/user'
|
import { getUserList } from '@/api/user'
|
||||||
import PageContainer from '@/components/PageContainer.vue'
|
import PageContainer from '@/components/PageContainer.vue'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
PageContainer
|
PageContainer,
|
||||||
|
ATag: Tag
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@ -66,6 +78,12 @@ export default defineComponent({
|
|||||||
key: 'phone',
|
key: 'phone',
|
||||||
width: 120,
|
width: 120,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: '角色',
|
||||||
|
dataIndex: 'roles',
|
||||||
|
key: 'roles',
|
||||||
|
width: 200,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '用户编号',
|
title: '用户编号',
|
||||||
dataIndex: 'user_code',
|
dataIndex: 'user_code',
|
||||||
@ -124,6 +142,29 @@ export default defineComponent({
|
|||||||
fetchData()
|
fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加角色名称映射函数
|
||||||
|
const getRoleName = (role) => {
|
||||||
|
const roleMap = {
|
||||||
|
'admin': '管理员',
|
||||||
|
'user': '普通用户',
|
||||||
|
'merchant': '商家',
|
||||||
|
'deliveryman': '配送员'
|
||||||
|
}
|
||||||
|
return roleMap[role] || role
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加角色颜色映射函数
|
||||||
|
const getRoleColor = (role) => {
|
||||||
|
const colorMap = {
|
||||||
|
'admin': 'red',
|
||||||
|
'user': 'blue',
|
||||||
|
'merchant': 'orange',
|
||||||
|
'operator': 'green',
|
||||||
|
'delivery': 'purple'
|
||||||
|
}
|
||||||
|
return colorMap[role] || 'default'
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fetchData()
|
fetchData()
|
||||||
})
|
})
|
||||||
@ -134,7 +175,9 @@ export default defineComponent({
|
|||||||
tableData,
|
tableData,
|
||||||
pagination,
|
pagination,
|
||||||
handleTableChange,
|
handleTableChange,
|
||||||
formatPhone
|
formatPhone,
|
||||||
|
getRoleName,
|
||||||
|
getRoleColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -159,4 +202,8 @@ export default defineComponent({
|
|||||||
.user-list {
|
.user-list {
|
||||||
/* 保留其他必要样式 */
|
/* 保留其他必要样式 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.ant-tag) {
|
||||||
|
margin: 2px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Loading…
Reference in New Issue
Block a user