Explorar o código

渠道(添加一级渠道、编辑、查看)、经销商管理(查看、)

guanglong %!s(int64=3) %!d(string=hai) anos
pai
achega
f6551c30a0

+ 10 - 0
src/api/admin/channel.js

@@ -29,6 +29,16 @@ export function listAllChannel() {
   })
 }
 
+export function getChannelDetail(channelId) {
+  return request({
+    url: '/api/v1/mp/admin/channel/detail',
+    method: 'post',
+    data: {
+      channelId
+    }
+  })
+}
+
 
 // 新增渠道
 export function addChannel(data) {

+ 9 - 0
src/api/admin/salesite.js

@@ -11,6 +11,15 @@ export function listSaleSite(urlParams, data) {
   })
 }
 
+export function getSaleSiteDetail(channelId) {
+  return request({
+    url: '/api/v1/mp/admin/salesite/detail',
+    method: 'post',
+    data: {
+      channelId
+    }
+  })
+}
 
 // 新增经销商
 export function addSaleSite(data) {

+ 49 - 36
src/views/business/channel/components/Create.vue

@@ -113,20 +113,10 @@
   </el-dialog>
 </template>
 <script>
-import { addChannel, updateChannel, listAllChannel} from "@/api/admin/channel";
+import { addChannel, updateChannel, listAllChannel, getChannelDetail} from "@/api/admin/channel";
 import { listAreaByPid} from "@/api/admin/area";
 import { mapGetters } from "vuex";
-import CustomFieldsMixin from "@/mixins/CustomFields";
-// import {
-//   getCollector,
-//   addCollector,
-//   updateCollector,
-//   itemTypes
-// } from "@/api/business/collector";
-// import { itemCustomer } from "@/api/business/customer";
-// import { itemStore } from "@/api/business/store";
 export default {
-  mixins: [CustomFieldsMixin],
   props: {
     dialogVisible: {
       type: Boolean,
@@ -146,7 +136,18 @@ export default {
       areaList:[],
       statusOptions: [],
       // 表单参数
-      form: {},
+      form: {
+        name:"",
+        mobile:"",
+        contact:"",
+        commRate:"",
+        provinceId:"",
+        cityId:"",
+        areaId:"",
+        province:"",
+        city:"",
+        area:""
+      },
       detail: {},
       // 表单校验
       rules: {
@@ -188,10 +189,12 @@ export default {
     //console.log("watch dialogVisible created == ");
     // 是编辑
     if (this.editId) {
-     // this.getDetail();
+       this.getDetail();
+    }else{
+       this.getProvinceList()
     }
     // this.getChannelList()
-    this.getProvinceList()
+
   },
 
   mounted() {
@@ -225,10 +228,18 @@ export default {
       this.cityList = []
       this.areaList = []
       this.form.cityId = ""
+      this.form.city = ""
       this.form.areaId = ""
+      this.form.area = ""
       listAreaByPid(0).then(response => {
         // console.log("getProvinceList"+JSON.stringify(response))
+         console.log("getProvinceList this.form=="+JSON.stringify(this.form))
          this.provinceList = response || [];
+          console.log("this.editId && this.form.provinceId == "+(this.editId && this.form.provinceId))
+         if(this.editId && this.detail.provinceId){
+            this.form.provinceId = this.detail.provinceId
+            this.getCityList()
+         }
       });
     },
 
@@ -254,8 +265,11 @@ export default {
       var provinceId = this.form.provinceId
       this.form.province = this.getProvinceName()
       listAreaByPid(provinceId).then(response => {
-        // console.log("getCityList"+JSON.stringify(response))
          this.cityList = response || [];
+         if(this.editId && this.detail.cityId){
+            this.form.cityId = this.detail.cityId
+            this.getAreaList()
+         }
       });
 
     },
@@ -277,6 +291,9 @@ export default {
       listAreaByPid(cityId).then(response => {
         // console.log("getAreaList"+JSON.stringify(response))
          this.areaList = response || [];
+         if(this.editId && this.detail.areaId){
+            this.form.areaId = this.detail.areaId
+         }
       });
     },
 
@@ -310,27 +327,23 @@ export default {
     /**
      * 获取项目详情
      */
-    // getDetail() {
-    //   this.loading = true;
-    //   getCollector({
-    //     colDeviceId: this.editId
-    //   }).then(res => {
-    //       const data = res.data || {}
-    //       // console.log("getDetail :" + JSON.stringify(data))
-    //       this.detail = data
-    //       this.$set(this.form,'custId', data.custId)
-    //       this.$set(this.form,'storeId', data.storeId)
-    //       this.$set(this.form,'colAddress', data.colAddress)
-    //       const deviceCategory = JSON.parse(data.typeId || {})
-    //       this.detail.typeId = deviceCategory
-    //       this.$set(this.form,'typeId', deviceCategory.value)
-    //       this.$set(this.form,'label', data.label)
-    //       this.loading = false
-    //     })
-    //     .catch(() => {
-    //       this.loading = false;
-    //     });
-    // },
+    getDetail() {
+      this.loading = true;
+      getChannelDetail(this.editId).then(res => {
+          const data = res.data || {}
+          // console.log("getDetail :" + JSON.stringify(data))
+          this.detail = data
+          this.form.name = data.name
+          this.form.mobile = data.mobile
+          this.form.contact = data.contact
+          this.form.commRate = data.commRate
+          this.loading = false
+          this.getProvinceList()
+        })
+        .catch(() => {
+          this.loading = false;
+        });
+    },
 
 
     saveClick(){

+ 85 - 39
src/views/business/channel/components/Detail.vue

@@ -7,37 +7,93 @@
     :before-close="close"
     :destroy-on-close="true"
     :close-on-click-modal="false">
-   <el-form ref="form" :model="form" label-width="120px" label-position="top" style="max-height: 375px;overflow: auto;">
+   <el-form ref="form" label-width="120px" label-position="top" >
      <flexbox
          class="ygp-form-items"
          align="flex-start"
          justify="flex-start">
-        <el-form-item label="运营企业" prop="custId" style="width: 50%;" >
-          <span :class="loading?'el-icon-loading':''">{{detail.customer && detail.customer.name}}</span>
+        <el-form-item label="渠道名称" style="width: 50%; margin-bottom:5px;" >
+          <span :class="loading?'el-icon-loading':''"></span>
+          {{detail.name}}
         </el-form-item>
-         <el-form-item label="门店" prop="storeId" style="width: 50%;" >
-            <span :class="loading?'el-icon-loading':''">{{detail.store && detail.store.name}}</span>
+         <el-form-item label="手机号码" style="width: 50%; margin-bottom:5px;" >
+            <span :class="loading?'el-icon-loading':''"></span>
+            {{detail.mobile}}
          </el-form-item>
      </flexbox>
      <flexbox
          class="ygp-form-items"
          align="flex-start"
          justify="flex-start">
-         <el-form-item label="采集器编号" prop="colAddress" style="width: 50%;">
-             <span :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
+         <el-form-item label="联系人" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.contact}}
          </el-form-item>
-         <el-form-item label="类型" prop="typeId" style="width: 50%;">
-           <span :class="loading?'el-icon-loading':''">{{detail.typeId && detail.typeId.desc}}</span>
+          <el-form-item label="渠道级别" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>
+             {{detail.level}}级渠道
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="上级渠道" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.parentName}}
+         </el-form-item>
+          <el-form-item label="佣金比例" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>
+             {{detail.commRate}}%
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="所在地区" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.province}} {{detail.city}} {{detail.area}}
          </el-form-item>
+          <el-form-item label="创建时间" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"> </span>
+            {{ detail.createdTime | moment("YYYY-MM-DD HH:mm:ss") }}
+          </el-form-item>
      </flexbox>
+      <el-divider></el-divider>
      <flexbox
-          class="ygp-form-items"
-          align="flex-start"
-          justify="flex-start">
-         <el-form-item label="备注" prop="label" style="width: 100%;">
-            <span :class="loading?'el-icon-loading':''">{{detail.label}}</span>
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="经销商" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.siteCnt}}
          </el-form-item>
-      </flexbox>
+          <el-form-item label="用户数" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>
+             {{detail.userCnt}}
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="订单数" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"> </span>
+           {{detail.operData && detail.operData.orderCnt}}
+         </el-form-item>
+          <el-form-item label="营业额" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>{{detail.operData &&detail.operData.saleAmt}}
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="佣金" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''">{{detail.operData && detail.operData.commAmt}} </span>
+         </el-form-item>
+     </flexbox>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">关 闭</el-button>
@@ -47,10 +103,8 @@
 <script>
 
 import { mapGetters } from 'vuex'
-import CustomFieldsMixin from '@/mixins/CustomFields'
-// import { getCollector } from "@/api/business/collector";
+import { getChannelDetail} from "@/api/admin/channel";
 export default {
-  mixins: [CustomFieldsMixin],
   props: {
     dialogVisible: {
       type: Boolean,
@@ -62,8 +116,7 @@ export default {
   data() {
     return {
       loading: false,
-      // 表单参数
-      form: {},
+      // 详情数据
       detail: {}
     }
   },
@@ -71,14 +124,14 @@ export default {
   computed: {
     ...mapGetters(['userInfo']),
     title() {
-      return '采集器详情'
+      return '渠道详情'
     }
   },
 
   created() {
     // 是编辑
     if (this.editId) {
-      // this.getDetail()
+      this.getDetail()
     }
   },
 
@@ -100,20 +153,11 @@ export default {
      */
     getDetail() {
       this.loading = true
-      getCollector({
-        colDeviceId: this.editId
-      }).then(res => {
+      getChannelDetail(this.editId).then(res => {
+          this.loading = false
           const data = res.data || {}
-          this.detail = data
           // console.log("getDetail :" + JSON.stringify(data))
-          this.$set(this.form,'custId', data.custId)
-          this.$set(this.form,'storeId', data.storeId)
-          this.$set(this.form,'colAddress', data.colAddress)
-          const deviceCategory = JSON.parse(data.typeId || {})
-          this.detail.typeId = deviceCategory
-          this.$set(this.form,'typeId', deviceCategory.value)
-          this.$set(this.form,'label', data.label)
-          this.loading = false
+          this.detail = data
         })
         .catch(() => {
           this.loading = false
@@ -125,10 +169,6 @@ export default {
      */
     close() {
       this.$emit('close')
-      this.form = {
-        month:3,
-        packageType:'1'
-      }
     }
   }
 }
@@ -178,13 +218,19 @@ export default {
 </style>
 
 <style lang="scss">
+
+.el-dialog__body {
+    padding: 15px 20px;
+}
+
 .ygp-form-items {
    .el-form-item{
      padding: 0 5px;
    }
+
   .el-form-item__label {
     line-height: 1.2;
-    padding-bottom: 8px;
+    padding-bottom: 0px;
     word-break: break-all;
     word-wrap: break-word;
     color: #333;

+ 14 - 6
src/views/business/channel/index.vue

@@ -18,6 +18,7 @@
             :props="defaultProps"
             ref="tree"
             :load="loadNode"
+            :data="channelOptions"
             lazy
             @node-click="handleNodeClick"
           />
@@ -135,14 +136,12 @@
               <el-button
                 size="mini"
                 type="text"
-                disabled
                 @click="handleDetail(scope.row)"
                 v-hasPermi="['admin:channel:read']"
               >查看</el-button>
               <el-button
                 size="mini"
                 type="text"
-                disabled
                 @click="handleUpdate(scope.row)"
                 v-hasPermi="['admin:channel:edit']"
               >编辑</el-button>
@@ -233,8 +232,8 @@ export default {
       // 总条数
       total: 0,
       // 用户表格数据
-      channelList: null,
-
+      channelList: [],
+      channelOptions: [],
       channelName:"",
       // 状态数据字典
       statusOptions: [],
@@ -303,6 +302,12 @@ export default {
 
     },
 
+    refreshChannelTree(){
+      treeChannel({}).then(response => {
+         this.channelOptions = response.data
+      });
+    },
+
     // 省
     getProvinceList(){
       this.cityList = []
@@ -377,7 +382,8 @@ export default {
       this.handleQuery();
     },
     handleDetail(row){
-
+      this.detailShow = true
+      this.editId = row.channelId
     },
     /** 新增按钮操作 */
     handleAdd() {
@@ -386,11 +392,13 @@ export default {
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
-
+      this.createShow = true
+      this.editId = row.channelId
     },
     // 保存后的操作
     submitSuccess(){
       this.getList();
+      this.refreshChannelTree();
     },
     /**关闭弹窗*/
     hideDialog(){

+ 265 - 147
src/views/business/salesite/components/Create.vue

@@ -18,53 +18,44 @@
     >
     <flexbox class="ygp-form-items" align="flex-start" justify="flex-start">
       <el-form-item label="经销商名称" prop="colAddress" style="width: 50%;">
-        <el-input v-model="form.colAddress" placeholder="请输入采集器编号" v-if="!editId" />
-        <span v-else :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
+        <el-input v-model="form.name" placeholder="请输入经销商名称" />
       </el-form-item>
-       <el-form-item label="手机号码" prop="colAddress" style="width: 50%;">
-         <el-input v-model="form.colAddress" placeholder="请输入采集器编号" v-if="!editId" />
-         <span v-else :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
+       <el-form-item label="手机号码" prop="mobile" style="width: 50%;">
+         <el-input v-model="form.mobile" placeholder="请输入采集器编号"/>
        </el-form-item>
     </flexbox>
       <flexbox class="ygp-form-items" align="flex-start" justify="flex-start">
-        <el-form-item label="上级渠道" prop="custId" style="width: 50%;">
+        <el-form-item label="上级渠道" prop="parentId" style="width: 50%;">
           <el-select
-            v-if="!editId"
-            v-model="form.custId"
-            placeholder="请选择客户"
+            v-model="form.parentId"
+            placeholder="请选择上级渠道"
             style="width: 100%;"
             filterable
             clearable
-            @change="getCustStoreItem"
           >
             <el-option
-              v-for="(item, index) in custOptions"
+              v-for="(item, index) in channelList"
               :key="index"
               :label="item.name"
-              :value="item.custId"
+              :value="item.channelId"
             />
           </el-select>
-          <span v-else :class="loading?'el-icon-loading':''">{{detail.customer && detail.customer.name}}</span>
         </el-form-item>
-       <el-form-item label="联系人" prop="colAddress" style="width: 50%;">
-         <el-input v-model="form.colAddress" placeholder="请输入采集器编号" v-if="!editId" />
-         <span v-else :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
+       <el-form-item label="联系人" prop="contact" style="width: 50%;">
+         <el-input v-model="form.contact" placeholder="请输入联系人" />
        </el-form-item>
       </flexbox>
       <flexbox class="ygp-form-items" align="flex-start" justify="flex-start">
-        <el-form-item label="佣金比例" prop="colAddress" style="width: 50%;">
-          <el-input v-model="form.colAddress" placeholder="请输入采集器编号" v-if="!editId" />
-          <span v-else :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
+        <el-form-item label="佣金比例" prop="commRate" style="width: 50%;">
+          <el-input v-model="form.commRate" placeholder="请输入佣金比例" />
         </el-form-item>
-        <el-form-item label="经销商类型" prop="typeId" style="width: 50%;">
+        <el-form-item label="门店类型" prop="siteType" style="width: 50%;">
           <el-select
-            v-if="!editId"
-            v-model="form.typeId"
-            placeholder="请选择类型"
+            v-model="form.siteType"
+            placeholder="请选择门店类型"
             style="width: 100%;"
             filterable
             clearable
-            :disabled="editId?true:false"
           >
             <el-option
               v-for="(item, index) in typeOptions"
@@ -73,89 +64,105 @@
               :value="item.typeId"
             />
           </el-select>
-          <span v-else :class="loading?'el-icon-loading':''">{{detail.typeId && detail.typeId.desc}}</span>
         </el-form-item>
       </flexbox>
-
       <flexbox class="ygp-form-items" align="flex-start" justify="flex-start">
-        <el-form-item label="地区" style="width: 50%;">
-          <el-select v-model="form.status" placeholder="选择省份" clearable size="small" style="width: 33%;margin-right: 1px;">
+       <el-form-item label="门店名称" prop="siteName" style="width: 100%;">
+         <el-input v-model="form.siteName" placeholder="例如xxxx店, 对用户可见" />
+       </el-form-item>
+      </flexbox>
+      <flexbox class="ygp-form-items" align="flex-start" justify="flex-start">
+        <el-form-item label="省" prop="provinceId" style="width: 30%;">
+          <el-select
+            v-model="form.provinceId"
+            placeholder="选择省份"
+            clearable
+            size="small"
+            @change="getCityList()"
+            style="width: 100%;margin-right: 1px;">
             <el-option
-              v-for="dict in statusOptions"
-              :key="dict.dictValue"
-              :label="dict.dictLabel"
-              :value="dict.dictValue"
+              v-for="item in provinceList"
+              :key="item.areaId"
+              :label="item.areaName"
+              :value="item.areaId"
             />
           </el-select>
-          <el-select v-model="form.status" placeholder="选择市" clearable size="small" style="width: 33%;margin-right: 1px;">
+
+        </el-form-item>
+        <el-form-item label="市" prop="cityId" style="width: 30%;">
+          <el-select
+            v-model="form.cityId"
+            placeholder="选择市"
+            clearable
+            size="small"
+             @change="getAreaList()"
+            style="width: 100%;margin-right: 1px;">
             <el-option
-              v-for="dict in statusOptions"
-              :key="dict.dictValue"
-              :label="dict.dictLabel"
-              :value="dict.dictValue"
+              v-for="item in cityList"
+              :key="item.areaId"
+              :label="item.areaName"
+              :value="item.areaId"
             />
           </el-select>
-          <el-select v-model="form.status" placeholder="选择区" clearable size="small" style="width: 33%;margin-right: 1px;">
+        </el-form-item>
+        <el-form-item label="区" prop="areaId" style="width: 30%;" >
+          <el-select v-model="form.areaId"
+            placeholder="选择区"
+            clearable
+            size="small"
+            @change="getAreaName()"
+            style="width: 100%;margin-right: 1px;">
             <el-option
-              v-for="dict in statusOptions"
-              :key="dict.dictValue"
-              :label="dict.dictLabel"
-              :value="dict.dictValue"
+              v-for="item in areaList"
+              :key="item.areaId"
+              :label="item.areaName"
+              :value="item.areaId"
             />
           </el-select>
         </el-form-item>
-        <el-form-item label="详细地址" prop="colAddress" style="width: 50%;">
-          <el-input v-model="form.colAddress" placeholder="请输入采集器编号" v-if="!editId" />
-          <span v-else :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
-        </el-form-item>
       </flexbox>
       <flexbox
           class="ygp-form-items"
           align="flex-start"
           justify="flex-start">
-         <el-form-item label="营业执照" prop="rentContract" style="width: 50%;">
+          <el-form-item label="详细地址" prop="adress" style="width: 100%;">
+            <el-input v-model="form.adress" placeholder="请输入详细地址" />
+          </el-form-item>
+      </flexbox>
+      <flexbox
+          class="ygp-form-items"
+          align="flex-start"
+          justify="flex-start">
+         <el-form-item label="营业执照" prop="bizLicensePic" style="width: 50%;">
           <image-upload
-            :limit="7"
-            :value="rentContract"
+            :limit="1"
+            :value="form.bizLicensePic"
             :file-size="50"
             :is-public="false"
             :show-file-list="true"
-            :auto-upload="false"
-             @input="rentContractSelect"
+             @input="bizLicensePicSelect"
           />
+
          </el-form-item>
-         <el-form-item label="门头照片" prop="rentContract" style="width: 50%;">
+
+         <el-form-item label="门头照片" prop="doorPic" style="width: 50%;">
           <image-upload
-            :limit="7"
-            :value="rentContract"
+            :limit="1"
+            :value="form.doorPic"
             :file-size="50"
-            :is-public="false"
+            :is-public="true"
             :show-file-list="true"
-            :auto-upload="false"
-             @input="rentContractSelect"
+             @input="doorPicSelect"
           />
+
          </el-form-item>
+
       </flexbox>
       <flexbox class="ygp-form-items" align="flex-start" justify="flex-start">
-         <el-form-item label="认证状态" prop="colAddress" style="width: 50%;">
-           <el-input v-model="form.colAddress" placeholder="请输入采集器编号" v-if="!editId" />
-           <span v-else :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
+         <el-form-item label="认证状态" prop="certifyStatus" style="width: 50%;">
+          <el-checkbox v-model="form.certifyStatus">已认证</el-checkbox>
          </el-form-item>
       </flexbox>
-     <!-- <flexbox class="ygp-form-items" align="flex-start" justify="flex-start">
-        <el-form-item label="备注" prop="label" style="width: 100%;">
-          <el-input
-            type="textarea"
-            :rows="3"
-            :autosize="{ minRows: 3}"
-            :maxlength="64"
-            show-word-limit
-            resize="none"
-            v-model="form.label"
-            placeholder="请输入备注"
-          />
-        </el-form-item>
-      </flexbox> -->
     </el-form>
     <div slot="footer" class="dialog-footer">
       <el-button @click="close">取 消</el-button>
@@ -164,18 +171,11 @@
   </el-dialog>
 </template>
 <script>
+import { addSaleSite, updateSaleSite, getSaleSiteDetail} from "@/api/admin/salesite";
+import { listAllChannel} from "@/api/admin/channel";
+import { listAreaByPid} from "@/api/admin/area";
 import { mapGetters } from "vuex";
-import CustomFieldsMixin from "@/mixins/CustomFields";
-// import {
-//   getCollector,
-//   addCollector,
-//   updateCollector,
-//   itemTypes
-// } from "@/api/business/collector";
-// import { itemCustomer } from "@/api/business/customer";
-// import { itemStore } from "@/api/business/store";
 export default {
-  mixins: [CustomFieldsMixin],
   props: {
     dialogVisible: {
       type: Boolean,
@@ -186,27 +186,66 @@ export default {
 
   data() {
     return {
+      IMG_URL: process.env.VUE_APP_IMG_URL,
       loading: false,
+      // 上级渠道列表
+      channelList:[],
+      channelCopyList:[],
+      provinceList:[],
+      cityList:[],
+      areaList:[],
       statusOptions: [],
+      typeOptions:[],
       // 表单参数
-      form: {},
+      form: {
+        name:"",
+        mobile:"",
+        contact:"",
+        commRate:"",
+        provinceId:"",
+        cityId:"",
+        areaId:"",
+        province:"",
+        city:"",
+        area:""
+      },
       detail: {},
-      feeItems: [],
-      checkedItems: [],
-      custOptions: [],
-      storeOptions: [],
-      typeOptions: [],
       // 表单校验
       rules: {
-        custId: [{ required: true, message: "请选择客户", trigger: "change" }],
-        storeId: [{ required: true, message: "请选择门店", trigger: "change" }],
-        colAddress: [
-          { required: true, message: "请输入采集器编号", trigger: "blur" }
+        name: [
+          { required: true, message: "请输入渠道名称", trigger: "blur" }
+        ],
+        mobile: [
+          { required: true, message: "请输入手机号码", trigger: "blur" },
+          {pattern: /^((\+?86)|(\(\+86\)))?1\d{10}$/, message: "请输入正确的手机号码", trigger: "blur" }
         ],
-        typeId: [
-          { required: true, message: "请选择设备类型", trigger: "change" }
+        parentId: [{ required: true, message: "请选择上级渠道", trigger: "change" }],
+        contact: [
+          { required: true, message: "请输入联系人", trigger: "blur" }
         ],
-        label: [{ required: false, message: "请输入备注", trigger: "blur" }]
+        commRate: [
+          { required: true, message: "请输入佣金比例", trigger: "blur" },
+          { pattern: /^(([1-9]{1}\d{0,99}))(\.\d{1,2})?$/, message: "佣金比例只能为大于0的数字", trigger:['blur', 'change'] },
+        ],
+        siteType: [
+          { required: true, message: "请选择门店类型", trigger: "change" }
+        ],
+        siteName: [
+          { required: true, message: "请输入门店名称", trigger: "blur" }
+        ],
+        provinceId: [{ required: true, message: "请选择省", trigger: "change" }],
+        cityId: [{ required: true, message: "请选择市", trigger: "change" }],
+        areaId: [{ required: true, message: "请选择区", trigger: "change" }],
+        address: [
+          { required: true, message: "请输入详细地址", trigger: "blur" }
+        ],
+        bizLicensePic: [
+          { required: true, message: "请选择营业执照", trigger: "blur" }
+        ],
+        doorPic: [
+          { required: true, message: "请选择门头照片", trigger: "blur" }
+        ],
+
       },
       //招商推广宣传图
       picture: []
@@ -226,8 +265,12 @@ export default {
     //console.log("watch dialogVisible created == ");
     // 是编辑
     if (this.editId) {
-     // this.getDetail();
+       this.getDetail();
+    }else{
+       this.getProvinceList()
     }
+    this.getChannelList()
+
   },
 
   mounted() {
@@ -242,70 +285,145 @@ export default {
   },
 
   methods: {
-    // /** 查询可分配的门店 */
-    getCustItems() {
-      this.custOptions = [];
-      itemCustomer({})
-        .then(res => {
-          const resData = res.data || [];
-          this.custOptions = resData;
+
+    // 获取上级渠道下拉列表
+    getChannelList(){
+      listAllChannel().then(response => {
+        // console.log("getChannelList == "+ JSON.stringify(response.data))
+         this.channelList = this.channelList.concat(response.data || []);
+         this.channelCopyList = this.channelList;
+      });
+    },
+
+
+    // 添加营业执照
+    bizLicensePicSelect(data) {
+      this.form.bizLicensePic = data
+      console.log("bizLicensePicSelect 添加营业执照 data = "+JSON.stringify(data))
+    },
+
+    // 添加门头照片
+    doorPicSelect(data) {
+      this.form.doorPic = data
+      console.log("doorPicSelect 添加门头照片 data = "+JSON.stringify(data))
+    },
+
+    // 省
+    getProvinceList(){
+      this.cityList = []
+      this.areaList = []
+      this.form.cityId = ""
+      this.form.city = ""
+      this.form.areaId = ""
+      this.form.area = ""
+      listAreaByPid(0).then(response => {
+        // console.log("getProvinceList"+JSON.stringify(response))
+         console.log("getProvinceList this.form=="+JSON.stringify(this.form))
+         this.provinceList = response || [];
+          console.log("this.editId && this.form.provinceId == "+(this.editId && this.form.provinceId))
+         if(this.editId && this.detail.provinceId){
+            this.form.provinceId = this.detail.provinceId
+            this.getCityList()
+         }
+      });
+    },
+
+    getProvinceName(){
+      let val = this.form.provinceId
+      if(val){
+        let nameObj = this.provinceList.find(item => {
+              return item.areaId == val;
         })
-        .catch(() => {
-          this.loading = false;
-        });
+        return nameObj && nameObj.areaName
+      }
+      return ""
+    },
+
+
+    getCityList(){
+      this.cityList = []
+      this.areaList = []
+      this.form.cityId = ""
+      this.form.city = ""
+      this.form.areaId = ""
+      this.form.area = ""
+      var provinceId = this.form.provinceId
+      this.form.province = this.getProvinceName()
+      listAreaByPid(provinceId).then(response => {
+         this.cityList = response || [];
+         if(this.editId && this.detail.cityId){
+            this.form.cityId = this.detail.cityId
+            this.getAreaList()
+         }
+      });
+
     },
 
-    // /** 查询可分配的门店 */
-    getCustStoreItem() {
-      this.storeOptions = [];
-      this.$set(this.form, "storeId", "");
-      itemStore({
-        custId: this.form.custId
-      })
-        .then(res => {
-          const resData = res.data || [];
-          this.storeOptions = resData;
+    getCityName(){
+      let val = this.form.cityId
+      if(val){
+        let nameObj = this.cityList.find(item => {
+              return item.areaId == val;
         })
-        .catch(() => {
-          this.loading = false;
-        });
+        return nameObj && nameObj.areaName
+      }
+      return ""
+    },
+
+    getAreaList(){
+      var cityId = this.form.cityId
+      this.form.city = this.getCityName();
+      listAreaByPid(cityId).then(response => {
+        // console.log("getAreaList"+JSON.stringify(response))
+         this.areaList = response || [];
+         if(this.editId && this.detail.areaId){
+            this.form.areaId = this.detail.areaId
+         }
+      });
     },
 
-    // /** 查询可分配的门店 */
-    getTypeItems() {
-      this.typeOptions = [];
-      itemTypes({})
-        .then(res => {
-          const resData = res.data || [];
-          this.typeOptions = resData;
+    getAreaName(){
+      let val = this.form.areaId
+      if(val){
+        let nameObj = this.areaList.find(item => {
+              return item.areaId == val;
         })
-        .catch(() => {
-          this.loading = false;
-        });
+        this.form.area = nameObj && nameObj.areaName
+      }else{
+        this.form.area = "";
+      }
     },
 
+    dataFilter(val) {
+      this.value = val;
+      if (val) { //val存在
+        this.channelList = this.channelCopyList.filter((item) => {
+          // console.log("dataFilter item"+JSON.stringify(item))
+          if (!!~item.mobile.indexOf(val) || !!~item.mobile.toUpperCase().indexOf(val.toUpperCase())) {
+             return true
+          }
+        })
+      } else { //val为空时,还原数组
+        this.channelList = this.channelCopyList;
+      }
+    },
+
+
     /**
      * 获取项目详情
      */
     getDetail() {
       this.loading = true;
-      getCollector({
-        colDeviceId: this.editId
-      }).then(res => {
+      getSaleSiteDetail(this.editId).then(res => {
           const data = res.data || {}
           // console.log("getDetail :" + JSON.stringify(data))
           this.detail = data
-          this.$set(this.form,'custId', data.custId)
-          this.$set(this.form,'storeId', data.storeId)
-          this.$set(this.form,'colAddress', data.colAddress)
-          const deviceCategory = JSON.parse(data.typeId || {})
-          this.detail.typeId = deviceCategory
-          this.$set(this.form,'typeId', deviceCategory.value)
-          this.$set(this.form,'label', data.label)
+          this.form.name = data.name
+          this.form.mobile = data.mobile
+          this.form.contact = data.contact
+          this.form.commRate = data.commRate
           this.loading = false
-          // if(this.editId){
-          //   this.getCustStoreItem()
-          // }
+          this.getProvinceList()
         })
         .catch(() => {
           this.loading = false;
@@ -333,11 +451,11 @@ export default {
      * 保存
      */
     submitForm(params) {
-      // console.log("submitForm =============")
+      //  console.log("submitForm =============")
       if (this.editId) {
-        params.colDeviceId = this.editId;
+        params.channelId = this.editId;
       }
-      const request = this.editId ? updateCollector : addCollector
+      const request = this.editId ? updateSaleSite : addSaleSite
       // console.log("submitForm params = "+ JSON.stringify(params))
       request(params).then(response => {
         this.loading = false

+ 113 - 39
src/views/business/salesite/components/Detail.vue

@@ -7,37 +7,120 @@
     :before-close="close"
     :destroy-on-close="true"
     :close-on-click-modal="false">
-   <el-form ref="form" :model="form" label-width="120px" label-position="top" style="max-height: 375px;overflow: auto;">
+   <el-form ref="form" label-width="120px" label-position="top" >
      <flexbox
          class="ygp-form-items"
          align="flex-start"
          justify="flex-start">
-        <el-form-item label="运营企业" prop="custId" style="width: 50%;" >
-          <span :class="loading?'el-icon-loading':''">{{detail.customer && detail.customer.name}}</span>
+        <el-form-item label="经销商名称" style="width: 50%; margin-bottom:5px;" >
+          <span :class="loading?'el-icon-loading':''"></span>
+          {{detail.name}}
         </el-form-item>
-         <el-form-item label="门店" prop="storeId" style="width: 50%;" >
-            <span :class="loading?'el-icon-loading':''">{{detail.store && detail.store.name}}</span>
+         <el-form-item label="手机号码" style="width: 50%; margin-bottom:5px;" >
+            <span :class="loading?'el-icon-loading':''"></span>
+            {{detail.mobile}}
          </el-form-item>
      </flexbox>
      <flexbox
          class="ygp-form-items"
          align="flex-start"
          justify="flex-start">
-         <el-form-item label="采集器编号" prop="colAddress" style="width: 50%;">
-             <span :class="loading?'el-icon-loading':''">{{detail.colAddress}}</span>
+         <el-form-item label="上级渠道" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.parentName}}
          </el-form-item>
-         <el-form-item label="类型" prop="typeId" style="width: 50%;">
-           <span :class="loading?'el-icon-loading':''">{{detail.typeId && detail.typeId.desc}}</span>
+         <el-form-item label="联系人" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.contact}}
          </el-form-item>
      </flexbox>
      <flexbox
-          class="ygp-form-items"
-          align="flex-start"
-          justify="flex-start">
-         <el-form-item label="备注" prop="label" style="width: 100%;">
-            <span :class="loading?'el-icon-loading':''">{{detail.label}}</span>
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+          <el-form-item label="佣金比例" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>
+             {{detail.commRate}}%
+          </el-form-item>
+          <el-form-item label="门店类型" style="width: 50%;margin-bottom:5px;" >
+            <span :class="loading?'el-icon-loading':''"></span>
+            <span v-if="detail.siteType">{{detail.siteType && JSON.parse(detail.siteType).desc}}</span>
+            <span v-else>--</span>
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+          <el-form-item label="门店名称" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>
+             <span v-if="detail.siteName">{{detail.siteName}}</span>
+             <span v-else>--</span>
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="所在地区" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.province}} {{detail.city}} {{detail.area}}
+         </el-form-item>
+          <el-form-item label="详细地址" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"> </span>
+             <span v-if="detail.address">{{ detail.address }}</span>
+             <span v-else>--</span>
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="认证状态" style="width: 100%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+           {{detail.certifyStatus && JSON.parse(detail.certifyStatus).desc}}
+         </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+         <el-form-item label="营业执照" style="width: 50%;margin-bottom:5px;" >
+           <span :class="loading?'el-icon-loading':''"></span>
+            <a target="_black" v-if="detail.bizLicensePic" :href="`${IMG_URL + detail.bizLicensePic}`"><img :src="`${IMG_URL + detail.bizLicensePic}`" style="max-height: 37px;max-width: 54px"></a>
+            <span v-else>无</span>
          </el-form-item>
-      </flexbox>
+          <el-form-item label="门头照片" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"> </span>
+            <a target="_black" v-if="detail.doorPic" :href="`${IMG_URL + detail.doorPic}`"><img :src="`${IMG_URL + detail.doorPic}`" style="max-height: 37px;max-width: 54px"></a>
+            <span v-else>无</span>
+          </el-form-item>
+     </flexbox>
+      <el-divider></el-divider>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+          <el-form-item label="用户数" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>
+             {{detail.userCnt}}
+          </el-form-item>
+          <el-form-item label="订单数" style="width: 50%;margin-bottom:5px;" >
+            <span :class="loading?'el-icon-loading':''"> </span>
+            {{detail.operData && detail.operData.orderCnt}}
+          </el-form-item>
+     </flexbox>
+     <flexbox
+         class="ygp-form-items"
+         align="flex-start"
+         justify="flex-start">
+          <el-form-item label="营业额" style="width: 50%;margin-bottom:5px;" >
+             <span :class="loading?'el-icon-loading':''"></span>{{detail.operData &&detail.operData.saleAmt}}
+          </el-form-item>
+          <el-form-item label="佣金" style="width: 50%;margin-bottom:5px;" >
+            <span :class="loading?'el-icon-loading':''">{{detail.operData && detail.operData.commAmt}} </span>
+          </el-form-item>
+     </flexbox>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">关 闭</el-button>
@@ -47,10 +130,8 @@
 <script>
 
 import { mapGetters } from 'vuex'
-import CustomFieldsMixin from '@/mixins/CustomFields'
-// import { getCollector } from "@/api/business/collector";
+import { getSaleSiteDetail} from "@/api/admin/salesite";
 export default {
-  mixins: [CustomFieldsMixin],
   props: {
     dialogVisible: {
       type: Boolean,
@@ -61,9 +142,9 @@ export default {
 
   data() {
     return {
+      IMG_URL: process.env.VUE_APP_IMG_URL,
       loading: false,
-      // 表单参数
-      form: {},
+      // 详情数据
       detail: {}
     }
   },
@@ -71,14 +152,14 @@ export default {
   computed: {
     ...mapGetters(['userInfo']),
     title() {
-      return '采集器详情'
+      return '渠道详情'
     }
   },
 
   created() {
     // 是编辑
     if (this.editId) {
-      // this.getDetail()
+      this.getDetail()
     }
   },
 
@@ -100,20 +181,11 @@ export default {
      */
     getDetail() {
       this.loading = true
-      getCollector({
-        colDeviceId: this.editId
-      }).then(res => {
+      getSaleSiteDetail(this.editId).then(res => {
+          this.loading = false
           const data = res.data || {}
-          this.detail = data
           // console.log("getDetail :" + JSON.stringify(data))
-          this.$set(this.form,'custId', data.custId)
-          this.$set(this.form,'storeId', data.storeId)
-          this.$set(this.form,'colAddress', data.colAddress)
-          const deviceCategory = JSON.parse(data.typeId || {})
-          this.detail.typeId = deviceCategory
-          this.$set(this.form,'typeId', deviceCategory.value)
-          this.$set(this.form,'label', data.label)
-          this.loading = false
+          this.detail = data
         })
         .catch(() => {
           this.loading = false
@@ -125,10 +197,6 @@ export default {
      */
     close() {
       this.$emit('close')
-      this.form = {
-        month:3,
-        packageType:'1'
-      }
     }
   }
 }
@@ -178,13 +246,19 @@ export default {
 </style>
 
 <style lang="scss">
+
+.el-dialog__body {
+    padding: 15px 20px;
+}
+
 .ygp-form-items {
    .el-form-item{
      padding: 0 5px;
    }
+
   .el-form-item__label {
     line-height: 1.2;
-    padding-bottom: 8px;
+    padding-bottom: 0px;
     word-break: break-all;
     word-wrap: break-word;
     color: #333;

+ 36 - 49
src/views/business/salesite/index.vue

@@ -90,7 +90,6 @@
           type="primary"
           icon="el-icon-plus"
           size="mini"
-          disabled=""
           @click="handleAdd"
           v-hasPermi="['system:post:add']"
         >添加经销商</el-button>
@@ -100,10 +99,11 @@
 
     <el-table v-loading="loading" :data="postList" @selection-change="handleSelectionChange">
      <!-- <el-table-column type="selection" width="55" align="center" /> -->
-      <el-table-column label="经销商ID" prop="channelId" />
-      <el-table-column label="经销商名称" align="center" prop="name" />
+      <el-table-column label="经销商ID" prop="channelId" width="100px"/>
+      <el-table-column label="经销商名称" show-overflow-tooltip align="center" prop="name" max-width="100px" />
       <el-table-column label="手机号码" align="center" prop="mobile" />
       <el-table-column label="佣金比例" align="center" prop="commRate" />
+      <el-table-column label="上级渠道" align="center" prop="parentName" />
       <el-table-column label="用户数" align="center" prop="userCnt" />
       <el-table-column label="认证状态" align="center" prop="certifyStatus" >
         <template slot-scope="{ row, column }">
@@ -122,14 +122,12 @@
           <el-button
             size="mini"
             type="text"
-            disabled
-            @click="handleUpdate(scope.row)"
+            @click="handleDetail(scope.row)"
             v-hasPermi="['admin:salesite:read']"
           >查看</el-button>
           <el-button
             size="mini"
             type="text"
-            disabled
             @click="handleUpdate(scope.row)"
             v-hasPermi="['admin:salesite:edit']"
           >编辑</el-button>
@@ -139,10 +137,8 @@
             @click="handleStatusChange(scope.row)"
             v-hasPermi="['admin:salesite:remove']"
           >
-
-          <span v-if="getValue(scope.row.status) == 1"> 停用</span>
-          <span v-if="getValue(scope.row.status) == 2"> 启用</span>
-
+            <span v-if="getValue(scope.row.status) == 1"> 停用</span>
+            <span v-if="getValue(scope.row.status) == 2"> 启用</span>
           </el-button>
         </template>
       </el-table-column>
@@ -397,6 +393,10 @@ export default {
       this.single = selection.length!=1
       this.multiple = !selection.length
     },
+    handleDetail(row){
+      this.detailShow = true
+      this.editId = row.channelId
+    },
     /** 新增按钮操作 */
     handleAdd() {
        this.createShow = true
@@ -404,49 +404,36 @@ export default {
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
-      this.reset();
-      const postId = row.postId || this.ids
-      getPost(postId).then(response => {
-        this.form = response.data;
-        this.open = true;
-        this.title = "修改岗位";
-      });
+      this.createShow = true
+      this.editId = row.channelId
     },
-    /** 提交按钮 */
-    submitForm: function() {
-      this.$refs["form"].validate(valid => {
-        if (valid) {
-          if (this.form.postId != undefined) {
-            updatePost(this.form).then(response => {
-              this.msgSuccess("修改成功");
-              this.open = false;
-              this.getList();
-            });
-          } else {
-            addPost(this.form).then(response => {
-              this.msgSuccess("新增成功");
-              this.open = false;
-              this.getList();
-            });
-          }
-        }
-      });
+
+    // 保存后的操作
+    submitSuccess(){
+      this.getList();
     },
-    /** 删除按钮操作 */
-    handleDelete(row) {
-      const postIds = row.postId || this.ids;
-      this.$confirm('是否确认删除名称为"' + row.name + '"的经销商?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return delPost(postIds);
-        }).then(() => {
-          this.getList();
-          this.msgSuccess("删除成功");
-        }).catch(() => {});
+
+    /**关闭弹窗*/
+    hideDialog(){
+      this.createShow = false
+      this.detailShow = false
     },
 
+    /** 删除按钮操作 */
+    // handleDelete(row) {
+    //   const postIds = row.postId || this.ids;
+    //   this.$confirm('是否确认删除名称为"' + row.name + '"的经销商?', "警告", {
+    //       confirmButtonText: "确定",
+    //       cancelButtonText: "取消",
+    //       type: "warning"
+    //     }).then(function() {
+    //       return delPost(postIds);
+    //     }).then(() => {
+    //       this.getList();
+    //       this.msgSuccess("删除成功");
+    //     }).catch(() => {});
+    // },
+
 
     // 状态修改
     handleStatusChange(row) {