Pārlūkot izejas kodu

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

chenrui 1 gadu atpakaļ
vecāks
revīzija
0de32e2b83

+ 25 - 4
src/api/dealer.js

@@ -221,9 +221,7 @@ export const getDealerListInfo = (params) => {
 
 // 经销商差价分配列表
 export const dealerUpsList = (params) => {
-  const url = `/dealerUps/queryPage/${params.pageNo}/${params.pageSize}`
-  delete params.pageNo
-  delete params.pageSize
+  const url = `/dealerUps/queryList`
   return axios({
     url: url,
     data: params,
@@ -234,10 +232,22 @@ export const dealerUpsList = (params) => {
   })
 }
 
+// 经销商差价列表删除
+export const dealerUpsDelete = (params) => {
+  const url = `/dealerUps/delete`
+  return axios({
+    url: url,
+    data: params,
+    method: 'post',
+    headers:{
+      'module': encodeURIComponent('经销商差价设置删除')
+    }
+  })
+}
 // 差价品类列表 
 export const dealerUpsPlTree = (params) => {
   return axios({
-    url: `/dealerScope/queryWaitingData`,
+    url: `/dealerUps/queryWaitingData`,
     data: params,
     method: 'post',
     headers:{
@@ -256,4 +266,15 @@ export const dealerUpsCreate = (params) => {
       'module': encodeURIComponent('经销商差价设置保存')
     }
   })
+}
+// 修改
+export const dealerUpsUpdate = (params) => {
+  return axios({
+    url: `/dealerUps/update`,
+    data: params,
+    method: 'post',
+    headers:{
+      'module': encodeURIComponent('经销商差价设置编辑')
+    }
+  })
 }

+ 1 - 1
src/api/salesReturn.js

@@ -210,7 +210,7 @@ export const salesQueryByReturn = (params) => {
 
 // 可选产品列表
 export const queryDealerProductPage = (params) => {
-  const url = `/product/queryDealerPage/${params.pageNo}/${params.pageSize}`
+  const url = `/product/querySalesReturnPage/${params.pageNo}/${params.pageSize}`
   delete params.pageNo
   delete params.pageSize
   return axios({

+ 114 - 154
src/views/dealerManagement/rebateBinding/categoryList.vue

@@ -1,40 +1,5 @@
 <template>
   <div class="categoryList-wrap">
-    <div ref="tableSearch" v-if="showTable" class="table-page-search-wrapper">
-      <a-form-model
-        ref="ruleForm"
-        class="form-model-con"
-        layout="inline"
-        :model="queryParam"
-        @keyup.enter.native="handleSearch">
-        <a-row :gutter="15">
-          <a-col :md="6" :sm="24">
-            <a-form-item label="品牌分类">
-              <v-select
-                code="BRAND_TYPE"
-                v-model="queryParam.productBrandType"
-                allowClear
-                placeholder="请选择品牌分类"></v-select>
-            </a-form-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-model-item label="品牌">
-              <ProductBrand v-model="queryParam.productBrandSn"></ProductBrand>
-            </a-form-model-item>
-          </a-col>
-          <a-col :md="6" :sm="24">
-            <a-form-model-item label="产品分类">
-              <ProductType placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
-            </a-form-model-item>
-          </a-col>
-          <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
-            <a-button type="primary" @click="handleSearch">查询</a-button>
-            <a-button style="margin-left: 5px" @click="resetSearchForm">重置</a-button>
-          </a-col>
-        </a-row>
-      </a-form-model>
-    </div>
-
     <a-spin :spinning="spinning" tip="Loading...">
       <ve-table
         v-show="!showEmpty"
@@ -45,10 +10,9 @@
         :cellSelectionOption="{enable: false}"
         :virtual-scroll-option="{enable: true}"
         :columns="columns"
-        :table-data="dataSource"
+        :table-data="list"
         row-key-field-name="id"
-        :cell-style-option="cellStyleOption"
-        :checkbox-option="checkboxOption"
+        :cell-span-option="cellSpanOption"
       />
       <div v-show="showEmpty" class="empty-data"><a-empty description="暂无品类" :image="simpleImage"/></div>
     </a-spin>
@@ -59,14 +23,12 @@
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { VSelect } from '@/components'
-import { dealerUpsPlQuery } from '@/api/dealer'
+import { dealerUpsList, dealerUpsDelete } from '@/api/dealer'
 import { Empty } from 'ant-design-vue'
-import ProductBrand from '@/views/common/productBrand.js'
-import ProductType from '@/views/common/productType.js'
 export default {
   name: 'DetailProductList',
   mixins: [commonMixin],
-  components: { VSelect, ProductType, ProductBrand },
+  components: { VSelect },
   props: {
     newLoading: {
       type: Boolean,
@@ -75,10 +37,6 @@ export default {
     maxHeight: {
       type: [String, Number],
       default: '300'
-    },
-    showTable: {
-      type: Boolean,
-      default: false
     }
   },
   data () {
@@ -87,150 +45,152 @@ export default {
       spinning: false,
       simpleImage: Empty.PRESENTED_IMAGE_SIMPLE,
       dataSource: [],
+      list: [],
       tableHeight: this.maxHeight,
-      cellStyleOption: {
-        bodyCellClass: ({ row, column, rowIndex }) => {
-          if (row.id.indexOf('promo-') >= 0 && column.field === 'no') {
-            return 'table-body-cell-no'
-          }
-        }
-      },
       columnWidthResizeOption: {
         // default false
         enable: true,
         // column resize min width
         minWidth: 50
       },
-      showEmpty: true,
-      disableSelectedRowKeys: [],
-      selectedRowKeys: [],
-      productType: [],
-      queryParam: { //  查询条件
-        productBrandType: undefined,
-        productBrandSn: undefined,
-        productTypeSn1: undefined,
-        productTypeSn2: undefined,
-        productTypeSn3: undefined
+      cellSpanOption: {
+        bodyCellSpan: this.bodyCellSpan
       },
-      dealerSn: undefined
+      showEmpty: true,
+      checkedDealerSn: []
     }
   },
   computed: {
-    checkboxOption () {
-      return {
-        disableSelectedRowKeys: this.disableSelectedRowKeys,
-        selectedRowKeys: this.selectedRowKeys,
-        // 行选择改变事件
-        selectedRowChange: ({ row, isSelected, selectedRowKeys }) => {
-          this.selectedRowChange({ row, isSelected, selectedRowKeys })
-        },
-        // 全选改变事件
-        selectedAllChange: ({ isSelected, selectedRowKeys }) => {
-          this.selectedAllChange({ isSelected, selectedRowKeys })
-        }
-      }
-    },
     columns () {
+      const _this = this
+      // 差价归属
+      const jcgsFormat = function (record, data, h) {
+        const colors = { 'ASSIGN': '#00aaff', 'SUPERIORS': '#ff0000', 'HEAD': '#55aa7f' }
+        return (
+          data.sort((a, b) => b.rebateParentType.localeCompare(a.rebateParentType)).map(item => {
+            return (
+              <a-tag style="margin:5px;" color={colors[item.rebateParentType]}>{item.parentDealer.dealerName}{Number(item.allotRate * 100).toFixed(2) + '%'}</a-tag>
+            )
+          })
+        )
+      }
+      // 操作按钮
+      const actionFormat = function (record, data, h) {
+        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-error"
+              onClick={() => _this.handleDel(record)}
+            >删除</a-button>
+          </div>
+        )
+      }
+
       const arr = [
-        // { title: '序号', field: 'no', key: 'a', width: 60, align: 'center', operationColumn: false },
-        { title: '', field: '', key: 'acheck', width: 40, type: 'checkbox', align: 'center' },
+        { title: '序号', field: 'no', key: 'a', width: 60, align: 'center', operationColumn: false },
         { title: '品牌', field: 'productBrandName', key: 'b', width: 100, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
         { title: '一级分类', field: 'productTypeName1', key: 'e', width: 180, align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
         { title: '二级分类', field: 'productTypeName2', width: 180, key: 'i', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
-        { title: '三级分类', field: 'productTypeName3', width: 180, key: 'm', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } }
+        { title: '三级分类', field: 'productTypeName3', width: 180, key: 'm', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
+        { title: '上级经销商', field: 'superDealerName', width: 180, key: 'h', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return row[column.field] || '--' } },
+        { title: '差价归属方', field: 'rebateDealerList', width: 180, key: 'k', align: 'center', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return jcgsFormat(row, row[column.field], h) } },
+        { title: '操作', field: 'action', width: 100, key: 's', align: 'center', fixed: 'right', operationColumn: false, renderBodyCell: ({ row, column, rowIndex }, h) => { return actionFormat(row, row[column.field], h) } }
       ]
       return arr
     }
   },
   methods: {
-    // 查询品类列表
-    handleSearch () {
-      if (this.detailData && this.detailData.upsPriceLevel && this.detailData.upsDealerSn) {
-        this.searchTable()
-      } else {
-        this.$message.info('请选择上级经销商及其价格级别')
-      }
-    },
-    //  产品分类  change
-    changeProductType (val, opt) {
-      this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
-      this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
-      this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
-    },
-    // 重置查询筛选表单
-    resetSearchForm () {
-      this.queryParam.productBrandType = undefined
-      this.queryParam.productBrandSn = undefined
-      this.queryParam.productTypeSn1 = undefined
-      this.queryParam.productTypeSn2 = undefined
-      this.queryParam.productTypeSn3 = undefined
-      this.productType = []
-      this.dataSource = []
-      this.clearSelectTable()
-      this.handleSearch()
-    },
-    // 清空选项
-    clearSelectTable () {
-      this.selectedRowKeys = []
-    },
-    // 选择单元格
-    selectedRowChange ({ row, isSelected, selectedRowKeys }) {
-      // console.log(row, isSelected, selectedRowKeys);
-      this.selectedRowKeys = selectedRowKeys
-    },
-    // 全选行
-    selectedAllChange ({ isSelected, selectedRowKeys }) {
-      // console.log(isSelected, selectedRowKeys)
-      this.selectedRowKeys = selectedRowKeys
-    },
-    // 获取已选数据
-    getChooseData () {
-      const result = []
-      if (this.selectedRowKeys.length) {
-        const rows = this.dataSource.filter(item => this.selectedRowKeys.includes(item.id))
-        if (rows) {
-          rows.map(item => {
-            result.push({
-              dealerSn: item.dealerSn,
-              priceLevel: item.priceLevel,
-              parentScopeSn: item.dealerScopeSn,
-              productBrandSn: item.productBrandSn,
-              productTypeSn1: item.productTypeSn1,
-              productTypeSn2: item.productTypeSn2,
-              productTypeSn3: item.productTypeSn3
-            })
-          })
+    bodyCellSpan ({ row, column, rowIndex }) {
+      if (column.field === 'superDealerName' || column.field === 'rebateDealerList' || column.field === 'action') {
+        if (row.rowspan) {
+          return {
+            rowspan: row.rowspan,
+            colspan: 1
+          }
+        } else {
+          return {
+            rowspan: 0,
+            colspan: 0
+          }
         }
       }
-      console.log(result)
-      return result
     },
-    async searchTable () {
-      this.selectedRowKeys = []
-      this.disableSelectedRowKeys = []
+    async searchTable (queryParam) {
       this.dataSource = []
+      this.list = []
       this.disabled = true
       this.spinning = true
-      const params = { ...this.detailData }
-      params.dealerScope = { dealerSn: this.dealerSn, ...this.queryParam }
-      console.log(params)
       // 品类列表
-      const listData = await dealerUpsPlQuery(params).then(res => res.data)
+      let listData = await dealerUpsList(queryParam).then(res => res.data)
+      this.$emit('loaded', listData)
       this.dataSource = listData
+      if (!listData) {
+        listData = []
+      }
       // 格式化数据
-      this.dataSource.map((item, i) => {
-        item.no = i + 1
+      let ret = []
+      let no = 0
+      listData.map((item, i) => {
+        const sub = item.rebateScopeList || [{ productBrandName: null, productTypeName1: null, productTypeName2: null, productTypeName3: null }]
+        const sup = item.rebateDealerList.find(b => b.rebateParentType == 'SUPERIORS')
+        this.checkedDealerSn.push(sup)
+        const rebateDealerList = item.rebateDealerList
+        sub.map((a, j) => {
+          if (j == 0) {
+            a.rowspan = sub.length
+          }
+          a.dealerUpsSn = item.dealerUpsSn
+          a.dealerSn = item.dealerSn
+          a.no = no + j + 1
+          a.sup = sup
+          a.superDealerName = sup.parentDealer.dealerName
+          a.rebateDealerList = rebateDealerList
+        })
+        no = no + sub.length
+        ret = ret.concat(sub)
       })
-      this.showEmpty = this.dataSource.length <= 0
+      console.log(ret)
+      this.list = ret
+      this.showEmpty = this.list.length <= 0
       this.tableHeight = (this.showEmpty ? 0 : this.maxHeight) + 'px'
       this.spinning = false
       this.disabled = false
     },
-    pageInit (detailData, dealerSn) {
-      this.detailData = detailData
-      this.dealerSn = dealerSn
+    handleEdit (record) {
+      const row = this.dataSource.find(item => item.dealerUpsSn == record.dealerUpsSn && item.dealerSn == record.dealerSn)
+      this.$emit('edit', row)
+    },
+    handleDel (record) {
+      const _this = this
+      console.log(record)
+      this.$confirm({
+        title: '提示',
+        content: '差价设置删除后,该商户关联的上级经销商和差价设置将同步解除,确定删除吗?',
+        centered: true,
+        closable: true,
+        onOk () {
+          _this.spinning = true
+          dealerUpsDelete({ dealerUpsSn: record.dealerUpsSn }).then(res => {
+            if (res.status == 200) {
+              _this.$message.success(res.message)
+              _this.$emit('del')
+            }
+            _this.spinning = false
+          })
+        }
+      })
+    },
+    pageInit (queryParam) {
       // 获取列表
-      this.resetSearchForm()
+      this.searchTable(queryParam)
     }
   }
 }

+ 84 - 23
src/views/dealerManagement/rebateBinding/categoryTree.vue

@@ -1,20 +1,24 @@
 <template>
   <div class="categoryTree-wrap">
-    <div style="padding-bottom:10px;" v-if="showTable">
+    <div style="padding-bottom:10px;">
       <span style="color:red;">*</span> 添加品类:
-      <a-radio-group name="radioGroup">
-        <a-radio :value="1">全选</a-radio>
-        <a-radio :value="2">自主品牌</a-radio>
-        <a-radio :value="3">代理品牌</a-radio>
-      </a-radio-group>
+      <a-checkbox v-model="check1" @change="(e)=> onAllChange(e,0)" v-show="!showEmpty">
+        全选
+      </a-checkbox>
+      <a-checkbox v-model="check2" @change="(e)=> onAllChange(e,1)" v-show="!showEmpty">
+        自主品牌
+      </a-checkbox>
+      <a-checkbox v-model="check3" @change="(e)=> onAllChange(e,2)" v-show="!showEmpty">
+        代理品牌
+      </a-checkbox>
     </div>
 
-    <a-spin :spinning="spinning" tip="Loading..." v-if="showTable">
+    <a-spin :spinning="spinning" tip="Loading...">
       <div v-show="showEmpty" class="empty-data"><a-empty description="暂无品类" :image="simpleImage"/></div>
-      <div style="height:350px;overflow: auto;">
+      <div v-show="!showEmpty" style="height:350px;overflow: auto;">
         <a-tree
-          v-show="!showEmpty"
           checkable
+          :selectable="false"
           v-model="checkedKeys"
           :tree-data="dataSource"
           :replaceFields="{children:'sonList', title:'name', key:'sn' }"
@@ -62,7 +66,11 @@ export default {
       parentDealerSn: undefined,
       checkedKeys: [],
       halfCheckedKeys: [],
-      allLeafKeys: []
+      allLeafKeys: [],
+      allBrands: [],
+      check1: false,
+      check2: false,
+      check3: false
     }
   },
   computed: {
@@ -70,11 +78,18 @@ export default {
   },
   methods: {
     onCheck (checkedKeys, info) {
-      console.log('onCheck', checkedKeys, info)
+      // console.log('onCheck', checkedKeys, info)
       this.checkedKeys = checkedKeys
       this.halfCheckedKeys = info.halfCheckedKeys
-
-      this.getResult()
+      if (this.check1) {
+        this.check1 = false
+      }
+      if (this.check2) {
+        this.check2 = false
+      }
+      if (this.check3) {
+        this.check3 = false
+      }
     },
     getResult () {
       // 所有已选叶子节点
@@ -93,7 +108,50 @@ export default {
           'productTypeSn3': d[1]
         })
       })
-      console.log(result)
+      return result
+    },
+    // 筛选并全选
+    onAllChange (e, type) {
+      console.log(e.target.checked, type)
+      if (type == 0) {
+        this.check2 = false
+        this.check3 = false
+        this.check1 = e.target.checked
+        this.allCheck(this.check1, type)
+      }
+      if (type == 1) {
+        this.check1 = false
+        this.check3 = false
+        this.check2 = e.target.checked
+        this.allCheck(this.check2, type)
+      }
+      if (type == 2) {
+        this.check1 = false
+        this.check2 = false
+        this.check3 = e.target.checked
+        this.allCheck(this.check3, type)
+      }
+    },
+    // 全选树
+    allCheck (checked, type) {
+      if (checked) {
+        this.checkedKeys = []
+        this.allLeafKeys.map(item => {
+          // 自主或代理
+          if (type) {
+            const psn = item.sn.split('_2_')[0]
+            const prow = this.dataSource.find(k => k.sn == psn)
+            if (prow && prow.productBrandType == type) {
+              this.checkedKeys.push(item.sn)
+            }
+          } else {
+            // 全品类
+            this.checkedKeys.push(item.sn)
+          }
+        })
+      } else {
+        this.checkedKeys = []
+      }
     },
     // 获取所有叶子结节
     getLeafKeys (tree) {
@@ -122,16 +180,19 @@ export default {
       this.dataSource = []
       this.allLeafKeys = []
       this.spinning = true
-      const params = { ...this.detailData }
-      params.dealerScope = { dealerSn: this.dealerSn }
+      const params = { dealerSn: this.dealerSn, upsDealerSn: this.parentDealerSn }
       // 品类列表
-      const listData = await dealerUpsPlTree({}).then(res => res.data)
-      this.dataSource = listData
-      // 获取所有叶子节点
-      this.dataSource.map(item => {
-        this.allLeafKeys = this.allLeafKeys.concat(this.getLeafKeys(item))
-      })
-      this.showEmpty = this.dataSource.length <= 0
+      const listData = await dealerUpsPlTree(params).then(res => res.data)
+      if (listData) {
+        this.dataSource = listData.sort((a, b) => a.productBrandType - b.productBrandType)
+        // 获取所有叶子节点
+        this.dataSource.map(item => {
+          this.allLeafKeys = this.allLeafKeys.concat(this.getLeafKeys(item))
+          // 获取所有品牌sn
+          this.allBrands.push(item.sn)
+        })
+        this.showEmpty = this.dataSource.length <= 0
+      }
       this.spinning = false
     },
     pageInit (detailData, parentDealerSn, dealerSn) {

+ 25 - 59
src/views/dealerManagement/rebateBinding/list.vue

@@ -34,7 +34,7 @@
                   <v-select code="PRICE_LEVEL" :notIn="['SPECIAL']" v-model="queryParam.priceLevel" allowClear placeholder="请选择价格级别"></v-select>
                 </a-form-model-item>
               </a-col>
-              <a-col :md="6" :sm="24">
+              <a-col :md="6" :sm="24" v-if="!isTeyue">
                 <a-form-model-item label="经销商">
                   <a-input v-model.trim="queryParam.dealerName" allowClear placeholder="请输入经销商名称"/>
                 </a-form-model-item>
@@ -52,80 +52,37 @@
           </a-form-model>
         </div>
         <!-- 操作按钮 -->
-        <div class="table-operator">
+        <div class="table-operator" v-if="showBtns">
           <a-button id="rebateBinding-brand" type="primary" class="button-error" @click="openGlModal">差价设置</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="handleEdit(record)">编辑</a-button>
-          </template>
-        </s-table>
+        <categoryList ref="categoryList" @loaded="loadList" @del="delOk" @edit="handleEdit" :maxHeight="tableHeight"></categoryList>
       </a-card>
     </a-spin>
 
     <!-- 差价设置 -->
-    <priceDiffModal ref="priceDiffModal" :openModal="openModal" @close="openModal=false"></pricediffmodal>
+    <priceDiffModal ref="priceDiffModal" :openModal="openModal" @ok="resetSearchForm" @close="openModal=false"></pricediffmodal>
   </div>
 </template>
 
 <script>
 import { commonMixin } from '@/utils/mixin'
 import { STable, VSelect } from '@/components'
-import { dealerDetailBySn, dealerUpsList } from '@/api/dealer'
+import { dealerDetailBySn } from '@/api/dealer'
 import ProductType from '@/views/common/productType.js'
 import ProductBrand from '@/views/common/productBrand.js'
 import priceDiffModal from './priceDiffModal.vue'
+import categoryList from './categoryList'
 export default {
   name: 'RebateBinding',
   mixins: [commonMixin],
-  components: { STable, VSelect, ProductType, ProductBrand, priceDiffModal },
+  components: { STable, VSelect, ProductType, ProductBrand, priceDiffModal, categoryList },
   data () {
     return {
       spinning: false,
       tableHeight: 0,
       disabled: false, //  查询、重置按钮是否可操作
       loading: false, //  表格加载中
-      columns: [
-        { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
-        { title: '品牌', dataIndex: 'productBrand', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '一级分类', dataIndex: 'productType1', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '二级分类', dataIndex: 'productType2', align: 'left', width: '12%', customRender: function (text) { return text || '--' } },
-        { title: '三级分类', dataIndex: 'productType3', align: 'left', width: '12%', customRender: function (text) { return text || '--' } },
-        { title: '价格', dataIndex: 'productPrice', width: '10%', align: 'left', customRender: function (text) { return text || '--' } },
-        { title: '经销商', dataIndex: 'dealerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '差价归属方', dataIndex: 'cjgsf', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '10%', align: 'center' }
-      ],
-      // 加载数据方法 必须为 Promise 对象
-      loadData: parameter => {
-        this.disabled = true
-        this.spinning = true
-        return dealerUpsList(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
-            }
-            this.disabled = false
-          }
-          this.spinning = false
-          return data
-        })
-      },
       openModal: false,
       detail: null,
       productType: [],
@@ -137,12 +94,13 @@ export default {
         productTypeSn2: undefined,
         productTypeSn3: undefined,
         dealerName: ''
-      }
+      },
+      showBtns: true
     }
   },
   computed: {
     isTeyue () {
-      return this.detail && this.detail.dealerType1 == 'special'
+      return this.detail && this.detail.dealerLevel == 'SPECIAL'
     }
   },
   methods: {
@@ -150,9 +108,13 @@ export default {
     handleBack () {
       this.$router.push({ name: 'merchantInfoManagementList', query: { closeLastOldTab: true } })
     },
+    loadList (list) {
+      this.showBtns = this.isTeyue ? list.length == 0 : true
+    },
     // 查询
     handleSearch () {
-      this.$refs.table.refresh(true)
+      this.queryParam.dealerSn = this.$route.params.sn
+      this.$refs.categoryList.pageInit(this.queryParam)
     },
     //  产品分类  change
     changeProductType (val, opt) {
@@ -170,21 +132,25 @@ export default {
       this.queryParam.productTypeSn2 = undefined
       this.queryParam.productTypeSn3 = undefined
       this.productType = []
-      this.$refs.table.refresh(true)
+      this.handleSearch()
+      this.openModal = false
     },
     // 打开关联弹框
     openGlModal () {
       this.openModal = true
-      this.$refs.priceDiffModal.setData(this.$refs.rpType.getOptionDatas(), this.$route.params.sn, this.detail)
+      const checkedDealerSn = this.$refs.categoryList.checkedDealerSn
+      this.$refs.priceDiffModal.setData(this.$refs.rpType.getOptionDatas(), this.$route.params.sn, this.detail, checkedDealerSn)
     },
     // 编辑
     handleEdit (row) {
       this.openModal = true
+      this.$refs.priceDiffModal.editData(this.$refs.rpType.getOptionDatas(), this.$route.params.sn, this.detail, row)
     },
-    handleDisassociate (val) {
-      this.queryParam.rebateParentType = val ? val.key : ''
+    // 删除成功
+    delOk () {
+      this.handleSearch()
     },
-    // 详情编辑
+    // 详情
     getDetail () {
       this.spinning = true
       dealerDetailBySn({ sn: this.$route.params.sn }).then(res => {
@@ -204,7 +170,7 @@ export default {
     },
     setTableH () {
       const tableSearchH = this.$refs.tableSearch.offsetHeight
-      this.tableHeight = window.innerHeight - tableSearchH - 292
+      this.tableHeight = window.innerHeight - tableSearchH - (!this.showBtns ? 140 : 205)
     }
   },
   watch: {

+ 112 - 40
src/views/dealerManagement/rebateBinding/priceDiffModal.vue

@@ -19,32 +19,25 @@
           :label-col="formItemLayout.labelCol"
           :wrapper-col="formItemLayout.wrapperCol"
         >
-          <!-- <a-form-model-item label="差价归属方" prop="rebateParentType">
-            <a-row :gutter="10">
-              <a-col :span="17">
-                <a-select
-                  v-model="form.rebateParentType"
-                  :disabled="detailData&&detailData.dealerType1 == 'special'"
-                  placeholder="请选择差价归属方"
-                  mode="multiple"
-                  @change="cjgsgChange"
-                  style="width: 100%">
-                  <a-select-option v-for="item in cjgsfList" :key="item.code" :value="item.code">{{ item.dispName }}</a-select-option>
-                </a-select>
-              </a-col>
-              <a-col :span="6">
-              </a-col>
-            </a-row>
-          </a-form-model-item> -->
+          <a-form-model-item label="经销商名称">
+            {{ detailData&&detailData.dealerName }}
+          </a-form-model-item>
           <a-form-model-item label="上级经销商" required>
             <a-row :gutter="10">
               <a-col :span="17">
-                <custList ref="custList" :notDealerSn="notZdDealer" :notDealerType="['special']" @change="custSupChange" placeholder="请输入经销商名称搜索"></custList>
+                <custList
+                  v-if="!form.dealerUpsSn"
+                  ref="custList"
+                  :notDealerSn="notZdDealer"
+                  :notDealerType="['special']"
+                  @change="custSupChange"
+                  placeholder="请输入经销商名称搜索"></custList>
+                <a-input v-else :value="superDealerName" disabled />
               </a-col>
-              <a-col :span="4">
+              <a-col :span="4" v-if="!isSpecial">
                 <a-input-number :min="0" :max="100" v-model="parentAllotRate" @change="rateSupChange" placeholder="请输入比例"/> %
               </a-col>
-              <a-col :span="2" v-if="zdDealearList.length==0">
+              <a-col :span="2" v-if="zdDealearList.length==0&&!isSpecial">
                 <a-button
                   type="primary"
                   ghost
@@ -56,7 +49,7 @@
           <a-form-model-item label="指定经销商" v-if="zdDealearList.length">
             <a-row :gutter="10" v-for="(item,index) in zdDealearList" :key="item.id">
               <a-col :span="17">
-                <custList :ref="'custList'+index" :notDealerSn="notZdDealer" @change="(v)=>custChange(v,index)" placeholder="请输入经销商名称搜索"></custList>
+                <custList :ref="'custList-'+item.id" :notDealerSn="notZdDealer" @change="(v,r)=>custChange(v,r,index)" placeholder="请输入经销商名称搜索"></custList>
               </a-col>
               <a-col :span="4">
                 <a-input-number :min="0" :max="100" v-model="item.allotRate" @change="(v)=>rateChange(v,index)" placeholder="请输入比例"/> %
@@ -81,7 +74,7 @@
               </a-col>
             </a-row>
           </a-form-model-item>
-          <a-form-model-item label="箭冠总公司">
+          <a-form-model-item label="箭冠总公司" v-if="!isSpecial">
             <a-row :gutter="10">
               <a-col :span="17">
                 <a-input value="箭冠总公司" disabled />
@@ -94,7 +87,7 @@
         </a-form-model>
       </div>
       <div style="padding:10px 10px 10px 40px;">
-        <categoryTree ref="categoryTree" :showTable="showTable"></categoryTree>
+        <categoryTree v-if="showTable&&!isSpecial&&!form.dealerUpsSn" ref="categoryTree"></categoryTree>
       </div>
       <div class="btn-cont">
         <a-button size="large" @click="isShow = false" style="font-size: 12px;">取消</a-button>
@@ -110,12 +103,14 @@
 </template>
 
 <script>
+import { commonMixin } from '@/utils/mixin'
 import custList from '@/views/common/custList.vue'
 import { VSelect } from '@/components'
-import { dealerUpsCreate } from '@/api/dealer'
+import { dealerUpsCreate, dealerUpsUpdate } from '@/api/dealer'
 import categoryTree from './categoryTree'
 export default {
   name: 'PriceDiffModal',
+  mixins: [commonMixin],
   components: { VSelect, custList, categoryTree },
   props: {
     openModal: { //  弹框显示状态
@@ -145,41 +140,97 @@ export default {
       },
       cjgsfList: [],
       zdDealearList: [],
-      detailData: null
+      detailData: null,
+      superDealerName: '',
+      checkedDealerSn: []
     }
   },
   computed: {
-    showPercent () {
-      return this.form.rebateParentType.length > 1
-    },
-    showPercent1 () {
-      return this.zdDealearList.length > 1
+    isSpecial () {
+      return this.detailData && this.detailData.dealerLevel == 'SPECIAL'
     },
     notZdDealer () {
-      return this.form.rebateDealerList.concat(this.zdDealearList).concat([{ 'parentDealerSn': this.form.dealerSn }])
+      return this.form.rebateDealerList.concat(this.zdDealearList).concat([{ 'parentDealerSn': this.form.dealerSn }, ...this.checkedDealerSn])
     },
     showTable () {
       return this.form.rebateParentType.indexOf('SUPERIORS') >= 0
     }
   },
   methods: {
-    setData (list, dealerSn, detail) {
+    // 新增
+    setData (list, dealerSn, detail, checkedDealerSn) {
       this.detailData = detail
       this.form.dealerSn = dealerSn
       this.cjgsfList = list
+      this.checkedDealerSn = checkedDealerSn
       // 如果当前经销商是特约经销商
-      if (this.detailData.dealerType1 == 'special') {
+      if (this.detailData.dealerLevel == 'SPECIAL') {
         // 默认只有上级经销商
-        this.form.rebateParentType = ['SUPERIORS']
         this.cjgsgChange(['SUPERIORS'])
       } else {
         this.cjgsgChange(['SUPERIORS', 'HEAD'])
       }
     },
+    // 编辑
+    editData (list, dealerSn, detail, row) {
+      this.detailData = detail
+      this.form.dealerSn = dealerSn
+      this.form.dealerUpsSn = row.dealerUpsSn
+      this.cjgsfList = list
+      // 如果当前经销商是特约经销商
+      if (this.detailData.dealerLevel == 'SPECIAL') {
+        // 默认只有上级经销商
+        this.form.rebateParentType = ['SUPERIORS']
+      } else {
+        this.form.rebateParentType = ['SUPERIORS', 'HEAD']
+      }
+
+      console.log(row)
+      if (row) {
+        row.rebateDealerList.map(item => {
+          const row = {
+            'id': item.id,
+            'dealerSn': item.dealerSn,
+            'parentDealerSn': item.parentDealerSn,
+            'rebateParentType': item.rebateParentType,
+            'dealerRelationSn': item.dealerRelationSn,
+            'allotRate': Number(item.allotRate * 100).toFixed(2)
+          }
+          // 指定
+          if (item.rebateParentType == 'ASSIGN') {
+            this.zdDealearList.push(row)
+            this.$nextTick(() => {
+              this.$refs['custList-' + item.id][0].setDufaultVal(item.parentDealer.dealerName)
+            })
+          } else {
+            // 上级和总部
+            if (item.rebateParentType == 'SUPERIORS') {
+              this.form.rebateDealerList[0] = row
+              this.parentAllotRate = Number(item.allotRate * 100).toFixed(2)
+              // 特约可编辑上级
+              if (this.detailData.dealerLevel == 'SPECIAL') {
+                this.$nextTick(() => {
+                  this.$refs.custList.setDufaultVal(item.parentDealer.dealerName)
+                })
+              } else {
+                // 其它不可编辑
+                this.superDealerName = item.parentDealer.dealerName
+              }
+            } else {
+              this.form.rebateDealerList[1] = row
+              this.hAllotRate = Number(item.allotRate * 100).toFixed(2)
+            }
+          }
+        })
+      }
+    },
     // 上级经销商修改
-    custSupChange (val) {
+    custSupChange (val, row) {
+      console.log(val, row)
       this.form.rebateDealerList[0]['parentDealerSn'] = val.key
-      this.getCategoryList()
+      if (!this.isSpecial) {
+        this.getCategoryList()
+      }
     },
     rateSupChange (val) {
       this.form.rebateDealerList[0]['allotRate'] = val
@@ -196,7 +247,7 @@ export default {
       this.form.rebateDealerList[1]['allotRate'] = val
     },
     // 指定经销商变更
-    custChange (val, index) {
+    custChange (val, row, index) {
       console.log(val, index)
       this.zdDealearList[index]['parentDealerSn'] = val.key
     },
@@ -269,14 +320,17 @@ export default {
     },
     // 重置表单
     resetForm () {
+      if (!this.isSpecial && !this.form.dealerUpsSn) {
+        this.$refs.custList.resetForm()
+      }
       this.form.dealerSn = undefined
+      this.form.dealerUpsSn = undefined
       this.form.rebateParentType = []
       this.form.rebateDealerList = []
       this.form.rebateScopeList = []
       this.zdDealearList = []
       this.hAllotRate = ''
       this.parentAllotRate = 100
-      this.$refs.custList.resetForm()
     },
     // 校验数据
     validateFormData (data) {
@@ -319,6 +373,7 @@ export default {
             formData.rebateDealerList.map(item => {
               item.allotRate = item.allotRate ? (item.allotRate / 100) : 0
               pa += item.allotRate
+              delete item.id
             })
             console.log(formData)
             console.log(pa)
@@ -327,12 +382,26 @@ export default {
               return
             }
 
+            if (this.showTable && !this.isSpecial && !this.form.dealerUpsSn) {
+              formData.rebateScopeList = this.$refs.categoryTree.getResult()
+              if (formData.rebateScopeList.length == 0) {
+                _this.$message.error('请选择品类')
+                return
+              }
+            }
+
+            delete formData.rebateParentType
+
+            // 提交数据
             _this.spinning = true
-            dealerUpsCreate(formData).then(res => {
+            const fun = this.form.dealerUpsSn ? dealerUpsUpdate : dealerUpsCreate
+            fun(formData).then(res => {
               if (res.status == 200) {
                 _this.$message.success(res.message)
-                _this.$emit('ok')
                 _this.isShow = false
+                setTimeout(() => {
+                  _this.$emit('ok')
+                }, 100)
               }
               _this.spinning = false
             })
@@ -363,6 +432,9 @@ export default {
   .priceDifference-modal{
     .ant-modal-body {
       padding: 24px!important;
+      .ant-input[disabled]{
+        color:#666;
+      }
     }
     .btn-cont {
       text-align: center;