Refactor code structure and remove redundant changes
This commit is contained in:
101
pages/model/index.vue
Normal file
101
pages/model/index.vue
Normal file
@ -0,0 +1,101 @@
|
||||
<template>
|
||||
<!-- 导航 -->
|
||||
<KlNavTab active="模型" :type="3" />
|
||||
<div class="ma-auto w-1440px">
|
||||
<!-- 图纸分类 -->
|
||||
<KlWallpaperCategory v-model="query" v-model:level="level" :type="3" />
|
||||
<!-- 推荐栏目 -->
|
||||
<RecommendedColumnsV2 v-model="query" v-model:result="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="[12, 24, 48]"
|
||||
: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/RecommendedColumnsV2.vue'
|
||||
// import FeaturedSpecials from './components/FeaturedSpecials.vue'
|
||||
|
||||
import { reactive, watch, ref } from 'vue'
|
||||
import { page } from '@/api/upnew/index'
|
||||
import { pageRes, pageReq } from '@/api/upnew/types'
|
||||
import { useRoute } from 'vue-router'
|
||||
const route = useRoute()
|
||||
const level = ref(
|
||||
route.query.level
|
||||
? JSON.parse(route.query.level as string)
|
||||
: [
|
||||
{
|
||||
id: '0',
|
||||
name: '模型库',
|
||||
isChildren: false,
|
||||
},
|
||||
]
|
||||
)
|
||||
|
||||
const query = reactive<pageReq>({
|
||||
pageNo: 1,
|
||||
pageSize: 12,
|
||||
projectType: '',
|
||||
editions: '',
|
||||
source: '',
|
||||
type: 3,
|
||||
})
|
||||
const result = reactive<pageRes>({
|
||||
list: [],
|
||||
total: 0,
|
||||
})
|
||||
|
||||
// 如果id存在,则设置projectType
|
||||
if (level.value.length) {
|
||||
query.projectType = level.value[level.value.length - 1].id || ''
|
||||
}
|
||||
|
||||
const getPage = () => {
|
||||
page(query).then((res) => {
|
||||
const { data, code } = res
|
||||
if (code === 0) {
|
||||
result.list = data.list
|
||||
result.total = data.total
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
getPage()
|
||||
|
||||
const handleChangeSize = (size: number) => {
|
||||
query.pageSize = size
|
||||
query.pageNo = 1
|
||||
getPage()
|
||||
}
|
||||
|
||||
const handleChangeCurrent = (current: number) => {
|
||||
query.pageNo = current
|
||||
getPage()
|
||||
}
|
||||
|
||||
watch([() => query.projectType, () => query.editions, () => query.source], (val) => {
|
||||
if (val) {
|
||||
getPage()
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-pagination) {
|
||||
.el-input__inner {
|
||||
text-align: center !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user