Bladeren bron

经销权

chenrui 1 jaar geleden
bovenliggende
commit
f89f7ad2c1

+ 2 - 2
src/api/dealerScope.js

@@ -84,7 +84,7 @@ export const dealerScopeCreate = (params) => {
 //  经销权  修改价格级别
 export const dealerScopeModifyPriceLevel = (params) => {
   return axios({
-    url: '/dealerScope/modifyPriceLevel',
+    url: '/dealerScope/modifyPriceLevelBatch',
     data: params,
     method: 'post',
     headers: {
@@ -95,7 +95,7 @@ export const dealerScopeModifyPriceLevel = (params) => {
 // 经销权  删除选择品类
 export const dealerScopeDelete = (params) => {
   return axios({
-    url: '/dealerScope/delete',
+    url: '/dealerScope/deleteBatch',
     data: params,
     method: 'post',
     headers: {

+ 135 - 42
src/views/dealerManagement/merchantInfoManagement/chooseTypeModal.vue

@@ -29,34 +29,27 @@
             placeholder="请选择价格级别"></v-select>
         </a-form-model-item>
         <a-form-model-item label="添加品类" prop="typeVal">
-          <a-radio-group v-model="form.typeVal" @change="onChangeType">
-            <a-radio :value="1">
-              全选
-            </a-radio>
-            <a-radio :value="2">
-              自主品牌
-            </a-radio>
-            <a-radio :value="3">
-              代理品牌
-            </a-radio>
-            <a-radio :value="4">
+          <a-checkbox v-for="(con,i) in filterList" :checked="con.checked" :key="con.id" @change="e=>onChangeType(e.target.checked,i)">
+            <span v-show="con.id!=4">{{ con.name }}</span>
+            <span v-show="con.id==4">
               <a-tooltip placement="rightTop">
                 <template slot="title">
                   <span>选择全品类后,未来新加入的品类也将自动默认为已选择状态,无需再次手动操作。</span>
                 </template>
-                <span>全品类</span>
+                <span>{{ con.name }}</span>
                 <a-icon type="question-circle" style="margin-left:5px;" />
               </a-tooltip>
-            </a-radio>
-          </a-radio-group>
+            </span>
+          </a-checkbox>
         </a-form-model-item>
-        <div class="typeListBox">
+        <div class="typeListBox" v-show="form.typeVal!=4">
           <a-tree
             v-model="checkedList"
             checkable
             :auto-expand-parent="autoExpandParent"
             :tree-data="treeData"
             :replaceFields="replaceObj"
+            :checkStrictly="true"
             @check="onCheck"
           />
         </div>
@@ -70,7 +63,7 @@
 </template>
 
 <script>
-import { dealerScopeCreate, queryWaitingData } from '@/api/dealerScope'
+import { dealerScopeCreate, queryWaitingData, dealerScopeQueryList } from '@/api/dealerScope'
 import chooseTypeList from './chooseTypeList.vue'
 import { VSelect } from '@/components'
 export default {
@@ -92,7 +85,7 @@ export default {
       },
       form: {
         priceLevel: undefined, // 价格级别
-        typeVal: ''
+        typeVal: '0'
       },
       rules: {
         priceLevel: [
@@ -109,25 +102,85 @@ export default {
       autoExpandParent: false, // 是否自动展开父节点
       replaceObj: {
         children: 'sonList', title: 'name', key: 'sn'
-      }
+      },
+      disabledList: [], // 已选过禁用调的品类数据
+      filterList: [{ id: '1', name: '全选', checked: false }, { id: '2', name: '自主品牌', checked: false }, { id: '3', name: '代理品牌', checked: false }, { id: '4', name: '全品类', checked: false }],
+      allBarndSnList: [],
+      ownBarndSnList: [],
+      agentBarndSnList: []
     }
   },
   methods: {
-    onChangeType () {
-
+    onChangeType (val, pos) {
+      this.filterList.map(item => item.checked = false)
+      this.filterList[pos].checked = val
+      // 选择全品类   隐藏选择品类数据
+      this.form.typeVal = '0'
+      if (pos === 3 && val) {
+        this.form.typeVal = this.filterList[pos].id
+      }
+      this.checkedList = []
+      // 全选
+      if (pos === 0 && val) {
+        this.checkedList = this.allBarndSnList
+      }
+      // 自主
+      if (pos === 1 && val) {
+        this.checkedList = this.ownBarndSnList
+      }
+      if (pos === 2 && val) {
+        this.checkedList = this.agentBarndSnList
+      }
+    },
+    // 获取品牌sn
+    getLevel1Data () {
+      // 全选
+      const allBarndSn = []; const ownBarndSn = []; const agentBarndSn = []
+      this.treeData.forEach(con => {
+        allBarndSn.push(con.sn)
+        if (con.productBrandType === '1') {
+          ownBarndSn.push(con.sn)
+        }
+        if (con.productBrandType === '2') {
+          agentBarndSn.push(con.sn)
+        }
+      })
+      // 全选
+      this.allBarndSnList = allBarndSn
+      // 自主品牌
+      this.ownBarndSnList = ownBarndSn
+      // 代理品牌
+      this.agentBarndSnList = agentBarndSn
     },
     //  保存
     handleSave () {
       const _this = this
-      const checkedArr = _this.changeCheckedList()
-      debugger
-      const getTableList = _this.$refs.chooseTypeInfo.chooseDataList
-      _this.form.productScopeList = getTableList
       _this.$refs.ruleForm.validate(valid => {
         if (valid) {
           const formData = JSON.parse(JSON.stringify(_this.form))
+          if (formData.typeVal != '4') {
+            const checkedArr = _this.changeCheckedList()
+            if (checkedArr.length == 0) {
+              _this.$message.warning('请选择添加品类!')
+              return
+            }
+            const arr = []
+            checkedArr.forEach(item => {
+              const newArr = item.split('_')
+              arr.push({
+                productBrandSn: newArr[2],
+                productTypeSn1: newArr[4] ? newArr[4] : undefined,
+                productTypeSn2: newArr[6] ? newArr[6] : undefined,
+                productTypeSn3: newArr[8] ? newArr[8] : undefined
+              })
+            })
+            formData.scopeList = arr
+          } else {
+            formData.scopeList = []
+          }
           formData.dealerSn = _this.$route.params.sn
           _this.spinning = true
+          delete formData.typeVal
           dealerScopeCreate(formData).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
@@ -147,29 +200,70 @@ export default {
       const _this = this
       queryWaitingData({}).then(res => {
         if (res.status == 200) {
-          _this.treeData = res.data
-          _this.spinning = false
-        } else {
-          _this.spinning = false
+          if (_this.disabledList && _this.disabledList.length > 0) {
+            const newTreeData = _this.resetDisabledList(res.data, _this.disabledList)
+            _this.treeData = newTreeData
+          } else {
+            _this.treeData = res.data
+          }
+          _this.getLevel1Data()
         }
+        _this.spinning = false
       })
     },
+    async getDisabledList () {
+      const res = await dealerScopeQueryList({ dealerSn: this.$route.params.sn })
+      // 重组数据
+      if (res.status === '200') {
+        const disabledList = res.data.map(item => {
+          return '-1_1_' + item.productBrandSn + (item.productTypeSn1 ? '_2_' + item.productTypeSn1 : '') + (item.productTypeSn2 ? '_3_' + item.productTypeSn2 : '') + (item.productTypeSn3 ? '_4_' + item.productTypeSn3 : '')
+        })
+        this.disabledList = disabledList
+        this.getDataList()
+      }
+    },
+    resetDisabledList (tree, arr) {
+      // 遍历树节点
+      function traverse (node) {
+        // 检查当前节点的 key 是否在 arr 中
+        if (arr.includes(node.sn)) {
+          // 如果在,则添加 disabled 属性
+          node.disableCheckbox = true
+        }
+
+        // 如果节点有子节点,则递归遍历子节点
+        if (node.sonList) {
+          node.sonList.forEach(child => traverse(child))
+        }
+      }
+
+      // 从树的根节点开始遍历
+      tree.forEach(node => traverse(node))
+
+      // 返回修改后的树
+      return tree
+    },
     onCheck (checkedKeys) {
-      console.log('onCheck', checkedKeys)
-      this.checkedList = checkedKeys
+      this.checkedList = checkedKeys.checked
+      this.filterList[0].checked = this.checkedList.length === this.allBarndSnList.length
+      this.filterList[1].checked = this.checkedList.length === this.ownBarndSnList.length
+      this.filterList[2].checked = this.checkedList.length === this.agentBarndSnList.length
     },
     changeCheckedList () {
-      const arr = this.checkedList.map(item => {
-        const newArr = item.split('_')
-        const obj = {
-          productBrandSn: newArr[2],
-          productTypeSn1: newArr[4] ? newArr[4] : undefined,
-          productTypeSn2: newArr[6] ? newArr[6] : undefined,
-          productTypeSn3: newArr[8] ? newArr[8] : undefined
+      const ret = []
+      this.checkedList.forEach((item, index) => {
+        var flag = true
+        this.checkedList.forEach(con => {
+          if (con.includes(item + '_')) {
+            flag = false
+          }
+        })
+        if (flag) {
+          ret.push(item)
         }
-        return obj
       })
-      return arr
+
+      return ret
     }
   },
   watch: {
@@ -181,17 +275,16 @@ export default {
     isShow (newValue, oldValue) {
       if (!newValue) {
         this.$refs.ruleForm.resetFields()
+        this.filterList.map(item => item.checked = false)
         this.$emit('close')
       } else {
+        // 特约经销商   价格级别不能修改  省、市经销商时,不能选择特约价
         if (this.$route.params.dealerLevel === 'special') {
           this.form.priceLevel = 'SPECIAL'
           this.notArrFlag = true
         } else {
           this.notArr = ['SPECIAL']
         }
-        this.$nextTick(() => {
-          this.getDataList()
-        })
       }
     }
   }

+ 54 - 28
src/views/dealerManagement/merchantInfoManagement/permissionSettingNew.vue

@@ -42,7 +42,11 @@
         </div>
         <!-- 操作按钮 -->
         <div class="table-operator">
-          <a-button id="permissionSetting-brand" type="primary" class="button-error" @click="chooseTModal">选择品类</a-button>
+          <a-button type="primary" class="button-info" @click="chooseTModal">选择品类</a-button>
+          <span v-if="!showEmpty && $route.params.dealerLevel != 'special'">
+            <a-button type="primary" class="button-success" @click="handleEdit()">批量编辑</a-button>
+            <a-button type="primary" class="button-error" @click="handleDel()">批量删除</a-button>
+          </span>
         </div>
         <!-- 列表 -->
         <div :style="{height:tableHeight+'px'}">
@@ -57,7 +61,7 @@
             :virtual-scroll-option="{enable: true}"
             :columns="columns"
             :table-data="dataSource"
-            row-key-field-name="no"
+            row-key-field-name="dealerScopeSn"
             :checkbox-option="checkboxOption"
           />
           <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
@@ -65,7 +69,7 @@
       </a-card>
     </a-spin>
     <!-- 选择产品分类 -->
-    <chooseTypeModal :openModal="openTypeModal" @close="openTypeModal=false" @ok="handleTypeOk" />
+    <chooseTypeModal ref="chooseType" :openModal="openTypeModal" @close="openTypeModal=false" @ok="resetSearchForm" />
     <!-- 修改价格等级 -->
     <editPriceLevelModal :priceLevelVal="itemPriceLevel" :openModal="openPriceLevelModal" @close="closePriceLevelModal" @ok="handlePriceLevelOk" />
   </div>
@@ -97,26 +101,14 @@ export default {
       },
       productType: [],
       disabled: false, //  查询、重置按钮是否可操作
-      loading: false, //  表格加载中
       openTypeModal: false, //  选择产品分类
-      chooseType: [], //  所选分类
       openPriceLevelModal: false,
-      itemSn: null,
       itemPriceLevel: '',
       simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
       dataSource: [],
       showEmpty: false,
       showTableHead: true, // 显示表头
-      checkboxOption: {
-        // 行选择改变事件
-        selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
-          console.log(row, isSelected, selectedRowKeys)
-        },
-        // 全选改变事件
-        selectedAllChange: ({ isSelected, selectedRowKeys }) => {
-          console.log(isSelected, selectedRowKeys)
-        }
-      }
+      selectedRowKeys: []
     }
   },
   computed: {
@@ -128,7 +120,7 @@ export default {
           return (
             <div>
               <a-button size="small" type="link" class="button-info" onClick={() => _this.handleEdit(record)}>编辑</a-button>
-              <a-button size="small" type="link" class="button-info" onClick={() => _this.handleDel(record)}>删除</a-button>
+              <a-button size="small" type="link" class="button-error" onClick={() => _this.handleDel(record)}>删除</a-button>
             </div>
           )
         } else {
@@ -153,6 +145,20 @@ export default {
         { title: '操作', field: 'action', width: 100, key: 'e', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return actionFormat(row, row[column.field], h) } }
       ]
       return arr
+    },
+    checkboxOption () {
+      const _this = this
+      return {
+        selectedRowKeys: _this.selectedRowKeys,
+        // 行选择改变事件
+        selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
+          _this.selectedRowKeys = selectedRowKeys
+        },
+        // 全选改变事件
+        selectedAllChange: ({ isSelected, selectedRowKeys }) => {
+          _this.selectedRowKeys = selectedRowKeys
+        }
+      }
     }
   },
   methods: {
@@ -173,11 +179,23 @@ export default {
     // 选择品类
     chooseTModal () {
       this.openTypeModal = true
+      this.$nextTick(() => {
+        this.$refs.chooseType.getDisabledList()
+      })
     },
     // 打开编辑弹窗
     handleEdit (row) {
-      this.itemSn = row.dealerScopeSn
-      this.itemPriceLevel = row.priceLevel
+      if (row) {
+        this.selectedRowKeys = []
+        this.selectedRowKeys.push(row.dealerScopeSn)
+        this.itemPriceLevel = row.priceLevel
+      } else {
+        this.itemPriceLevel = ''
+        if (this.selectedRowKeys && this.selectedRowKeys.length === 0) {
+          this.$message.warning('请选择一条数据')
+          return
+        }
+      }
       this.$nextTick(() => {
         this.openPriceLevelModal = true
       })
@@ -185,9 +203,13 @@ export default {
     // 编辑价格等级
     handlePriceLevelOk (val) {
       const _this = this
-      dealerScopeModifyPriceLevel({ dealerScopeSn: this.itemSn, priceLevel: val }).then(res => {
+      dealerScopeModifyPriceLevel({
+        snList: this.selectedRowKeys,
+        priceLevel: val
+      }).then(res => {
         if (res.status == 200) {
           _this.$message.success(res.message)
+          _this.resetSearchForm()
           _this.spinning = false
         } else {
           _this.spinning = false
@@ -196,7 +218,6 @@ export default {
     },
     closePriceLevelModal () {
       this.itemPriceLevel = ''
-      this.itemSn = null
       this.openPriceLevelModal = false
     },
     //  选择分类  change
@@ -205,23 +226,27 @@ export default {
       this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
       this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
     },
-    // 选择品类完成
-    handleTypeOk (obj) {
-      // this.$refs.table.refresh(true)
-    },
-    // 删除
+    // 批量删除
     handleDel (row) {
       const _this = this
+      if (!row && this.selectedRowKeys && this.selectedRowKeys.length === 0) {
+        this.$message.warning('请选择一条数据')
+        return
+      }
+      if (row) {
+        this.selectedRowKeys = []
+        this.selectedRowKeys.push(row.dealerScopeSn)
+      }
       this.$confirm({
         title: '提示',
         content: '删除后无法向总部或上级采购,确认删除吗?',
         centered: true,
         onOk () {
           _this.spinning = true
-          dealerScopeDelete({ dealerScopeSn: row.dealerScopeSn }).then(res => {
+          dealerScopeDelete({ snList: _this.selectedRowKeys }).then(res => {
             if (res.status == 200) {
               _this.$message.success(res.message)
-              // _this.$refs.table.refresh()
+              _this.resetSearchForm()
               _this.spinning = false
             } else {
               _this.spinning = false
@@ -242,6 +267,7 @@ export default {
     },
     // 返回
     handleBack () {
+      this.selectedRowKeys = []
       this.$router.push({ path: '/dealerManagement/merchantInfoManagement/list', query: { closeLastOldTab: true } })
     },
     pageInit () {

+ 0 - 3
src/views/dealerManagement/merchantInfoManagement/priceLevelModal.vue

@@ -96,9 +96,6 @@ export default {
         this.$emit('close')
       } else {
         this.form.priceLevel = this.priceLevelVal ? this.priceLevelVal : undefined
-        this.$nextTick(() => {
-          this.$refs.chooseTypeInfo.getTableData()
-        })
       }
     }
   }