Explorar el Código

:bug: Fixing a bug. #814 pigx-ui前端字典管理分页BUG

:bug: Fixing a bug. #814 pigx-ui前端字典管理分页BUG
冷冷 hace 5 años
padre
commit
52d0bf06cd
Se han modificado 2 ficheros con 110 adiciones y 106 borrados
  1. 49 41
      src/views/admin/dict/index.vue
  2. 61 65
      src/views/admin/log/index.vue

+ 49 - 41
src/views/admin/dict/index.vue

@@ -47,18 +47,19 @@
     </basic-container>
     <el-dialog
       :visible.sync="dialogFormVisible"
-      :table-loading="tableLoading"
       title="字典项管理"
       width="90%"
       @close="dialogFormVisible=false">
       <avue-crud
         ref="crudItem"
+        :page="itemPage"
         :data="tableDictItemData"
         :permission="permissionList"
         v-model="form"
         :before-open="handleBeforeOpen"
         :option="tableDictItemOption"
-        :table-loading="tableLoading"
+        @size-change="itemSizeChange"
+        @current-change="itemCurrentChange"
         @row-update="handleItemUpdate"
         @row-save="handleItemSave"
         @row-del="rowItemDel"/>
@@ -90,15 +91,16 @@
           currentPage: 1, // 当前页数
           pageSize: 20 // 每页显示多少条
         },
+        itemPage: {
+          total: 0, // 总页数
+          currentPage: 1, // 当前页数
+          pageSize: 20 // 每页显示多少条
+        },
         tableLoading: false,
         tableOption: tableOption,
         tableDictItemOption: tableDictItemOption
       }
     },
-    created() {
-    },
-    mounted: function () {
-    },
     computed: {
       ...mapGetters(['permissions']),
       permissionList() {
@@ -110,6 +112,7 @@
       }
     },
     methods: {
+      //======字典表格相关=====
       getList(page, params) {
         this.tableLoading = true
         fetchList(Object.assign({
@@ -121,27 +124,7 @@
           this.tableLoading = false
         })
       },
-
-      getDictItemList(dictId, type) {
-        this.dictType = type
-        this.dictId = dictId
-        this.dialogFormVisible = true
-        this.tableLoading = true
-        fetchItemList(Object.assign({
-          current: this.page.currentPage,
-          size: this.page.pageSize
-        }, {dictId: dictId})).then(response => {
-          this.tableDictItemData = response.data.data.records
-          this.tableLoading = false
-        })
-      },
-      handleBeforeOpen(done) {
-        this.form.type = this.dictType
-        this.form.dictId = this.dictId
-        done()
-      },
       rowDel: function (row) {
-        var _this = this
         this.$confirm('是否确认删除数据类型为"' + row.type + '"的数据项?', '警告', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
@@ -150,7 +133,7 @@
           return delObj(row)
         }).then(() => {
           this.getList(this.page)
-          _this.$message.success('删除成功')
+          this.$message.success('删除成功')
         }).catch(function () {
         })
       },
@@ -168,6 +151,38 @@
           done()
         })
       },
+      searchChange(form, done) {
+        this.searchForm = form
+        this.getList(this.page, form)
+        done()
+      },
+      sizeChange(pageSize) {
+        this.page.pageSize = pageSize
+      },
+      currentChange(current) {
+        this.page.currentPage = current
+      },
+      //======字典项表格相关=====
+      handleItem: function (row) {
+        this.getDictItemList(row.id, row.type)
+      },
+      getDictItemList(dictId, type) {
+        this.dictType = type
+        this.dictId = dictId
+        this.dialogFormVisible = true
+        fetchItemList(Object.assign({
+          current: this.itemPage.currentPage,
+          size: this.itemPage.pageSize
+        }, {dictId: dictId})).then(response => {
+          this.tableDictItemData = response.data.data.records
+          this.itemPage.total = response.data.data.total
+        })
+      },
+      handleBeforeOpen(done) {
+        this.form.type = this.dictType
+        this.form.dictId = this.dictId
+        done()
+      },
       handleItemSave: function (row, done) {
         addItemObj(row).then(() => {
           this.$message.success('添加成功')
@@ -182,22 +197,15 @@
           done()
         })
       },
-      searchChange(form, done) {
-        this.searchForm = form
-        this.getList(this.page, form)
-        done()
-      },
-      sizeChange(pageSize) {
-        this.page.pageSize = pageSize
-      },
-      currentChange(current) {
-        this.page.currentPage = current
+      itemSizeChange(pageSize) {
+        this.itemPage.pageSize = pageSize
+        this.getDictItemList(this.dictId, this.type)
       },
-      handleItem: function (row) {
-        this.getDictItemList(row.id, row.type)
+      itemCurrentChange(current) {
+        this.itemPage.currentPage = current
+        this.getDictItemList(this.dictId, this.type)
       },
       rowItemDel: function (row) {
-        var _this = this
         this.$confirm('是否确认删除数据为"' + row.label + '"的数据项?', '警告', {
           confirmButtonText: '确定',
           cancelButtonText: '取消',
@@ -206,7 +214,7 @@
           return delItemObj(row.id)
         }).then(() => {
           this.getDictItemList(row.dictId, row.type)
-          _this.$message.success('删除成功')
+          this.$message.success('删除成功')
         }).catch(function () {
         })
       }

+ 61 - 65
src/views/admin/log/index.vue

@@ -36,76 +36,72 @@
 </template>
 
 <script>
-import { delObj, fetchList } from '@/api/admin/log'
-import { tableOption } from '@/const/crud/admin/log'
-import { mapGetters } from 'vuex'
+  import {delObj, fetchList} from '@/api/admin/log'
+  import {tableOption} from '@/const/crud/admin/log'
+  import {mapGetters} from 'vuex'
 
-export default {
-  name: 'Log',
-  data() {
-    return {
-      tableData: [],
-      searchForm: {},
-      page: {
-        total: 0, // 总页数
-        currentPage: 1, // 当前页数
-        pageSize: 20 // 每页显示多少条
-      },
-      tableLoading: false,
-      tableOption: tableOption
-    }
-  },
-  created() {
-  },
-  mounted: function() {
-  },
-  computed: {
-    ...mapGetters(['permissions']),
-    permissionList() {
+  export default {
+    name: 'Log',
+    data() {
       return {
-        delBtn: this.vaildData(this.permissions.sys_log_del, false)
+        tableData: [],
+        searchForm: {},
+        page: {
+          total: 0, // 总页数
+          currentPage: 1, // 当前页数
+          pageSize: 20 // 每页显示多少条
+        },
+        tableLoading: false,
+        tableOption: tableOption
       }
-    }
-  },
-  methods: {
-    getList(page, params) {
-      this.tableLoading = true
-      fetchList(Object.assign({
-        descs: 'create_time',
-        current: page.currentPage,
-        size: page.pageSize
-      }, params, this.searchForm)).then(response => {
-        this.tableData = response.data.data.records
-        this.page.total = response.data.data.total
-        this.tableLoading = false
-      })
-    },
-    handleDel: function(row) {
-      this.$confirm('是否确认删除ID为"' + row.id + '"的日志?', '警告', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(function() {
-        return delObj(row.id)
-      }).then(() => {
-        this.getList(this.page)
-        this.$message.success('删除成功')
-      })
-    },
-    searchChange(form, done) {
-      this.searchForm = form
-      this.getList(this.page, form)
-      done()
     },
-    sizeChange(pageSize){
-      this.page.pageSize = pageSize
-    },
-    currentChange(current){
-      this.page.currentPage = current
+    computed: {
+      ...mapGetters(['permissions']),
+      permissionList() {
+        return {
+          delBtn: this.vaildData(this.permissions.sys_log_del, false)
+        }
+      }
     },
-    refreshChange() {
-      this.getList(this.page)
+    methods: {
+      getList(page, params) {
+        this.tableLoading = true
+        fetchList(Object.assign({
+          descs: 'create_time',
+          current: page.currentPage,
+          size: page.pageSize
+        }, params, this.searchForm)).then(response => {
+          this.tableData = response.data.data.records
+          this.page.total = response.data.data.total
+          this.tableLoading = false
+        })
+      },
+      handleDel: function (row) {
+        this.$confirm('是否确认删除ID为"' + row.id + '"的日志?', '警告', {
+          confirmButtonText: '确定',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(function () {
+          return delObj(row.id)
+        }).then(() => {
+          this.getList(this.page)
+          this.$message.success('删除成功')
+        })
+      },
+      searchChange(form, done) {
+        this.searchForm = form
+        this.getList(this.page, form)
+        done()
+      },
+      sizeChange(pageSize) {
+        this.page.pageSize = pageSize
+      },
+      currentChange(current) {
+        this.page.currentPage = current
+      },
+      refreshChange() {
+        this.getList(this.page)
+      }
     }
   }
-}
 </script>