Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
啊嘞嘞EC
vue-vben-admin
提交
60577d67
V
vue-vben-admin
项目概览
啊嘞嘞EC
/
vue-vben-admin
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vue-vben-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
60577d67
编写于
8月 11, 2021
作者:
无
无木
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(tree): add searchable function
添加搜索功能相关属性和方法 close: #1057
上级
953bfc6f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
51 addition
and
7 deletion
+51
-7
CHANGELOG.zh_CN.md
CHANGELOG.zh_CN.md
+4
-0
src/components/Tree/src/Tree.vue
src/components/Tree/src/Tree.vue
+22
-1
src/components/Tree/src/TreeHeader.vue
src/components/Tree/src/TreeHeader.vue
+22
-6
src/components/Tree/src/props.ts
src/components/Tree/src/props.ts
+1
-0
src/components/Tree/src/typing.ts
src/components/Tree/src/typing.ts
+2
-0
未找到文件。
CHANGELOG.zh_CN.md
浏览文件 @
60577d67
### ✨ Features
-
**BasicTree**
添加搜索功能相关属性和方法
### 🐛 Bug Fixes
-
**Cropper**
修复未能及时销毁的问题
...
...
src/components/Tree/src/Tree.vue
浏览文件 @
60577d67
...
...
@@ -42,7 +42,14 @@
name
:
'
BasicTree
'
,
inheritAttrs
:
false
,
props
:
basicProps
,
emits
:
[
'
update:expandedKeys
'
,
'
update:selectedKeys
'
,
'
update:value
'
,
'
change
'
,
'
check
'
],
emits
:
[
'
update:expandedKeys
'
,
'
update:selectedKeys
'
,
'
update:value
'
,
'
change
'
,
'
check
'
,
'
update:searchValue
'
,
],
setup
(
props
,
{
attrs
,
slots
,
emit
,
expose
})
{
const
state
=
reactive
<
State
>
({
checkStrictly
:
props
.
checkStrictly
,
...
...
@@ -192,7 +199,14 @@
state
.
checkStrictly
=
strictly
;
}
const
searchText
=
ref
(
''
);
watchEffect
(()
=>
{
if
(
props
.
searchValue
!==
searchText
.
value
)
searchText
.
value
=
props
.
searchValue
;
});
function
handleSearch
(
searchValue
:
string
)
{
if
(
searchValue
!==
searchText
.
value
)
searchText
.
value
=
searchValue
;
emit
(
'
update:searchValue
'
,
searchValue
);
if
(
!
searchValue
)
{
searchState
.
startSearch
=
false
;
return
;
...
...
@@ -293,6 +307,12 @@
filterByLevel
:
(
level
:
number
)
=>
{
state
.
expandedKeys
=
filterByLevel
(
level
);
},
setSearchValue
:
(
value
:
string
)
=>
{
handleSearch
(
value
);
},
getSearchValue
:
()
=>
{
return
searchText
.
value
;
},
};
expose
(
instance
);
...
...
@@ -380,6 +400,7 @@
helpMessage
=
{
helpMessage
}
onStrictlyChange
=
{
onStrictlyChange
}
onSearch
=
{
handleSearch
}
searchText
=
{
unref
(
searchText
)}
>
{
extendSlots
(
slots
)}
<
/TreeHeader
>
...
...
src/components/Tree/src/TreeHeader.vue
浏览文件 @
60577d67
...
...
@@ -11,7 +11,7 @@
:placeholder=
"t('common.searchText')"
size=
"small"
allowClear
@
change=
"handleSearch
"
v-model:value=
"searchValue
"
/>
</div>
<Dropdown
@
click.prevent
v-if=
"toolbar"
>
...
...
@@ -32,7 +32,7 @@
</template>
<
script
lang=
"ts"
>
import
type
{
PropType
}
from
'
vue
'
;
import
{
defineComponent
,
computed
}
from
'
vue
'
;
import
{
defineComponent
,
computed
,
ref
,
watch
}
from
'
vue
'
;
import
{
Dropdown
,
Menu
,
Input
}
from
'
ant-design-vue
'
;
import
{
Icon
}
from
'
/@/components/Icon
'
;
...
...
@@ -77,10 +77,12 @@
search
:
propTypes
.
bool
,
checkAll
:
propTypes
.
func
,
expandAll
:
propTypes
.
func
,
searchText
:
propTypes
.
string
,
},
emits
:
[
'
strictly-change
'
,
'
search
'
],
setup
(
props
,
{
emit
})
{
const
{
t
}
=
useI18n
();
const
searchValue
=
ref
(
''
);
const
toolbarList
=
computed
(()
=>
{
const
{
checkable
}
=
props
;
...
...
@@ -137,11 +139,25 @@
}
const
debounceEmitChange
=
useDebounceFn
(
emitChange
,
200
);
function
handleSearch
(
e
:
ChangeEvent
):
void
{
debounceEmitChange
(
e
.
target
.
value
);
}
watch
(
()
=>
searchValue
.
value
,
(
v
)
=>
{
debounceEmitChange
(
v
);
}
);
watch
(
()
=>
props
.
searchText
,
(
v
)
=>
{
if
(
v
!==
searchValue
.
value
)
{
searchValue
.
value
=
v
;
}
}
);
// function handleSearch(e: ChangeEvent): void {
// debounceEmitChange(e.target.value);
// }
return
{
t
,
toolbarList
,
handleMenuClick
,
handleSearch
};
return
{
t
,
toolbarList
,
handleMenuClick
,
searchValue
};
},
});
</
script
>
...
...
src/components/Tree/src/props.ts
浏览文件 @
60577d67
...
...
@@ -20,6 +20,7 @@ export const basicProps = {
title
:
propTypes
.
string
,
toolbar
:
propTypes
.
bool
,
search
:
propTypes
.
bool
,
searchValue
:
propTypes
.
string
,
checkStrictly
:
propTypes
.
bool
,
clickRowToExpand
:
propTypes
.
bool
.
def
(
true
),
checkable
:
propTypes
.
bool
.
def
(
false
),
...
...
src/components/Tree/src/typing.ts
浏览文件 @
60577d67
...
...
@@ -34,6 +34,8 @@ export interface TreeActionType {
insertNodesByKey
:
(
opt
:
InsertNodeParams
)
=>
void
;
deleteNodeByKey
:
(
key
:
string
)
=>
void
;
updateNodeByKey
:
(
key
:
string
,
node
:
Omit
<
TreeDataItem
,
'
key
'
>
)
=>
void
;
setSearchValue
:
(
value
:
string
)
=>
void
;
getSearchValue
:
()
=>
string
;
}
export
interface
InsertNodeParams
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录