Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gantt-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭铭瑶
gantt-project
Commits
586ad073
Commit
586ad073
authored
Nov 06, 2019
by
郭铭瑶
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加搜索功能
parent
8faefbf3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
10 deletions
+43
-10
gantt-chart.vue
src/components/GanttChart/gantt-chart.vue
+18
-0
gantt-config.js
src/components/GanttChart/gantt-config.js
+1
-0
main.vue
src/components/main.vue
+24
-10
No files found.
src/components/GanttChart/gantt-chart.vue
View file @
586ad073
...
@@ -34,6 +34,7 @@ export default {
...
@@ -34,6 +34,7 @@ export default {
left
:
config
.
grid_width
,
left
:
config
.
grid_width
,
curTask
:
{},
curTask
:
{},
columns
:
config
.
columns
,
columns
:
config
.
columns
,
event
:
null
,
}
}
},
},
mounted
()
{
mounted
()
{
...
@@ -81,6 +82,23 @@ export default {
...
@@ -81,6 +82,23 @@ export default {
return
true
return
true
})
})
},
},
search
(
val
=
null
)
{
// 搜索
if
(
this
.
event
)
{
// 移除原先的事件,否则搜索事件会一直叠加
gantt
.
detachEvent
(
this
.
event
)
}
gantt
.
eachTask
(
function
(
task
){
task
.
$open
=
true
})
this
.
event
=
gantt
.
attachEvent
(
'onBeforeTaskDisplay'
,
(
id
,
task
)
=>
{
if
(
!
val
)
return
true
const
taskText
=
task
.
text
.
toLowerCase
()
const
taskPerson
=
task
.
name
.
toLowerCase
()
const
searchText
=
val
.
toLowerCase
()
return
(
taskText
.
indexOf
(
searchText
)
>
-
1
||
taskPerson
.
indexOf
(
searchText
)
>
-
1
)
})
gantt
.
render
()
},
reset
(
config
=
{}){
reset
(
config
=
{}){
if
(
gantt
.
$container
)
{
if
(
gantt
.
$container
)
{
gantt
.
clearAll
()
gantt
.
clearAll
()
...
...
src/components/GanttChart/gantt-config.js
View file @
586ad073
...
@@ -15,6 +15,7 @@ export const config = {
...
@@ -15,6 +15,7 @@ export const config = {
drag_links
:
false
,
drag_links
:
false
,
order_branch
:
true
,
// 拖拽任务
order_branch
:
true
,
// 拖拽任务
order_branch_free
:
true
,
// 拖拽任务
order_branch_free
:
true
,
// 拖拽任务
open_tree_initially
:
true
,
// 初始默认展开所有树
}
}
export
const
template
=
{
export
const
template
=
{
...
...
src/components/main.vue
View file @
586ad073
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
<a-tabs
class=
"chart-tab"
defaultActiveKey=
"1"
@
change=
"getData"
>
<a-tabs
class=
"chart-tab"
defaultActiveKey=
"1"
@
change=
"getData"
>
<a-tab-pane
tab=
"基于任务"
key=
"1"
/>
<a-tab-pane
tab=
"基于任务"
key=
"1"
/>
<a-tab-pane
tab=
"基于人员"
key=
"2"
/>
<a-tab-pane
tab=
"基于人员"
key=
"2"
/>
<a-dropdown
class=
"user"
slot=
"tabBarExtraContent"
>
<div
slot=
"tabBarExtraContent"
>
<a-input-search
class=
"search-input"
@
search=
"handleSearch"
:allowClear=
"true"
size=
"small"
placeholder=
"搜索任务名、人名"
/>
<a-dropdown
class=
"user"
>
<span>
<span>
<a-icon
type=
"user"
/>
<span
class=
"name"
>
{{
info
.
username
||
'用户名'
}}
</span>
<a-icon
type=
"user"
/>
<span
class=
"name"
>
{{
info
.
username
||
'用户名'
}}
</span>
<a-icon
type=
"down"
/>
<a-icon
type=
"down"
/>
...
@@ -13,6 +15,7 @@
...
@@ -13,6 +15,7 @@
<a-menu-item
key=
"logout"
>
退出登录
</a-menu-item>
<a-menu-item
key=
"logout"
>
退出登录
</a-menu-item>
</a-menu>
</a-menu>
</a-dropdown>
</a-dropdown>
</div>
</a-tabs>
</a-tabs>
<div
class=
"container"
>
<div
class=
"container"
>
<GanttChart
@
progressChange=
"handleProgressChange"
@
taskChange=
"handleTaskChange"
ref=
"gantt"
:tasks=
"tasks"
/>
<GanttChart
@
progressChange=
"handleProgressChange"
@
taskChange=
"handleTaskChange"
ref=
"gantt"
:tasks=
"tasks"
/>
...
@@ -113,7 +116,7 @@ export default {
...
@@ -113,7 +116,7 @@ export default {
const
data
=
this
.
$com
.
confirm
(
res
[
0
],
'data.content'
,
[])
const
data
=
this
.
$com
.
confirm
(
res
[
0
],
'data.content'
,
[])
const
baseData
=
this
.
$com
.
confirm
(
res
[
1
],
'data.content.content1'
,
[])
const
baseData
=
this
.
$com
.
confirm
(
res
[
1
],
'data.content.content1'
,
[])
this
.
tasks
.
data
=
data
.
map
(
item
=>
{
this
.
tasks
.
data
=
data
.
map
(
item
=>
{
const
plan
=
baseData
.
find
(
base
=>
base
.
id
===
item
.
id
)
const
plan
=
baseData
.
find
(
base
=>
base
.
tid
===
item
.
t
id
)
const
result
=
{
const
result
=
{
id
:
item
.
tid
,
id
:
item
.
tid
,
dataId
:
item
.
id
,
dataId
:
item
.
id
,
...
@@ -147,6 +150,9 @@ export default {
...
@@ -147,6 +150,9 @@ export default {
handleTaskChange
({
task
,
parentTask
})
{
handleTaskChange
({
task
,
parentTask
})
{
console
.
log
(
task
,
parentTask
)
console
.
log
(
task
,
parentTask
)
},
},
handleSearch
(
val
)
{
this
.
$refs
.
gantt
.
search
(
val
)
},
handleClick
({
key
})
{
handleClick
({
key
})
{
switch
(
key
)
{
switch
(
key
)
{
case
'logout'
:
case
'logout'
:
...
@@ -186,4 +192,12 @@ export default {
...
@@ -186,4 +192,12 @@ export default {
.user
{
.user
{
cursor
:
pointer
;
cursor
:
pointer
;
}
}
.search-input
{
width
:
150px
;
margin-right
:
50px
;
transition
:
all
0.5s
;
}
.search-input
:hover
{
width
:
200px
;
}
</
style
>
</
style
>
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