Selaa lähdekoodia

Merge branch 'master' of 350469199/pigx-ui into dev

pig666 5 vuotta sitten
vanhempi
commit
351f4ce9af
3 muutettua tiedostoa jossa 41 lisäystä ja 7 poistoa
  1. 0 1
      src/const/logs/index.js
  2. 40 6
      src/page/logs/index.vue
  3. 1 0
      src/store/modules/logs.js

+ 0 - 1
src/const/logs/index.js

@@ -1,7 +1,6 @@
 export default {
   menu: false,
   addBtn: false,
-  page: false,
   border: true,
   expand: true,
   refreshBtn: false,

+ 40 - 6
src/page/logs/index.vue

@@ -1,7 +1,10 @@
 <template>
   <avue-crud
-    :data="logsList"
-    :option="option">
+    :data="list"
+    :option="option"
+    :page="page"
+    @current-change="currentChange"
+    @size-change="sizeChange">
     <template slot="menuLeft">
       <el-button
         type="primary"
@@ -38,17 +41,46 @@ export default {
   name: 'ErrLogs',
   data() {
     return {
-      option: option
+      // 默认不分页,若记录数超过,则分页
+      onePageMaxSize: 10,
+      page: {
+        currentPage: 1,
+        pageSize: 10,
+        total: 0
+      },
+      option: option,
+      list: []
     }
   },
   created() {
 
   },
-  mounted() { },
+  mounted() {
+    this.getList();
+  },
   computed: {
-    ...mapGetters(['logsList'])
+    ...mapGetters(['logsList', 'logsLen'])
   },
   methods: {
+    sizeChange(pageSize) {
+      this.page.pageSize = pageSize;
+      this.getList();
+    },
+    currentChange(currentPage) {
+      this.page.currentPage = currentPage;
+      this.getList();
+    },
+    getList() {
+      const total = this.logsLen;
+      if (total <= this.onePageMaxSize) {
+        this.list = this.logsList;
+      } else {
+        const currentPage = this.page.currentPage;
+        const pageSize = this.page.pageSize;
+        this.list = this.logsList.slice((currentPage - 1) * pageSize, currentPage * pageSize);
+        this.page.total = total;
+      }
+    },
     send() {
       this.$confirm('确定上传本地日志到服务器?', '提示', {
         confirmButtonText: '确定',
@@ -69,6 +101,8 @@ export default {
         cancelButtonText: '取消',
         type: 'warning'
       }).then(() => {
+        this.page.currentPage = 1;
+        this.page.total = 0;
         this.$store.commit('CLEAR_LOGS')
         this.$parent.$parent.box = false
         this.$message.success( '清空成功!')
@@ -86,6 +120,6 @@ export default {
   display: block;
   font-family: monospace;
   white-space: pre;
-  margin: 1em 0px;
+  margin: 0 1em;
 }
 </style>

+ 1 - 0
src/store/modules/logs.js

@@ -22,6 +22,7 @@ const logs = {
   mutations: {
     ADD_LOGS: (state, { type, message, stack, info }) => {
       state.logsList.push(Object.assign({
+        id: state.logsList.length,
         url: window.location.href,
         time: dateFormat(new Date())
       }, {