mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-31 09:12:10 +08:00
Merge branch 'master' into dev
This commit is contained in:
commit
aab44b42d2
@ -1,30 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="layout-search-dialog">
|
<div class="layout-search-dialog">
|
||||||
<el-dialog v-model="state.isShowSearch" destroy-on-close :show-close="false">
|
<el-dialog v-model="state.isShowSearch" destroy-on-close :show-close="false">
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-autocomplete
|
<el-autocomplete
|
||||||
v-model="state.menuQuery"
|
v-model="state.menuQuery"
|
||||||
:fetch-suggestions="menuSearch"
|
:fetch-suggestions="menuSearch"
|
||||||
:placeholder="$t('user.searchPlaceholder')"
|
:placeholder="$t('user.searchPlaceholder')"
|
||||||
ref="layoutMenuAutocompleteRef"
|
ref="layoutMenuAutocompleteRef"
|
||||||
@select="onHandleSelect"
|
@select="onHandleSelect"
|
||||||
:fit-input-width="true"
|
:fit-input-width="true"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon class="el-input__icon">
|
<el-icon class="el-input__icon">
|
||||||
<ele-Search />
|
<ele-Search />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</template>
|
</template>
|
||||||
<template #default="{ item }">
|
<template #default="{ item }">
|
||||||
<div>
|
<div>
|
||||||
<SvgIcon :name="item.meta.icon" class="mr5" />
|
<SvgIcon :name="item.meta.icon" class="mr5" />
|
||||||
{{ $t(item.name) }}
|
{{ $t(item.name) }}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-autocomplete>
|
</el-autocomplete>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts" name="layoutBreadcrumbSearch">
|
<script setup lang="ts" name="layoutBreadcrumbSearch">
|
||||||
@ -38,80 +38,81 @@ const layoutMenuAutocompleteRef = ref();
|
|||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const state = reactive<SearchState>({
|
const state = reactive<SearchState>({
|
||||||
isShowSearch: false,
|
isShowSearch: false,
|
||||||
menuQuery: '',
|
menuQuery: '',
|
||||||
tagsViewList: [],
|
tagsViewList: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
// 搜索弹窗打开
|
// 搜索弹窗打开
|
||||||
const openSearch = () => {
|
const openSearch = () => {
|
||||||
state.menuQuery = '';
|
state.menuQuery = '';
|
||||||
state.isShowSearch = true;
|
state.isShowSearch = true;
|
||||||
initTageView();
|
initTageView();
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
layoutMenuAutocompleteRef.value.focus();
|
layoutMenuAutocompleteRef.value.focus();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 搜索弹窗关闭
|
// 搜索弹窗关闭
|
||||||
const closeSearch = () => {
|
const closeSearch = () => {
|
||||||
state.isShowSearch = false;
|
state.isShowSearch = false;
|
||||||
};
|
};
|
||||||
// 菜单搜索数据过滤
|
// 菜单搜索数据过滤
|
||||||
const menuSearch = (queryString: string, cb: Function) => {
|
const menuSearch = (queryString: string, cb: Function) => {
|
||||||
let results = queryString ? state.tagsViewList.filter(createFilter(queryString)) : state.tagsViewList;
|
let results = queryString ? state.tagsViewList.filter(createFilter(queryString)) : state.tagsViewList;
|
||||||
cb(results);
|
cb(results);
|
||||||
};
|
};
|
||||||
// 菜单搜索过滤
|
// 菜单搜索过滤
|
||||||
const createFilter = (queryString: string) => {
|
const createFilter = (queryString: string) => {
|
||||||
return (restaurant: RouteItem) => {
|
return (restaurant: RouteItem) => {
|
||||||
return restaurant.path.toLowerCase().indexOf(queryString.toLowerCase()) > -1 || t(restaurant!.name!).indexOf(queryString.toLowerCase()) > -1;
|
return restaurant.path.toLowerCase().indexOf(queryString.toLowerCase()) > -1 || t(restaurant!.name!).indexOf(queryString.toLowerCase()) > -1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
// 初始化菜单数据
|
// 初始化菜单数据
|
||||||
const initTageView = () => {
|
const initTageView = () => {
|
||||||
if (state.tagsViewList.length > 0) return false;
|
if (state.tagsViewList.length > 0) return false;
|
||||||
tagsViewRoutes.value.map((v: RouteItem) => {
|
tagsViewRoutes.value.map((v: RouteItem) => {
|
||||||
if (!v.meta?.isHide) state.tagsViewList.push({ ...v });
|
if (!v.meta?.isHide) state.tagsViewList.push({ ...v });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// 当前菜单选中时
|
// 当前菜单选中时
|
||||||
const onHandleSelect = (item: RouteItem) => {
|
const onHandleSelect = (item: RouteItem) => {
|
||||||
let { path, redirect } = item;
|
let { path, redirect } = item;
|
||||||
if (item.meta?.isLink && !item.meta?.isIframe) window.open(item.meta?.isLink);
|
if (item.meta?.isLink && !item.meta?.isIframe) window.open(item.meta?.isLink);
|
||||||
else if (redirect) router.push(redirect);
|
else if (redirect) router.push(redirect);
|
||||||
else router.push(path);
|
else router.push(path);
|
||||||
closeSearch();
|
closeSearch();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 暴露变量
|
// 暴露变量
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openSearch,
|
openSearch,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.layout-search-dialog {
|
.layout-search-dialog {
|
||||||
position: relative;
|
position: relative;
|
||||||
:deep(.el-dialog) {
|
:deep(.el-dialog) {
|
||||||
.el-dialog__header,
|
width: 560px;
|
||||||
.el-dialog__body {
|
.el-dialog__header,
|
||||||
display: none;
|
.el-dialog__body {
|
||||||
}
|
display: none;
|
||||||
.el-dialog__footer {
|
}
|
||||||
position: absolute;
|
.el-dialog__footer {
|
||||||
left: 50%;
|
position: absolute;
|
||||||
transform: translateX(-50%);
|
left: 50%;
|
||||||
top: -53vh;
|
transform: translateX(-50%);
|
||||||
}
|
top: -53vh;
|
||||||
}
|
}
|
||||||
:deep(.el-autocomplete) {
|
}
|
||||||
width: 560px;
|
:deep(.el-autocomplete) {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 150px;
|
width: 560px;
|
||||||
left: 50%;
|
top: 53vh;
|
||||||
transform: translateX(-50%);
|
left: 50%;
|
||||||
}
|
transform: translateX(-50%);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ts-nocheck
|
||||||
/**
|
/**
|
||||||
* 判断是否为空
|
* 判断是否为空
|
||||||
* @param val 数据
|
* @param val 数据
|
||||||
|
Loading…
Reference in New Issue
Block a user