refactor: 重构国外专区组件结构和路由配置
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
<script lang="ts" setup>
|
||||
import KlTabBar from '~/components/kl-tab-bar/index.vue'
|
||||
import CardPicture from '~/components/kl-card-picture/index.vue'
|
||||
import KlWallpaperCategory from '~/components/kl-wallpaper-category/index.vue'
|
||||
import { ref } from 'vue'
|
||||
import type { pageRes } from '~/api/upnew/types'
|
||||
|
||||
@ -38,19 +39,19 @@
|
||||
required: true,
|
||||
})
|
||||
|
||||
const tabIndex = ref(1)
|
||||
const tabIndex = ref(-1)
|
||||
const tabBar = ref([
|
||||
{
|
||||
label: '图纸推荐',
|
||||
value: 1,
|
||||
value: -1,
|
||||
},
|
||||
{
|
||||
label: '原创图纸',
|
||||
value: 2,
|
||||
value: 1,
|
||||
},
|
||||
{
|
||||
label: '最新上传',
|
||||
value: 3,
|
||||
value: 2,
|
||||
},
|
||||
])
|
||||
</script>
|
||||
@ -87,7 +87,7 @@
|
||||
const { data: breadList } = await useAsyncData(
|
||||
`breadList-${props.type}-${props.id}-${query.value.projectType}-${Date.now()}`,
|
||||
async () => {
|
||||
const res = await getDictTree({ type: props.type, id: query.value.projectType })
|
||||
const res = await getDictTree({ type: 1, id: query.value.projectType })
|
||||
const all = [
|
||||
{
|
||||
id: -1,
|
||||
|
||||
@ -0,0 +1,128 @@
|
||||
<template>
|
||||
<!-- 导航 -->
|
||||
<KlNavTab active="国外专区" />
|
||||
<!-- banneer提示 -->
|
||||
<BannerTips />
|
||||
<div class="ma-auto w-[1440px]">
|
||||
<!-- 图片展示鼠标移上去展示提示语 -->
|
||||
<!-- <ImageTips /> -->
|
||||
<!-- 推荐栏目 -->
|
||||
<RecommendedColumnsV2 v-model:query="query" v-model="result"></RecommendedColumnsV2>
|
||||
<!-- 精选专题 -->
|
||||
<!-- <FeaturedSpecials></FeaturedSpecials> -->
|
||||
<!-- 分页 -->
|
||||
<div class="mt-[10px] flex justify-center">
|
||||
<el-pagination
|
||||
v-model:current-page="query.pageNo"
|
||||
v-model:page-size="query.pageSize"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
:total="result?.total"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
@size-change="handleChangeSize"
|
||||
@current-change="handleChangeCurrent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import KlNavTab from '~/components/kl-nav-tab/index.vue'
|
||||
import KlWallpaperCategory from '~/components/kl-wallpaper-category/index.vue'
|
||||
import RecommendedColumnsV2 from '~/components/foreign-components/RecommendedColumnsV2.vue'
|
||||
import BannerTips from '~/components/foreign-components/BannerTips.vue'
|
||||
// import FeaturedSpecials from './components/FeaturedSpecials.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { reactive, watch, ref } from 'vue'
|
||||
import { page } from '~/api/upnew/index'
|
||||
import { getDictTree } from '~/api/home/index'
|
||||
import type { pageRes, pageReq } from '~/api/upnew/types'
|
||||
const route = useRoute()
|
||||
const projectType = computed(() => (route.params?.projectType ? route.params?.projectType : ''))
|
||||
const pageNo = computed(() => Number(route.params?.pageNo))
|
||||
const pageSize = computed(() => Number(route.params?.pageSize))
|
||||
const editions = computed(() => (route.params?.editions ? route.params?.editions : ''))
|
||||
const source = computed(() => (route.params?.source ? Number(route.params?.source) : ''))
|
||||
|
||||
console.log('route.params----', route.params)
|
||||
|
||||
const level = ref(
|
||||
route.query?.valuelevel
|
||||
? JSON.parse(route.query.valuelevel as string)
|
||||
: [
|
||||
{
|
||||
id: -1,
|
||||
name: '图纸库',
|
||||
isChildren: false,
|
||||
},
|
||||
]
|
||||
)
|
||||
const keywords = ref((route.query?.valuekeywords as string) || '')
|
||||
|
||||
const query = ref<pageReq>({
|
||||
pageNo: pageNo.value || 1,
|
||||
pageSize: pageSize.value || 12,
|
||||
projectType: projectType.value || '-1',
|
||||
editions: editions.value || '-1',
|
||||
source: source.value || -1,
|
||||
type: 1,
|
||||
title: keywords.value,
|
||||
})
|
||||
// const result = reactive<pageRes>({
|
||||
// list: [],
|
||||
// total: 0,
|
||||
// })
|
||||
|
||||
// 如果id存在,则设置projectType
|
||||
if (level.value.length) {
|
||||
// query.value.projectType = level.value[level.value.length - 1].id || ''
|
||||
}
|
||||
|
||||
const handleChangeSize = (val: number) => {
|
||||
query.value.pageSize = val
|
||||
// getPage()
|
||||
navigateTo(`/foreign/${query.value.projectType}/${query.value.pageNo}/${val}/${query.value.editions}/${query.value.source}`)
|
||||
}
|
||||
|
||||
const handleChangeCurrent = (val: number) => {
|
||||
query.value.pageNo = val
|
||||
// getPage()
|
||||
navigateTo(`/foreign/${query.value.projectType}/${val}/${query.value.pageSize}/${query.value.editions}/${query.value.source}`)
|
||||
}
|
||||
|
||||
const { data: result, refresh: getPage } = useAsyncData(
|
||||
`foreign-page-list-${query.value.projectType}-${query.value.editions}-${query.value.source}-${query.value.pageNo}-${query.value.pageSize}-${query.value.title}`,
|
||||
async () => {
|
||||
const res = await page({
|
||||
...query.value,
|
||||
editions: query.value.editions === '-1' ? '' : query.value.editions,
|
||||
source: query.value.source === -1 ? '' : query.value.source,
|
||||
projectType: query.value.projectType === '-1' ? '' : query.value.projectType,
|
||||
})
|
||||
return res.data
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
}
|
||||
)
|
||||
// const getPage = () => {
|
||||
// page(query).then((res) => {
|
||||
// const { data, code } = res
|
||||
// if (code === 0) {
|
||||
// result.list = data.list
|
||||
// result.total = data.total
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
|
||||
watch([() => query.value.projectType, () => query.value.editions, () => query.value.source], (val) => {
|
||||
if (val) {
|
||||
navigateTo(`/foreign/${query.value.projectType}/1/${query.value.pageSize}/${query.value.editions}/${query.value.source}`)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-pagination) {
|
||||
.el-input__inner {
|
||||
text-align: center !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -26,9 +26,9 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import KlNavTab from '~/components/kl-nav-tab/index.vue'
|
||||
import RecommendedColumnsV2 from './components/RecommendedColumnsV2.vue'
|
||||
import RecommendedColumnsV2 from '~/components/foreign-components/RecommendedColumnsV2.vue'
|
||||
// import FeaturedSpecials from './components/FeaturedSpecials.vue'
|
||||
import BannerTips from './components/BannerTips.vue'
|
||||
import BannerTips from '~/components/foreign-components/BannerTips.vue'
|
||||
// import ImageTips from './components/ImageTips.vue'
|
||||
|
||||
import { reactive, watch } from 'vue'
|
||||
@ -38,9 +38,9 @@
|
||||
const query = reactive<pageReq>({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
projectType: '',
|
||||
editions: '',
|
||||
source: '',
|
||||
projectType: '-1',
|
||||
editions: '-1',
|
||||
source: -1,
|
||||
type: 1,
|
||||
})
|
||||
// const result = reactive<pageRes>({
|
||||
@ -48,8 +48,13 @@
|
||||
// total: 0,
|
||||
// })
|
||||
|
||||
const {data:result, refresh:getPage } = await useAsyncData(`draw-page-list-${Date.now()}`, async () => {
|
||||
const res = await page(query)
|
||||
const { data: result } = await useAsyncData(`draw-page-list-${Date.now()}`, async () => {
|
||||
const res = await page({
|
||||
...query,
|
||||
editions: query.editions === '-1' ? '' : query.editions,
|
||||
source: query.source === -1 ? '' : query.source,
|
||||
projectType: query.projectType === '-1' ? '' : query.projectType,
|
||||
})
|
||||
return res.data
|
||||
})
|
||||
// const getPage = () => {
|
||||
@ -66,18 +71,23 @@
|
||||
|
||||
const handleChangeSize = (val: number) => {
|
||||
query.pageSize = val
|
||||
query.pageNo = 1
|
||||
getPage()
|
||||
// query.pageNo = 1
|
||||
// getPage()
|
||||
|
||||
navigateTo(`/foreign/${query.projectType}/${query.pageNo}/${val}/${query.editions}/${query.source}`)
|
||||
}
|
||||
|
||||
const handleChangeCurrent = (val: number) => {
|
||||
query.pageNo = val
|
||||
getPage()
|
||||
// getPage()
|
||||
navigateTo(`/foreign/${query.projectType}/${val}/${query.pageSize}/${query.editions}/${query.source}`)
|
||||
}
|
||||
|
||||
watch([() => query.projectType, () => query.editions, () => query.source], (val) => {
|
||||
if (val) {
|
||||
getPage()
|
||||
// getPage()
|
||||
|
||||
navigateTo(`/foreign/${query.projectType}/1/${query.pageSize}/${query.editions}/${query.source}`)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user