Bladeren bron

业务负责人回显

chenrui 2 jaren geleden
bovenliggende
commit
aa3fece69b

+ 8 - 9
src/api/bizuser.js

@@ -106,12 +106,11 @@ export const deleteProductType = params => {
     method: 'get'
   })
 }
-//  业务负责人配置列表 导出
-// export const allocateBillExport = (params) => {
-//   return axios({
-//     url: '/allocateBill/exportExcel',
-//     data: params,
-//     method: 'post',
-//     responseType: 'blob'
-//   })
-// }
+
+export const bizuserScopeSaveList = params => {
+  return axios({
+    url: '/bizuser/scope/saveList',
+    data: params,
+    method: 'post'
+  })
+}

+ 23 - 4
src/api/reportData.js

@@ -472,15 +472,24 @@ export const reportSalesReturnThjdReportExport = (params) => {
 // 全国各省类销售明细报表
 export const realReportSalesByProvince = (params) => {
   return axios({
-    url: '/report/realReportSales/queryListByProvince',
+    url: '/report/realReportSales/subareaArea/reportList',
     data: params,
     method: 'post'
   })
 }
+// 标题
+export const subareaAreaReportTitle = (params) => {
+  const url = `/report/realReportSales/subareaArea/reportTitle `
+  return axios({
+    url: url,
+    data: params,
+    method: 'get'
+  })
+}
 // 导出
 export const realReportSalesByProvinceExport = (params) => {
   return axios({
-    url: '/report/realReportSales/exportByProvince',
+    url: '/report/realReportSales/subareaArea/reportExport',
     data: params,
     method: 'post',
     responseType: 'blob'
@@ -489,20 +498,30 @@ export const realReportSalesByProvinceExport = (params) => {
 // 全国各区类销售明细报表
 export const realReportSalesBySubArea = (params) => {
   return axios({
-    url: '/report/realReportSales/queryListBySubArea',
+    url: '/report/realReportSales/subarea/reportList',
     data: params,
     method: 'post'
   })
 }
+// 标题
+export const subareaReportTitle = (params) => {
+  const url = `/report/realReportSales/subarea/reportTitle`
+  return axios({
+    url: url,
+    data: params,
+    method: 'get'
+  })
+}
 // 导出
 export const realReportSalesBySubAreaExport = (params) => {
   return axios({
-    url: '/report/realReportSales/exportBySubArea',
+    url: '/report/realReportSales/subarea/reportExport',
     data: params,
     method: 'post',
     responseType: 'blob'
   })
 }
+
 // 调拨退货单报表
 export const allocateReturnReportQueryPage = (params) => {
   const url = `/report/allocateReturnReport/queryPage/${params.pageNo}/${params.pageSize}`

+ 1 - 1
src/views/common/chooseDealer.vue

@@ -211,7 +211,7 @@ export default {
         return
       }
       const dealerSnList = _this.rowSelectionInfo.selectedRowKeys
-      this.spinning = true
+      this.spinning = false
       this.$emit('plAdd', dealerSnList)
     },
     handleAdd (row) {

+ 2 - 1
src/views/dealerManagement/businessOwnerSettings/addModal.vue

@@ -18,7 +18,7 @@
       >
         <a-form-model-item label="人员名称" prop="userSn">
           <userName v-if="!itemId" ref="userName" id="businessOwnerSettings-userSn" @change="userChange"></userName>
-          <span>{{ user_name }}</span>
+          <span v-else>{{ user_name }}</span>
         </a-form-model-item>
         <a-form-model-item label="人员类型" prop="bizUserType">
           <v-select
@@ -123,6 +123,7 @@ export default {
       if (!this.itemId) {
         this.$refs.userName.resetForm()
       }
+      this.user_name = ''
       this.$refs.ruleForm.resetFields()
     },
     userChange (val) {

+ 64 - 49
src/views/dealerManagement/businessOwnerSettings/categorySet.vue

@@ -15,47 +15,51 @@
           :scroll="{ y: tableHeight }" -->
           <!-- 产品分类 -->
           <template slot="classify" slot-scope="text,record,index">
-            <a-row v-if="record.productTypeList && record.productTypeList.length>0">
-              <a-col :span="20">
-                <a-tag closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeList" :key="i">
-                  {{ con.dataName }}
-                </a-tag>
-              </a-col>
-              <a-col :span="4" style="text-align:right;">
-                <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
-                  <a-icon type="plus" /> 选择
-                </a-tag>
-              </a-col>
-            </a-row>
-            <a-row v-else>
-              <a-col :span="24">
-                <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
-                  <a-icon type="plus" /> 选择
-                </a-tag>
-              </a-col>
-            </a-row>
+            <div style="max-height:230px;overflow-y:scroll;">
+              <a-row v-if="record.productTypeList && record.productTypeList.length>0">
+                <a-col :span="20">
+                  <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,con,'typeList')" v-for="(con,i) in record.productTypeList" :key="i">
+                    {{ con.dataName }}
+                  </a-tag>
+                </a-col>
+                <a-col :span="4" style="text-align:right;">
+                  <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
+                    <a-icon type="plus" /> 选择
+                  </a-tag>
+                </a-col>
+              </a-row>
+              <a-row v-else>
+                <a-col :span="24">
+                  <a-tag style="background: #fff; borderStyle: dashed;" @click="addClassifyTag(index, record)" color="blue">
+                    <a-icon type="plus" /> 选择
+                  </a-tag>
+                </a-col>
+              </a-row>
+            </div>
           </template>
           <!-- 产品品牌 -->
           <template slot="brand" slot-scope="text,record,index">
-            <a-row v-if="record.productBrandList && record.productBrandList.length>0">
-              <a-col :span="20">
-                <a-tag closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandList" :key="j">
-                  {{ item.dataName }}
-                </a-tag>
-              </a-col>
-              <a-col :span="4" style="text-align:right;">
-                <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag(index, record)" color="blue">
-                  <a-icon type="plus" /> 选择
-                </a-tag>
-              </a-col>
-            </a-row>
-            <a-row v-else>
-              <a-col :span="24">
-                <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag(index, record)" color="blue">
-                  <a-icon type="plus" /> 选择
-                </a-tag>
-              </a-col>
-            </a-row>
+            <div style="max-height:230px;overflow-y:scroll;">
+              <a-row v-if="record.productBrandList && record.productBrandList.length>0">
+                <a-col :span="20">
+                  <a-tag style="margin-bottom:10px;" closable @close.prevent="delLabel(record.bizUserScopeSn,item,'brandList')" v-for="(item,j) in record.productBrandList" :key="j">
+                    {{ item.dataName }}
+                  </a-tag>
+                </a-col>
+                <a-col :span="4" style="text-align:right;">
+                  <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag(index, record)" color="blue">
+                    <a-icon type="plus" /> 选择
+                  </a-tag>
+                </a-col>
+              </a-row>
+              <a-row v-else>
+                <a-col :span="24">
+                  <a-tag style="background: #fff; borderStyle: dashed;" @click="addBrandTag(index, record)" color="blue">
+                    <a-icon type="plus" /> 选择
+                  </a-tag>
+                </a-col>
+              </a-row>
+            </div>
           </template>
           <span slot="action" slot-scope="text,record">
             <a-button
@@ -71,9 +75,9 @@
       </a-card>
     </a-spin>
     <!-- 选择产品品牌 -->
-    <chooseBrandModal :openModal="openBrandModal" @close="openBrandModal=false" @ok="handleBrandOk" />
+    <chooseBrandModal :openModal="openBrandModal" :chooseData="chooseBrand" @close="openBrandModal=false" @ok="handleBrandOk" />
     <!-- 选择产品分类 -->
-    <chooseTypeModal :openModal="openTypeModal" @close="openTypeModal=false" @ok="handleTypeOk" />
+    <chooseTypeModal :openModal="openTypeModal" :chooseData="chooseType" @close="openTypeModal=false" @ok="handleTypeOk" />
   </div>
 </template>
 
@@ -90,10 +94,6 @@ export default {
     return {
       spinning: false,
       tableHeight: 0,
-      queryParam: { //  查询条件
-        warehouseSn: this.$route.params.sn, //  仓库sn
-        name: '' //  仓位名称
-      },
       disabled: false, //  查询、重置按钮是否可操作
       columns: [
         { title: '分类', dataIndex: 'no', width: '42%', align: 'center', scopedSlots: { customRender: 'classify' } },
@@ -106,8 +106,8 @@ export default {
       nowData: null, //  当前记录数据
       openBrandModal: false,
       openTypeModal: false,
-      chooseBrand: null,
-      chooseType: null,
+      chooseBrand: [],
+      chooseType: [],
       chooseObj: null// 选择品牌 内容
     }
   },
@@ -142,17 +142,16 @@ export default {
         content: '删除后不可恢复,确定要删除吗?',
         centered: true,
         onOk () {
-          console.log('11111', bigRow)
           const bigPos = _this.dataSource.findIndex(con => { return bigRow == con.bizUserScopeSn })
           if (type == 'typeList') {
-            const typePos = _this.dataSource[bigPos].productTypeList.findIndex(item => { return item.id == item.id })
+            const typePos = _this.dataSource[bigPos].productTypeList.findIndex(item => { return item.id == row.id })
             deleteProductType({ id: _this.dataSource[bigPos].productTypeList[typePos].id }).then(res => {
               if (res.status == 200) {
                 _this.dataSource[bigPos].productTypeList.splice(typePos, 1)
               }
             })
           } else {
-            const brandPos = _this.dataSource[bigPos].productBrandList.findIndex(obj => { return obj.id == obj.id })
+            const brandPos = _this.dataSource[bigPos].productBrandList.findIndex(obj => { return obj.id == row.id })
             deleteProductBrand({ id: _this.dataSource[bigPos].productBrandList[brandPos].id }).then(res => {
               if (res.status == 200) {
                 _this.dataSource[bigPos].productBrandList.splice(brandPos, 1)
@@ -164,6 +163,15 @@ export default {
     },
     // 添加分类标签
     addClassifyTag (pos, row) {
+      const newData = []
+      row.productTypeList.forEach(item => {
+        const obj = {}
+        obj.productTypeSn = item.dataSn
+        obj.goodsSn = item.dataSn
+        obj.productTypeName = item.dataName
+        newData.push(obj)
+      })
+      this.chooseType = newData
       this.chooseObj = row
       this.openTypeModal = true
     },
@@ -179,6 +187,13 @@ export default {
     },
     // 添加品牌标签
     addBrandTag (pos, row) {
+      const newData = []
+      row.productBrandList.forEach(item => {
+        const obj = {}
+        obj.goodsSn = item.dataSn
+        newData.push(obj)
+      })
+      this.chooseBrand = newData
       this.chooseObj = row
       this.openBrandModal = true
     },

+ 38 - 23
src/views/dealerManagement/businessOwnerSettings/chooseAreaModal.vue

@@ -8,9 +8,21 @@
     :wrap-style="{ position: 'absolute' }"
     @close="visible = false">
     <div class="areaSetModal">
-      <div :style="{ height: tableHeight+84.5+'px' }"><a-tree :load-data="onLoadData" :tree-data="treeData" /></div>
+      <div :style="{ height: tableHeight+84.5+'px' }">
+        <div :style="{ height: tableHeight+30+'px' }" style="overflow-y:scroll;">
+          <a-tree
+            v-model="checkedKeys"
+            checkable
+            :auto-expand-parent="autoExpandParent"
+            :tree-data="subregionData"
+            :checkStrictly="true"
+            @check="onCheck"
+            :replaceFields="{children:'subareaAreaList', title:'name', key:'areaSn'}"
+          />
+        </div>
+      </div>
       <div class="areaFooter">
-        <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="areaSet-refresh">保存</a-button>
+        <a-button type="primary" @click="save" :disabled="disabled" id="areaSet-refresh">保存</a-button>
         <a-button style="margin-left: 5px" @click="visible = false" :disabled="disabled" id="areaSet-reset">取消</a-button>
       </div>
     </div>
@@ -19,12 +31,19 @@
 
 <script>
 import { commonMixin } from '@/utils/mixin'
+import { subareaQueryAll } from '@/api/subarea'
 export default {
   mixins: [commonMixin],
   props: {
     showModal: {
       type: Boolean,
       default: false
+    },
+    chooseData: {
+      type: Object,
+      default: () => {
+        return []
+      }
     }
   },
   watch: {
@@ -33,16 +52,19 @@ export default {
     },
     visible (newValue, oldValue) {
       if (!newValue) {
+        this.checkedKeys = []
         this.$emit('close')
       }
     }
   },
   data () {
     return {
-      visible: this.showModal,
-      treeData: [{ title: 'Expand to load', key: '0' }, { title: 'Expand to load', key: '1' }, { title: 'Tree Node', key: '2', isLeaf: true }],
-      disabled: false,
-      tableHeight: 0
+      autoExpandParent: false,
+      checkedKeys: [],
+      subregionData: null,
+      tableHeight: 0,
+      visible: false,
+      disabled: false
     }
   },
   methods: {
@@ -55,38 +77,31 @@ export default {
             if (item.subareaAreaList) {
               item.subareaAreaList.map(cd => {
                 cd.name = cd.subareaAreaName
-                cd.areaSn = cd.subareaAreaSn
+                cd.areaSn = cd.subareaAreaSn + '_'
               })
             }
           })
-          this.list = res.data
+          this.subregionData = res.data
+          this.checkedKeys = this.chooseData ? this.chooseData : []
         }
       })
     },
+    save () {
+      this.$emit('ok', this.checkedKeys)
+    },
+    onCheck (checkedKeys) {
+      this.checkedKeys = checkedKeys
+    },
     pageInit () {
       const _this = this
       this.$nextTick(() => { // 页面渲染完成后的回调
         _this.setTableH()
       })
+      this.getArea()
     },
     setTableH () {
       this.tableHeight = window.innerHeight - 345
     }
-  },
-  mounted () {
-    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
-      this.pageInit()
-    }
-  },
-  activated () {
-    // 如果是新页签打开,则重置当前页面
-    if (this.$store.state.app.isNewTab) {
-      this.pageInit()
-    }
-    // 仅刷新列表,不重置页面
-    if (this.$store.state.app.updateList) {
-      this.pageInit()
-    }
   }
 }
 </script>

+ 8 - 8
src/views/dealerManagement/businessOwnerSettings/list.vue

@@ -93,14 +93,13 @@ export default {
         this.spinning = true
         return queryPage(Object.assign(parameter, this.queryParam)).then(res => {
           let data
-          if (res.status == 200) {
-            data = res.data
-            const no = 0
-            for (var i = 0; i < data.length; i++) {
-              data[i].no = no + i + 1
-            }
-            this.disabled = false
+          data = res.data
+          const no = (data.pageNo - 1) * data.pageSize
+          this.total = data.count || 0
+          for (var i = 0; i < data.list.length; i++) {
+            data.list[i].no = no + i + 1
           }
+          this.disabled = false
           this.spinning = false
           return data
         })
@@ -114,7 +113,8 @@ export default {
       this.queryParam.userSn = val.key
     },
     handleSetCategory (row) {
-      this.$router.push({ name: 'categorySet', query: { sn: row.userSn } })
+      const name = encodeURI(row.userName)
+      this.$router.push({ name: 'categorySet', query: { sn: row.userSn, name: name } })
     },
     // 新增
     handleAdd () {

+ 275 - 259
src/views/dealerManagement/businessOwnerSettings/settingsIndex.vue

@@ -1,289 +1,305 @@
-<template>
-  <div class="categorySet-wrap">
-    <a-spin :spinning="spinning" tip="Loading...">
-      <div ref="headerBar">
-        <a-page-header :ghost="false" :backIcon="false" class="header-bar">
-          <!-- 自定义的二级文字标题 -->
-          <template slot="subTitle">
-            <span class="subTitle-word text-overflow" style="max-width:300px;">用户姓名:测试测试</span>
-            <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
-          </template>
-        </a-page-header>
-      </div>
-      <a-card size="small" :bordered="false" class="categorySet-cont">
-        <div :style="{ height: tableHeight+84.5+'px' }">
-          <a-tabs default-active-key="1" @change="handleTabs">
-            <a-tab-pane key="1" tab="设置管辖区域">
-              <div class="areaSet-wrap">
-                <div class="table-page-search-wrapper newTableSearchName" >
-                  <div class="areaSet-btnGroup" style="margin-bottom:20px;">
-                    <a-button type="primary" class="button-error" @click="openAreaModal" ghost>选择区域</a-button>
-                    <a-button type="primary" class="button-error" @click="openDealerModal" ghost>选择经销商</a-button>
-                  </div>
-                  <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
-                    <a-row :gutter="15">
-                      <a-col :md="6" :sm="24">
-                        <a-form-model-item label="所在区域/分区">
-                          <subarea id="chooseDealer-subarea" ref="subarea" @change="subareaChange"></subarea>
-                        </a-form-model-item>
-                      </a-col>
-                      <a-col :md="6" :sm="24">
-                        <a-form-item label="经销商名称">
-                          <a-input id="areaSet-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入经销商名称"/>
-                        </a-form-item>
-                      </a-col>
-                      <a-col :md="6" :sm="24">
-                        <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="areaSet-refresh">查询</a-button>
-                        <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="areaSet-reset">重置</a-button>
-                      </a-col>
-                    </a-row>
-                  </a-form>
-                </div>
-                <a-spin :spinning="spinning" tip="Loading...">
+<template>
+  <div class="categorySet-wrap">
+    <a-spin :spinning="spinning" tip="Loading...">
+      <div ref="headerBar">
+        <a-page-header :ghost="false" :backIcon="false" class="header-bar">
+          <!-- 自定义的二级文字标题 -->
+          <template slot="subTitle">
+            <span class="subTitle-word text-overflow" style="max-width:300px;">用户姓名:{{ decodeURI($route.query.name) }}</span>
+            <a-button id="purchaseNewOrderEdit-back-btn" type="link" @click="handleBack" class="button-default"> <a-icon type="rollback" /> 返回列表</a-button>
+          </template>
+        </a-page-header>
+      </div>
+      <a-card size="small" :bordered="false" class="categorySet-cont">
+        <div :style="{ height: tableHeight+84.5+'px' }">
+          <a-tabs default-active-key="1" @change="handleTabs">
+            <a-tab-pane key="1" tab="设置管辖区域">
+              <div class="areaSet-wrap">
+                <div class="table-page-search-wrapper newTableSearchName" >
+                  <div class="areaSet-btnGroup" style="margin-bottom:20px;">
+                    <a-button type="primary" class="button-error" @click="openAreaModal" ghost>选择区域</a-button>
+                    <a-button type="primary" class="button-error" @click="openDealerModal" ghost>选择经销商</a-button>
+                  </div>
+                  <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
+                    <a-row :gutter="15">
+                      <a-col :md="6" :sm="24">
+                        <a-form-model-item label="所在区域/分区">
+                          <subarea id="chooseDealer-subarea" ref="subarea" @change="subareaChange"></subarea>
+                        </a-form-model-item>
+                      </a-col>
+                      <a-col :md="6" :sm="24">
+                        <a-form-item label="经销商名称">
+                          <a-input id="areaSet-dealerName" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入经销商名称"/>
+                        </a-form-item>
+                      </a-col>
+                      <a-col :md="6" :sm="24">
+                        <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="areaSet-refresh">查询</a-button>
+                        <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="areaSet-reset">重置</a-button>
+                      </a-col>
+                    </a-row>
+                  </a-form>
+                </div>
+                <a-spin :spinning="spinning" tip="Loading...">
                   <!-- 列表 -->
-                  <s-table
-                    class="sTable fixPagination"
-                    ref="table"
-                    size="small"
-                    :rowKey="(record) => record.id"
-                    :columns="columns"
-                    :showPagination="false"
-                    :data="loadData"
-
+                  <!-- :showPagination="false" -->
+                  <s-table
+                    class="sTable fixPagination"
+                    ref="table"
+                    size="small"
+                    :rowKey="(record) => record.id"
+                    :columns="columns"
+                    :data="loadData"
                     :defaultLoadData="false"
+                    :style="{ height: tableHeight-100+'px' }"
+                    :scroll="{ y: tableHeight-180 }"
                     bordered>
-                  </s-table>
-                </a-spin>
-                <!-- :style="{ height: tableHeight+'px' }"
-                :scroll="{ y: tableHeight }" -->
-              </div>
-            </a-tab-pane>
-            <a-tab-pane key="2" tab="设置管辖品类" force-render>
-              <categorySet ref="setCategory"></categorySet>
-            </a-tab-pane>
-          </a-tabs>
-        </div>
-      </a-card>
-      <!-- 选择区域 -->
-      <chooseAreaModal
-        ref="partQuery"
+                    <!-- 操作 -->
+                    <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-spin>
+              </div>
+            </a-tab-pane>
+            <a-tab-pane key="2" tab="设置管辖品类" force-render>
+              <categorySet ref="setCategory"></categorySet>
+            </a-tab-pane>
+          </a-tabs>
+        </div>
+      </a-card>
+      <!-- 选择区域 -->
+      <chooseAreaModal
+        ref="partQuery"
         :showModal="openChooseArea"
-        @close="openChooseArea=false">
-      </chooseAreaModal>
-      <!-- 选择经销商 -->
-      <a-drawer
-        title="选择经销商"
-        width="80%"
-        :zIndex="100"
-        :visible="openChooseDealer"
-        :get-container="false"
-        :wrap-style="{ position: 'absolute' }"
-        @close="openChooseDealer = false">
-        <div class="dealerModalCon">
-          <chooseDealer @plAdd="handleAddDealer"></chooseDealer>
-        </div>
-      </a-drawer>
-    </a-spin>
-  </div>
-</template>
-
-<script>
-import { commonMixin } from '@/utils/mixin'
-import { STable } from '@/components'
-import categorySet from './categorySet'
-import chooseAreaModal from './chooseAreaModal'
+        :chooseData="newChooseData"
+        @ok="handleArea"
+        @close="openChooseArea=false">
+      </chooseAreaModal>
+      <!-- 选择经销商 -->
+      <a-drawer
+        title="选择经销商"
+        width="80%"
+        :zIndex="100"
+        :visible="openChooseDealer"
+        :get-container="false"
+        :wrap-style="{ position: 'absolute' }"
+        @close="openChooseDealer = false">
+        <div class="dealerModalCon">
+          <chooseDealer @plAdd="handleAddDealer"></chooseDealer>
+        </div>
+      </a-drawer>
+    </a-spin>
+  </div>
+</template>
+
+<script>
+import { commonMixin } from '@/utils/mixin'
+import { STable } from '@/components'
+import categorySet from './categorySet'
+import chooseAreaModal from './chooseAreaModal'
 import chooseDealer from '@/views/common/chooseDealer.vue'
-import { bizuserScopeQueryPage } from '@/api/bizuser'
-import subarea from '@/views/common/subarea.js'
-export default {
-  name: 'SettingsIndex',
-  mixins: [commonMixin],
-  components: { STable, categorySet, chooseAreaModal, chooseDealer, subarea },
-  data () {
-    return {
-      openChooseArea: false,
-      openChooseDealer: false,
-      spinning: false,
-      tableHeight: 0,
+import { bizuserScopeQueryPage, bizuserScopeSaveList, bizuserScopeDelete } from '@/api/bizuser'
+import subarea from '@/views/common/subarea.js'
+export default {
+  name: 'SettingsIndex',
+  mixins: [commonMixin],
+  components: { STable, categorySet, chooseAreaModal, chooseDealer, subarea },
+  data () {
+    return {
+      openChooseArea: false,
+      openChooseDealer: false,
+      spinning: false,
+      tableHeight: 0,
       queryParam: {
-        hasDetail: 0,
-        subareaSn: undefined,
-        subareaAreaSn: undefined,
-        dealerName: ''
+        hasDetail: 0,
+        subareaSn: undefined,
+        subareaAreaSn: undefined,
+        dealerName: ''
       },
-      columns: [
-        { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
-        { title: '添加时间', dataIndex: 'subareaName1', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '区域', dataIndex: 'subareaName2', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '分区', dataIndex: 'subareaName3', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
-        { title: '经销商', dataIndex: 'subareaName4', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
-        { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
+      newChooseData: {
+        checked: [],
+        halfChecked: []
+      },
+      columns: [
+        { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
+        { title: '添加时间', dataIndex: 'createDate', width: '16%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '区域', dataIndex: 'subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '分区', dataIndex: 'subareaAreaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
+        { title: '经销商', dataIndex: 'dealerName', width: '16%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
+        { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
       ],
-      disabled: false, //  查询、重置按钮是否可操作
-      dataSource: [],
-      openModal: false, //  新增编辑产品品牌  弹框
-      itemSn: '', //  当前sn
-      nowData: null, //  当前记录数据
-      showClassifyModal: false,
-      showBrandModal: false,
-      ChooseClassifyPos: null,
-      loadData: parameter => {
-        this.disabled = true
+      dataList: [],
+      disabled: false, //  查询、重置按钮是否可操作
+      dataSource: [],
+      openModal: false, //  新增编辑产品品牌  弹框
+      itemSn: '', //  当前sn
+      nowData: null, //  当前记录数据
+      showClassifyModal: false,
+      showBrandModal: false,
+      ChooseClassifyPos: null,
+      loadData: parameter => {
+        this.disabled = true
         this.spinning = true
-        return bizuserScopeQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
-          let data
-          if (res.status == 200) {
+        this.queryParam.userSn = this.$route.query.sn
+        return bizuserScopeQueryPage(Object.assign(parameter, this.queryParam)).then(res => {
+          let data
+          if (res.status == 200) {
             data = res.data
-            const no = 0
-            for (var i = 0; i < data.length; i++) {
-              data[i].no = no + i + 1
+            const no = (data.pageNo - 1) * data.pageSize
+            this.total = data.count || 0
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
             }
-            this.disabled = false
+            this.disabled = false
           }
-          this.spinning = false
-          return data
-        })
-      }
-    }
-  },
+          this.dataList = data.list
+          this.spinning = false
+          return data
+        })
+      }
+    }
+  },
   methods: {
+    // 选择区域>分区
+    handleArea (con) {
+      const chooseData = con.checked
+      const newData = []
+      chooseData.forEach(item => {
+        const obj = {}
+        obj.userSn = this.$route.query.sn
+        if (item.indexOf('_') != -1) { // 分区获取数据带_    区域不带下划线
+          obj.bizType = 'subarea_area'
+          obj.bizSn = item.replace('_', '')
+          newData.push(obj)
+        } else {
+          obj.bizType = 'subarea'
+          obj.bizSn = item
+          newData.push(obj)
+        }
+      })
+      this.saveChooseData(newData)
+    },
+    // 保存所选区域或经销商
+    saveChooseData (ajaxdata) {
+      const _this = this
+      bizuserScopeSaveList(ajaxdata).then(res => {
+        if (res.status == 200) {
+          _this.openChooseArea = false
+          _this.openChooseDealer = false
+          _this.resetSearchForm()
+        }
+      })
+    },
     handleTabs (val) {
       if (val == 2) {
         this.$refs.setCategory.pageInit()
       }
     },
+    // 所在区域分区查询
     subareaChange (val) {
-      this.queryParam.subareaSn = val[0] ? val[0] : undefined
-      this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
+      this.queryParam.subareaSn = val[0] ? val[0] : undefined
+      this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
     },
-    resetSearchForm () {
-      this.queryParam = {
-        subareaSn: undefined,
-        subareaAreaSn: undefined,
-        dealerName: ''
+    // 重置
+    resetSearchForm () {
+      this.queryParam = {
+        subareaSn: undefined,
+        subareaAreaSn: undefined,
+        dealerName: ''
       }
-      this.$refs.subarea.clearData()
-      this.$refs.table.refresh(true)
-    },
+      this.$refs.subarea.clearData()
+      this.$refs.table.refresh(true)
+    },
     openAreaModal () {
-      this.openChooseArea = true
-    },
-    openDealerModal () {
-      this.openChooseDealer = true
-    },
-    //  返回
-    handleBack () {
-      this.$router.push({ name: 'businessOwnerSettings' })
-    },
-    // 新增管辖品类
-    addCategory () {
-      const newData = {
-        classifyList: [],
-        brandList: []
-      }
-      this.dataSource.push(newData)
-    },
-    handleAddDealer (list) {
-      this.openChooseDealer = false
-    },
-    // 删除分类、品牌标签
-    delLabel (pos, i, name) {
-      this.dataSource[pos][name].splice(i, 1)
-    },
-    // 添加分类标签
-    addClassifyTag (pos, row) {
-      this.ChooseClassifyPos = pos
-      this.showClassifyModal = true
-    },
-    handleClassifyModal (con) {
-      const chooseList = con
-      this.showClassifyModal = false
-      this.dataSource[this.ChooseClassifyPos].classifyList = [...this.dataSource[this.ChooseClassifyPos].classifyList, ...chooseList]
-    },
-    // 添加品牌标签
-    addBrandTag (pos, row) {
-      this.ChooseBrandPos = pos
-      this.showBrandModal = true
-    },
-    // 保存
-    save () {
-
-    },
-    //  新增/编辑
-    handleEdit (row) {
-      if (row) {
-        this.itemSn = row.warehouseLocationSn
-        row.warehouseSn = this.$route.params.sn
-        this.nowData = row
-      } else {
-        this.itemSn = null
-        this.nowData = { warehouseSn: this.$route.params.sn }
-      }
-      this.openModal = true
-    },
-    //  新增/编辑  成功
-    handleOk () {
-      this.$refs.table.refresh(true)
-    },
-    //  关闭弹框
-    closeModal () {
-      this.itemSn = ''
-      this.openModal = false
-    },
-    //  删除
-    handleDel (pos) {
+      this.$refs.partQuery.pageInit()
       const _this = this
+      const checkedArr = []
+      _this.dataList.forEach(item => {
+        if (item.bizType == 'subarea_area') {
+          item.bixSn = item.bizSn + '_'
+        }
+        checkedArr.push(item.bizSn)
+      })
+      console.log('1111', checkedArr)
+      this.newChooseData.checked = checkedArr
+      _this.$nextTick(() => {
+        _this.openChooseArea = true
+      })
+    },
+    openDealerModal () {
+      this.openChooseDealer = true
+    },
+    //  返回
+    handleBack () {
+      this.$router.push({ name: 'businessOwnerSettings' })
+    },
+    handleAddDealer (list) {
      const newData = []
      list.forEach(con => {
        const obj = {}
+        obj.userSn = this.$route.query.sn
        obj.bizType = 'dealer'
        obj.bizSn = con
        newData.push(obj)
      })
      this.saveChooseData(newData)
    },
+    //  删除
+    handleDel (row) {
+      const _this = this
       this.$confirm({
         title: '提示',
         content: '删除后不可恢复,确定要进行删除吗?',
         centered: true,
         onOk () {
-          _this.dataSource.splice(pos, 1)
+          bizuserScopeDelete({ id: row.bizUserScopeSn }).then(res => {
+            if (res.status == 200) {
+              _this.resetSearchForm()
+            }
+          })
         }
+      })
+    },
+    pageInit () {
+      const _this = this
+      this.$nextTick(() => { // 页面渲染完成后的回调
+        _this.setTableH()
       })
-    },
-    pageInit () {
-      const _this = this
-      this.$nextTick(() => { // 页面渲染完成后的回调
-        _this.setTableH()
-      })
-      this.$refs.table.refresh()
-    },
-    setTableH () {
-      const headHeight = this.$refs.headerBar.offsetHeight
-      this.tableHeight = window.innerHeight - headHeight - 230
-    }
-  },
-  watch: {
-    '$store.state.app.winHeight' (newValue, oldValue) { //  窗口变更时,需同时更改表格高度
-      this.setTableH()
-    }
-  },
-  mounted () {
-    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
-      this.pageInit()
-    }
-  },
-  activated () {
-    // 如果是新页签打开,则重置当前页面
-    if (this.$store.state.app.isNewTab) {
-      this.pageInit()
-    }
-    // 仅刷新列表,不重置页面
-    if (this.$store.state.app.updateList) {
-      this.pageInit()
-    }
-  },
-  beforeRouteEnter (to, from, next) {
-    next(vm => {})
-  }
-}
-</script>
-
-<style lang="less" scoped>
-  .categorySet-wrap{
-    .table-operator{
-    text-align:right;
-    }
-  }
-</style>
+      this.resetSearchForm()
+    },
+    setTableH () {
+      const headHeight = this.$refs.headerBar.offsetHeight
+      this.tableHeight = window.innerHeight - headHeight - 230
+    }
+  },
+  watch: {
+    '$store.state.app.winHeight' (newValue, oldValue) { //  窗口变更时,需同时更改表格高度
+      this.setTableH()
+    }
+  },
+  mounted () {
+    if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
+      this.pageInit()
+    }
+  },
+  activated () {
+    // 如果是新页签打开,则重置当前页面
+    if (this.$store.state.app.isNewTab) {
+      this.pageInit()
+    }
+    // 仅刷新列表,不重置页面
+    if (this.$store.state.app.updateList) {
+      this.pageInit()
+    }
+  },
+  beforeRouteEnter (to, from, next) {
+    next(vm => {})
+  }
+}
+</script>
+
+<style lang="less" scoped>
+  .categorySet-wrap{
+    .table-operator{
+    text-align:right;
+    }
+  }
+</style>