Commit b384f59b authored by wuyongsheng's avatar wuyongsheng

feat: 添加回车搜索

parent 11d05219
......@@ -144,7 +144,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
};
// 获取模板列表
const getAddTemplateListFun = useCallback(() => {
const getAddTemplateListFun = useCallback((newTitle?: string) => {
const userName = JSON.parse(localStorage.getItem("userInfo") || "{}")?.name;
setSelectTemplateData([]);
setAddTemplateList([]);
......@@ -153,14 +153,14 @@ const AddTemplate = (props: IAddTemplateProps) => {
projectId: projectId as string,
productId: productId as string,
creator: "root",
keyword: title,
keyword: newTitle,
});
} else {
getAddTemplateList({
projectId: projectId as string,
productId: productId as string,
creator: userName,
keyword: title,
keyword: newTitle,
});
}
}, [
......@@ -169,7 +169,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
productId,
projectId,
templateType,
title,
// title,
]);
//模板启用切换
......@@ -193,6 +193,13 @@ const AddTemplate = (props: IAddTemplateProps) => {
getAddTemplateListFun();
}, [getAddTemplateListFun]);
// 按回车搜索
const handleKeyWordChangeKeyUp = (e: any) => {
if (e.keyCode === 13) {
getAddTemplateListFun(e.target.value);
}
};
const hiddenBoxArr = useMemo(() => {
const length =
templateType === "public"
......@@ -231,6 +238,7 @@ const AddTemplate = (props: IAddTemplateProps) => {
onChange={(e: any) => {
setTitle(e.target.value);
}}
onKeyUp={handleKeyWordChangeKeyUp}
placeholder="输入关键词搜索"
size="small"
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