Procházet zdrojové kódy

Merge branch 'develop_yh39' of http://git.chelingzhu.com/jianguan-web/jg-ocs-html into develop_yh39

lilei před 1 rokem
rodič
revize
9eecee3c6b

+ 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: {

+ 0 - 196
src/views/dealerManagement/merchantInfoManagement/chooseTypeList.vue

@@ -1,196 +0,0 @@
-<template>
-  <div>
-    <div ref="tableSearch" class="table-page-search-wrapper">
-      <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
-        <a-row :gutter="15">
-          <a-col :md="6" :sm="24">
-            <a-form-item label="品牌分类">
-              <v-select
-                code="BRAND_TYPE"
-                id="inventoryQueryList-productBrandType"
-                v-model="queryParam.productBrandType"
-                allowClear
-                placeholder="请选择品牌分类"></v-select>
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-item label="产品品牌">
-              <ProductBrand id="inventoryQueryList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-model-item label="产品分类">
-              <ProductType id="inventoryQueryList-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
-            </a-form-model-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-button type="primary" @click="getTableData" :disabled="disabled" id="inventoryQueryList-refresh">查询</a-button>
-            <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryQueryList-reset">重置</a-button>
-          </a-col>
-        </a-row>
-      </a-form>
-    </div>
-    <!-- 表格区域 -->
-    <!-- cellSelectionOption 单元格选择 -->
-    <a-spin :spinning="spinning" tip="Loading...">
-      <ve-table
-        border-y
-        v-show="!showEmpty"
-        :scroll-width="0"
-        :max-height="tableHeight"
-        :show-header="showTableHead"
-        :row-style-option="{clickHighlight: true}"
-        :cellSelectionOption="{enable: false}"
-        :virtual-scroll-option="{enable: true}"
-        :columns="columns"
-        :table-data="dataSource"
-        row-key-field-name="no"
-        :checkbox-option="checkboxOption"
-      />
-      <div v-show="showEmpty" class="empty-data"><a-empty description="暂无产品" :image="simpleImage"/></div>
-    </a-spin>
-  </div>
-</template>
-
-<script>
-import { commonMixin } from '@/utils/mixin'
-import ProductType from '@/views/common/productType.js'
-import ProductBrand from '@/views/common/productBrand.js'
-import { Empty } from 'ant-design-vue'
-import { queryWaitingData } from '@/api/dealerScope'
-import { VSelect } from '@/components'
-export default {
-  name: 'DetailProductList',
-  mixins: [commonMixin],
-  components: { ProductType, ProductBrand, VSelect },
-  props: {
-    maxHeight: {
-      type: [String, Number],
-      default: '300'
-    }
-  },
-  data () {
-    return {
-      spinning: false,
-      disabled: false,
-      showEmpty: false,
-      tableHeight: this.maxHeight,
-      showTableHead: true, // 显示表头
-      chooseDataList: [],
-      selectedRowKeys: [],
-      queryParam: {
-        productBrandType: undefined,
-        productBrandSn: undefined,
-        productTypeSn1: undefined, //  产品一级分类
-        productTypeSn2: undefined, //  产品二级分类
-        productTypeSn3: undefined //  产品三级分类
-      },
-      productType: [],
-      simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
-      dataSource: []
-    }
-  },
-  computed: {
-    columns () {
-      const arr = [
-        { title: '', field: '', key: 'acheck', width: 60, type: 'checkbox', align: 'center' },
-        { title: '品牌', field: 'productBrandName', key: 'a', align: 'center', width: 160, operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
-        { title: '一级分类', field: 'productTypeName1', key: 'b', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
-        { title: '二级分类', field: 'productTypeName2', key: 'c', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } },
-        { title: '三级分类', field: 'productTypeName3', key: 'd', width: 160, align: 'center', operationColumn: false, renderBodyCell: ({ row, column }) => { return row[column.field] || '--' } }
-      ]
-      return arr
-    },
-    checkboxOption () {
-      return {
-        selectedRowKeys: this.selectedRowKeys,
-        // 行选择改变事件
-        selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
-          const selectedRowKeysInfo = selectedRowKeys.map(item => {
-            return { productBrandSn: this.dataSource[item - 1].productBrandSn,
-              productTypeSn1: this.dataSource[item - 1].productTypeSn1,
-              productTypeSn2: this.dataSource[item - 1].productTypeSn2,
-              productTypeSn3: this.dataSource[item - 1].productTypeSn3 }
-          })
-          this.selectedRowKeys = selectedRowKeys
-          this.chooseDataList = selectedRowKeysInfo
-        },
-        // 全选改变事件
-        selectedAllChange: ({ isSelected, selectedRowKeys }) => {
-          const selectedRowKeysInfo = selectedRowKeys.map(item => {
-            return { productBrandSn: this.dataSource[item - 1].productBrandSn,
-              productTypeSn1: this.dataSource[item - 1].productTypeSn1,
-              productTypeSn2: this.dataSource[item - 1].productTypeSn2,
-              productTypeSn3: this.dataSource[item - 1].productTypeSn3 }
-          })
-          this.selectedRowKeys = selectedRowKeys
-          this.chooseDataList = selectedRowKeysInfo
-        }
-      }
-    }
-  },
-  methods: {
-    getTableData () {
-      const _this = this
-      _this.spinning = true
-      _this.disabled = true
-      const ajaxData = JSON.parse(JSON.stringify(_this.queryParam))
-      ajaxData.dealerSn = _this.$route.params.sn
-      queryWaitingData(ajaxData).then(res => {
-        if (res.status == 200 && res.data && res.data.length > 0) {
-          for (var i = 0; i < res.data.length; i++) {
-            res.data[i].no = i + 1
-          }
-          _this.dataSource = res.data
-        } else {
-          _this.dataSource = []
-        }
-        _this.showEmpty = _this.dataSource.length <= 0
-        _this.tableHeight = (_this.showEmpty ? 300 : _this.maxHeight) + 'px'
-        _this.spinning = false
-        _this.disabled = false
-      })
-    },
-    resetSearchForm () {
-      this.queryParam = {
-        productBrandType: undefined,
-        productBrandSn: undefined,
-        productTypeSn1: undefined, //  产品一级分类
-        productTypeSn2: undefined, //  产品二级分类
-        productTypeSn3: undefined //  产品三级分类
-      }
-      this.productType = []
-      this.getTableData()
-      this.clearSelectTable()
-    },
-    changeProductType (val, opt) {
-      this.queryParam.productTypeSn1 = val[0] ? val[0] : undefined
-      this.queryParam.productTypeSn2 = val[1] ? val[1] : undefined
-      this.queryParam.productTypeSn3 = val[2] ? val[2] : undefined
-    },
-    // 清空选项
-    clearSelectTable () {
-      this.selectedRowKeys = []
-      this.chooseDataList = []
-    }
-  }
-
-}
-</script>
-
-<style lang="less" scoped>
-  .empty-data{
-        color: #999;
-        text-align: center;
-        padding: 20px;
-        border:1px solid #eee;
-    }
-    /* 修改表格多选框颜色 */
-  /deep/.ve-checkbox .ve-checkbox-checked .ve-checkbox-inner {
-      background-color: #ed1c24 !important;
-      border-color: #ed1c24 !important;
-    }
-  /deep/.ve-checkbox .ve-checkbox-indeterminate .ve-checkbox-inner::after{
-    background-color: #ed1c24 !important;
-  }
-</style>

+ 147 - 46
src/views/dealerManagement/merchantInfoManagement/chooseTypeModal.vue

@@ -7,7 +7,7 @@
     title="选择品类"
     v-model="isShow"
     @cancel="isShow=false"
-    width="50%">
+    :width="960">
     <a-spin :spinning="spinning" tip="Loading...">
       <!-- 表单 -->
       <a-form-model
@@ -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,12 +63,12 @@
 </template>
 
 <script>
-import { dealerScopeCreate, queryWaitingData } from '@/api/dealerScope'
-import chooseTypeList from './chooseTypeList.vue'
+import { dealerScopeCreate, queryWaitingData, dealerScopeQueryList } from '@/api/dealerScope'
+// import chooseTypeList from './chooseTypeList.vue'
 import { VSelect } from '@/components'
 export default {
   name: 'ChooseTypeModal',
-  components: { chooseTypeList, VSelect },
+  components: { VSelect },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -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') {
+        // 特约经销商   价格级别不能修改  省、市经销商时,不能选择特约价
+        if (this.$route.params.dealerLevel === 'SPECIAL') {
           this.form.priceLevel = 'SPECIAL'
           this.notArrFlag = true
         } else {
           this.notArr = ['SPECIAL']
         }
-        this.$nextTick(() => {
-          this.getDataList()
-        })
       }
     }
   }
@@ -216,4 +309,12 @@ export default {
   .has-error .ant-form-explain, .has-error .ant-form-split{
     margin-top:9px;
   }
+  .ant-tree{
+    display:flex;
+    justify-content: space-between;
+    flex-wrap: wrap;
+  }
+  /deep/.ant-tree li{
+    width: 33% !important;
+  }
 </style>

+ 1 - 1
src/views/dealerManagement/merchantInfoManagement/list.vue

@@ -248,7 +248,7 @@ export default {
     },
     // 经销权
     handleDistribution (row) {
-      this.$router.push({ name: `merchantInfoManagementSet`, params: { sn: row.dealerSn, name: row.dealerName, dealerLevel: row.dealerType1 } })
+      this.$router.push({ name: `merchantInfoManagementSet`, params: { sn: row.dealerSn, name: row.dealerName, dealerLevel: row.dealerLevel } })
     },
     // 差价
     handlePriceSpread (row) {

+ 0 - 331
src/views/dealerManagement/merchantInfoManagement/permissionSetting.vue

@@ -1,331 +0,0 @@
-<template>
-  <div class="permissionSetting-wrap">
-    <a-spin :spinning="spinning" tip="Loading...">
-      <a-page-header :ghost="false" :backIcon="false" @back="handleBack" class="permissionSetting-cont">
-        <!-- 自定义的二级文字标题 -->
-        <template slot="subTitle">
-          <a id="permissionSetting-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
-          <span style="margin-left: 20px;color: #666;">经销商:{{ $route.params.name }}</span>
-        </template>
-      </a-page-header>
-      <a-card size="small" :bordered="false" class="permissionSetting-main">
-        <!-- 搜索条件 -->
-        <div ref="tableSearch" class="table-page-search-wrapper">
-          <a-form-model
-            id="permissionSetting-form"
-            ref="ruleForm"
-            class="form-model-con"
-            layout="inline"
-            :model="queryParam"
-            :rules="rules"
-            @keyup.enter.native="handleSearch">
-            <a-row :gutter="15">
-              <a-col :md="6" :sm="24">
-                <a-form-model-item label="类型" prop="goodsType">
-                  <v-select code="DEALER_GOODS_TYPE" id="permissionSetting-goodsType" v-model="queryParam.goodsType" allowClear placeholder="请选择类型"></v-select>
-                </a-form-model-item>
-              </a-col>
-              <a-col :md="6" :sm="24">
-                <a-form-model-item label="类型名称" prop="goodsName">
-                  <a-input id="permissionSetting-goodsName" v-model.trim="queryParam.goodsName" allowClear placeholder="请输入类型名称"/>
-                </a-form-model-item>
-              </a-col>
-              <a-col :md="6" :sm="24">
-                <a-form-model-item label="产品编码" prop="goodsCode">
-                  <a-input id="permissionSetting-goodsCode" v-model.trim="queryParam.goodsCode" allowClear placeholder="请输入产品编码"/>
-                </a-form-model-item>
-              </a-col>
-              <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
-                <a-button type="primary" @click="handleSearch" :disabled="disabled" id="permissionSetting-refresh">查询</a-button>
-                <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="permissionSetting-reset">重置</a-button>
-              </a-col>
-            </a-row>
-          </a-form-model>
-        </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('CATEGORY')">选择产品分类</a-button>
-          <a-button id="permissionSetting-product" type="primary" class="button-success" @click="choosePModal('PRODUCT')">选择产品</a-button>
-        </div>
-        <!-- 列表 -->
-        <s-table
-          class="sTable fixPagination"
-          ref="table"
-          :style="{ height: tableHeight+84.5+'px' }"
-          size="small"
-          :rowKey="(record) => record.id"
-          :columns="columns"
-          :data="loadData"
-          :scroll="{ y: tableHeight }"
-          :defaultLoadData="false"
-          bordered>
-          <!-- 操作 -->
-          <template slot="action" slot-scope="text, record">
-            <a-button size="small" type="link" class="button-error" @click="handleDel(record)">删除</a-button>
-          </template>
-        </s-table>
-      </a-card>
-    </a-spin>
-    <!-- 选择产品品牌 -->
-    <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
-    <!-- 选择产品分类 -->
-    <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
-    <!-- 选择产品 -->
-    <chooseProductsModal
-      type="dealership"
-      :dealerSn="$route.params.sn"
-      :openModal="openProductsModal"
-      :chooseData="chooseProducts"
-      @close="openProductsModal=false"
-      @ok="handleProductsOk" />
-  </div>
-</template>
-
-<script>
-import { commonMixin } from '@/utils/mixin'
-import { STable, VSelect } from '@/components'
-import ChooseProductsModal from '@/views/common/chooseProductsModal.vue'
-import ChooseBrandModal from '@/views/common/chooseBrandModal.vue'
-import ChooseTypeModal from '@/views/common/chooseTypeModal.vue'
-import { dealerScopeList, dealerScopeSave, dealerScopeDel, dealerScopeQueryList } from '@/api/dealerScope'
-export default {
-  name: 'MerchantInfoManagementSet',
-  mixins: [commonMixin],
-  components: { STable, VSelect, ChooseProductsModal, ChooseBrandModal, ChooseTypeModal },
-  data () {
-    return {
-      spinning: false,
-      tableHeight: 0,
-      queryParam: { //  查询条件
-        goodsType: undefined,
-        goodsName: '',
-        goodsCode: ''
-      },
-      rules: {
-        // goodsType: [ { required: true, message: '请选择类型', trigger: 'change' } ]
-      },
-      disabled: false, //  查询、重置按钮是否可操作
-      loading: false, //  表格加载中
-      columns: [
-        { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
-        { title: '添加时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '类型', dataIndex: 'type', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '类型名称', dataIndex: 'goodsName', align: 'left', width: '20%', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '产品名称', dataIndex: 'product.name', align: 'left', width: '30%', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '产品编码', dataIndex: 'product.code', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
-      ],
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        this.disabled = true
-        this.spinning = true
-        return dealerScopeList(Object.assign(parameter, this.queryParam, { dealerSn: this.$route.params.sn })).then(res => {
-          let data
-          if (res.status == 200) {
-            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
-              const goodsType = data.list[i].goodsType
-              data.list[i].type = goodsType == 'PRODUCT' ? '产品' : goodsType == 'BRAND' ? '品牌' : goodsType == 'CATEGORY' ? '分类' : '--'
-            }
-            this.disabled = false
-          }
-          this.spinning = false
-          return data
-        })
-      },
-      openBrandModal: false, //  选择产品品牌
-      openTypeModal: false, //  选择产品分类
-      openProductsModal: false, //  选择产品
-      chooseBrand: [], //  所选品牌
-      chooseProducts: [], //  所选产品
-      chooseType: [] //  所选分类
-    }
-  },
-  methods: {
-    // 查询
-    handleSearch () {
-      const _this = this
-      this.$refs.ruleForm.validate(valid => {
-        if (valid) {
-          _this.$refs.table.refresh(true)
-        } else {
-          return false
-        }
-      })
-    },
-    // 选择产品
-    choosePModal (type) {
-      const productList = []
-      const brandList = []
-      const typeList = []
-      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)
-            }
-          })
-          if (type == 'PRODUCT') { //  选择产品
-            // this.chooseProducts = productList  //  包含先前所选产品
-            this.chooseProducts = [] //  不包含先前所选产品
-            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) {
-      this.chooseBrand = obj
-      this.changeData('BRAND')
-    },
-    // 产品
-    handleProductsOk (obj) {
-      this.chooseProducts = obj
-      this.changeData('PRODUCT')
-    },
-    // 分类
-    handleTypeOk (obj) {
-      this.chooseType = obj
-      this.changeData('CATEGORY')
-    },
-    changeData (type) {
-      const _this = this
-      if (type == 'PRODUCT') { //  选择产品
-        if (_this.chooseProducts.length > 0) {
-          const snList = []
-          _this.chooseProducts.map(item => {
-            const productSn = item.productSn ? item.productSn : item.product.productSn ? item.product.productSn : ''
-            snList.push(productSn)
-          })
-          this.setData(snList, type)
-        }
-      } else if (type == 'BRAND') { //  选择品牌
-        if (_this.chooseBrand.length > 0) {
-          const snList = []
-          _this.chooseBrand.map(item => {
-            snList.push(item.brandSn)
-          })
-          this.setData(snList, type)
-        }
-      } else if (type == 'CATEGORY') { //  选择分类
-        if (_this.chooseType.length > 0) {
-          const snList = []
-          _this.chooseType.map(item => {
-            snList.push(item.productTypeSn)
-          })
-          this.setData(snList, type)
-        }
-      }
-    },
-    // 添加经销权
-    setData (snList, type) {
-      const _this = this
-      const params = {
-        dealerSn: _this.$route.params.sn,
-        goodsType: type,
-        goodsSnList: snList
-      }
-      _this.spinning = true
-      dealerScopeSave(params).then(res => {
-        if (res.status == 200) {
-          _this.$message.success(res.message)
-          _this.$refs.table.refresh(true)
-          _this.spinning = false
-        } else {
-          _this.spinning = false
-        }
-      })
-    },
-    // 删除
-    handleDel (row) {
-      const _this = this
-      this.$confirm({
-        title: '提示',
-        content: '确认要删除吗?',
-        centered: true,
-        onOk () {
-          _this.spinning = true
-          dealerScopeDel({ sn: row.dealerScopeSn }).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$refs.table.refresh()
-              _this.spinning = false
-            } else {
-              _this.spinning = false
-            }
-          })
-        }
-      })
-    },
-    // 重置表单
-    resetSearchForm () {
-      this.queryParam.goodsType = undefined
-      this.queryParam.goodsName = ''
-      this.queryParam.goodsCode = ''
-      this.$refs.table.refresh(true)
-    },
-    // 返回
-    handleBack () {
-      this.$router.push({ path: '/dealerManagement/merchantInfoManagement/list', query: { closeLastOldTab: true } })
-    },
-    filterOption (input, option) {
-      return (
-        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
-      )
-    },
-    pageInit () {
-      const _this = this
-      this.$nextTick(() => { // 页面渲染完成后的回调
-        _this.setTableH()
-      })
-    },
-    setTableH () {
-      const tableSearchH = this.$refs.tableSearch.offsetHeight
-      this.tableHeight = window.innerHeight - tableSearchH - 292
-    }
-  },
-  watch: {
-    '$store.state.app.winHeight' (newValue, oldValue) { //  窗口变更时,需同时更改表格高度
-      this.setTableH()
-    }
-  },
-  mounted () {
-    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
-      this.$refs.table.refresh(true)
-      this.pageInit()
-    }
-  },
-  activated () {
-    // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
-    if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
-      this.$refs.table.refresh(true)
-      this.pageInit()
-    }
-  },
-  beforeRouteEnter (to, from, next) {
-    next(vm => {})
-  }
-}
-</script>
-
-<style lang="less" scoped>
-  .permissionSetting-wrap{
-    .permissionSetting-cont{
-      margin-bottom: 6px;
-    }
-  }
-</style>

+ 53 - 30
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-error" @click="chooseTModal">选择品类</a-button>
+          <span v-if="!showEmpty && $route.params.dealerLevel != 'SPECIAL'">
+            <a-button type="primary" class="button-info" @click="handleEdit()">批量编辑</a-button>
+            <a-button type="primary" ghost 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: {
@@ -124,11 +116,11 @@ export default {
       const _this = this
       // 操作按钮
       const actionFormat = function (record, data, h) {
-        if (_this.$route.params.dealerLevel != 'special') {
+        if (_this.$route.params.dealerLevel != 'SPECIAL') {
           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,24 @@ 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
+      }
+      const newSnList = row ? [row.dealerScopeSn] : _this.selectedRowKeys
       this.$confirm({
         title: '提示',
-        content: '删除后无法向总部或上级采购,确认删除吗?',
+        content: '经销权删除后,该商户的差价设置将同步解除,确定删除吗?',
         centered: true,
         onOk () {
           _this.spinning = true
-          dealerScopeDelete({ dealerScopeSn: row.dealerScopeSn }).then(res => {
+          dealerScopeDelete({ snList: newSnList }).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 +264,7 @@ export default {
     },
     // 返回
     handleBack () {
+      this.selectedRowKeys = []
       this.$router.push({ path: '/dealerManagement/merchantInfoManagement/list', query: { closeLastOldTab: true } })
     },
     pageInit () {

+ 1 - 4
src/views/dealerManagement/merchantInfoManagement/priceLevelModal.vue

@@ -27,7 +27,7 @@
             placeholder="请选择价格级别"></v-select>
 
         </a-form-model-item>
-        <div class="fontRed">注意:改价后,差价关系、返利关系也同步解除</div>
+        <div class="fontRed">注意:价格变更后,该商户的差价设置将同步清空</div>
       </a-form-model>
       <div class="btn-cont">
         <a-button id="chooseType-modal-back" @click="isShow = false" >取消</a-button>
@@ -96,9 +96,6 @@ export default {
         this.$emit('close')
       } else {
         this.form.priceLevel = this.priceLevelVal ? this.priceLevelVal : undefined
-        this.$nextTick(() => {
-          this.$refs.chooseTypeInfo.getTableData()
-        })
       }
     }
   }