From ae6d20ec4a30b7e796feb05958bcfc80e55f247b Mon Sep 17 00:00:00 2001 From: 田源 <lastanimals@163.com> Date: 星期四, 20 七月 2023 15:21:45 +0800 Subject: [PATCH] 整合代码部署 --- Source/UBCS-WEB/dist/src/page/index/top/top-search.vue | 131 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 131 insertions(+), 0 deletions(-) diff --git a/Source/UBCS-WEB/dist/src/page/index/top/top-search.vue b/Source/UBCS-WEB/dist/src/page/index/top/top-search.vue new file mode 100644 index 0000000..a8d2dfb --- /dev/null +++ b/Source/UBCS-WEB/dist/src/page/index/top/top-search.vue @@ -0,0 +1,131 @@ +<template> + <el-autocomplete class="top-search" + popper-class="my-autocomplete" + v-model="value" + :fetch-suggestions="querySearch" + :placeholder="$t('search')" + @select="handleSelect"> + + <template slot-scope="{ item }"> + <i :class="[item[iconKey],'icon']"></i> + <div class="name">{{ item[labelKey] }}</div> + <div class="addr">{{ item[pathKey] }}</div> + </template> + </el-autocomplete> +</template> + +<script> + import config from "../sidebar/config.js"; + import {mapGetters} from "vuex"; + + export default { + data() { + return { + config: config, + value: "", + menuList: [] + }; + }, + created() { + this.getMenuList(); + }, + + watch: { + menu() { + this.getMenuList(); + } + }, + computed: { + labelKey() { + return this.website.menu.props.label || this.config.propsDefault.label; + }, + pathKey() { + return this.website.menu.props.path || this.config.propsDefault.path; + }, + iconKey() { + return this.website.menu.props.icon || this.config.propsDefault.icon; + }, + childrenKey() { + return ( + this.website.menu.props.children || this.config.propsDefault.children + ); + }, + ...mapGetters(["menu", "website"]) + }, + methods: { + getMenuList() { + const findMenu = list => { + for (let i = 0; i < list.length; i++) { + const ele = Object.assign({}, list[i]); + if (this.validatenull(ele[this.childrenKey])) { + this.menuList.push(ele); + } else { + findMenu(ele[this.childrenKey]); + } + } + }; + this.menuList = []; + findMenu(this.menu); + }, + querySearch(queryString, cb) { + var restaurants = this.menuList; + var results = queryString + ? restaurants.filter(this.createFilter(queryString)) + : restaurants; + // 璋冪敤 callback 杩斿洖寤鸿鍒楄〃鐨勬暟鎹� + cb(results); + }, + createFilter(queryString) { + return restaurant => { + return ( + restaurant.name.toLowerCase().indexOf(queryString.toLowerCase()) === + 0 + ); + }; + }, + handleSelect(item) { + this.value = ""; + this.$router.push({ + path: this.$router.$avueRouter.getPath({ + name: item[this.labelKey], + src: item[this.pathKey] + }, item.meta), + query: item.query + }); + } + } + }; +</script> + +<style lang="scss"> + .my-autocomplete { + li { + line-height: normal; + padding: 7px; + + .icon { + margin-right: 5px; + display: inline-block; + vertical-align: middle; + } + + .name { + display: inline-block; + text-overflow: ellipsis; + overflow: hidden; + vertical-align: middle; + } + + .addr { + padding-top: 5px; + width: 100%; + font-size: 12px; + color: #b4b4b4; + } + + .highlighted .addr { + color: #ddd; + } + } + } +</style> -- Gitblit v1.9.3