Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
center-zws
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
EzijingWeb
center-zws
Commits
9596dca9
提交
9596dca9
authored
12月 09, 2022
作者:
王鹏飞
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 重构用户管理
上级
96a73e15
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
52 行增加
和
75 行删除
+52
-75
UserInfo.vue
src/modules/base/users/components/UserInfo.vue
+21
-68
types.ts
src/modules/base/users/types.ts
+23
-0
Index.vue
src/modules/base/users/views/Index.vue
+8
-7
没有找到文件。
src/modules/base/users/components/UserInfo.vue
浏览文件 @
9596dca9
<
script
setup
lang=
"ts"
>
import
type
{
UserInfo
,
UserProject
,
UserChannel
}
from
'../types'
import
{
getMemberDetail
}
from
'../api'
const
emit
=
defineEmits
<
{
(
e
:
'update:modelValue'
,
visible
:
boolean
):
void
}
>
()
const
prop
=
defineProps
<
{
id
:
string
}
>
()
const
prop
=
defineProps
({
id
:
String
})
interface
Channels
{
channel_id
:
string
title
:
string
roles
:
string
[]
let
userInfo
=
$ref
<
UserInfo
>
()
function
fetchInfo
()
{
getMemberDetail
({
user_id
:
prop
.
id
}).
then
(
res
=>
{
userInfo
=
res
.
data
})
}
interface
Info
{
user_id
:
string
user_name
:
string
mobile
:
string
email
:
string
projects
:
[
{
title
:
string
project_id
:
string
roles
:
string
[]
channels
:
Channels
[]
}
]
}
let
userInfo
=
$ref
<
Info
>
()
getMemberDetail
({
user_id
:
prop
.
id
}).
then
((
res
:
any
)
=>
{
userInfo
=
res
.
data
console
.
log
(
userInfo
,
'userInfouserInfo'
)
onMounted
(()
=>
{
fetchInfo
()
})
const
projectValue
=
$ref
()
const
channelValue
=
$ref
()
let
projectRole
=
$ref
<
string
[]
>
()
let
channelRole
=
$ref
<
string
[]
>
()
let
channelsOption
=
$ref
<
Channels
[]
>
()
// 项目渠道联动
const
projectChange
=
function
()
{
const
findData
=
userInfo
.
projects
.
find
(
item
=>
item
.
project_id
===
projectValue
)
if
(
findData
)
{
channelsOption
=
findData
.
channels
projectRole
=
findData
.
roles
}
}
// 选择渠道
const
channelChange
=
function
()
{
const
findData
=
channelsOption
.
find
(
item
=>
item
.
channel_id
===
channelValue
)
if
(
findData
)
{
channelRole
=
findData
.
roles
}
}
// 项目
const
projectValue
=
$ref
<
UserProject
>
()
// 渠道
const
channelValue
=
$ref
<
UserChannel
>
()
</
script
>
<
template
>
...
...
@@ -80,47 +41,39 @@ const channelChange = function () {
<div
class=
"item"
>
<div
class=
"label"
>
选择项目:
</div>
<div
class=
"value"
>
<el-select
@
change=
"projectChange"
v-model=
"projectValue"
class=
"m-2"
placeholder=
"选择项目"
size=
"small"
>
<el-option
v-for=
"item in userInfo.projects"
:key=
"item.project_id"
:label=
"item.title"
:value=
"item.project_id"
/>
<el-select
v-model=
"projectValue"
placeholder=
"选择项目"
size=
"small"
value-key=
"project_id"
>
<el-option
v-for=
"item in userInfo.projects"
:key=
"item.project_id"
:label=
"item.title"
:value=
"item"
/>
</el-select>
</div>
</div>
<div
class=
"item"
>
<div
class=
"label"
>
角色权限:
</div>
<div
v-for=
"(item, index) in project
Role
"
:key=
"index"
class=
"value"
style=
"margin-right: 10px"
>
<div
v-for=
"(item, index) in project
Value?.roles
"
:key=
"index"
class=
"value"
style=
"margin-right: 10px"
>
<el-tag>
{{
item
}}
</el-tag>
</div>
</div>
<div
class=
"item mt-20"
>
<div
class=
"label"
>
选择渠道:
</div>
<div
class=
"value"
>
<el-select
@
change=
"channelChange"
v-model=
"channelValue"
class=
"m-2"
placeholder=
"选择渠道"
size=
"small
"
>
<el-select
v-model=
"channelValue"
placeholder=
"选择渠道"
size=
"small"
value-key=
"channel_id
"
>
<el-option
v-for=
"item in
channelsOption
"
v-for=
"item in
projectValue?.channels
"
:key=
"item.channel_id"
:label=
"item.title"
:value=
"item.channel_id"
/>
:value=
"item"
/>
</el-select>
</div>
</div>
<div
class=
"item"
>
<div
class=
"label"
>
角色权限:
</div>
<div
v-for=
"(item, index) in channel
Role
"
:key=
"index"
class=
"value"
style=
"margin-right: 10px"
>
<div
v-for=
"(item, index) in channel
Value?.roles
"
:key=
"index"
class=
"value"
style=
"margin-right: 10px"
>
<el-tag>
{{
item
}}
</el-tag>
</div>
</div>
</div>
</el-card>
<template
#
footer
>
<span
class=
"dialog-footer"
>
<el-button
@
click=
"emit('update:modelValue', false)"
>
关闭
</el-button>
</span>
<el-button
@
click=
"$emit('update:modelValue', false)"
>
关闭
</el-button>
</
template
>
</el-dialog>
</template>
...
...
src/modules/base/users/types.ts
0 → 100644
浏览文件 @
9596dca9
export
interface
UserItem
{
email
:
string
mobile
:
string
roles_count
:
number
user_id
:
string
user_name
:
string
}
export
interface
UserProject
{
project_id
:
string
title
:
string
channels
:
UserChannel
[]
roles
:
string
[]
}
export
interface
UserChannel
{
channel_id
:
string
title
:
string
projects
:
string
[]
roles
:
string
[]
}
export
type
UserInfo
=
UserItem
&
{
projects
:
UserProject
[]
}
src/modules/base/users/views/Index.vue
浏览文件 @
9596dca9
<
script
setup
lang=
"ts"
>
import
type
{
UserItem
}
from
'../types'
import
AppList
from
'@/components/base/AppList.vue'
import
{
getMemberList
}
from
'../api'
...
...
@@ -35,19 +36,19 @@ const listOptions = $computed(() => {
})
// 查看
let
label
Visible
=
$ref
(
false
)
let
currentRow
Id
=
$ref
(
''
)
function
handleView
(
row
:
any
)
{
currentRow
Id
=
row
.
user_id
label
Visible
=
true
let
view
Visible
=
$ref
(
false
)
let
currentRow
=
$ref
<
UserItem
>
(
)
function
handleView
(
row
:
UserItem
)
{
currentRow
=
row
view
Visible
=
true
}
</
script
>
<
template
>
<AppCard
title=
"用户管理"
>
<AppList
v-bind=
"listOptions"
ref=
"appList"
>
<UserInfo
v-
if=
"currentRowId && labelVisible"
v-model=
"labelVisible"
:id=
"currentRowId
"
></UserInfo>
<template
#
table-x=
"
{ row }">
<UserInfo
v-
model=
"viewVisible"
:id=
"currentRow.user_id"
v-if=
"viewVisible && currentRow
"
></UserInfo>
<template
#
table-x=
"
{ row }
: { row: UserItem }
">
<el-button
text
type=
"primary"
@
click=
"handleView(row)"
>
查看
</el-button>
</
template
>
</AppList>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论