123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <template>
- <div class="web-home">
- <div class="title">
- <img src="@/assets/images/web/web-home_title.png"/>
- </div>
- <div class="area">
- <div class="selected">
- <div class="label">搜索范围:</div>
- <div class="value" v-if="!noAreaCpt">
- <template v-if="searchAreaCpt.text">
- {{searchAreaCpt.text}}
- </template>
- <template v-else>
- <template v-for="item in searchAreaCpt.arr">
- <div>{{item.treeName}}</div>
- </template>
- </template>
- </div>
- </div>
- <div class="search-input">
- <template v-if="!noAreaCpt">
- <div class="left-select __hover" @click="state.showArea = true">
- 搜索范围<SvgIcon name="arrow_1" rotate="90" size="14" color="var(--cus-text-color-3)"/>
- </div>
- </template>
- <template v-else>
- <div class="left-select __disabled">
- 暂无范围
- </div>
- </template>
- <el-input v-model="state.searchText" :placeholder="!noAreaCpt ? '请输入关键字进行查询' : '请先配置搜索范围'" @keyup.enter="toList(state.searchText)" :disabled="noAreaCpt"/>
- <div class="right-icon __hover" @click="toList(state.searchText)">
- <SvgIcon name="search_1" color="var(--cus-main-color)" size="40"/>
- </div>
- </div>
- </div>
- <div class="history" v-if="state.historyList?.length > 0">
- <div class="label">搜索记录</div>
- <div class="result">
- <template v-for="(item, index) in state.historyList">
- <span class="__hover" @click="toList(item, true)">{{index + 1}}.{{item}}</span>
- </template>
- </div>
- </div>
- <CusDialog
- :show="state.showArea"
- @onClose="$emit('update:show', false)"
- width="1000px"
- height="auto"
- submit-text="关闭"
- :show-close="false"
- @onSubmit="state.showArea = false"
- >
- <CusTab :tabs="state.areaList" type="type1" v-model:param="state.areaTab" label-key="treeName" value-key="treeId"/>
- <div class="index-list">
- <div class="all">
- <div class="__check" :class="{active: indexTabAllCpt}" @click="onIndexTabAll">全选</div>
- </div>
- <div class="list">
- <template v-for="(item, index) in indexListCpt">
- <div class="list-item">
- <div class="__check" :class="{active: item.__select}" @click="item.__select = !item.__select">{{ item.treeName }}</div>
- </div>
- </template>
- </div>
- </div>
- </CusDialog>
- </div>
- </template>
- <script setup lang="ts">
- import {computed, getCurrentInstance, onMounted, reactive} from "vue";
- import router from "@/router";
- import {ElMessage} from "element-plus";
- import {useWebStore} from "@/stores";
- const {proxy} = getCurrentInstance()
- const WebStore = useWebStore()
- const state: any = reactive({
- searchText: '',
- historyList: [],
- areaList: [],
- showArea: false,
- areaTab: ''
- })
- const indexListCpt = computed(() => {
- return state.areaList.filter(v => v.treeId === state.areaTab)?.[0]?.children || []
- })
- const indexTabAllCpt = computed(() => {
- return indexListCpt.value.every(v => v.__select)
- })
- const searchAreaCpt = computed(() => {
- const obj = {
- text: '',
- arr: []
- }
- let i = 0
- state.areaList.forEach(v => {
- v.children.forEach(c => {
- i++
- if (c.__select) {
- obj.arr.push(c)
- }
- })
- })
- if (i === obj.arr.length) {
- obj.arr = []
- }
- if (obj.arr.length === 0) {
- obj.text = '全部'
- }
- return obj
- })
- const noAreaCpt = computed(() => {
- return !(state.areaList.length > 0)
- })
- const initHistory = () => {
- proxy.$api.mockGetSearchHistory().then(res => {
- state.historyList = res.data
- })
- }
- const initArea = () => {
- WebStore.getSearchAreaTree().then(res => {
- state.areaList = JSON.parse(JSON.stringify(res))
- state.areaTab = state.areaList[0]?.treeId
- })
- }
- const onIndexTabAll = () => {
- const flag = JSON.parse(JSON.stringify(indexTabAllCpt.value))
- indexListCpt.value.forEach(v => {
- v.__select = !flag
- })
- }
- const toList = (text, isAll = false) => {
- console.log(searchAreaCpt.value.arr)
- if (text) {
- const routerUrl = router.resolve({
- name: '4f6dd2ea-7c0a-4923-9a57-932ef42235f6',
- query: {
- text,
- index: isAll ? '' : searchAreaCpt.value.arr.map(v => v.treeId).join(',')
- }
- });
- window.open(routerUrl.href, "_blank");
- } else {
- ElMessage({
- message: '请输入关键字进行查询!',
- grouping: true,
- type: 'warning',
- })
- }
- }
- onMounted(() => {
- // initHistory()
- initArea()
- })
- </script>
- <style lang="scss" scoped>
- .web-home {
- width: 100%;
- height: 100%;
- background-image: url("@/assets/images/web/web-home_bg.png");
- background-size: 100% 100%;
- background-repeat: no-repeat;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- gap: 40px;
- .area {
- width: 1000px;
- .selected {
- display: flex;
- line-height: 30px;
- .label {
- font-weight: 500;
- font-size: 16px;
- color: var(--cus-main-color);
- padding-left: 16px;
- }
- .value {
- flex: 1;
- color: var(--cus-text-color-2);
- display: flex;
- flex-wrap: wrap;
- column-gap: 20px;
- }
- }
- .search-input {
- margin-top: 10px;
- display: flex;
- align-items: center;
- width: 100%;
- height: 60px;
- background: rgba(255,255,255,0.9);
- box-shadow: 0px 0px 2px 0px rgba(167,220,255,0.5);
- border-radius: 60px;
- border: 1px solid var(--cus-main-color);
- .left-select {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 184px;
- gap: 17px;
- color: var(--cus-text-color-4);
- font-size: 18px;
- position: relative;
- &:after {
- content: '';
- position: absolute;
- right: 0;
- height: 40px;
- width: 1px;
- background-color: var(--cus-main-color);
- }
- }
- :deep(.el-input) {
- font-size: 18px;
- color: var(--cus-text-color-2);
- .el-input__wrapper {
- box-shadow: none !important;
- background-color: transparent;
- .el-input__inner {
- &::placeholder {
- color: var(--cus-text-color-4);
- }
- }
- }
- }
- .right-icon {
- margin-right: 20px;
- }
- }
- }
- .history {
- width: 1000px;
- .label {
- font-weight: 500;
- font-size: 16px;
- color: var(--cus-main-color);
- padding-left: 16px;
- }
- .result {
- margin-top: 10px;
- width: 100%;
- padding: 16px;
- background: rgba(255,255,255,0.8);
- box-shadow: 0px 4px 4px 0px rgba(255,255,255,0.15);
- border-radius: 8px;
- font-weight: 400;
- font-size: 16px;
- color: var(--cus-text-color-2);
- display: flex;
- flex-wrap: wrap;
- gap: 10px 32px;
- }
- }
- }
- .cus-tab {
- padding: 30px 0 22px 28px;
- :deep(.cus-tab-item::after) {
- bottom: -23px !important;
- }
- }
- .index-list {
- padding: 20px 28px 0;
- .list {
- margin-top: 10px;
- display: flex;
- flex-wrap: wrap;
- gap: 30px;
- }
- }
- </style>
|