chenrui 2 anos atrás
pai
commit
f587e30b33

+ 40 - 30
src/views/dealerManagement/businessOwnerSettings/categorySet.vue

@@ -5,14 +5,17 @@
         <div class="table-operator" ref="categorySetAddBtn">
           <a-button type="primary" class="button-error" @click="addCategory" :disabled="disabled">+新增管辖品类</a-button>
         </div>
-        <a-table
-          bordered
-          :data-source="dataSource"
-          :columns="columns"
+        <s-table
+          class="sTable fixPagination"
           ref="table"
-          style="word-break: break-all;">
-          <!-- :style="{ height: tableHeight+84.5+'px' }"
-          :scroll="{ y: tableHeight }" -->
+          :style="{ height: tableHeight+84.5+'px' }"
+          size="small"
+          :rowKey="(record) => record.id"
+          :columns="columns"
+          :data="loadData"
+          :scroll="{ y: tableHeight }"
+          :defaultLoadData="false"
+          bordered>
           <!-- 产品分类 -->
           <template slot="classify" slot-scope="text,record,index">
             <div style="max-height:64px;overflow-y:scroll;">
@@ -71,7 +74,7 @@
               删除
             </a-button>
           </span>
-        </a-table>
+        </s-table>
       </a-card>
     </a-spin>
     <!-- 选择产品品牌 -->
@@ -85,11 +88,12 @@
 import { commonMixin } from '@/utils/mixin'
 import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
+import { STable } from '@/components'
 import { getNewScopeSn, bizuserScopeQueryPage, saveProductBrandList, saveProductTypeList, bizuserScopeDelete, deleteProductBrand, deleteProductType } from '@/api/bizuser'
 export default {
   name: 'CategorySet',
   mixins: [commonMixin],
-  components: { ChooseBrandModal, ChooseTypeModal },
+  components: { ChooseBrandModal, ChooseTypeModal, STable },
   props: {
     bizUserSn: {
       type: String,
@@ -106,6 +110,11 @@ export default {
         { title: '品牌', dataIndex: 'name', width: '42%', align: 'center', scopedSlots: { customRender: 'brand' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: '16%', align: 'center' }
       ],
+      queryParam: {
+        userSn: this.$route.query.sn,
+        hasDetail: 1,
+        bizUserSn: this.bizUserSn
+      },
       dataSource: [],
       openModal: false, //  新增编辑产品品牌  弹框
       itemSn: '', //  当前sn
@@ -114,7 +123,25 @@ export default {
       openTypeModal: false,
       chooseBrand: [],
       chooseType: [],
-      chooseObj: null// 选择品牌 内容
+      chooseObj: null, // 选择品牌 内容
+      // 加载数据方法 必须为 Promise 对象
+      loadData: parameter => {
+        this.disabled = true
+        this.spinning = true
+        return bizuserScopeQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
+          let data
+          data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          this.total = data.count || 0
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
+          }
+          this.dataSource = data.list
+          this.disabled = false
+          this.spinning = false
+          return data
+        })
+      }
     }
   },
   methods: {
@@ -232,7 +259,7 @@ export default {
         saveProductBrandList(ajaxdata).then(res => {
           if (res.status == 200) {
             this.openBrandModal = false
-            this.getTableData()
+            this.$refs.table.refresh()
           }
         })
       } else if (type == 'CATEGORY') {
@@ -240,7 +267,7 @@ export default {
         saveProductTypeList(ajaxdata).then(res => {
           if (res.status == 200) {
             this.openTypeModal = false
-            this.getTableData()
+            this.$refs.table.refresh()
           }
         })
       }
@@ -267,24 +294,7 @@ export default {
       this.$nextTick(() => { // 页面渲染完成后的回调
         _this.setTableH()
       })
-      this.getTableData()
-    },
-    // 获取列表数据
-    getTableData (params = {}) {
-      this.spinning = true
-      bizuserScopeQueryPage({
-        pageNo: 1,
-        pageSize: 20,
-        userSn: this.$route.query.sn,
-        hasDetail: 1,
-        bizUserSn: this.bizUserSn,
-        ...params
-      }).then(res => {
-        if (res.status == 200) {
-          this.dataSource = res.data.list
-        }
-        this.spinning = false
-      })
+      this.$refs.table.refresh()
     },
     setTableH () {
       const addBtnHeight = this.$refs.categorySetAddBtn.offsetHeight