Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
胡锦波
/
org-manager-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
67b186ec
authored
Apr 13, 2022
by
胡锦波
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1. init interface处理
parent
4ff1d9a6
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
165 additions
and
67 deletions
src/api/company-service.ts
src/api/sdk-service.ts
src/views/pages/employ-management/address-book/address-book.vue
src/views/pages/employ-management/address-book/aside.vue
src/views/pages/employ-management/address-book/components/search-list.vue
src/views/pages/employ-management/address-book/employ-list.vue
src/views/service/department-controller.ts
src/views/service/emp-tree.ts
src/api/company-service.ts
View file @
67b186ec
import
BaseService
from
"@/api/core"
;
/* eslint-disable */
export
interface
OldDepartmentItem
{
deep
:
string
;
id
:
string
;
is_main
:
boolean
;
name
:
string
;
name_pinyin
:
string
;
order
:
number
;
parentid
:
string
;
}
/* eslint-enable */
interface
CompanyDepTree
{
comid
:
string
;
departments
:
OldDepartmentItem
[];
ver
:
string
;
}
class
CompanyService
extends
BaseService
{
public
constructor
()
{
...
...
@@ -6,7 +23,7 @@ class CompanyService extends BaseService {
}
public
getDepartment
(
comid
:
string
)
{
return
this
.
getWithCompanyToken
(
`/v1/companies/
${
comid
}
/departments/all`
);
return
this
.
getWithCompanyToken
<
CompanyDepTree
>
(
`/v1/companies/
${
comid
}
/departments/all`
);
}
}
...
...
src/api/sdk-service.ts
View file @
67b186ec
...
...
@@ -49,17 +49,42 @@ class SdkCoreService {
});
}
protected
async
get
(
url
:
string
)
{
protected
async
get
<
T
>
(
url
:
string
)
{
const
config
=
await
this
.
buildSdkHeaders
();
return
this
.
invokeGet
(
url
,
config
);
return
this
.
invokeGet
(
url
,
config
)
as
Promise
<
T
>
;
}
protected
async
post
(
url
:
string
,
body
:
any
)
{
protected
async
post
<
T
>
(
url
:
string
,
body
:
any
)
{
const
config
=
await
this
.
buildSdkHeaders
();
return
this
.
invokePost
(
url
,
body
,
config
);
return
this
.
invokePost
(
url
,
body
,
config
)
as
Promise
<
T
>
;
}
}
export
interface
BaseOrgMemberItem
{
display
:
string
;
emp
:
boolean
;
id
:
string
;
name
:
string
;
}
export
interface
OrgMemberItem
extends
BaseOrgMemberItem
{
active
:
number
;
joined
:
boolean
;
enable
:
number
;
bound
:
boolean
;
email
:
string
;
mobile
:
string
;
peid
:
string
;
permitted
:
boolean
;
puid
:
string
;
uid
:
string
;
avatarUrl
:
string
;
}
export
interface
OrgDepartmentItem
extends
BaseOrgMemberItem
{
pdid
:
string
;
children
?:
OrgDepartmentItem
[]
|
OrgMemberItem
[];
}
class
SdkService
extends
SdkCoreService
{
getJoinedList
()
{
return
this
.
get
(
`/system/org/joined/list`
);
...
...
@@ -71,7 +96,7 @@ class SdkService extends SdkCoreService {
getOrgTree
()
{
const
oid
=
EnterpriseHost
.
getOid
();
return
this
.
get
(
`/system/org/
${
oid
}
/emptree`
);
return
this
.
get
<
OrgDepartmentItem
[]
>
(
`/system/org/
${
oid
}
/emptree`
);
}
}
...
...
src/views/pages/employ-management/address-book/address-book.vue
View file @
67b186ec
...
...
@@ -4,6 +4,7 @@
<EmployList
:pdid2Members=
"pdid2Members"
:curDepId=
"curDepId"
:init=
"init"
class=
"flex-fill"
></EmployList>
</div>
...
...
@@ -13,13 +14,15 @@
import
{
Component
,
Vue
}
from
"vue-property-decorator"
;
import
Aside
from
"@/views/pages/employ-management/address-book/aside.vue"
;
import
EmployList
from
"@/views/pages/employ-management/address-book/employ-list.vue"
;
import
{
empTreeController
}
from
"@/views/service/emp-tree"
;
import
{
empTreeController
,
OrgMemberItem2Map
}
from
"@/views/service/emp-tree"
;
@
Component
({
components
:
{
Aside
,
EmployList
}
})
export
default
class
AddressBook
extends
Vue
{
private
pdid2Members
:
{
[
key
:
string
]:
any
}
=
{};
private
pdid2Members
:
{
[
key
:
string
]:
OrgMemberItem2Map
}
=
{};
private
curDepId
=
""
;
private
init
=
false
;
created
()
{
this
.
initOrgTree
();
}
...
...
@@ -29,9 +32,14 @@
}
private
initOrgTree
()
{
empTreeController
.
initTree
(
this
).
then
(()
=>
{
this
.
pdid2Members
=
empTreeController
.
getPdid2Members
();
});
empTreeController
.
initTree
(
this
)
.
then
(()
=>
{
this
.
pdid2Members
=
empTreeController
.
getPdid2Members
();
})
.
finally
(()
=>
{
this
.
init
=
true
;
});
}
}
</
script
>
...
...
src/views/pages/employ-management/address-book/aside.vue
View file @
67b186ec
...
...
@@ -44,7 +44,10 @@
<
script
lang=
"ts"
>
import
{
Component
,
Vue
,
Ref
}
from
"vue-property-decorator"
;
import
{
departmentController
}
from
"@/views/service/department-controller"
;
import
{
departmentController
,
OldDepartment4Tree
,
}
from
"@/views/service/department-controller"
;
import
{
popupService
}
from
"@/apppackage/element-upgrades/popup"
;
import
SearchList
from
"@/views/pages/employ-management/address-book/components/search-list.vue"
;
import
{
Direction
}
from
"@/router"
;
...
...
@@ -57,7 +60,7 @@
value
:
"id"
,
};
private
departments
=
[];
private
departments
:
OldDepartment4Tree
[]
=
[];
private
searchVal
=
""
;
private
defaultExpandedKeys
:
string
[]
=
[];
private
defaultCheckedKeys
:
string
[]
=
[];
...
...
@@ -72,9 +75,10 @@
private
getDepartmentInfo
()
{
departmentController
.
getDepartments
()
.
then
((
r
:
any
)
=>
{
.
then
((
r
)
=>
{
this
.
departments
=
r
.
departments4tree
;
const
curPdid
=
this
.
$route
.
query
.
pdid
||
r
.
departments
[
0
].
id
;
const
curPdid
=
(
this
.
$route
.
query
.
pdid
as
string
)
||
r
.
departments
[
0
].
id
;
this
.
$nextTick
(()
=>
{
this
.
tree
.
setCurrentKey
(
curPdid
);
});
...
...
@@ -100,7 +104,7 @@
});
}
private
handleNodeClick
(
data
:
any
)
{
private
handleNodeClick
(
data
:
OldDepartment4Tree
)
{
this
.
onEmpChange
(
data
.
id
);
}
...
...
@@ -108,11 +112,11 @@
return
""
;
}
private
isChecked
(
value
:
any
,
chk
:
any
)
{
private
isChecked
(
value
:
OldDepartment4Tree
,
chk
:
any
)
{
chk
.
checked
=
false
;
}
private
filterNode
(
value
:
any
,
data
:
any
)
{
private
filterNode
(
value
:
OldDepartment4Tree
,
data
:
any
)
{
if
(
!
value
)
return
true
;
return
data
.
label
.
indexOf
(
value
)
!==
-
1
;
}
...
...
src/views/pages/employ-management/address-book/components/search-list.vue
View file @
67b186ec
...
...
@@ -15,16 +15,17 @@
<
script
lang=
"ts"
>
import
{
departmentController
}
from
"@/views/service/department-controller"
;
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
"vue-property-decorator"
;
import
{
empTreeController
}
from
"@/views/service/emp-tree"
;
import
{
empTreeController
,
OrgMemberItem2Map
}
from
"@/views/service/emp-tree"
;
import
{
popupService
}
from
"@/apppackage/element-upgrades/popup"
;
import
{
OldDepartmentItem
}
from
"@/api/company-service"
;
@
Component
({
components
:
{}
})
export
default
class
SearchList
extends
Vue
{
@
Prop
()
private
val
!
:
string
;
private
emps
:
any
[]
=
[];
private
depts
:
any
[]
=
[];
private
emps
:
OrgMemberItem2Map
[]
=
[];
private
depts
:
OldDepartmentItem
[]
=
[];
@
Watch
(
"val"
,
{
immediate
:
true
})
private
onValChange
()
{
...
...
@@ -33,7 +34,7 @@
departmentController
.
getDepartments
(),
empTreeController
.
initTree
(),
])
.
then
((
r
:
any
)
=>
{
.
then
((
r
)
=>
{
if
(
this
.
val
!==
curVal
)
{
return
;
}
...
...
@@ -43,7 +44,7 @@
const
cacheMember
:
string
[]
=
[];
this
.
depts
=
[];
this
.
emps
=
[];
members
.
forEach
((
m
:
any
)
=>
{
members
.
forEach
((
m
)
=>
{
if
(
m
.
name
&&
m
.
name
.
includes
(
curVal
)
&&
...
...
@@ -55,7 +56,7 @@
}
});
departments
.
forEach
((
d
:
any
)
=>
{
departments
.
forEach
((
d
)
=>
{
if
(
d
.
name
&&
d
.
name
.
includes
(
curVal
))
{
cacheMember
.
push
(
d
.
id
);
const
params
=
JSON
.
parse
(
JSON
.
stringify
(
d
));
...
...
src/views/pages/employ-management/address-book/employ-list.vue
View file @
67b186ec
...
...
@@ -90,14 +90,14 @@
align=
"center"
>
<
template
slot-scope=
"scope"
>
<
com
-button
<
mg
-button
@
click=
"handleClick(scope.row.peid)"
type=
"text"
size=
"small"
class=
"act-btn"
>
详情
</
com
-button>
</
mg
-button>
</
template
>
</el-table-column>
</el-table>
...
...
@@ -116,20 +116,24 @@
<
script
lang=
"ts"
>
import
{
departmentController
}
from
"@/views/service/department-controller"
;
import
{
OrgMemberItem2Map
}
from
"@/views/service/emp-tree"
;
import
{
Component
,
Vue
,
Prop
,
Watch
}
from
"vue-property-decorator"
;
@
Component
({
components
:
{}
})
export
default
class
EmployList
extends
Vue
{
@
Prop
({
default
:
{}
})
private
pdid2Members
!
:
{
[
key
:
string
]:
any
};
private
pdid2Members
!
:
{
[
key
:
string
]:
OrgMemberItem2Map
[]
};
@
Prop
({
default
:
""
})
private
curDepId
!
:
string
;
private
list
=
[];
@
Prop
({
default
:
false
})
private
init
!
:
boolean
;
private
list
:
OrgMemberItem2Map
[]
=
[];
private
totalCount
=
0
;
private
pageIndex
=
1
;
private
tableData
:
any
[]
=
[];
private
tableData
:
OrgMemberItem2Map
[]
=
[];
private
size
=
10
;
private
listTotal
=
0
;
...
...
@@ -141,8 +145,18 @@
@
Watch
(
"curDepId"
,
{
immediate
:
true
})
private
onCurDepIdChange
()
{
this
.
getPageList
(
1
);
this
.
getDeptName
(
this
.
curDepId
);
if
(
this
.
init
)
{
this
.
getPageList
(
1
);
this
.
getDeptName
(
this
.
curDepId
);
}
}
@
Watch
(
"init"
,
{
immediate
:
true
})
private
onInitChange
()
{
if
(
this
.
curDepId
)
{
this
.
getPageList
(
1
);
this
.
getDeptName
(
this
.
curDepId
);
}
}
private
getPageList
(
page
?:
number
)
{
...
...
@@ -155,9 +169,9 @@
}
private
getDeptName
(
depId
:
string
)
{
departmentController
.
getDepartments
().
then
((
r
:
any
)
=>
{
departmentController
.
getDepartments
().
then
((
r
)
=>
{
const
departments
=
r
.
departments
;
const
result
=
departments
.
find
((
i
:
any
)
=>
i
.
id
===
depId
);
const
result
=
departments
.
find
((
i
)
=>
i
.
id
===
depId
);
if
(
result
)
{
this
.
name
=
result
.
name
;
}
...
...
src/views/service/department-controller.ts
View file @
67b186ec
import
companyService
from
"@/api/company-service"
;
import
companyService
,
{
OldDepartmentItem
}
from
"@/api/company-service"
;
import
EnterpriseHost
from
"./enterprise-host"
;
/* eslint-disable */
export
interface
OldDepartment4Tree
{
id
:
string
;
name
:
string
;
name_pinyin
:
string
;
parentid
:
string
;
order
:
number
;
children
?:
OldDepartment4Tree
[],
}
/* eslint-enable */
export
interface
OldDepartmentsData
{
departments4tree
:
OldDepartment4Tree
[],
departments
:
OldDepartmentItem
[]
}
class
DepartmentController
{
private
curPoid
=
""
;
private
departments4tree
=
[];
private
departments
=
[]
private
departments4tree
:
OldDepartment4Tree
[]
=
[];
private
departments
:
OldDepartmentItem
[]
=
[]
public
getDepartments
(
reload
=
false
)
{
const
poid
=
EnterpriseHost
.
getPoid
();
...
...
@@ -16,9 +32,9 @@ class DepartmentController {
};
return
Promise
.
resolve
(
p
);
}
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
<
OldDepartmentsData
>
((
resolve
,
reject
)
=>
{
this
.
curPoid
=
poid
;
companyService
.
getDepartment
(
poid
).
then
((
res
:
any
)
=>
{
companyService
.
getDepartment
(
poid
).
then
((
res
)
=>
{
const
ary
=
res
.
departments
;
this
.
departments
=
res
.
departments
;
const
r
=
this
.
parseMarksTree
(
ary
);
...
...
@@ -36,9 +52,9 @@ class DepartmentController {
this
.
getDepartments
(
true
);
}
private
parseMarksTree
(
ary
:
any
[],
pid
=
'0'
):
any
{
private
parseMarksTree
(
ary
:
OldDepartmentItem
[],
pid
=
'0'
):
OldDepartment4Tree
[]
{
if
(
!
Array
.
isArray
(
ary
))
{
return
null
;
return
[]
;
}
const
marks
=
ary
.
filter
(
item
=>
item
.
parentid
===
pid
);
...
...
@@ -52,7 +68,7 @@ class DepartmentController {
parentid
:
item
.
parentid
,
order
:
item
.
order
,
children
:
children
};
}
as
OldDepartment4Tree
;
}
else
{
return
{
id
:
item
.
id
,
...
...
@@ -60,7 +76,7 @@ class DepartmentController {
name_pinyin
:
item
.
name_pinyin
,
order
:
item
.
order
,
parentid
:
item
.
parentid
,
};
}
as
OldDepartment4Tree
;
}
});
}
...
...
src/views/service/emp-tree.ts
View file @
67b186ec
import
{
sdkService
}
from
"@/api/sdk-service"
;
import
{
OrgDepartmentItem
,
OrgMemberItem
,
sdkService
}
from
"@/api/sdk-service"
;
import
Vue
from
"vue"
;
export
interface
OrgMemberItem2Map
extends
OrgMemberItem
{
empid
:
string
;
depNames
:
string
[];
depIds
:
string
[];
}
class
EmpTreeController
{
private
tree
:
any
[]
=
[];
private
pdid2Members
:
{
[
key
:
string
]:
any
}
=
{}
private
roleList
:
any
[]
=
[];
private
roleMap4PeidOrEid
:
{
[
key
:
string
]:
any
}
=
{}
private
tree
:
OrgDepartmentItem
[]
=
[];
private
pdid2Members
:
{
[
key
:
string
]:
OrgMemberItem2Map
[]
}
=
{}
private
roleList
:
OrgMemberItem2Map
[]
=
[];
private
roleMap4PeidOrEid
:
{
[
key
:
string
]:
OrgMemberItem2Map
}
=
{}
private
success
=
false
private
busy
=
false
;
private
action
:
any
[]
=
[];
...
...
@@ -22,7 +28,7 @@ class EmpTreeController {
});
this
.
busy
=
true
;
return
new
Promise
((
resolve
,
reject
)
=>
{
sdkService
.
getOrgTree
().
then
((
r
:
any
)
=>
{
sdkService
.
getOrgTree
().
then
((
r
)
=>
{
this
.
tree
=
r
;
this
.
success
=
true
;
this
.
handlerAction
();
...
...
@@ -57,10 +63,10 @@ class EmpTreeController {
this
.
action
=
[];
}
filterData2Use
(
tree
:
any
)
{
filterData2Use
(
tree
:
OrgDepartmentItem
[]
)
{
if
(
tree
)
{
this
.
pdid2Members
=
{};
this
.
buildPdid2Members
(
tree
[
0
]);
this
.
buildPdid2Members
(
tree
[
0
]
,
""
,
""
,
true
);
this
.
roleList
=
[];
Object
.
keys
(
this
.
pdid2Members
).
forEach
((
i
)
=>
{
this
.
roleList
=
this
.
roleList
.
concat
(
...
...
@@ -80,7 +86,7 @@ class EmpTreeController {
}
getRoleList
()
{
return
JSON
.
parse
(
JSON
.
stringify
(
this
.
roleList
));
return
JSON
.
parse
(
JSON
.
stringify
(
this
.
roleList
))
as
OrgMemberItem2Map
[]
;
}
getPdid2Members
()
{
...
...
@@ -91,18 +97,23 @@ class EmpTreeController {
return
this
.
roleMap4PeidOrEid
[
pidOrId
].
id
;
}
buildPdid2Members
(
tree
:
any
)
{
if
(
tree
&&
tree
.
pdid
)
{
this
.
pdid2Members
[
tree
.
pdid
]
=
this
.
pdid2Members
[
tree
.
pdid
]
||
[];
if
(
!
tree
.
children
.
length
)
{
buildPdid2Members
(
tree
:
OrgDepartmentItem
|
OrgMemberItem
,
depName
=
""
,
depId
=
""
,
root
=
false
)
{
const
pTree
:
OrgDepartmentItem
|
null
=
tree
as
OrgDepartmentItem
;
const
mTree
:
OrgMemberItem
|
null
=
tree
as
OrgMemberItem
;
if
(
pTree
&&
pTree
.
pdid
)
{
this
.
pdid2Members
[
pTree
.
pdid
]
=
this
.
pdid2Members
[
pTree
.
pdid
]
||
[];
const
chilren
=
pTree
.
children
;
if
(
!
chilren
||
!
chilren
.
length
)
{
return
{
_last
:
true
,
};
}
let
users
:
any
[]
=
[];
for
(
let
i
=
0
;
i
<
tree
.
children
.
length
;
i
++
)
{
const
user
=
this
.
buildPdid2Members
(
tree
.
children
[
i
]);
let
users
:
OrgMemberItem2Map
[]
=
[];
for
(
let
i
=
0
;
i
<
chilren
.
length
;
i
++
)
{
const
user
=
this
.
buildPdid2Members
(
chilren
[
i
],
root
?
""
:
pTree
.
name
,
root
?
""
:
pTree
.
pdid
);
if
(
user
.
_last
)
{
continue
;
}
...
...
@@ -115,20 +126,22 @@ class EmpTreeController {
}
users
.
push
(
user
);
}
this
.
pdid2Members
[
t
ree
.
pdid
]
=
this
.
quchong
(
this
.
pdid2Members
[
t
ree
.
pdid
].
concat
(
users
)
this
.
pdid2Members
[
pT
ree
.
pdid
]
=
this
.
quchong
(
this
.
pdid2Members
[
pT
ree
.
pdid
].
concat
(
users
)
);
return
{
_isPid
:
JSON
.
parse
(
JSON
.
stringify
(
this
.
pdid2Members
[
t
ree
.
pdid
])
JSON
.
stringify
(
this
.
pdid2Members
[
pT
ree
.
pdid
])
),
};
}
else
{
Object
.
assign
(
tree
,
{
empid
:
tree
.
peid
,
empid
:
mTree
.
peid
,
depNames
:
depName
?
[
depName
]
:
[],
depIds
:
depId
?
[
depId
]
:
[],
});
if
([
0
,
1
,
"0"
,
"1"
].
includes
(
t
ree
.
enable
))
{
if
([
0
,
1
,
"0"
,
"1"
].
includes
(
mT
ree
.
enable
))
{
return
JSON
.
parse
(
JSON
.
stringify
(
tree
));
}
return
{
...
...
@@ -137,10 +150,10 @@ class EmpTreeController {
}
}
quchong
(
arr
:
any
[])
{
quchong
(
arr
:
OrgMemberItem2Map
[])
{
const
result
=
[];
const
obj
:
{
[
key
:
string
]:
any
}
=
{};
const
objIndex
:
{
[
key
:
string
]:
any
}
=
{};
const
obj
:
{
[
key
:
string
]:
boolean
}
=
{};
const
objIndex
:
{
[
key
:
string
]:
number
}
=
{};
for
(
let
i
=
0
;
i
<
arr
.
length
;
i
++
)
{
if
(
!
obj
[
arr
[
i
].
id
])
{
result
.
push
(
arr
[
i
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment