完成大部分页面的分页抽取的逻辑
This commit is contained in:
@@ -40,30 +40,30 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页栏 -->
|
<!-- 分页栏 -->
|
||||||
<view class="pagination-bar">
|
<CommonPagination
|
||||||
<text class="page-total">共 {{ kefuList.length }} 条</text>
|
v-if="kefuList.length > 0"
|
||||||
<view class="page-size-select">
|
:total="kefuList.length"
|
||||||
<text class="size-txt">15条/页</text>
|
:loading="false"
|
||||||
<text class="arrow-down">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
<view class="page-nav">
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="nav-prev"><text class="nav-icon"> < </text></view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<view class="nav-item active"><text class="nav-num">1</text></view>
|
:visiblePages="visiblePages"
|
||||||
<view class="nav-next"><text class="nav-icon"> > </text></view>
|
:totalPage="totalPage"
|
||||||
</view>
|
:jumpPageInput="jumpPageInput"
|
||||||
<view class="page-jump">
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="jump-txt">前往</text>
|
@page-change="handlePageChange"
|
||||||
<input class="jump-input" value="1" />
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<text class="jump-txt">页</text>
|
@jump-page="handleJumpPage"
|
||||||
</view>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface KefuItem {
|
interface KefuItem {
|
||||||
id: string
|
id: string
|
||||||
@@ -86,6 +86,36 @@ const kefuList = ref<KefuItem[]>([
|
|||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
console.log('Add Kefu')
|
console.log('Add Kefu')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(kefuList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -208,70 +238,5 @@ const handleAdd = () => {
|
|||||||
margin: 0 12px;
|
margin: 0 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页栏 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-bar {
|
|
||||||
padding: 20px 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-total { font-size: 13px; color: #606266; margin-right: 15px; }
|
|
||||||
|
|
||||||
.page-size-select {
|
|
||||||
border: 1px solid #dcdee2;
|
|
||||||
padding: 4px 10px;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.size-txt { font-size: 13px; color: #606266; margin-right: 8px; }
|
|
||||||
.arrow-down { font-size: 10px; color: #808695; }
|
|
||||||
|
|
||||||
.page-nav { display: flex; flex-direction: row; align-items: center; margin-right: 15px; }
|
|
||||||
.nav-prev, .nav-next {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #dcdee2;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin: 0 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #dcdee2;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin: 0 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.active {
|
|
||||||
background-color: #2d8cf0;
|
|
||||||
border-color: #2d8cf0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.active .nav-num { color: #fff; }
|
|
||||||
.nav-num, .nav-icon { font-size: 13px; color: #606266; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input {
|
|
||||||
width: 40px;
|
|
||||||
height: 30px;
|
|
||||||
border: 1px solid #dcdee2;
|
|
||||||
border-radius: 4px;
|
|
||||||
text-align: center;
|
|
||||||
margin: 0 8px;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -58,23 +58,22 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-bar">
|
<CommonPagination
|
||||||
<text class="page-total">共 {{ wordList.length }} 条</text>
|
v-if="wordList.length > 0"
|
||||||
<view class="page-size-select">
|
:total="wordList.length"
|
||||||
<text class="size-txt">15条/页</text>
|
:loading="false"
|
||||||
<text class="arrow-down">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
<view class="page-nav">
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="nav-prev"><text class="nav-icon"> < </text></view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<view class="nav-item active"><text class="nav-num">1</text></view>
|
:visiblePages="visiblePages"
|
||||||
<view class="nav-next"><text class="nav-icon"> > </text></view>
|
:totalPage="totalPage"
|
||||||
</view>
|
:jumpPageInput="jumpPageInput"
|
||||||
<view class="page-jump">
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="jump-txt">前往</text>
|
@page-change="handlePageChange"
|
||||||
<input class="jump-input" value="1" />
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<text class="jump-txt">页</text>
|
@jump-page="handleJumpPage"
|
||||||
</view>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -144,7 +143,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface WordItem {
|
interface WordItem {
|
||||||
id: string
|
id: string
|
||||||
@@ -224,6 +224,36 @@ const submitForm = () => {
|
|||||||
console.log('提交表单', formData)
|
console.log('提交表单', formData)
|
||||||
showDrawer.value = false
|
showDrawer.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(wordList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -421,62 +451,7 @@ const submitForm = () => {
|
|||||||
margin: 0 10px;
|
margin: 0 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-bar {
|
|
||||||
padding: 15px 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
border-top: 1px solid #f0f0f0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-total { font-size: 13px; color: #606266; margin-right: 15px; }
|
|
||||||
|
|
||||||
.page-size-select {
|
|
||||||
border: 1px solid #dcdee2;
|
|
||||||
padding: 4px 10px;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.size-txt { font-size: 13px; color: #606266; margin-right: 8px; }
|
|
||||||
.nav-icon, .arrow-down { font-size: 10px; color: #808695; }
|
|
||||||
|
|
||||||
.page-nav { display: flex; flex-direction: row; align-items: center; margin-right: 15px; }
|
|
||||||
.nav-prev, .nav-next, .nav-item {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
border: 1px solid #dcdee2;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin: 0 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item.active {
|
|
||||||
background-color: #2d8cf0;
|
|
||||||
border-color: #2d8cf0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.active .nav-num { color: #fff; }
|
|
||||||
.nav-num { font-size: 13px; color: #606266; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input {
|
|
||||||
width: 40px;
|
|
||||||
height: 30px;
|
|
||||||
border: 1px solid #dcdee2;
|
|
||||||
border-radius: 4px;
|
|
||||||
text-align: center;
|
|
||||||
margin: 0 8px;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 抽屉 Drawer 1:1 复刻 - 修正位置到右侧 */
|
/* 抽屉 Drawer 1:1 复刻 - 修正位置到右侧 */
|
||||||
.drawer-mask {
|
.drawer-mask {
|
||||||
|
|||||||
@@ -93,33 +93,30 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total">
|
<CommonPagination
|
||||||
<text class="total-txt">共 {{ combos.length }} 条</text>
|
v-if="combos.length > 0"
|
||||||
</view>
|
:total="combos.length"
|
||||||
<view class="page-select">
|
:loading="false"
|
||||||
<view class="select-mock mini">
|
:currentPage="currentPage"
|
||||||
<text class="select-val">15条/页</text>
|
:pageSize="pageSize"
|
||||||
<text class="arrow">▼</text>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
</view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
</view>
|
:visiblePages="visiblePages"
|
||||||
<view class="page-btns">
|
:totalPage="totalPage"
|
||||||
<text class="p-btn">‹</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
<text class="p-btn active">1</text>
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="p-btn">›</text>
|
@page-change="handlePageChange"
|
||||||
</view>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<view class="page-jump">
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">前往</text>
|
/>
|
||||||
<input class="jump-input" placeholder="1" />
|
|
||||||
<text class="jump-txt">页</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const statusLabels = {
|
const statusLabels = {
|
||||||
ongoing: '进行中',
|
ongoing: '进行中',
|
||||||
@@ -228,6 +225,36 @@ const viewDetails = (item: any) => {
|
|||||||
const completeGroup = (item: any) => {
|
const completeGroup = (item: any) => {
|
||||||
console.log('立即成团', item.id)
|
console.log('立即成团', item.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(combos.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -402,32 +429,5 @@ const completeGroup = (item: any) => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #1890ff; border-color: #1890ff; color: #fff; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 28px; border: 1px solid #dcdfe6; border-radius: 4px; text-align: center; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -93,33 +93,30 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total">
|
<CommonPagination
|
||||||
<text class="total-txt">共 {{ combos.length }} 条</text>
|
v-if="combos.length > 0"
|
||||||
</view>
|
:total="combos.length"
|
||||||
<view class="page-select">
|
:loading="false"
|
||||||
<view class="select-mock mini">
|
:currentPage="currentPage"
|
||||||
<text class="select-val">15条/页</text>
|
:pageSize="pageSize"
|
||||||
<text class="arrow">▼</text>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
</view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
</view>
|
:visiblePages="visiblePages"
|
||||||
<view class="page-btns">
|
:totalPage="totalPage"
|
||||||
<text class="p-btn">‹</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
<text class="p-btn active">1</text>
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="p-btn">›</text>
|
@page-change="handlePageChange"
|
||||||
</view>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<view class="page-jump">
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">前往</text>
|
/>
|
||||||
<input class="jump-input" placeholder="1" />
|
|
||||||
<text class="jump-txt">页</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const statusLabels = {
|
const statusLabels = {
|
||||||
ongoing: '进行中',
|
ongoing: '进行中',
|
||||||
@@ -228,6 +225,36 @@ const viewDetails = (item: any) => {
|
|||||||
const completeGroup = (item: any) => {
|
const completeGroup = (item: any) => {
|
||||||
console.log('立即成团', item.id)
|
console.log('立即成团', item.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(combos.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -405,32 +432,5 @@ const completeGroup = (item: any) => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #1890ff; border-color: #1890ff; color: #fff; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 28px; border: 1px solid #dcdfe6; border-radius: 4px; text-align: center; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -107,25 +107,30 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total">
|
<CommonPagination
|
||||||
<text class="total-txt">共 {{ total }} 条</text>
|
v-if="total > 0"
|
||||||
</view>
|
:total="total"
|
||||||
<view class="page-select">
|
:loading="false"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
<view class="page-btns">
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<text class="p-btn"><</text>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn active">1</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn">></text>
|
:totalPage="totalPage"
|
||||||
</view>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface CombinationProduct {
|
interface CombinationProduct {
|
||||||
id: number
|
id: number
|
||||||
@@ -219,6 +224,36 @@ const handleStats = (item: CombinationProduct) => { console.log('Stats...', item
|
|||||||
const toggleShow = (item: CombinationProduct) => {
|
const toggleShow = (item: CombinationProduct) => {
|
||||||
item.is_show = !item.is_show
|
item.is_show = !item.is_show
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -438,28 +473,5 @@ const toggleShow = (item: CombinationProduct) => {
|
|||||||
.op-split { color: #e8eaec; margin: 0 5px; }
|
.op-split { color: #e8eaec; margin: 0 5px; }
|
||||||
.text-danger { color: #ed4014; }
|
.text-danger { color: #ed4014; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-val { font-size: 13px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #e8eaec;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -107,30 +107,30 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-footer">
|
<CommonPagination
|
||||||
<text class="total-txt">共 16 条</text>
|
v-if="total > 0"
|
||||||
<view class="page-select">
|
:total="total"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:loading="false"
|
||||||
</view>
|
:currentPage="currentPage"
|
||||||
<view class="page-btns">
|
:pageSize="pageSize"
|
||||||
<text class="p-btn disabled"><</text>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<text class="p-btn active">1</text>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn">2</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn">></text>
|
:totalPage="totalPage"
|
||||||
</view>
|
:jumpPageInput="jumpPageInput"
|
||||||
<view class="page-jump">
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="jump-txt">前往</text>
|
@page-change="handlePageChange"
|
||||||
<input class="jump-input" placeholder="1" />
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<text class="jump-txt">页</text>
|
@jump-page="handleJumpPage"
|
||||||
</view>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface CouponItem {
|
interface CouponItem {
|
||||||
id: number
|
id: number
|
||||||
@@ -169,6 +169,37 @@ const handleAdd = () => { console.log('Adding coupon...') }
|
|||||||
const toggleStatus = (index: number) => {
|
const toggleStatus = (index: number) => {
|
||||||
dataList.value[index].isOpen = !dataList.value[index].isOpen
|
dataList.value[index].isOpen = !dataList.value[index].isOpen
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const total = ref(16)
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -297,28 +328,6 @@ const toggleStatus = (index: number) => {
|
|||||||
.op-split { color: #e8eaec; margin: 0 5px; }
|
.op-split { color: #e8eaec; margin: 0 5px; }
|
||||||
.text-danger { color: #ed4014; }
|
.text-danger { color: #ed4014; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
border-top: 1px solid #f0f0f0;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 14px; color: #606266; }
|
|
||||||
.page-val { font-size: 14px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px; height: 32px; border: 1px solid #dcdfe6; border-radius: 4px;
|
|
||||||
display: flex; align-items: center; justify-content: center; font-size: 14px; color: #666;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
.p-btn.disabled { color: #c0c4cc; background-color: #f5f7fa; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 14px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 14px; }
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -64,30 +64,30 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-footer">
|
<CommonPagination
|
||||||
<text class="total-txt">共 16 条</text>
|
v-if="total > 0"
|
||||||
<view class="page-select">
|
:total="total"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:loading="false"
|
||||||
</view>
|
:currentPage="currentPage"
|
||||||
<view class="page-btns">
|
:pageSize="pageSize"
|
||||||
<text class="p-btn disabled"><</text>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<text class="p-btn active">1</text>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn">2</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn">></text>
|
:totalPage="totalPage"
|
||||||
</view>
|
:jumpPageInput="jumpPageInput"
|
||||||
<view class="page-jump">
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="jump-txt">前往</text>
|
@page-change="handlePageChange"
|
||||||
<input class="jump-input" placeholder="1" />
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<text class="jump-txt">页</text>
|
@jump-page="handleJumpPage"
|
||||||
</view>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface CouponRecord {
|
interface CouponRecord {
|
||||||
id: number
|
id: number
|
||||||
@@ -121,6 +121,37 @@ const recordList = ref<CouponRecord[]>([
|
|||||||
])
|
])
|
||||||
|
|
||||||
const handleQuery = () => { console.log('Querying redemption records...') }
|
const handleQuery = () => { console.log('Querying redemption records...') }
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const total = ref(16)
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -204,27 +235,5 @@ const handleQuery = () => { console.log('Querying redemption records...') }
|
|||||||
|
|
||||||
.status-used { color: #999; }
|
.status-used { color: #999; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
border-top: 1px solid #f0f0f0;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 14px; color: #606266; }
|
|
||||||
.page-val { font-size: 14px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px; height: 32px; border: 1px solid #dcdfe6; border-radius: 4px;
|
|
||||||
display: flex; align-items: center; justify-content: center; font-size: 14px; color: #666;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
.p-btn.disabled { color: #c0c4cc; background-color: #f5f7fa; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 14px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 14px; }
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -31,20 +31,23 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total"><text class="total-txt">共 {{ anchorList.length }} 条</text></view>
|
<CommonPagination
|
||||||
<view class="page-select">
|
v-if="anchorList.length > 0"
|
||||||
<view class="select-mock mini">
|
:total="anchorList.length"
|
||||||
<text class="select-val">15条/页</text>
|
:loading="false"
|
||||||
<text class="arrow">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn disabled">‹</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn disabled">›</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
</view>
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- Modal Overlay -->
|
<!-- Modal Overlay -->
|
||||||
@@ -86,7 +89,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const showModal = ref(false)
|
const showModal = ref(false)
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
@@ -143,6 +147,36 @@ const handleSubmit = () => {
|
|||||||
uni.showToast({ title: '操作成功', icon: 'success' })
|
uni.showToast({ title: '操作成功', icon: 'success' })
|
||||||
showModal.value = false
|
showModal.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(anchorList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -225,29 +259,7 @@ const handleSubmit = () => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* Pagination */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.select-mock.mini {
|
|
||||||
width: 100px;
|
|
||||||
height: 28px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 0 12px;
|
|
||||||
}
|
|
||||||
.select-val { font-size: 12px; color: #606266; }
|
|
||||||
.arrow { font-size: 10px; color: #c0c4cc; }
|
|
||||||
|
|
||||||
/* Modal Styles */
|
/* Modal Styles */
|
||||||
.modal-mask {
|
.modal-mask {
|
||||||
|
|||||||
@@ -66,20 +66,23 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total"><text class="total-txt">共 {{ roomList.length }} 条</text></view>
|
<CommonPagination
|
||||||
<view class="page-select">
|
v-if="roomList.length > 0"
|
||||||
<view class="select-mock mini">
|
:total="roomList.length"
|
||||||
<text class="select-val">20条/页</text>
|
:loading="false"
|
||||||
<text class="arrow">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn disabled">‹</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn disabled">›</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
</view>
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- Drawer Overlay -->
|
<!-- Drawer Overlay -->
|
||||||
@@ -200,7 +203,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const showDrawer = ref(false)
|
const showDrawer = ref(false)
|
||||||
const isAnimating = ref(false)
|
const isAnimating = ref(false)
|
||||||
@@ -327,6 +331,36 @@ const closeDrawer = () => {
|
|||||||
isAnimating.value = false
|
isAnimating.value = false
|
||||||
}, 300)
|
}, 300)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(roomList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -514,16 +548,7 @@ const closeDrawer = () => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
|
|
||||||
/* Drawer Styles */
|
/* Drawer Styles */
|
||||||
.drawer-mask {
|
.drawer-mask {
|
||||||
|
|||||||
@@ -66,20 +66,23 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total"><text class="total-txt">共 {{ productList.length }} 条</text></view>
|
<CommonPagination
|
||||||
<view class="page-select">
|
v-if="productList.length > 0"
|
||||||
<view class="select-mock mini">
|
:total="productList.length"
|
||||||
<text class="select-val">20条/页</text>
|
:loading="false"
|
||||||
<text class="arrow">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn disabled">‹</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn disabled">›</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
</view>
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -112,7 +115,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const isAdding = ref(false)
|
const isAdding = ref(false)
|
||||||
const selectedList = ref([
|
const selectedList = ref([
|
||||||
@@ -196,6 +200,36 @@ const handleGenerate = () => {
|
|||||||
uni.showToast({ title: '生成成功', icon: 'success' })
|
uni.showToast({ title: '生成成功', icon: 'success' })
|
||||||
isAdding.value = false
|
isAdding.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(productList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -472,16 +506,7 @@ const handleGenerate = () => {
|
|||||||
margin-left: 100px;
|
margin-left: 100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -66,20 +66,23 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total"><text class="total-txt">共 {{ roomList.length }} 条</text></view>
|
<CommonPagination
|
||||||
<view class="page-select">
|
v-if="roomList.length > 0"
|
||||||
<view class="select-mock mini">
|
:total="roomList.length"
|
||||||
<text class="select-val">20条/页</text>
|
:loading="false"
|
||||||
<text class="arrow">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn disabled">‹</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn disabled">›</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
</view>
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- Drawer Overlay -->
|
<!-- Drawer Overlay -->
|
||||||
@@ -200,7 +203,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const showDrawer = ref(false)
|
const showDrawer = ref(false)
|
||||||
const isAnimating = ref(false)
|
const isAnimating = ref(false)
|
||||||
@@ -327,6 +331,36 @@ const closeDrawer = () => {
|
|||||||
isAnimating.value = false
|
isAnimating.value = false
|
||||||
}, 300)
|
}, 300)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(roomList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -517,16 +551,7 @@ const closeDrawer = () => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
|
|
||||||
/* Drawer Styles */
|
/* Drawer Styles */
|
||||||
.drawer-mask {
|
.drawer-mask {
|
||||||
|
|||||||
@@ -85,30 +85,34 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页区域 -->
|
<!-- 分页区域 -->
|
||||||
<view class="table-pagination">
|
<CommonPagination
|
||||||
<text class="total-text">共 {{ total }} 条</text>
|
v-if="total > 0"
|
||||||
<view class="page-ops">
|
:total="total"
|
||||||
<picker :range="pageSizes" @change="pageSizeChange">
|
:loading="false"
|
||||||
<view class="size-picker">{{ currentSize }}条/页 <text class="iconfont icon-arrow-down"></text></view>
|
:currentPage="currentPage"
|
||||||
</picker>
|
:pageSize="currentSize"
|
||||||
<button class="page-btn" disabled>上一页</button>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<text class="current-page">1</text>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<button class="page-btn" disabled>下一页</button>
|
:visiblePages="visiblePages"
|
||||||
<text class="jump-text">前往</text>
|
:totalPage="totalPage"
|
||||||
<input class="jump-input" value="1" />
|
:jumpPageInput="jumpPageInput"
|
||||||
<text class="jump-text">页</text>
|
@page-size-change="handlePageSizeChange"
|
||||||
</view>
|
@page-change="handlePageChange"
|
||||||
</view>
|
@update:jumpPageInput="updateJumpPageInput"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script uts>
|
<script uts>
|
||||||
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
StatusSwitch
|
StatusSwitch,
|
||||||
|
CommonPagination
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -116,7 +120,9 @@ export default {
|
|||||||
currentStatus: 0,
|
currentStatus: 0,
|
||||||
currentType: 0,
|
currentType: 0,
|
||||||
total: 4,
|
total: 4,
|
||||||
|
currentPage: 1,
|
||||||
currentSize: 15,
|
currentSize: 15,
|
||||||
|
jumpPageInput: '',
|
||||||
pageSizes: ['15条/页', '30条/页', '50条/页'],
|
pageSizes: ['15条/页', '30条/页', '50条/页'],
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
{ label: '全部', value: 0 },
|
{ label: '全部', value: 0 },
|
||||||
@@ -186,6 +192,23 @@ export default {
|
|||||||
] as any[]
|
] as any[]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
pageSizeOptions(): number[] { return [10, 15, 20, 30, 50] },
|
||||||
|
pageSizeOptionLabels(): string[] { return (this.pageSizeOptions as number[]).map((n: number) => `${n}条/页`) },
|
||||||
|
pageSizeIndex(): number {
|
||||||
|
const idx = (this.pageSizeOptions as number[]).indexOf(this.currentSize as number)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
},
|
||||||
|
totalPage(): number { return Math.max(1, Math.ceil((this.total as number) / (this.currentSize as number))) },
|
||||||
|
visiblePages(): number[] {
|
||||||
|
const t = this.totalPage as number
|
||||||
|
const cur = this.currentPage as number
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getStatusLabel(val : number) : string {
|
getStatusLabel(val : number) : string {
|
||||||
const found = this.statusOptions.find((item : any) : boolean => item.value == val)
|
const found = this.statusOptions.find((item : any) : boolean => item.value == val)
|
||||||
@@ -207,7 +230,18 @@ export default {
|
|||||||
},
|
},
|
||||||
handleSearch() {
|
handleSearch() {
|
||||||
uni.showToast({ title: '搜索', icon: 'none' })
|
uni.showToast({ title: '搜索', icon: 'none' })
|
||||||
}
|
},
|
||||||
|
handlePageChange(p: number) { this.currentPage = p as any },
|
||||||
|
handlePageSizeChange(e: any) {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
this.currentSize = ((this.pageSizeOptions as number[])[idx] ?? (this.pageSizeOptions as number[])[0]) as any
|
||||||
|
this.currentPage = 1 as any
|
||||||
|
},
|
||||||
|
handleJumpPage() {
|
||||||
|
const p = parseInt(this.jumpPageInput as string)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= (this.totalPage as number)) this.currentPage = p as any
|
||||||
|
},
|
||||||
|
updateJumpPageInput(val: string) { this.jumpPageInput = val as any }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -354,63 +388,7 @@ export default {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.table-pagination {
|
|
||||||
padding: 16px 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
.total-text {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #515a6e;
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
|
||||||
.page-ops {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.size-picker {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #515a6e;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
padding: 2px 8px;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin-right: 15px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.page-btn {
|
|
||||||
height: 28px;
|
|
||||||
line-height: 28px;
|
|
||||||
padding: 0 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
.current-page {
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
line-height: 28px;
|
|
||||||
text-align: center;
|
|
||||||
background-color: #2d8cf0;
|
|
||||||
color: #fff;
|
|
||||||
font-size: 14px;
|
|
||||||
border-radius: 2px;
|
|
||||||
margin: 0 8px;
|
|
||||||
}
|
|
||||||
.jump-text { font-size: 14px; color: #515a6e; margin: 0 5px; }
|
|
||||||
.jump-input {
|
|
||||||
width: 40px;
|
|
||||||
height: 28px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -86,31 +86,30 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-footer">
|
<CommonPagination
|
||||||
<view class="page-total">
|
v-if="total > 0"
|
||||||
<text class="total-txt">共 {{ total }} 条</text>
|
:total="total"
|
||||||
</view>
|
:loading="false"
|
||||||
<view class="page-select">
|
:currentPage="currentPage"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn"><</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn">></text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
<view class="page-jump">
|
@page-change="handlePageChange"
|
||||||
<text class="jump-txt">前往</text>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<input class="jump-input" placeholder="1" />
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">页</text>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface ProductItem {
|
interface ProductItem {
|
||||||
id: number
|
id: number
|
||||||
@@ -169,6 +168,36 @@ const handleEdit = (item: ProductItem) => { console.log('Editing...', item.id) }
|
|||||||
const toggleStatus = (index: number) => {
|
const toggleStatus = (index: number) => {
|
||||||
productList.value[index].status = !productList.value[index].status
|
productList.value[index].status = !productList.value[index].status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -365,34 +394,7 @@ const toggleStatus = (index: number) => {
|
|||||||
.op-split { color: #e8eaec; margin: 0 5px; }
|
.op-split { color: #e8eaec; margin: 0 5px; }
|
||||||
.text-danger { color: #ed4014; }
|
.text-danger { color: #ed4014; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-val { font-size: 13px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #e8eaec;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 13px; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -86,31 +86,30 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-footer">
|
<CommonPagination
|
||||||
<view class="page-total">
|
v-if="total > 0"
|
||||||
<text class="total-txt">共 {{ total }} 条</text>
|
:total="total"
|
||||||
</view>
|
:loading="false"
|
||||||
<view class="page-select">
|
:currentPage="currentPage"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn"><</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn">></text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
<view class="page-jump">
|
@page-change="handlePageChange"
|
||||||
<text class="jump-txt">前往</text>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<input class="jump-input" placeholder="1" />
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">页</text>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface ProductItem {
|
interface ProductItem {
|
||||||
id: number
|
id: number
|
||||||
@@ -169,6 +168,36 @@ const handleEdit = (item: ProductItem) => { console.log('Editing...', item.id) }
|
|||||||
const toggleStatus = (index: number) => {
|
const toggleStatus = (index: number) => {
|
||||||
productList.value[index].status = !productList.value[index].status
|
productList.value[index].status = !productList.value[index].status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -365,34 +394,7 @@ const toggleStatus = (index: number) => {
|
|||||||
.op-split { color: #e8eaec; margin: 0 5px; }
|
.op-split { color: #e8eaec; margin: 0 5px; }
|
||||||
.text-danger { color: #ed4014; }
|
.text-danger { color: #ed4014; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-val { font-size: 13px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #e8eaec;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 13px; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -86,31 +86,30 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-footer">
|
<CommonPagination
|
||||||
<view class="page-total">
|
v-if="total > 0"
|
||||||
<text class="total-txt">共 {{ total }} 条</text>
|
:total="total"
|
||||||
</view>
|
:loading="false"
|
||||||
<view class="page-select">
|
:currentPage="currentPage"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn"><</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn">></text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
<view class="page-jump">
|
@page-change="handlePageChange"
|
||||||
<text class="jump-txt">前往</text>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<input class="jump-input" placeholder="1" />
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">页</text>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface ProductItem {
|
interface ProductItem {
|
||||||
id: number
|
id: number
|
||||||
@@ -169,6 +168,36 @@ const handleEdit = (item: ProductItem) => { console.log('Editing...', item.id) }
|
|||||||
const toggleStatus = (index: number) => {
|
const toggleStatus = (index: number) => {
|
||||||
productList.value[index].status = !productList.value[index].status
|
productList.value[index].status = !productList.value[index].status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -365,34 +394,7 @@ const toggleStatus = (index: number) => {
|
|||||||
.op-split { color: #e8eaec; margin: 0 5px; }
|
.op-split { color: #e8eaec; margin: 0 5px; }
|
||||||
.text-danger { color: #ed4014; }
|
.text-danger { color: #ed4014; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-val { font-size: 13px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #e8eaec;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 13px; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -90,26 +90,41 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页区域 -->
|
||||||
<view class="table-pagination">
|
<CommonPagination
|
||||||
<text class="total-text">共 {{ total }} 条</text>
|
v-if="total > 0"
|
||||||
<view class="page-ops">
|
:total="total"
|
||||||
<button class="page-btn" disabled>上一页</button>
|
:loading="false"
|
||||||
<text class="current-page">1</text>
|
:currentPage="currentPage"
|
||||||
<button class="page-btn">下一页</button>
|
:pageSize="currentSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
</view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
|
:visiblePages="visiblePages"
|
||||||
|
:totalPage="totalPage"
|
||||||
|
:jumpPageInput="jumpPageInput"
|
||||||
|
@page-size-change="handlePageSizeChange"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="updateJumpPageInput"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script uts>
|
<script uts>
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CommonPagination
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentStatus: -1,
|
currentStatus: -1,
|
||||||
searchQuery: '',
|
searchQuery: '',
|
||||||
total: 8,
|
total: 8,
|
||||||
|
currentPage: 1,
|
||||||
|
currentSize: 15,
|
||||||
|
jumpPageInput: '',
|
||||||
statusOptions: [
|
statusOptions: [
|
||||||
{ label: '全部', value: -1, count: 8 },
|
{ label: '全部', value: -1, count: 8 },
|
||||||
{ label: '待发货', value: 0, count: 6 },
|
{ label: '待发货', value: 0, count: 6 },
|
||||||
@@ -181,6 +196,23 @@ export default {
|
|||||||
] as any[]
|
] as any[]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
pageSizeOptions(): number[] { return [10, 15, 20, 30, 50] },
|
||||||
|
pageSizeOptionLabels(): string[] { return (this.pageSizeOptions as number[]).map((n: number) => `${n}条/页`) },
|
||||||
|
pageSizeIndex(): number {
|
||||||
|
const idx = (this.pageSizeOptions as number[]).indexOf(this.currentSize as number)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
},
|
||||||
|
totalPage(): number { return Math.max(1, Math.ceil((this.total as number) / (this.currentSize as number))) },
|
||||||
|
visiblePages(): number[] {
|
||||||
|
const t = this.totalPage as number
|
||||||
|
const cur = this.currentPage as number
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getStatusLabel(val : number) : string {
|
getStatusLabel(val : number) : string {
|
||||||
const item = this.statusOptions.find((opt: any) => opt.value === val)
|
const item = this.statusOptions.find((opt: any) => opt.value === val)
|
||||||
@@ -215,7 +247,18 @@ export default {
|
|||||||
handleReset() {
|
handleReset() {
|
||||||
this.searchQuery = ''
|
this.searchQuery = ''
|
||||||
this.currentStatus = -1
|
this.currentStatus = -1
|
||||||
}
|
},
|
||||||
|
handlePageChange(p: number) { this.currentPage = p as any },
|
||||||
|
handlePageSizeChange(e: any) {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
this.currentSize = ((this.pageSizeOptions as number[])[idx] ?? (this.pageSizeOptions as number[])[0]) as any
|
||||||
|
this.currentPage = 1 as any
|
||||||
|
},
|
||||||
|
handleJumpPage() {
|
||||||
|
const p = parseInt(this.jumpPageInput as string)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= (this.totalPage as number)) this.currentPage = p as any
|
||||||
|
},
|
||||||
|
updateJumpPageInput(val: string) { this.jumpPageInput = val as any }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -399,14 +442,6 @@ export default {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.table-pagination {
|
|
||||||
padding: 16px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
.total-text { font-size: 14px; color: #515a6e; margin-right: 15px; }
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -86,31 +86,30 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-footer">
|
<CommonPagination
|
||||||
<view class="page-total">
|
v-if="total > 0"
|
||||||
<text class="total-txt">共 {{ total }} 条</text>
|
:total="total"
|
||||||
</view>
|
:loading="false"
|
||||||
<view class="page-select">
|
:currentPage="currentPage"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn"><</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn">></text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
<view class="page-jump">
|
@page-change="handlePageChange"
|
||||||
<text class="jump-txt">前往</text>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<input class="jump-input" placeholder="1" />
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">页</text>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface ProductItem {
|
interface ProductItem {
|
||||||
id: number
|
id: number
|
||||||
@@ -169,6 +168,36 @@ const handleEdit = (item: ProductItem) => { console.log('Editing...', item.id) }
|
|||||||
const toggleStatus = (index: number) => {
|
const toggleStatus = (index: number) => {
|
||||||
productList.value[index].status = !productList.value[index].status
|
productList.value[index].status = !productList.value[index].status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -365,34 +394,7 @@ const toggleStatus = (index: number) => {
|
|||||||
.op-split { color: #e8eaec; margin: 0 5px; }
|
.op-split { color: #e8eaec; margin: 0 5px; }
|
||||||
.text-danger { color: #ed4014; }
|
.text-danger { color: #ed4014; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-val { font-size: 13px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #e8eaec;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #666;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 13px; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -57,21 +57,33 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页区域 -->
|
||||||
<view class="table-pagination">
|
<CommonPagination
|
||||||
<text class="total-text">共 {{ total }} 条</text>
|
v-if="total > 0"
|
||||||
<view class="page-ops">
|
:total="total"
|
||||||
<button class="page-btn" disabled>上一页</button>
|
:loading="false"
|
||||||
<text class="current-page">1</text>
|
:currentPage="currentPage"
|
||||||
<button class="page-btn">下一页</button>
|
:pageSize="currentSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
</view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
|
:visiblePages="visiblePages"
|
||||||
|
:totalPage="totalPage"
|
||||||
|
:jumpPageInput="jumpPageInput"
|
||||||
|
@page-size-change="handlePageSizeChange"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="updateJumpPageInput"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script uts>
|
<script uts>
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CommonPagination
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
searchQuery: '',
|
searchQuery: '',
|
||||||
@@ -83,6 +95,9 @@ export default {
|
|||||||
{ label: '后台充值', value: 'system' }
|
{ label: '后台充值', value: 'system' }
|
||||||
] as any[],
|
] as any[],
|
||||||
total: 5,
|
total: 5,
|
||||||
|
currentPage: 1,
|
||||||
|
currentSize: 15,
|
||||||
|
jumpPageInput: '',
|
||||||
tableData: [
|
tableData: [
|
||||||
{
|
{
|
||||||
id: 1256,
|
id: 1256,
|
||||||
@@ -121,6 +136,21 @@ export default {
|
|||||||
typeLabel(): string {
|
typeLabel(): string {
|
||||||
const found = this.typeOptions.find((o: any): boolean => o.value == this.currentType)
|
const found = this.typeOptions.find((o: any): boolean => o.value == this.currentType)
|
||||||
return found != null ? (found['label'] as string) : '全部'
|
return found != null ? (found['label'] as string) : '全部'
|
||||||
|
},
|
||||||
|
pageSizeOptions(): number[] { return [10, 15, 20, 30, 50] },
|
||||||
|
pageSizeOptionLabels(): string[] { return (this.pageSizeOptions as number[]).map((n: number) => `${n}条/页`) },
|
||||||
|
pageSizeIndex(): number {
|
||||||
|
const idx = (this.pageSizeOptions as number[]).indexOf(this.currentSize as number)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
},
|
||||||
|
totalPage(): number { return Math.max(1, Math.ceil((this.total as number) / (this.currentSize as number))) },
|
||||||
|
visiblePages(): number[] {
|
||||||
|
const t = this.totalPage as number
|
||||||
|
const cur = this.currentPage as number
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -136,7 +166,18 @@ export default {
|
|||||||
},
|
},
|
||||||
handleMark(item: any) {
|
handleMark(item: any) {
|
||||||
uni.showToast({ title: '修改备注: ' + item.id, icon: 'none' })
|
uni.showToast({ title: '修改备注: ' + item.id, icon: 'none' })
|
||||||
}
|
},
|
||||||
|
handlePageChange(p: number) { this.currentPage = p as any },
|
||||||
|
handlePageSizeChange(e: any) {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
this.currentSize = ((this.pageSizeOptions as number[])[idx] ?? (this.pageSizeOptions as number[])[0]) as any
|
||||||
|
this.currentPage = 1 as any
|
||||||
|
},
|
||||||
|
handleJumpPage() {
|
||||||
|
const p = parseInt(this.jumpPageInput as string)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= (this.totalPage as number)) this.currentPage = p as any
|
||||||
|
},
|
||||||
|
updateJumpPageInput(val: string) { this.jumpPageInput = val as any }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -267,36 +308,7 @@ export default {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.table-pagination {
|
|
||||||
padding: 16px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
}
|
|
||||||
.total-text { font-size: 14px; color: #515a6e; margin-right: 15px; }
|
|
||||||
|
|
||||||
.page-ops {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
.page-btn {
|
|
||||||
height: 32px;
|
|
||||||
padding: 0 12px;
|
|
||||||
font-size: 14px;
|
|
||||||
border-radius: 2px;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
background: #fff;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
.current-page {
|
|
||||||
padding: 0 12px;
|
|
||||||
font-size: 14px;
|
|
||||||
color: #2d8cf0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -91,34 +91,31 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total">
|
<CommonPagination
|
||||||
<text class="total-txt">共 {{ seckillList.length }} 条</text>
|
v-if="seckillList.length > 0"
|
||||||
</view>
|
:total="seckillList.length"
|
||||||
<view class="page-select">
|
:loading="false"
|
||||||
<view class="select-mock mini">
|
:currentPage="currentPage"
|
||||||
<text class="select-val">15条/页</text>
|
:pageSize="pageSize"
|
||||||
<text class="arrow">▼</text>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
</view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
</view>
|
:visiblePages="visiblePages"
|
||||||
<view class="page-btns">
|
:totalPage="totalPage"
|
||||||
<text class="p-btn disabled">‹</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
<text class="p-btn active">1</text>
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="p-btn disabled">›</text>
|
@page-change="handlePageChange"
|
||||||
</view>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<view class="page-jump">
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">前往</text>
|
/>
|
||||||
<input class="jump-input" placeholder="1" />
|
|
||||||
<text class="jump-txt">页</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const seckillList = ref([
|
const seckillList = ref([
|
||||||
{
|
{
|
||||||
@@ -159,6 +156,36 @@ const handleDelete = (item: any) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(seckillList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -315,34 +342,7 @@ const handleDelete = (item: any) => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #1890ff; border-color: #1890ff; color: #fff; }
|
|
||||||
.p-btn.disabled { color: #c0c4cc; cursor: not-allowed; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 28px; border: 1px solid #dcdfe6; border-radius: 4px; text-align: center; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -91,34 +91,31 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total">
|
<CommonPagination
|
||||||
<text class="total-txt">共 {{ seckillList.length }} 条</text>
|
v-if="seckillList.length > 0"
|
||||||
</view>
|
:total="seckillList.length"
|
||||||
<view class="page-select">
|
:loading="false"
|
||||||
<view class="select-mock mini">
|
:currentPage="currentPage"
|
||||||
<text class="select-val">15条/页</text>
|
:pageSize="pageSize"
|
||||||
<text class="arrow">▼</text>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
</view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
</view>
|
:visiblePages="visiblePages"
|
||||||
<view class="page-btns">
|
:totalPage="totalPage"
|
||||||
<text class="p-btn disabled">‹</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
<text class="p-btn active">1</text>
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="p-btn disabled">›</text>
|
@page-change="handlePageChange"
|
||||||
</view>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<view class="page-jump">
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">前往</text>
|
/>
|
||||||
<input class="jump-input" placeholder="1" />
|
|
||||||
<text class="jump-txt">页</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
import StatusSwitch from '@/components/StatusSwitch.uvue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const seckillList = ref([
|
const seckillList = ref([
|
||||||
{
|
{
|
||||||
@@ -154,6 +151,36 @@ const handleDelete = (item: any) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(seckillList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -312,34 +339,7 @@ const handleDelete = (item: any) => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #1890ff; border-color: #1890ff; color: #fff; }
|
|
||||||
.p-btn.disabled { color: #c0c4cc; cursor: not-allowed; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 28px; border: 1px solid #dcdfe6; border-radius: 4px; text-align: center; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -105,33 +105,30 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="pagination-footer">
|
<!-- 分页 -->
|
||||||
<view class="page-total">
|
<CommonPagination
|
||||||
<text class="total-txt">共 {{ productList.length }} 条</text>
|
v-if="productList.length > 0"
|
||||||
</view>
|
:total="productList.length"
|
||||||
<view class="page-select">
|
:loading="false"
|
||||||
<view class="select-mock mini">
|
:currentPage="currentPage"
|
||||||
<text class="select-val">15条/页</text>
|
:pageSize="pageSize"
|
||||||
<text class="arrow">▼</text>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
</view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
</view>
|
:visiblePages="visiblePages"
|
||||||
<view class="page-btns">
|
:totalPage="totalPage"
|
||||||
<text class="p-btn disabled">‹</text>
|
:jumpPageInput="jumpPageInput"
|
||||||
<text class="p-btn active">1</text>
|
@page-size-change="handlePageSizeChange"
|
||||||
<text class="p-btn disabled">›</text>
|
@page-change="handlePageChange"
|
||||||
</view>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<view class="page-jump">
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">前往</text>
|
/>
|
||||||
<input class="jump-input" placeholder="1" />
|
|
||||||
<text class="jump-txt">页</text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const productList = ref([
|
const productList = ref([
|
||||||
{
|
{
|
||||||
@@ -199,6 +196,36 @@ const handleDelete = (item: any) => {
|
|||||||
const handleStats = (item: any) => {
|
const handleStats = (item: any) => {
|
||||||
uni.showToast({ title: '统计查看中', icon: 'none' })
|
uni.showToast({ title: '统计查看中', icon: 'none' })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(productList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -396,34 +423,7 @@ const handleStats = (item: any) => {
|
|||||||
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
.op-link { color: #1890ff; font-size: 13px; cursor: pointer; }
|
||||||
.op-split { color: #e8eaec; margin: 0 8px; }
|
.op-split { color: #e8eaec; margin: 0 8px; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 13px; color: #606266; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 13px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #1890ff; border-color: #1890ff; color: #fff; }
|
|
||||||
.p-btn.disabled { color: #c0c4cc; cursor: not-allowed; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 13px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 28px; border: 1px solid #dcdfe6; border-radius: 4px; text-align: center; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|||||||
@@ -29,24 +29,23 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页区域 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-row">
|
<CommonPagination
|
||||||
<text class="total-text">共 {{ groupList.length }} 条</text>
|
v-if="groupList.length > 0"
|
||||||
<view class="page-size-selector">
|
:total="groupList.length"
|
||||||
<text>15条/页</text>
|
:loading="false"
|
||||||
<text class="arrow">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
<view class="page-btns">
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btn disabled"><text>‹</text></view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<view class="page-btn active"><text>1</text></view>
|
:visiblePages="visiblePages"
|
||||||
<view class="page-btn disabled"><text>›</text></view>
|
:totalPage="totalPage"
|
||||||
</view>
|
:jumpPageInput="jumpPageInput"
|
||||||
<view class="page-jump">
|
@page-size-change="handlePageSizeChange"
|
||||||
<text>前往</text>
|
@page-change="handlePageChange"
|
||||||
<input class="jump-input" value="1" />
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<text>页</text>
|
@jump-page="handleJumpPage"
|
||||||
</view>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 添加/修改分组弹窗 -->
|
<!-- 添加/修改分组弹窗 -->
|
||||||
@@ -81,6 +80,7 @@
|
|||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive, computed } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
// 分组数据
|
// 分组数据
|
||||||
const groupList = ref([
|
const groupList = ref([
|
||||||
@@ -162,6 +162,36 @@ function submitForm() {
|
|||||||
|
|
||||||
closeModal()
|
closeModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(groupList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -290,82 +320,7 @@ function submitForm() {
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页样式 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-row {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.total-text {
|
|
||||||
margin-right: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-size-selector {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 8px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 2px;
|
|
||||||
margin-right: 16px;
|
|
||||||
|
|
||||||
.arrow {
|
|
||||||
font-size: 10px;
|
|
||||||
margin-left: 8px;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-btns {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
margin-right: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 2px;
|
|
||||||
margin-right: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
background: #1890ff;
|
|
||||||
border-color: #1890ff;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
color: #ccc;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-jump {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.jump-input {
|
|
||||||
width: 48px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 2px;
|
|
||||||
margin: 0 8px;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 弹窗样式 */
|
/* 弹窗样式 */
|
||||||
.modal-mask {
|
.modal-mask {
|
||||||
|
|||||||
@@ -29,24 +29,23 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页区域 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-row">
|
<CommonPagination
|
||||||
<text class="total-text">共 {{ labelList.length }} 条</text>
|
v-if="labelList.length > 0"
|
||||||
<view class="page-size-selector">
|
:total="labelList.length"
|
||||||
<text>15条/页</text>
|
:loading="false"
|
||||||
<text class="arrow">▼</text>
|
:currentPage="currentPage"
|
||||||
</view>
|
:pageSize="pageSize"
|
||||||
<view class="page-btns">
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btn disabled"><text>‹</text></view>
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<view class="page-btn active"><text>1</text></view>
|
:visiblePages="visiblePages"
|
||||||
<view class="page-btn disabled"><text>›</text></view>
|
:totalPage="totalPage"
|
||||||
</view>
|
:jumpPageInput="jumpPageInput"
|
||||||
<view class="page-jump">
|
@page-size-change="handlePageSizeChange"
|
||||||
<text>前往</text>
|
@page-change="handlePageChange"
|
||||||
<input class="jump-input" value="1" />
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<text>页</text>
|
@jump-page="handleJumpPage"
|
||||||
</view>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 添加/修改标签弹窗 -->
|
<!-- 添加/修改标签弹窗 -->
|
||||||
@@ -81,6 +80,7 @@
|
|||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive, computed } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
// 标签数据
|
// 标签数据
|
||||||
const labelList = ref([
|
const labelList = ref([
|
||||||
@@ -160,6 +160,36 @@ function submitForm() {
|
|||||||
|
|
||||||
closeModal()
|
closeModal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(labelList.value.length / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@@ -288,78 +318,7 @@ function submitForm() {
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 分页样式 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-row {
|
|
||||||
margin-top: 24px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
color: #666;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.total-text {
|
|
||||||
margin-right: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-size-selector {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 0 8px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 2px;
|
|
||||||
margin-right: 16px;
|
|
||||||
|
|
||||||
.arrow {
|
|
||||||
font-size: 10px;
|
|
||||||
margin-left: 8px;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-btns {
|
|
||||||
display: flex;
|
|
||||||
margin-right: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 2px;
|
|
||||||
margin-right: 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&.active {
|
|
||||||
background: #1890ff;
|
|
||||||
border-color: #1890ff;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.disabled {
|
|
||||||
color: #ccc;
|
|
||||||
cursor: not-allowed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-jump {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
.jump-input {
|
|
||||||
width: 48px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #d9d9d9;
|
|
||||||
border-radius: 2px;
|
|
||||||
margin: 0 8px;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 弹窗样式 */
|
/* 弹窗样式 */
|
||||||
.modal-mask {
|
.modal-mask {
|
||||||
|
|||||||
@@ -73,24 +73,22 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页 -->
|
<!-- 分页 -->
|
||||||
<view class="pagination-footer">
|
<CommonPagination
|
||||||
<view class="page-total">
|
v-if="total > 0"
|
||||||
<text class="total-txt">共 {{ total }} 条</text>
|
:total="total"
|
||||||
</view>
|
:loading="false"
|
||||||
<view class="page-select">
|
:currentPage="currentPage"
|
||||||
<text class="page-val">15条/页 ▼</text>
|
:pageSize="pageSize"
|
||||||
</view>
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
<view class="page-btns">
|
:pageSizeIndex="pageSizeIndex"
|
||||||
<text class="p-btn disabled"><</text>
|
:visiblePages="visiblePages"
|
||||||
<text class="p-btn active">1</text>
|
:totalPage="totalPage"
|
||||||
<text class="p-btn">></text>
|
:jumpPageInput="jumpPageInput"
|
||||||
</view>
|
@page-size-change="handlePageSizeChange"
|
||||||
<view class="page-jump">
|
@page-change="handlePageChange"
|
||||||
<text class="jump-txt">前往</text>
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
<input class="jump-input" placeholder="1" />
|
@jump-page="handleJumpPage"
|
||||||
<text class="jump-txt">页</text>
|
/>
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
@@ -157,7 +155,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
interface LevelItem {
|
interface LevelItem {
|
||||||
id: number
|
id: number
|
||||||
@@ -183,6 +182,36 @@ const levelList = ref<LevelItem[]>([
|
|||||||
|
|
||||||
const showDrawer = ref(false)
|
const showDrawer = ref(false)
|
||||||
const isClosing = ref(false)
|
const isClosing = ref(false)
|
||||||
|
|
||||||
|
// 分页适配状态
|
||||||
|
const currentPage = ref(1)
|
||||||
|
const pageSize = ref(15)
|
||||||
|
let jumpPageInput = ''
|
||||||
|
const pageSizeOptions = [10, 15, 20, 30, 50]
|
||||||
|
const pageSizeOptionLabels = computed(() => pageSizeOptions.map((n: number) => `${n}条/页`))
|
||||||
|
const pageSizeIndex = computed(() => {
|
||||||
|
const idx = pageSizeOptions.indexOf(pageSize.value)
|
||||||
|
return idx >= 0 ? idx : 0
|
||||||
|
})
|
||||||
|
const totalPage = computed(() => Math.max(1, Math.ceil(total.value / pageSize.value)))
|
||||||
|
const visiblePages = computed(() => {
|
||||||
|
const t = totalPage.value
|
||||||
|
const cur = currentPage.value
|
||||||
|
if (t <= 7) return Array.from({ length: t }, (_: any, i: number) => i + 1)
|
||||||
|
if (cur <= 4) return [1, 2, 3, 4, 5, -1, t]
|
||||||
|
if (cur >= t - 3) return [1, -1, t - 4, t - 3, t - 2, t - 1, t]
|
||||||
|
return [1, -1, cur - 1, cur, cur + 1, -1, t]
|
||||||
|
})
|
||||||
|
const handlePageChange = (p: number) => { currentPage.value = p }
|
||||||
|
const handlePageSizeChange = (e: any) => {
|
||||||
|
const idx = Number(e.detail.value)
|
||||||
|
pageSize.value = pageSizeOptions[idx] ?? pageSizeOptions[0]
|
||||||
|
currentPage.value = 1
|
||||||
|
}
|
||||||
|
const handleJumpPage = () => {
|
||||||
|
const p = parseInt(jumpPageInput)
|
||||||
|
if (!isNaN(p) && p >= 1 && p <= totalPage.value) currentPage.value = p
|
||||||
|
}
|
||||||
const isEdit = ref(false)
|
const isEdit = ref(false)
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
@@ -400,34 +429,7 @@ const handleSave = () => {
|
|||||||
.op-split { color: #e8eaec; margin: 0 5px; }
|
.op-split { color: #e8eaec; margin: 0 5px; }
|
||||||
.text-danger { color: #ed4014; }
|
.text-danger { color: #ed4014; }
|
||||||
|
|
||||||
/* 分页 */
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
.pagination-footer {
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
.total-txt { font-size: 14px; color: #606266; }
|
|
||||||
.page-val { font-size: 14px; color: #606266; border: 1px solid #dcdfe6; padding: 4px 10px; border-radius: 4px; }
|
|
||||||
.page-btns { display: flex; flex-direction: row; gap: 8px; }
|
|
||||||
.p-btn {
|
|
||||||
width: 32px;
|
|
||||||
height: 32px;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 4px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
.p-btn.active { background-color: #2d8cf0; border-color: #2d8cf0; color: #fff; }
|
|
||||||
.p-btn.disabled { color: #c0c4cc; background-color: #f5f7fa; }
|
|
||||||
|
|
||||||
.page-jump { display: flex; flex-direction: row; align-items: center; gap: 8px; }
|
|
||||||
.jump-txt { font-size: 14px; color: #606266; }
|
|
||||||
.jump-input { width: 40px; height: 32px; border: 1px solid #dcdfe6; text-align: center; border-radius: 4px; font-size: 14px; }
|
|
||||||
|
|
||||||
/* Drawer Styles */
|
/* Drawer Styles */
|
||||||
.drawer-mask {
|
.drawer-mask {
|
||||||
|
|||||||
@@ -138,17 +138,31 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 分页区域 (模拟) -->
|
<!-- 分页 -->
|
||||||
<view class="pagination">
|
<CommonPagination
|
||||||
<text class="page-info">共 80834 条数据</text>
|
v-if="total > 0"
|
||||||
</view>
|
:total="total"
|
||||||
|
:loading="false"
|
||||||
|
:currentPage="currentPage"
|
||||||
|
:pageSize="pageSize"
|
||||||
|
:pageSizeOptionLabels="pageSizeOptionLabels"
|
||||||
|
:pageSizeIndex="pageSizeIndex"
|
||||||
|
:visiblePages="visiblePages"
|
||||||
|
:totalPage="totalPage"
|
||||||
|
:jumpPageInput="jumpPageInput"
|
||||||
|
@page-size-change="handlePageSizeChange"
|
||||||
|
@page-change="handlePageChange"
|
||||||
|
@update:jumpPageInput="(val : string) => { jumpPageInput = val }"
|
||||||
|
@jump-page="handleJumpPage"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="uts">
|
<script setup lang="uts">
|
||||||
import { ref } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
import CommonPagination from '@/components/CommonPagination/CommonPagination.uvue'
|
||||||
|
|
||||||
const activeTab = ref(0)
|
const activeTab = ref(0)
|
||||||
const tabs = ['全部', '微信公众号', '微信小程序', 'H5', 'PC', 'APP']
|
const tabs = ['全部', '微信公众号', '微信小程序', 'H5', 'PC', 'APP']
|
||||||
@@ -513,16 +527,5 @@ function onDetail(user: any) {
|
|||||||
margin: 0 8px;
|
margin: 0 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination {
|
/* 分页区域已迁至 CommonPagination 组件 */
|
||||||
padding: 16px 24px;
|
|
||||||
border-top: 1px solid #f0f0f0;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: flex-start;
|
|
||||||
}
|
|
||||||
|
|
||||||
.page-info {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user