基于Java spring + vue3 + nuxt构建的内容管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

146 lines
4.7 KiB

<template>
<div v-infinite-scroll="load" class="login-layout mt-[100px] min-h-2xl m-auto sm:w-screen-sm w-full">
<div class="title text-xl text-gray-700 px-4 py-2 font-500 text-center">
<div class="sm:w-screen-sm w-full">
<el-input
v-model="where.keywords"
class="w-full"
size="large"
placeholder="搜索"
:prefix-icon="Search"
@keydown.enter="reload"
>
<template #append>
<el-button size="large" type="primary" @click="reload">搜索</el-button>
</template>
</el-input>
<el-tabs v-model="activeName" class="my-3" @tab-click="handleClick">
<el-tab-pane label="应用" name="web"></el-tab-pane>
<el-tab-pane label="公众号" name="mp-official"></el-tab-pane>
<el-tab-pane label="小程序" name="mp-weixin"></el-tab-pane>
<el-tab-pane label="移动应用" name="app"></el-tab-pane>
<el-tab-pane label="小商店" name="mp-shop"></el-tab-pane>
<el-tab-pane label="其他" name="other"></el-tab-pane>
</el-tabs>
</div>
</div>
<template v-if="activeName === 'web'">
<div class="search bg-white rounded-lg p-3 w-full" v-if="list.length > 0">
<div class="title text-gray-400 px-4 py-2 mb-4">搜索结果</div>
<div class="result px-3">
<div v-for="(item,index) in list" :key="index" class="app-item block border-solid rounded-lg border-gray-300 border-1 mb-4 p-3 flex flex-row items-center hover:border-blue-4 hover:border-2 cursor-pointer">
<el-space @click="navTo(item)">
<div class="avatar flex flex-col items-center justify-center">
<el-avatar :src="item.appIcon" style="background-color: #f3f3f3" size="large" />
</div>
<div class="app-info flex flex-col">
<div class="text-lg">{{ item.appName }}</div>
<div class="text-gray-400">{{ item.comments }}</div>
<div class="text-gray-300 text-xs-1">{{ item.companyName }}</div>
</div>
</el-space>
</div>
</div>
</div>
</template>
<div v-else class="px-1 text-center text-gray-500 min-h-xs">
{{ resultText }}
</div>
</div>
</template>
<script setup lang="ts">
import { Search } from '@element-plus/icons-vue'
import type {ApiResult, PageResult} from "~/api";
import {useServerRequest} from "~/composables/useServerRequest";
import {useWebsite} from "~/composables/configState";
import type {Navigation} from "~/api/cms/navigation/model";
import {getPath} from "~/utils/common";
import type {CompanyParam} from "~/api/system/company/model";
import {navigateTo} from "#imports";
import type {App} from "~/api/oa/app/model";
const route = useRoute();
// 页面信息
const runtimeConfig = useRuntimeConfig();
const list = ref<App[]>([]);
const disabled = ref<boolean>(false);
const activeName = ref('web');
const page = ref<number>(1);
const resultText = ref('');
const layout = ref<any>();
// 获取状态
const form = ref<Navigation>();
const website = useWebsite();
// 搜索表单
const where = reactive<CompanyParam>({
keywords: ''
});
const load = () => {
if(!disabled.value){
console.log('load>>>')
page.value++;
handleClick();
}
}
const navTo = (item: App) => {
navigateTo(`/market/${item.appId}`)
}
// 请求数据
const reload = async () => {
const { data: nav } = await useServerRequest<ApiResult<Navigation>>('/cms/cms-navigation/getNavigationByPath',{query: {path: getPath()}})
if(nav.value?.data){
form.value = nav.value?.data;
}
// 页面布局
if(form.value?.layout){
layout.value = JSON.parse(form.value?.layout)
}
useHead({
title: `搜索结果 - ${website.value.websiteName}`,
bodyAttrs: {
class: "page-container",
}
});
page.value = 1;
list.value = [];
await handleClick()
}
// 搜索结果
const handleClick = async () => {
const {data: response} = await useServerRequest<ApiResult<PageResult<App>>>('/oa/oa-app/page',{baseURL: runtimeConfig.public.apiServer, params: {
page: page.value,
keywords: where.keywords
}})
if(response.value?.data){
console.log(response.value?.data.count,'count>')
if (list.value.length < response.value?.data.count) {
disabled.value = false;
if (response.value?.data.list) {
list.value = list.value.concat(response.value?.data.list);
}
}else {
disabled.value = true;
}
if(response.value.data.count == 0){
resultText.value = '暂无相关结果'
}
}
}
watch(
() => route,
() => {
reload();
},
{ immediate: true }
);
</script>