chenrui 4 лет назад
Родитель
Сommit
1b062feba2

+ 8 - 0
src/api/dealerScope.js

@@ -11,6 +11,14 @@ export const dealerScopeList = (params) => {
     method: 'post'
   })
 }
+//  经销权 列表 无分页
+export const dealerScopeQueryList = (params) => {
+  return axios({
+    url: '/dealerScope/queryList',
+    data: params,
+    method: 'post'
+  })
+}
 //  经销权  添加
 export const dealerScopeSave = (params) => {
   return axios({

+ 26 - 7
src/views/common/chooseProductsModal.vue

@@ -12,7 +12,6 @@
       <div>
         <!-- 搜索条件 -->
         <div class="table-page-search-wrapper">
-          <!-- <a-form layout="inline" @keyup.enter.native="getProductList(1)"> -->
           <a-form-model
             layout="inline"
             ref="ruleForm"
@@ -28,7 +27,7 @@
                 </a-form-model-item>
               </a-col>
               <a-col :md="6" :sm="24">
-                <a-form-model-item label="产品品牌" prop="productBrandSn">
+                <a-form-model-item label="产品品牌" :prop="type=='dealership'?'productBrandSn':''">
                   <a-select
                     placeholder="请选择产品品牌"
                     id="chooseProducts-productBrandSn"
@@ -42,7 +41,7 @@
                 </a-form-model-item>
               </a-col>
               <a-col :md="6" :sm="24">
-                <a-form-model-item label="产品分类" prop="productType">
+                <a-form-model-item label="产品分类" :prop="type=='dealership'?'productType':''">
                   <a-cascader
                     @change="changeProductType"
                     change-on-select
@@ -69,7 +68,7 @@
           ref="table"
           size="small"
           :rowKey="(record) => record.productSn"
-          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onChange, onSelect: onSelectChange }"
+          :row-selection="{ selectedRowKeys: selectedRowKeys, onChange: onChange, onSelect: onSelectChange, onSelectAll: onSelectAllChange }"
           :data-source="loadData"
           :columns="columns"
           :pagination="paginationProps"
@@ -115,6 +114,10 @@ export default {
       default: () => {
         return []
       }
+    },
+    type: { //  类型,经销权设置dealership
+      type: String,
+      default: ''
     }
   },
   data () {
@@ -153,7 +156,6 @@ export default {
         onShowSizeChange: (current, pageSize) => this.changePageSize(current, pageSize),
         onChange: (current) => this.changePage(current)
       },
-      // productType: [],
       productBrandList: [], //  品牌下拉数据
       productTypeList: [], //  分类下拉数据
       selectedRowKeys: [],
@@ -184,7 +186,8 @@ export default {
     //  重置
     resetSearchForm () {
       this.resetData()
-      this.getProductList(1)
+      this.loadData = []
+      this.disabled = false
     },
     // 保存
     handleSave () {
@@ -210,6 +213,21 @@ export default {
         })
       }
     },
+    // 本页全选/取消全选
+    onSelectAllChange (selected, selectedRows, changeRows) {
+      const _this = this
+      if (selected) { //  选择
+        this.selectedRows = [...this.selectedRows, ...changeRows]
+      } else { //  取消
+        this.selectedRows.map((item, index) => {
+          this.selectedRows.map((subItem, ind) => {
+            if (item.productSn == subItem.productSn) {
+              _this.selectedRows.splice(index, 1)
+            }
+          })
+        })
+      }
+    },
     // 产品列表
     getProductList (pageNo) {
       this.pageNo = pageNo || this.pageNo
@@ -219,7 +237,6 @@ export default {
         pageSize: this.pageSize
       }
       this.loading = true
-      delete this.queryParam.productType
       productList(Object.assign(params, this.queryParam)).then(res => {
         this.loading = false
         if (res.status == 200) {
@@ -291,6 +308,8 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$emit('close')
+        this.loadData = []
+        this.disabled = false
         this.resetData()
       } else {
         this.selectedRows = this.chooseData

+ 62 - 73
src/views/dealerManagement/merchantInfoManagement/permissionSetting.vue

@@ -64,15 +64,15 @@
       </div>
       <!-- 操作按钮 -->
       <div class="table-operator">
-        <a-button id="permissionSetting-brand" type="primary" class="button-error" @click="choosePModal('brand')">选择产品品牌</a-button>
-        <a-button id="permissionSetting-type" type="primary" class="button-info" @click="choosePModal('type')">选择产品分类</a-button>
-        <a-button id="permissionSetting-product" type="primary" class="button-success" @click="choosePModal('product')">选择产品</a-button>
+        <a-button id="permissionSetting-brand" type="primary" class="button-error" @click="choosePModal('BRAND')">选择产品品牌</a-button>
+        <a-button id="permissionSetting-type" type="primary" class="button-info" @click="choosePModal('CATEGORY')">选择产品分类</a-button>
+        <a-button id="permissionSetting-product" type="primary" class="button-success" @click="choosePModal('PRODUCT')">选择产品</a-button>
       </div>
       <!-- 列表 -->
       <a-table
         class="sTable"
         ref="table"
-        size="default"
+        size="small"
         :rowKey="(record) => record.id"
         :columns="columns"
         :data-source="loadData"
@@ -91,7 +91,7 @@
     <!-- 选择产品分类 -->
     <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
     <!-- 选择产品 -->
-    <chooseProductsModal :openModal="openProductsModal" :chooseData="chooseProducts" @close="openProductsModal=false" @ok="handleProductsOk" />
+    <chooseProductsModal type="dealership" :openModal="openProductsModal" :chooseData="chooseProducts" @close="openProductsModal=false" @ok="handleProductsOk" />
   </div>
 </template>
 
@@ -102,7 +102,7 @@ import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
 import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
 import { productBrandQuery } from '@/api/productBrand'
 import { productTypeQuery } from '@/api/productType'
-import { dealerScopeList, dealerScopeSave, dealerScopeDel } from '@/api/dealerScope'
+import { dealerScopeList, dealerScopeSave, dealerScopeDel, dealerScopeQueryList } from '@/api/dealerScope'
 export default {
   components: { STable, VSelect, ChooseProductsModal, ChooseBrandModal, ChooseTypeModal },
   data () {
@@ -123,28 +123,12 @@ export default {
       columns: [
         { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
         { title: '添加时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '类型', dataIndex: 'productBrandName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '类型名称', dataIndex: 'origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
-        { title: '产品编码', dataIndex: 'code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型', dataIndex: 'type', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '类型名称', dataIndex: 'goodsName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品名称', dataIndex: 'product.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '产品编码', dataIndex: 'product.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
         { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
       ],
-      // 加载数据方法 必须为 Promise 对象
-      // loadData: parameter => {
-      //   this.disabled = true
-      //   if (this.tableHeight == 0) {
-      //     this.tableHeight = window.innerHeight - 380
-      //   }
-      //   return dealerScopeList(Object.assign(parameter, this.queryParam, { dealerSn: this.$route.params.sn })).then(res => {
-      //     const data = res.data
-      //     const no = (data.pageNo - 1) * data.pageSize
-      //     for (var i = 0; i < data.list.length; i++) {
-      //       data.list[i].no = no + i + 1
-      //     }
-      //     this.disabled = false
-      //     return data
-      //   })
-      // },
       loadData: [],
       pageNo: 1, //  分页页码
       pageSize: 10, //  分页 每页多少条
@@ -187,6 +171,8 @@ export default {
           const no = (data.pageNo - 1) * data.pageSize
           for (var i = 0; i < data.list.length; i++) {
             data.list[i].no = no + i + 1
+            const goodsType = data.list[i].goodsType
+            data.list[i].type = goodsType == 'PRODUCT' ? '产品' : goodsType == 'BRAND' ? '品牌' : goodsType == 'CATEGORY' ? '分类' : '--'
           }
           this.loadData = data.list
           this.disabled = false
@@ -213,90 +199,93 @@ export default {
       const productList = []
       const brandList = []
       const typeList = []
-      // this.loadData.map(item => {
-      //   if (item.goodsType == 'PRODUCT') {
-      //     productList.push(item)
-      //   } else if (item.goodsType == 'BRAND') {
-      //     brandList.push(item)
-      //   } else if ((item.goodsType == 'TYPE_1') || (item.goodsType == 'TYPE_2') || (item.goodsType == 'TYPE_3')) {
-      //     typeList.push(item)
-      //   }
-      // })
-      if (type == 'product') { //  选择产品
-        this.chooseProducts = productList
-        this.openProductsModal = true
-      } else if (type == 'brand') { //  选择品牌
-        this.chooseBrand = brandList
-        this.openBrandModal = true
-      } else if (type == 'type') { //  选择分类
-        this.chooseType = typeList
-        this.openTypeModal = true
-      }
+      dealerScopeQueryList({ dealerSn: this.$route.params.sn, goodsType: type }).then(res => {
+        if (res.status == 200) {
+          const data = res.data
+          data.map(item => {
+            if (item.goodsType == 'PRODUCT') {
+              productList.push(item)
+            } else if (item.goodsType == 'BRAND') {
+              brandList.push(item)
+            } else if (item.goodsType == 'CATEGORY') {
+              typeList.push(item)
+            }
+          })
+          console.log('chanp', productList)
+          console.log('pinpai', brandList)
+          console.log('fenlei', typeList)
+          if (type == 'PRODUCT') { //  选择产品
+            this.chooseProducts = productList
+            this.openProductsModal = true
+          } else if (type == 'BRAND') { //  选择品牌
+            this.chooseBrand = brandList
+            this.openBrandModal = true
+          } else if (type == 'CATEGORY') { //  选择分类
+            this.chooseType = typeList
+            this.openTypeModal = true
+          }
+        }
+      })
     },
     // 品牌
     handleBrandOk (obj) {
       console.log(obj, '---------------品牌')
       this.chooseBrand = obj
-      this.changeData('brand')
+      this.changeData('BRAND')
     },
     // 产品
     handleProductsOk (obj) {
       console.log(obj, '---------------产品')
       this.chooseProducts = obj
-      this.changeData('product')
+      this.changeData('PRODUCT')
     },
     // 分类
     handleTypeOk (obj) {
       console.log(obj, '---------------分类')
       this.chooseType = obj
-      this.changeData('type')
+      this.changeData('CATEGORY')
     },
     changeData (type) {
       const _this = this
-      if (type == 'product') { //  选择产品
+      if (type == 'PRODUCT') { //  选择产品
         if (_this.chooseProducts.length > 0) {
+          const snList = []
           _this.chooseProducts.map(item => {
-            item.goodsType = 'PRODUCT'
-            item.goodsTypeName = '产品'
-            item.goodsName = item.name
-            item.goodsSn = item.productSn
-            item.goodsCode = item.code
-            delete item.id
+            const productSn = item.productSn ? item.productSn : item.product.productSn ? item.product.productSn : ''
+            snList.push(productSn)
           })
-          this.setData(_this.chooseProducts)
+          this.setData(snList, type)
         }
-      } else if (type == 'brand') { //  选择品牌
+      } else if (type == 'BRAND') { //  选择品牌
         if (_this.chooseBrand.length > 0) {
+          const snList = []
           _this.chooseBrand.map(item => {
-            item.goodsType = 'BRAND'
-            item.goodsTypeName = '品牌'
-            item.goodsName = item.brandName
-            item.goodsSn = item.brandSn
-            delete item.id
+            snList.push(item.brandSn)
           })
-          this.setData(_this.chooseBrand)
+          this.setData(snList, type)
         }
-      } else if (type == 'type') { //  选择分类
+      } else if (type == 'CATEGORY') { //  选择分类
         if (_this.chooseType.length > 0) {
+          const snList = []
           _this.chooseType.map(item => {
-            item.goodsType = 'TYPE_' + item.productTypeLevel
-            item.goodsTypeName = (item.productTypeLevel == 1 ? '一级' : item.productTypeLevel == 2 ? '二级' : item.productTypeLevel == 3 ? '三级' : '') + '分类'
-            item.goodsName = item.productTypeName
-            item.goodsSn = item.productTypeSn
-            delete item.id
+            snList.push(item.productTypeSn)
           })
-          this.setData(_this.chooseType)
+          this.setData(snList, type)
         }
       }
     },
     // 添加经销权
-    setData (data) {
+    setData (snList, type) {
       const _this = this
       const params = {
-        dealerSn: _this.$route.params.sn
+        dealerSn: _this.$route.params.sn,
+        goodsType: type,
+        goodsSnList: snList
       }
+      console.log('传参-------------', snList)
       dealerScopeSave(params).then(res => {
-        if (res.data == 200) {
+        if (res.status == 200) {
+          console.log('----------chenggong')
           _this.$message.success(res.message)
           _this.getProductList(1)
         }