Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_43301624
Component
提交
7ceaf26e
C
Component
项目概览
weixin_43301624
/
Component
与 Fork 源项目一致
Fork自
inscode / VueJS
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Component
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
You need to sign in or sign up before continuing.
提交
7ceaf26e
编写于
11月 16, 2023
作者:
水
水晶土豆
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Thu Nov 16 13:11:00 CST 2023 inscode
上级
2d270d6b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
127 addition
and
72 deletion
+127
-72
src/App.vue
src/App.vue
+2
-0
src/api/api.ts
src/api/api.ts
+5
-1
src/api/path.ts
src/api/path.ts
+3
-1
src/component/humanResources/department.vue
src/component/humanResources/department.vue
+22
-37
src/util/deepCode.js
src/util/deepCode.js
+62
-0
src/util/toTree.js
src/util/toTree.js
+33
-33
未找到文件。
src/App.vue
浏览文件 @
7ceaf26e
...
@@ -3,12 +3,14 @@ import contractList from './component/contractManagement/contractList/contractLi
...
@@ -3,12 +3,14 @@ import contractList from './component/contractManagement/contractList/contractLi
import
contractCategory
from
'
./component/contractManagement/contractCategory/contractCategory.vue
'
import
contractCategory
from
'
./component/contractManagement/contractCategory/contractCategory.vue
'
import
register
from
'
./component/userLogin/login-dialog-button.vue
'
import
register
from
'
./component/userLogin/login-dialog-button.vue
'
import
announcementType
from
'
./component/enterpriseAnnouncement/announcementType.vue
'
;
import
announcementType
from
'
./component/enterpriseAnnouncement/announcementType.vue
'
;
import
departments
from
'
./component/humanResources/department.vue
'
</
script
>
</
script
>
<
template
>
<
template
>
<!--
<contractCategory></contractCategory>
<!--
<contractCategory></contractCategory>
<contract-list></contract-list>
-->
<contract-list></contract-list>
-->
<announcementType></announcementType>
<announcementType></announcementType>
<departments></departments>
<el-row>
<el-row>
<el-col>
后台管理平台
</el-col>
<el-col>
后台管理平台
</el-col>
</el-row>
</el-row>
...
...
src/api/api.ts
浏览文件 @
7ceaf26e
import
request
from
"
./index
"
;
import
request
from
"
./index
"
;
import
type
{
IParams
}
from
'
./index
'
;
import
type
{
IParams
}
from
'
./index
'
;
import
{
CONTRACT_CATEGORY
,
CONTRACT_LIST
,
CONTRACT_LIST_Type
,
DEPT_MENU
,
LOGIN
,
TABLE_ANNOUNCEMENT
}
from
"
./path
"
;
import
{
CONTRACT_CATEGORY
,
CONTRACT_LIST
,
CONTRACT_LIST_Type
,
DEPT_MENU
,
HUMAN_RESOURCES_DEPARTMENT
,
LOGIN
,
TABLE_ANNOUNCEMENT
}
from
"
./path
"
;
import
type
{
AxiosResponse
}
from
"
axios
"
;
import
type
{
AxiosResponse
}
from
"
axios
"
;
...
@@ -45,4 +45,8 @@ export function getContractList(body: IParams): Promise<AxiosResponse<IContractC
...
@@ -45,4 +45,8 @@ export function getContractList(body: IParams): Promise<AxiosResponse<IContractC
export
function
getContractListType
():
Promise
<
AxiosResponse
<
any
>>
{
export
function
getContractListType
():
Promise
<
AxiosResponse
<
any
>>
{
return
request
.
get
(
CONTRACT_LIST_Type
,
{});
return
request
.
get
(
CONTRACT_LIST_Type
,
{});
}
export
function
getHumanResourcesDepartment
():
Promise
<
AxiosResponse
<
any
>>
{
return
request
.
get
(
HUMAN_RESOURCES_DEPARTMENT
,
{});
}
}
\ No newline at end of file
src/api/path.ts
浏览文件 @
7ceaf26e
...
@@ -9,4 +9,6 @@ export const TABLE_ANNOUNCEMENT = baseURL + "/table/announcement";
...
@@ -9,4 +9,6 @@ export const TABLE_ANNOUNCEMENT = baseURL + "/table/announcement";
export
const
CONTRACT_CATEGORY
=
baseURL
+
"
/contract/category
"
;
export
const
CONTRACT_CATEGORY
=
baseURL
+
"
/contract/category
"
;
export
const
CONTRACT_LIST
=
baseURL
+
"
/contract/list
"
;
export
const
CONTRACT_LIST
=
baseURL
+
"
/contract/list
"
;
export
const
CONTRACT_LIST_Type
=
CONTRACT_LIST
+
'
/Type
'
;
export
const
CONTRACT_LIST_Type
=
CONTRACT_LIST
+
'
/Type
'
;
\ No newline at end of file
export
const
HUMAN_RESOURCES_DEPARTMENT
=
baseURL
+
'
/humanResources/department
'
;
\ No newline at end of file
src/component/humanResources/department.vue
浏览文件 @
7ceaf26e
...
@@ -5,41 +5,19 @@ import addDownload from '@/component/main/header/add_download/addDownload.vue';
...
@@ -5,41 +5,19 @@ import addDownload from '@/component/main/header/add_download/addDownload.vue';
import
buttoner
from
'
@/component/main/header/add_download/button.vue
'
;
import
buttoner
from
'
@/component/main/header/add_download/button.vue
'
;
import
downloadItem
from
'
@/component/main/header/add_download/downloadItem.vue
'
;
import
downloadItem
from
'
@/component/main/header/add_download/downloadItem.vue
'
;
import
ejectDialog
from
'
@/component/main/ejectDialog.vue
'
;
import
ejectDialog
from
'
@/component/main/ejectDialog.vue
'
;
import
{
ref
,
provide
}
from
'
vue
'
;
import
{
ref
,
provide
,
onMounted
}
from
'
vue
'
;
import
{
getHumanResourcesDepartment
}
from
'
@/api/api
'
;
import
{
FlatToTree
}
from
'
@/util/toTree
'
;
import
{
deepClone
}
from
'
@/util/deepCode
'
;
const
addText
=
ref
(
'
添加分类
'
);
const
addText
=
ref
(
'
添加分类
'
);
let
tableData
=
ref
([
let
tableData
=
ref
([
{
id
:
1
,
sort
:
1
,
typeName
:
"
普通公告
"
,
parent
:
0
,
state
:
true
,
},
{
id
:
2
,
sort
:
2
,
typeName
:
"
紧急公告
"
,
parent
:
0
,
state
:
true
,
children
:
[
{
id
:
6
,
sort
:
0
,
typeName
:
"
紧急公告
"
,
state
:
true
,
parent
:
2
,
}
]
},
{
id
:
3
,
sort
:
3
,
typeName
:
"
防疫公告
"
,
state
:
true
,
parent
:
0
,
},
])
])
onMounted
(
async
()
=>
{
let
data
=
(
await
getHumanResourcesDepartment
()).
data
.
data
.
data
;
console
.
log
(
FlatToTree
(
data
));
tableData
.
value
=
FlatToTree
(
data
).
tree
;
})
let
tableType
=
ref
([
let
tableType
=
ref
([
{
{
...
@@ -57,22 +35,29 @@ let tableType = ref([
...
@@ -57,22 +35,29 @@ let tableType = ref([
align
:
"
center
"
align
:
"
center
"
},
},
{
{
name
:
'
分类名称
'
,
name
:
'
上级ID
'
,
type
:
"
typeName
"
,
type
:
"
parentID
"
,
width
:
"
auto
"
,
width
:
"
auto
"
,
isSort
:
false
,
isSort
:
false
,
align
:
"
left
"
align
:
"
left
"
},
},
{
{
name
:
'
父级id
'
,
name
:
'
部门名称
'
,
type
:
"
parent
"
,
type
:
"
departmentName
"
,
width
:
"
80px
"
,
width
:
"
80px
"
,
isSort
:
false
,
isSort
:
false
,
align
:
"
center
"
align
:
"
center
"
},
},
{
{
name
:
'
状态
'
,
name
:
'
部门负责人
'
,
type
:
"
state
"
,
type
:
"
departmentHead
"
,
width
:
"
100px
"
,
isSort
:
false
,
align
:
"
center
"
},
{
name
:
'
部门电话
'
,
type
:
"
departmentPhone
"
,
width
:
"
100px
"
,
width
:
"
100px
"
,
isSort
:
false
,
isSort
:
false
,
align
:
"
center
"
align
:
"
center
"
...
...
src/util/deepCode.js
0 → 100644
浏览文件 @
7ceaf26e
export
function
deepClone
(
target
)
{
const
map
=
new
WeakMap
()
function
isObject
(
target
)
{
return
(
typeof
target
===
'
object
'
&&
target
)
||
typeof
target
===
'
function
'
}
function
clone
(
data
)
{
if
(
!
isObject
(
data
))
{
return
data
}
if
([
Date
,
RegExp
].
includes
(
data
.
constructor
))
{
return
new
data
.
constructor
(
data
)
}
if
(
typeof
data
===
'
function
'
)
{
return
new
Function
(
'
return
'
+
data
.
toString
())()
}
const
exist
=
map
.
get
(
data
)
if
(
exist
)
{
return
exist
}
if
(
data
instanceof
Map
)
{
const
result
=
new
Map
()
map
.
set
(
data
,
result
)
data
.
forEach
((
val
,
key
)
=>
{
if
(
isObject
(
val
))
{
result
.
set
(
key
,
clone
(
val
))
}
else
{
result
.
set
(
key
,
val
)
}
})
return
result
}
if
(
data
instanceof
Set
)
{
const
result
=
new
Set
()
map
.
set
(
data
,
result
)
data
.
forEach
(
val
=>
{
if
(
isObject
(
val
))
{
result
.
add
(
clone
(
val
))
}
else
{
result
.
add
(
val
)
}
})
return
result
}
const
keys
=
Reflect
.
ownKeys
(
data
)
const
allDesc
=
Object
.
getOwnPropertyDescriptors
(
data
)
const
result
=
Object
.
create
(
Object
.
getPrototypeOf
(
data
),
allDesc
)
map
.
set
(
data
,
result
)
keys
.
forEach
(
key
=>
{
const
val
=
data
[
key
]
if
(
isObject
(
val
))
{
result
[
key
]
=
clone
(
val
)
}
else
{
result
[
key
]
=
val
}
})
return
result
}
return
clone
(
target
)
}
src/util/toTree.js
浏览文件 @
7ceaf26e
const
treeData
=
[
//
const treeData = [
{
//
{
id
:
1
,
//
id: 1,
title
:
"
课程1
"
,
//
title: "课程1",
children
:
[
//
children: [
{
id
:
4
,
title
:
"
课程1-1
"
},
//
{ id: 4, title: "课程1-1" },
{
//
{
id
:
5
,
//
id: 5,
title
:
"
课程1-2
"
,
//
title: "课程1-2",
children
:
[
//
children: [
{
id
:
6
,
title
:
"
课程1-2-1
"
},
//
{ id: 6, title: "课程1-2-1" },
{
id
:
7
,
title
:
"
课程1-2-2
"
},
//
{ id: 7, title: "课程1-2-2" },
],
//
],
},
//
},
],
//
],
},
//
},
{
id
:
2
,
title
:
"
课程2
"
},
//
{ id: 2, title: "课程2" },
{
id
:
3
,
title
:
"
课程3
"
},
//
{ id: 3, title: "课程3" },
];
//
];
const
flatData
=
[
const
flatData
=
[
{
id
:
1
,
parent
:
0
,
title
:
"
课程1
"
},
{
id
:
1
,
parent
ID
:
0
,
title
:
"
课程1
"
},
{
id
:
4
,
parent
:
1
,
title
:
"
课程1-1
"
},
{
id
:
4
,
parent
ID
:
1
,
title
:
"
课程1-1
"
},
{
id
:
5
,
parent
:
1
,
title
:
"
课程1-2
"
},
{
id
:
5
,
parent
ID
:
1
,
title
:
"
课程1-2
"
},
{
id
:
6
,
parent
:
5
,
title
:
"
课程1-2-1
"
},
{
id
:
6
,
parent
ID
:
5
,
title
:
"
课程1-2-1
"
},
{
id
:
7
,
parent
:
5
,
title
:
"
课程1-2-2
"
},
{
id
:
7
,
parent
ID
:
5
,
title
:
"
课程1-2-2
"
},
{
id
:
2
,
parent
:
0
,
title
:
"
课程2
"
},
{
id
:
2
,
parent
ID
:
0
,
title
:
"
课程2
"
},
{
id
:
3
,
parent
:
0
,
title
:
"
课程3
"
},
{
id
:
3
,
parent
ID
:
0
,
title
:
"
课程3
"
},
]
]
export
function
TreeToFlat
(
data
)
{
export
function
TreeToFlat
(
data
)
{
...
@@ -42,20 +42,20 @@ export function TreeToFlat(data) {
...
@@ -42,20 +42,20 @@ export function TreeToFlat(data) {
}
}
// console.log(TreeToFlat(treeData), '输出为扁平化结构')
// console.log(TreeToFlat(treeData), '输出为扁平化结构')
function
FlatToTree
(
arr
)
{
export
function
FlatToTree
(
arr
)
{
const
map
=
arr
.
reduce
((
acc
,
val
)
=>
{
const
map
=
arr
.
reduce
((
acc
,
val
)
=>
{
acc
[
val
.
id
]
=
val
acc
[
Number
(
val
.
id
)
]
=
val
return
acc
return
acc
},
{})
},
{})
const
tree
=
[]
const
tree
=
[]
arr
.
forEach
(
region
=>
{
arr
.
forEach
(
region
=>
{
if
(
region
.
parent
)
{
if
(
Number
(
region
.
parentID
)
)
{
const
parent
=
map
[
region
.
parent
]
const
parent
ID
=
map
[
Number
(
region
.
parentID
)];
if
(
!
parent
.
children
)
{
if
(
!
parent
ID
?
.
children
)
{
parent
.
children
=
[
region
]
parent
ID
.
children
=
[
region
]
}
}
else
{
else
{
parent
.
children
.
push
(
region
)
parent
ID
.
children
.
push
(
region
)
}
}
}
}
else
{
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录