1
PC-20250623MANY\Administrator
2025-08-23 7c4de2cb1422f6f4748928df5bbcc802d85dd820
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
  <div class="n_pagination flex-center">
    <div
      class="n_pagination_item flex-center"
      @click="prev"
      :class="pageNo <= 1 ? 'prohibited' : ''"
    >
      <span>{{ $t("Previous") }}</span>
    </div>
    <div class="n_page_number flex-center">
      <span>{{ pageNo }}</span>
      <span>/</span>
      <span>{{ totalPage }}</span>
    </div>
    <div
      class="n_pagination_item flex-center"
      @click="next"
      :class="pageNo >= totalPage ? 'prohibited' : ''"
    >
      <span>{{ $t("Next") }}</span>
    </div>
  </div>
</template>
 
<script>
export default {
  name: "nPagination",
  props: {
    total: {
      type: Number,
      default: 1
    },
    pageSize: {
      type: Number,
      default: 10
    },
    pageNo: {
      type: Number,
      default: 1
    },
    // 是否跳转到页面顶部
    toTop: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      pageList: []
      //   totalPage: 0
    };
  },
  watch: {
    total() {
      this.init();
    },
    pageSize() {
      this.init();
    },
    pageNo() {
      if (this.toTop) {
        // 页码变动时跳转到页面顶部
        window.scrollTo({
          top: 0,
          behavior: "smooth"
        });
      }
    }
  },
  computed: {
    totalPage() {
      return Math.ceil(this.total / this.pageSize);
    }
  },
  methods: {
    init() {
      // this.totalPage = Math.ceil(this.total / this.pageSize)
      // console.log("aaaaaaaaaaaaaaaaaaaaa");
      // this.pageList = []
      // for (let i = 1; i <= this.totalPage; i++) {
      //     this.pageList.push(i)
      // }
    },
    next() {
      if (this.pageNo < this.totalPage) {
        this.$emit("update:pageNo", this.pageNo + 1);
      }
    },
    prev() {
      if (this.pageNo > 1) {
        this.$emit("update:pageNo", this.pageNo - 1);
      }
    }
  }
};
</script>
 
<style lang="less" scoped>
@green2: #f0f0f0;
@green: #c4d600;
 
.n_pagination {
  width: 100%;
  height: 2em;
  color: #646566;
 
  .n_page_number {
    width: 3em;
 
    span {
      font-size: 0.37em;
    }
  }
 
  .n_pagination_item {
    border: 0.01em solid @green2;
    width: 3em;
    height: 1em;
    color: @green;
    background-color: #fff;
 
    span {
      font-size: 0.4em;
    }
  }
 
  .prohibited {
    background-color: #f7f8fa;
    color: #c4c5c6;
  }
}
</style>