Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
李宁
/
Activity
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0b2f302d
authored
Nov 24, 2025
by
李宁
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
f539d7a0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
97 deletions
channelBusiManage/src/components/OrganizationTree.vue
channelBusiManage/src/components/UserManagement.vue
channelBusiManage/src/components/OrganizationTree.vue
View file @
0b2f302
...
...
@@ -130,7 +130,7 @@ interface Props {
roleId
?:
string
roles
?:
Role
[]
expandedIds
?:
Set
<
string
>
accountType
?:
'
地市级'
|
'区县级'
|
'一线人员
'
accountType
?:
'
1'
|
'2'
|
'3
'
}
const
props
=
withDefaults
(
defineProps
<
Props
>
(),
{
selectedId
:
''
,
...
...
@@ -155,22 +155,22 @@ const hasChildren = (org: Organization): boolean => {
return
!!
(
org
.
children
&&
org
.
children
.
length
>
0
)
}
const
isSelectable
=
(
org
:
Organization
):
boolean
=>
{
console
.
log
(
'检查组织可选性:'
,
org
.
name
,
org
.
type
,
'账号类型:'
,
props
.
accountType
)
//
console.log('检查组织可选性:', org.name, org.type, '账号类型:', props.accountType)
// 只根据账号类型判断,不根据角色层级判断
if
(
props
.
accountType
)
{
switch
(
props
.
accountType
)
{
case
'
地市级
'
:
case
'
1
'
:
// 地市级只能选择地市级组织
console
.
log
(
'地市级账号,检查组织类型是否为地市:'
,
org
.
type
===
'地市'
)
//
console.log('地市级账号,检查组织类型是否为地市:', org.type === '地市')
return
org
.
type
===
'地市'
case
'
区县级
'
:
case
'
2
'
:
// 区县级只能选择区县级组织
console
.
log
(
'区县级账号,检查组织类型是否为区县:'
,
org
.
type
===
'区县'
)
//
console.log('区县级账号,检查组织类型是否为区县:', org.type === '区县')
return
org
.
type
===
'区县'
case
'
一线人员
'
:
case
'
3
'
:
// 区县级只能选择区县级组织
console
.
log
(
'区县级账号,检查组织类型是否为区县:'
,
org
.
type
===
'区县'
)
//
console.log('区县级账号,检查组织类型是否为区县:', org.type === '区县')
return
org
.
type
===
'区县'
default
:
return
true
...
...
channelBusiManage/src/components/UserManagement.vue
View file @
0b2f302
...
...
@@ -63,9 +63,9 @@
class=
"h-10 w-full"
clearable
>
<el-option
label=
"全部状态"
value=
"
all
"
/>
<el-option
label=
"
正常
"
value=
"1"
/>
<el-option
label=
"
禁用
"
value=
"0"
/>
<el-option
label=
"全部状态"
value=
""
/>
<el-option
label=
"
开启
"
value=
"1"
/>
<el-option
label=
"
关闭
"
value=
"0"
/>
</el-select>
<el-select
v-model=
"organizationFilter"
...
...
@@ -73,7 +73,7 @@
class=
"h-10 w-full"
clearable
>
<el-option
label=
"全部区域"
value=
"
all
"
/>
<el-option
label=
"全部区域"
value=
""
/>
<el-option
v-for=
"org in organizationOptions"
:key=
"org.id"
...
...
@@ -81,6 +81,13 @@
:value=
"org.id"
/>
</el-select>
<el-button
class=
"h-13 px-2"
@
click=
"getAccountList"
style=
"width: 100px;"
>
查询
</el-button>
</div>
</el-card>
<!-- 用户列表 -->
...
...
@@ -93,18 +100,10 @@
:header-cell-style=
"
{ backgroundColor: '#f3f4f6', color: '#374151', fontWeight: '500', borderBottom: '1px solid #e5e7eb' }"
:row-style="getRowStyle"
>
<el-table-column
prop=
"
realN
ame"
label=
"用户姓名"
min-width=
"100"
>
<el-table-column
prop=
"
usern
ame"
label=
"用户姓名"
min-width=
"100"
>
<template
#
default=
"
{ row }">
<div
class=
"flex items-center gap-2"
>
<span
:class=
"
{ 'font-semibold': isCurrentUser(row) }">
{{
row
.
realName
}}
</span>
<el-tag
v-if=
"isCurrentUser(row)"
type=
"primary"
size=
"small"
class=
"text-xs"
>
当前登录
</el-tag>
<span>
{{
row
.
username
||
'--'
}}
</span>
</div>
</
template
>
</el-table-column>
...
...
@@ -115,54 +114,50 @@
</
template
>
</el-table-column>
<el-table-column
prop=
"user
nam
e"
label=
"工号"
min-width=
"120"
>
<el-table-column
prop=
"user
Cod
e"
label=
"工号"
min-width=
"120"
>
<
template
#
default=
"{ row }"
>
<span
:class=
"
{ 'font-semibold': isCurrentUser(row) }">
{{
row
.
usernam
e
}}
</span>
<span
>
{{
row
.
userCod
e
}}
</span>
</
template
>
</el-table-column>
<el-table-column
prop=
"
account
Type"
label=
"账号类型"
min-width=
"100"
>
<el-table-column
prop=
"
user
Type"
label=
"账号类型"
min-width=
"100"
>
<
template
#
default=
"{ row }"
>
<el-tag
:type=
"getAccountTypeTagType(row.
account
Type)"
:type=
"getAccountTypeTagType(row.
user
Type)"
effect=
"plain"
size=
"small"
>
{{
row
.
accountType
||
'-'
}}
{{
getAccountTypeName
(
row
.
userType
)
||
'-'
}}
</el-tag>
</
template
>
</el-table-column>
<el-table-column
prop=
"role
Id
"
label=
"角色"
min-width=
"120"
>
<el-table-column
prop=
"role
Name
"
label=
"角色"
min-width=
"120"
>
<
template
#
default=
"{ row }"
>
{{
getRoleById
(
row
.
roleId
)?.
name
||
'-'
}}
<span>
{{
row
.
roleName
||
'--'
}}
</span>
</
template
>
</el-table-column>
<el-table-column
prop=
"status"
label=
"状态"
min-width=
"80"
>
<
template
#
default=
"{ row }"
>
<el-tag
:type=
"row.status ===
'正常'
? 'success' : 'info'"
:type=
"row.status ===
1
? 'success' : 'info'"
size=
"small"
>
{{
row
.
status
}}
{{
row
.
status
==
1
?
'开启'
:
'关闭'
}}
</el-tag>
</
template
>
</el-table-column>
<el-table-column
prop=
"
organizationId"
label=
"所属组织
"
min-width=
"150"
>
<el-table-column
prop=
"
areaName"
label=
"所属区域
"
min-width=
"150"
>
<
template
#
default=
"{ row }"
>
<div
v-if=
"getOrganizationById(row.organizationId)"
class=
"flex items-center gap-2"
>
<el-tag
size=
"small"
type=
"info"
>
{{
getOrganizationById
(
row
.
organizationId
)?.
type
}}
</el-tag>
<span>
{{
getOrganizationById
(
row
.
organizationId
)?.
name
}}
</span>
</div>
<span
v-else
>
-
</span>
<span>
{{
row
.
areaName
||
'--'
}}
</span>
</
template
>
</el-table-column>
<el-table-column
prop=
"createTime"
label=
"创建时间"
min-width=
"120"
>
<
template
#
default=
"{ row }"
>
{{
row
.
createTime
||
'-'
}}
{{
$utils
.
detailTime
(
row
.
createTime
)
}}
</
template
>
</el-table-column>
...
...
@@ -222,9 +217,9 @@
class=
"w-full"
@
change=
"handleAccountTypeChange"
>
<el-option
label=
"地市级"
value=
"
地市级
"
/>
<el-option
label=
"区县级"
value=
"
区县级
"
/>
<el-option
label=
"一线人员"
value=
"
一线人员
"
/>
<el-option
label=
"地市级"
value=
"
1
"
/>
<el-option
label=
"区县级"
value=
"
2
"
/>
<el-option
label=
"一线人员"
value=
"
3
"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"角色"
required
class=
"col-span-2"
>
...
...
@@ -321,7 +316,7 @@ import { ref, computed, watch ,onMounted,getCurrentInstance} from 'vue'
import
{
ElMessage
,
ElMessageBox
}
from
'element-plus'
import
{
Plus
,
Building2
,
Search
}
from
'lucide-vue-next'
import
OrganizationTree
from
'./OrganizationTree.vue'
const
{
$api
}
=
getCurrentInstance
()
!
.
appContext
.
config
.
globalProperties
const
{
$api
,
$utils
}
=
getCurrentInstance
()
!
.
appContext
.
config
.
globalProperties
// 类型定义
export
interface
User
{
id
:
string
...
...
@@ -329,7 +324,7 @@ export interface User {
realName
:
string
organizationId
:
string
roleId
:
string
accountType
?:
'
地市级'
|
'区县级'
|
'一线人员
'
accountType
?:
'
1'
|
'2'
|
'3
'
phone
?:
string
email
?:
string
status
:
'正常'
|
'禁用'
...
...
@@ -347,6 +342,7 @@ interface Role {
interface
Organization
{
id
:
string
name
:
string
areaCode
:
string
type
:
'地市'
|
'区县'
|
'客户经理团队'
parentId
?:
string
children
?:
Organization
[]
...
...
@@ -372,7 +368,7 @@ const codeSearch = ref('')
const
roleFilter
=
ref
<
string
>
(
'all'
)
const
accountTypeFilter
=
ref
<
''
|
'1'
|
'2'
|
'3'
>
(
''
)
const
statusFilter
=
ref
<
''
|
'1'
|
'0'
>
(
''
)
const
organizationFilter
=
ref
<
string
>
(
'
all
'
)
const
organizationFilter
=
ref
<
string
>
(
''
)
const
organizationExpandedIds
=
ref
(
new
Set
<
string
>
())
// 表单数据
const
formData
=
ref
({
...
...
@@ -407,27 +403,25 @@ const getRoleList = async ()=>{
const
getAccountList
=
async
()
=>
{
try
{
const
response
=
await
$api
.
queryAccountList
({
phone
:
''
,
status
:
''
,
username
:
userNameSearch
.
value
,
phone
:
phoneSearch
.
value
,
userCode
:
codeSearch
.
value
,
userType
:
accountTypeFilter
.
value
,
status
:
statusFilter
.
value
,
areaCode
:
organizationFilter
.
value
,
page
:
1
,
pageSize
:
1000
})
if
(
response
&&
response
.
c
===
0
)
{
filteredUsers
.
value
=
response
.
d
filteredUsers
.
value
=
response
.
d
.
content
}
}
catch
(
error
)
{
console
.
log
(
'报错了'
)
}
}
const
totalUsers
=
computed
(()
=>
props
.
users
.
length
-
1
)
// 排除当前登录用户
const
hasFilters
=
computed
(()
=>
generalSearch
.
value
!==
''
||
roleFilter
.
value
!==
'all'
||
accountTypeFilter
.
value
!==
'all'
||
statusFilter
.
value
!==
'all'
||
organizationFilter
.
value
!==
'all'
)
const
roleHint
=
computed
(()
=>
{
if
(
!
formData
.
value
.
roleId
)
return
''
...
...
@@ -454,14 +448,22 @@ const getOrganizationById = (id: string): Organization | undefined => {
const
getRoleById
=
(
id
:
string
):
Role
|
undefined
=>
{
return
props
.
roles
.
find
(
r
=>
r
.
id
===
id
)
}
const
getAccountTypeTagType
=
(
accountType
:
string
)
=>
{
const
getAccountTypeTagType
=
(
accountType
:
Number
)
=>
{
switch
(
accountType
)
{
case
'地市级'
:
return
'warning'
case
'区县级'
:
return
'primary'
case
'一线人员'
:
return
'success'
case
1
:
return
'warning'
case
2
:
return
'primary'
case
3
:
return
'success'
default
:
return
'info'
}
}
const
getAccountTypeName
=
(
accountType
:
Number
)
=>
{
switch
(
accountType
)
{
case
1
:
return
'地市级'
case
2
:
return
'区县级'
case
3
:
return
'一线管理员'
default
:
return
'--'
}
}
const
isCurrentUser
=
(
user
:
User
):
boolean
=>
{
return
user
.
id
===
props
.
currentUserId
}
...
...
@@ -478,23 +480,23 @@ const handleOpenAddDialog = () => {
username
:
''
,
realName
:
''
,
phone
:
''
,
accountType
:
'
一线人员'
as
'地市级'
|
'区县级'
|
'一线人员
'
,
accountType
:
''
,
organizationId
:
''
,
roleId
:
''
,
isActive
:
true
}
isDialogOpen
.
value
=
true
}
const
handleOpenEditDialog
=
(
user
:
User
)
=>
{
editingUser
.
value
=
user
const
handleOpenEditDialog
=
(
row
)
=>
{
editingUser
.
value
=
row
formData
.
value
=
{
username
:
user
.
usernam
e
,
realName
:
user
.
realN
ame
,
phone
:
user
.
phone
||
''
,
accountType
:
user
.
accountType
||
'一线人员
'
,
organizationId
:
user
.
organization
Id
,
roleId
:
user
.
roleId
,
isActive
:
user
.
status
===
'正常'
username
:
row
.
userCod
e
,
realName
:
row
.
usern
ame
,
phone
:
row
.
phone
||
''
,
accountType
:
row
.
userType
+
'
'
,
organizationId
:
row
.
area
Id
,
roleId
:
row
.
roleId
,
isActive
:
row
.
status
===
1
}
isDialogOpen
.
value
=
true
}
...
...
@@ -579,36 +581,19 @@ const handleSave = async () => {
return
}
}
// 检查用户名是否重复
const
existingUser
=
props
.
users
.
find
(
u
=>
u
.
username
===
formData
.
value
.
username
.
trim
()
&&
u
.
id
!==
editingUser
.
value
?.
id
)
if
(
existingUser
)
{
ElMessage
.
error
(
'该工号已存在'
)
return
}
const
userData
:
any
=
{
username
:
formData
.
value
.
username
.
trim
(),
realName
:
formData
.
value
.
realName
.
trim
(),
roleId
:
formData
.
value
.
roleId
,
accountType
:
formData
.
value
.
accountType
,
status
:
formData
.
value
.
isActive
?
'正常'
:
'禁用'
,
phone
:
formData
.
value
.
phone
.
trim
()
||
undefined
,
creatorId
:
props
.
currentUserId
}
// 当前登录用户不可修改自己的所属组织
// if (!editingUser.value || !isCurrentUser(editingUser.value)) {
// userData.organizationId = formData.value.organizationId
// }
const
response
=
await
$api
.
addAndUpdateRole
({
id
:
editingUser
.
value
?
editingUser
.
value
.
id
:
''
,
userCode
:
formData
.
value
.
username
.
trim
(),
userName
:
formData
.
value
.
realName
.
trim
(),
phone
:
formData
.
value
.
phone
.
trim
(),
userType
:
formData
.
value
.
accountType
,
roleId
:
formData
.
value
.
roleId
,
status
:
formData
.
value
.
isActive
?
'1'
:
'0'
,
areaId
:
formData
.
value
.
organizationId
})
if
(
response
.
c
===
0
)
{
//handleFilter
()
getAccountList
()
ElMessage
.
success
(
editingUser
.
value
?
'编辑成功'
:
'创建成功'
);
}
else
{
ElMessage
.
error
(
response
.
m
);
...
...
@@ -622,7 +607,7 @@ const organizationOptions = computed(() => {
const
traverse
=
(
orgs
:
Organization
[],
depth
=
0
)
=>
{
const
prefix
=
depth
>
0
?
'— '
.
repeat
(
depth
)
:
''
orgs
.
forEach
(
org
=>
{
result
.
push
({
id
:
org
.
id
,
label
:
`
${
prefix
}${
org
.
name
}
`
})
result
.
push
({
id
:
org
.
areaCode
,
label
:
`
${
prefix
}${
org
.
name
}
`
})
if
(
org
.
children
&&
org
.
children
.
length
)
traverse
(
org
.
children
,
depth
+
1
)
})
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment