chenrui 2 سال پیش
والد
کامیت
62db79eca6
1فایلهای تغییر یافته به همراه27 افزوده شده و 27 حذف شده
  1. 27 27
      src/views/promotionRulesManagement/promotionManagement/chooseDealer.vue

+ 27 - 27
src/views/promotionRulesManagement/promotionManagement/chooseDealer.vue

@@ -55,7 +55,7 @@
       :scroll="{ y: 230 }"
       :bordered="true"
       :pagination="pagination"
-      :row-key="record => record.no"
+      :row-key="record => record.dealerSn"
       :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
       :columns="columns"
       :data-source="dealerList"
@@ -68,7 +68,7 @@
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
 import AreaList from '@/views/common/areaList.js'
-import { dealerQueryList } from '@/api/dealer'
+import { dealerQueryList, getDealerListInfo } from '@/api/dealer'
 import subarea from '@/views/common/subarea.js'
 export default {
   name: 'ChooseDealer',
@@ -130,26 +130,24 @@ export default {
   },
   methods: {
     onSelectChange (selectedRowKeys) {
-      console.log('selectedRowKeys changed: ', selectedRowKeys)
       this.selectedRowKeys = selectedRowKeys
     },
     handlePage (pagination, filters, sorter) {
-      console.log(pagination);
-      const pager = { ...this.pagination };
-      pager.current = pagination.current;
-      pager.pageSize = pagination.pageSize;
-      this.pagination = pager;
-      
+      const pager = { ...this.pagination }
+      pager.current = pagination.current
+      pager.pageSize = pagination.pageSize
+      this.pagination = pager
+
       this.loadData({ pageNo: pagination.current, pageSize: pagination.pageSize })
     },
     loadData (pager) {
       this.spinning = true
-      const params = {pageSize: 20,pageNo:1,...pager}
+      const params = { pageSize: 20, pageNo: 1, ...pager }
       dealerQueryList(Object.assign(params, this.queryParam)).then(res => {
         let data
         if (res.status == 200) {
           data = res.data
-          const pagination = { ...this.pagination };
+          const pagination = { ...this.pagination }
           pagination.total = data.count
           const no = 0
           for (var i = 0; i < data.list.length; i++) {
@@ -157,6 +155,10 @@ export default {
           }
           this.dealerList = data.list
           this.pagination = pagination
+          if (this.chooseInfo && !this.pageFlag) {
+            this.pageFlag = true
+            this.selectedRowKeys = this.chooseInfo
+          }
         }
         this.spinning = false
       })
@@ -170,8 +172,8 @@ export default {
       this.queryParam.citySn = val[1] ? val[1] : ''
       this.queryParam.districtSn = val[2] ? val[2] : ''
     },
-    searchForm (flag) {
-      this.$refs.table.refresh(flag)
+    searchForm () {
+      this.loadData()
       this.spinning = false
     },
     subareaChange (val) {
@@ -198,8 +200,13 @@ export default {
       } else {
         this.$refs.areaList.clearData()
       }
-      this.$refs.table.clearSelected()
-      this.$refs.table.refresh(true)
+      this.pagination = {
+        pageSize: 20,
+        showSizeChanger: true,
+        current: 1
+      }
+      this.selectedRowKeys = []
+      this.loadData()
       this.pageFlag = false
     },
     clearTable () {
@@ -207,22 +214,15 @@ export default {
       this.$refs.table.clearTable()
     },
     // 批量添加
-    handleBatchAudit () {
+    async handleBatchAudit () {
       const _this = this
-      if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
+      if (_this.selectedRowKeys && _this.selectedRowKeys.length < 1) {
         _this.$message.warning('请在列表勾选后再进行批量操作!')
         return
       }
-      const dealerSnList = _this.rowSelectionInfo.selectedRows
-      // const newDealerSnList = dealerSnList.map(con => {
-      //   const obj = {
-      //     buyerName: con.dealerName,
-      //     buyerSn: con.dealerSn
-      //   }
-      //   return obj
-      // })
+      const dealerInfoList = await getDealerListInfo({ dealerSnList: _this.selectedRowKeys })
       this.spinning = false
-      this.$emit('plAdd', dealerSnList)
+      this.$emit('plAdd', dealerInfoList.data)
     },
     handleAdd (row) {
       if (row.subareaArea) {
@@ -247,7 +247,7 @@ export default {
         _this.setTableH()
       })
       this.chooseInfo = data || []
-      this.loadData()
+      this.resetSearchForm()
     },
     setTableH () {
       const tableSearchH = this.$refs.tableSearch.offsetHeight