chenrui před 4 roky
rodič
revize
b826930d9f

+ 52 - 33
src/views/salesManagement/salesQuery/productSalesRecordModal.vue

@@ -20,12 +20,11 @@
         class="sTable"
         ref="table"
         size="small"
-        :data-source="list"
-        :pagination="pagination"
-        :loading="loading"
-        :row-key="(record) => record.id"
+        :rowKey="(record) => record.id"
         :columns="columns"
-        @change="handleTableChange"
+        :dataSource="list"
+        :loading="loading"
+        :pagination="paginationProps"
         bordered>
       </a-table>
     </div>
@@ -58,9 +57,7 @@ export default {
       isShow: this.openModal, //  是否打开弹框
       buyerSn: null,
       queryParam: {
-        productSn: null,
-        pageNo: 1,
-        pageSize: 10
+        productSn: null
       },
       // 表头
       columns: [
@@ -91,29 +88,19 @@ export default {
       list: [],
       pagination: {},
       loading: false,
-      curTab: '1'
+      curTab: '1',
+      pageNo: 1, //  分页页码
+      pageSize: 10, //  分页 每页多少条
+      paginationProps: {
+        showSizeChanger: true, //  是否可以改变 pageSize
+        total: 0, //  分页总条数
+        current: 1,
+        onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
+        onChange: (current) => this.changePage(current)
+      }
     }
   },
   methods: {
-    handleTableChange (pagination, filters, sorter) {
-      console.log(pagination)
-      const pager = { ...this.pagination }
-      pager.current = pagination.current
-      this.pagination = pager
-      this.loading = true
-      this.queryParam = Object.assign(this.queryParam, {
-        results: pagination.pageSize,
-        page: pagination.current,
-        sortField: sorter.field,
-        sortOrder: sorter.order,
-        ...filters
-      })
-
-      salesRecordlList(this.queryParam).then(res => {
-        this.list = res.data.list || []
-        this.loading = false
-      })
-    },
     //  获取详情
     getDetail (buyerSn, productSn) {
       this.buyerSn = buyerSn
@@ -123,16 +110,44 @@ export default {
         delete this.queryParam.buyerSn
       }
       this.queryParam.productSn = productSn
-      this.queryParam.pageNo = 1
-      this.queryParam.pageSize = 10
+      this.handelSearch(1)
+    },
+    // 查询列表
+    handelSearch (pageNo) {
+      this.pageNo = pageNo || this.pageNo
+      const params = {
+        pageNo: this.pageNo,
+        pageSize: this.pageSize
+      }
+      // 开始查询
       this.loading = true
-      salesRecordlList(this.queryParam).then(res => {
-        this.list = res.data.list || []
+      salesRecordlList({ ...params, ...this.queryParam }).then(res => {
         this.loading = false
+        if (res.status == 200) {
+          const data = res.data
+          this.paginationProps.total = Number(res.data.count) || 0
+          this.paginationProps.current = data.pageNo
+          this.list = data.list
+        } else {
+          this.paginationProps.total = 0
+          this.paginationProps.current = 1
+          this.list = []
+        }
       })
     },
+    //  分页  一页多少条change
+    changePageSize (current, pageSize) {
+      this.pageNo = current
+      this.pageSize = pageSize
+      this.handelSearch()
+    },
+    //  分页 页码change
+    changePage (current) {
+      console.log(current)
+      this.pageNo = current
+      this.handelSearch()
+    },
     callback (key) {
-      console.log(key)
       this.curTab = key
       this.getDetail(this.buyerSn, this.queryParam.productSn)
     }
@@ -146,6 +161,10 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
+        this.pageNo = 1
+        this.pageSize = 10
+        this.paginationProps.total = 0
+        this.paginationProps.current = 1
         this.curTab = '1'
         this.list = []
       }