Commit b384f59b authored by wuyongsheng's avatar wuyongsheng

feat: 添加回车搜索

parent 11d05219
...@@ -144,7 +144,7 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -144,7 +144,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
}; };
// 获取模板列表 // 获取模板列表
const getAddTemplateListFun = useCallback(() => { const getAddTemplateListFun = useCallback((newTitle?: string) => {
const userName = JSON.parse(localStorage.getItem("userInfo") || "{}")?.name; const userName = JSON.parse(localStorage.getItem("userInfo") || "{}")?.name;
setSelectTemplateData([]); setSelectTemplateData([]);
setAddTemplateList([]); setAddTemplateList([]);
...@@ -153,14 +153,14 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -153,14 +153,14 @@ const AddTemplate = (props: IAddTemplateProps) => {
projectId: projectId as string, projectId: projectId as string,
productId: productId as string, productId: productId as string,
creator: "root", creator: "root",
keyword: title, keyword: newTitle,
}); });
} else { } else {
getAddTemplateList({ getAddTemplateList({
projectId: projectId as string, projectId: projectId as string,
productId: productId as string, productId: productId as string,
creator: userName, creator: userName,
keyword: title, keyword: newTitle,
}); });
} }
}, [ }, [
...@@ -169,7 +169,7 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -169,7 +169,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
productId, productId,
projectId, projectId,
templateType, templateType,
title, // title,
]); ]);
//模板启用切换 //模板启用切换
...@@ -193,6 +193,13 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -193,6 +193,13 @@ const AddTemplate = (props: IAddTemplateProps) => {
getAddTemplateListFun(); getAddTemplateListFun();
}, [getAddTemplateListFun]); }, [getAddTemplateListFun]);
// 按回车搜索
const handleKeyWordChangeKeyUp = (e: any) => {
if (e.keyCode === 13) {
getAddTemplateListFun(e.target.value);
}
};
const hiddenBoxArr = useMemo(() => { const hiddenBoxArr = useMemo(() => {
const length = const length =
templateType === "public" templateType === "public"
...@@ -231,6 +238,7 @@ const AddTemplate = (props: IAddTemplateProps) => { ...@@ -231,6 +238,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
onChange={(e: any) => { onChange={(e: any) => {
setTitle(e.target.value); setTitle(e.target.value);
}} }}
onKeyUp={handleKeyWordChangeKeyUp}
placeholder="输入关键词搜索" placeholder="输入关键词搜索"
size="small" size="small"
sx={{ width: 340, height: 32 }} sx={{ width: 340, height: 32 }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment