Browse Source

Merge branch '客户分级'

Long 3 ngày trước cách đây
mục cha
commit
8f476fd958

+ 7 - 0
src/api/crm/customer.js

@@ -156,3 +156,10 @@ export function delCustomer(customerId) {
     method: 'delete'
   })
 }
+
+export function switchToTop(customerId) {
+  return request({
+    url: '/crm/customer/switchToTop/' + customerId,
+    method: 'post',
+  })
+}

+ 47 - 0
src/api/crm/customerLevel.js

@@ -0,0 +1,47 @@
+import request from "@/utils/request";
+
+export const list = (query) => {
+  return request({
+    url: "/crm/customerLevel/list",
+    method: "get",
+    params: query,
+  });
+};
+
+export const get = (id) => {
+  return request({
+    url: "/crm/customerLevel/" + id,
+    method: "get",
+  });
+};
+
+export const add = (data) => {
+  return request({
+    url: "/crm/customerLevel/add",
+    method: "post",
+    data: data,
+  });
+};
+
+export const edit = (data) => {
+  return request({
+    url: "/crm/customerLevel/edit",
+    method: "put",
+    data: data,
+  });
+};
+
+export const del = (data) => {
+  return request({
+    url: "/crm/customerLevel/delete/" + data,
+    method: "delete",
+  });
+};
+
+export const customerLevelOption = (query) => {
+  return request({
+    url: "/crm/customerLevel/getCustomerLevelOption",
+    method: "get",
+    params: query,
+  });
+};

+ 9 - 1
src/views/crm/components/customerDetails.vue

@@ -43,7 +43,7 @@
             </el-descriptions-item>
             <el-descriptions-item label="客户类型" >
                 <span v-if="item!=null">
-                    <el-tag  v-for="(dict, index) in typeOptions"    v-if="item.customerType==dict.dictValue">{{dict.dictLabel}}</el-tag>
+                    <el-tag v-for="dict in customerLevelOptions"  v-if="item.customerLevel === dict.dictValue">{{dict.dictLabel}}</el-tag>
                 </span>
             </el-descriptions-item>
             <el-descriptions-item label="客户状态" >
@@ -141,6 +141,7 @@
     import customerStoreOrderList from '../components/customerStoreOrderList.vue';
     import customerContacts from './customerContacts.vue';
     import { getCustomer,getCustomer1,getCustomer2 } from "@/api/crm/customer";
+    import {customerLevelOption} from "@/api/crm/customerLevel";
     export default {
         name: "customer",
         components: { customerContacts,customerVisitList,customerLogsList,customerVoiceLogsList,customerStoreOrderList,customerSmsLogsList },
@@ -155,6 +156,7 @@
                 sexOptions:[],
                 item:null,
                 company:null,
+              customerLevelOptions: [],
 
             };
         },
@@ -176,11 +178,17 @@
                 this.customerExts = response.data;
 
             });
+          this.getCustomerLevelOptions()
 
         },
         mounted(){
         },
         methods: {
+          getCustomerLevelOptions() {
+            customerLevelOption().then(response => {
+              this.customerLevelOptions = response.data;
+            })
+          },
             handleMobile(){
                 const customerId = this.item.customerId;
                 getCustomer2(customerId).then(response =>{

+ 53 - 32
src/views/crm/customer/index.vue

@@ -60,17 +60,17 @@
               />
         </el-select>
       </el-form-item>
-      <el-form-item label="客户类型" prop="customerType">
-        <el-select multiple v-model="ctsTypeArr" placeholder="请选择客户类型" clearable size="small">
+      <el-form-item label="客户类型" prop="customerLevel">
+        <el-select v-model="queryParams.customerLevel" placeholder="请选择客户类型" clearable size="small">
            <el-option
-                v-for="item in typeOptions"
+                v-for="item in customerLevelOptions"
                 :key="'type'+item.dictValue"
                 :label="item.dictLabel"
                 :value="item.dictValue"
               />
         </el-select>
       </el-form-item>
-      
+
       <el-form-item label="创建时间" prop="createTime">
         <el-date-picker clearable size="small" style="width: 205.4px"
           v-model="dateRange"
@@ -186,9 +186,9 @@
         </template>
       </el-table-column>
 
-      <el-table-column  label="客户类型" align="center" prop="customerType">
+      <el-table-column  label="客户类型" align="center">
         <template slot-scope="scope">
-            <el-tag prop="customerType" v-for="(item, index) in typeOptions" :key="'customerType'+index"   v-if="scope.row.customerType==item.dictValue">{{item.dictLabel}}</el-tag>
+          <el-tag v-for="item in customerLevelOptions"  v-if="scope.row.customerLevel === item.dictValue">{{item.dictLabel}}</el-tag>
         </template>
       </el-table-column>
 
@@ -228,6 +228,13 @@
             @click="handleDelete(scope.row)"
             v-hasPermi="['crm:customer:remove']"
           >删除</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-mouse"
+            @click="handleSwitchToTop(scope.row)"
+            v-hasPermi="['crm:customer:switchToTop']"
+          >{{ scope.row.isTop === 1 ? '取消置顶' : '置顶' }}</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -280,10 +287,10 @@
                 />
           </el-select>
         </el-form-item>
-        <el-form-item label="客户类型" prop="customerType">
-          <el-select v-model="form.customerType" placeholder="请选择客户类型" clearable size="small">
+        <el-form-item label="客户类型">
+          <el-select v-model="form.customerLevel" placeholder="请选择客户类型" clearable size="small">
             <el-option
-                  v-for="item in typeOptions"
+                  v-for="item in customerLevelOpenOptions"
                   :key="item.dictValue"
                   :label="item.dictLabel"
                   :value="item.dictValue"
@@ -346,7 +353,15 @@
 </template>
 
 <script>
-import { listCustomer,getCustomer,addCustomer,updateCustomer,delCustomer,exportCustomer  } from "@/api/crm/customer";
+import {
+  listCustomer,
+  getCustomer,
+  addCustomer,
+  updateCustomer,
+  delCustomer,
+  exportCustomer,
+  switchToTop
+} from "@/api/crm/customer";
 import { getCompanyList } from "@/api/company/company";
 import customerDetails from '../components/customerDetails.vue';
 import editCustomerSource from '../components/editCustomerSource.vue';
@@ -356,6 +371,7 @@ import { throwStatement } from "@babel/types";
 import { treeselect } from "@/api/company/companyDept";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import {customerLevelOption} from "@/api/crm/customerLevel";
 
 export default {
    watch: {
@@ -441,7 +457,8 @@ export default {
         companyId: null,
         isLine: null,
         source: null,
-        tags: null
+        tags: null,
+        customerLevel: null,
       },
       // 表单参数
       form: {},
@@ -459,7 +476,9 @@ export default {
         source: [
           { required: true, message: "客户来源不能为空", trigger: "blur" }
         ],
-      }
+      },
+      customerLevelOptions: [],
+      customerLevelOpenOptions: [],
     };
   },
   created() {
@@ -483,8 +502,14 @@ export default {
     });
     this.getCitys();
     this.getList();
+    this.getCustomerLevelOptions()
   },
   methods: {
+     getCustomerLevelOptions() {
+       customerLevelOption().then(response => {
+         this.customerLevelOptions = response.data;
+       })
+     },
     handleEditSource(){
       this.source.open=true;
       var that=this;
@@ -534,25 +559,6 @@ export default {
           this.citys=res.data;
         })
     },
-    handleClose(tag) {
-        this.tags.splice(this.tags.indexOf(tag), 1);
-        this.form.tags=this.tags.toString();
-    },
-    showInput() {
-      this.inputVisible = true;
-      this.$nextTick(_ => {
-        this.$refs.saveTagInput.$refs.input.focus();
-      });
-    },
-    handleInputConfirm() {
-      let inputValue = this.inputValue;
-      if (inputValue) {
-        this.tags.push(inputValue);
-      }
-      this.inputVisible = false;
-      this.inputValue = '';
-      this.form.tags=this.tags.toString();
-    },
     handleShow(row){
       var that=this;
       that.show.open=true;
@@ -631,7 +637,8 @@ export default {
         companyId: null,
         isLine: null,
         source: null,
-        tags: null
+        tags: null,
+        customerLevel: null,
       };
       this.tags=[];
       this.cityIds=[];
@@ -689,6 +696,11 @@ export default {
               that.cityIds.push(id)
           });
         }
+
+        customerLevelOption({status: 0}).then(response => {
+          this.customerLevelOpenOptions = response.data;
+        })
+
         this.open = true;
         this.title = "修改客户";
       });
@@ -731,6 +743,15 @@ export default {
           this.msgSuccess("删除成功");
         }).catch(function() {});
     },
+    handleSwitchToTop(row) {
+      switchToTop(row.customerId).then(response => {
+        const {code} = response
+        if (code === 200) {
+          this.msgSuccess(row.isTop === 0 ? "已置顶" : "已取消置顶");
+          this.getList();
+        }
+      })
+    },
     /** 导出按钮操作 */
     handleExport() {
       //const queryParams = this.queryParams;

+ 34 - 5
src/views/crm/customer/line.vue

@@ -158,7 +158,7 @@
       </el-table-column>
       <el-table-column label="流量来源" align="center" prop="trafficSource" />
       <el-table-column label="备注" align="center" prop="remark" />
-      <el-table-column label="操作"   align="center" class-name="small-padding fixed-width">
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -285,6 +285,12 @@
         <el-form-item label="备注" prop="remark">
           <el-input type="textarea" :rows="2" v-model="form.remark"   placeholder="请输入备注" />
         </el-form-item>
+        <el-form-item label="是否置顶">
+          <el-radio-group v-model="form.isTop">
+            <el-radio :label="0" >否</el-radio>
+            <el-radio :label="1" >是</el-radio>
+          </el-radio-group>
+        </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -329,7 +335,17 @@
 </template>
 
 <script>
-import { assignCustomer,importLineTemplate,listLineCustomer, getLineCustomer, delLineCustomer, addLineCustomer, updateLineCustomer, exportLineCustomer } from "@/api/crm/customer";
+import {
+  assignCustomer,
+  importLineTemplate,
+  listLineCustomer,
+  getLineCustomer,
+  delLineCustomer,
+  addLineCustomer,
+  updateLineCustomer,
+  exportLineCustomer,
+  switchToTop
+} from "@/api/crm/customer";
 import {getCitys} from "@/api/store/city";
 import { getToken } from "@/utils/auth";
 import { isAdmin } from "@/api/system/user";
@@ -337,6 +353,7 @@ import editCustomerSource from '../components/editCustomerSource.vue';
 
 import customerAssignList from '../components/customerAssignList.vue';
 import assignCompany from '../components/assignCompany.vue';
+import {customerLevelOption} from "@/api/crm/customerLevel";
 
 export default {
   name: "Customer",
@@ -453,6 +470,8 @@ export default {
         province:null,
         city:null,
         district:null,
+        customerLevel: null,
+        isTop: 0
       },
       // 表单校验
       rules: {
@@ -462,7 +481,7 @@ export default {
         source: [
           { required: true, message: "客户来源不能为空", trigger: "blur" }
         ],
-      }
+      },
     };
   },
   created() {
@@ -602,7 +621,9 @@ export default {
         companyId: null,
         isLine: null,
         source: null,
-        tags: null
+        tags: null,
+        customerLevel: null,
+        isTop: 0
       };
       this.tags=[];
       this.cityIds=[];
@@ -739,6 +760,14 @@ export default {
           this.msgSuccess("删除成功");
         }).catch(function() {});
     },
+    handleSwitchToTop(row) {
+      switchToTop(row.customerId).then(response => {
+        if (response.code === 200) {
+          this.msgSuccess(row.isTop === 0 ? "置顶成功" : "已取消置顶");
+          this.getList();
+        }
+      })
+    },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;
@@ -779,7 +808,7 @@ export default {
      // 提交上传文件
      submitFileForm() {
       this.$refs.upload.submit();
-    }
+    },
   }
 };
 </script>

+ 233 - 0
src/views/crm/customerLevel/index.vue

@@ -0,0 +1,233 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+      <el-form-item label="级别名称" prop="name">
+        <el-input
+          v-model="queryParams.name"
+          placeholder="请输入级别名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          icon="el-icon-plus"
+          size="mini"
+          @click="handleAdd"
+          v-hasPermi="['crm:customerLevel:add']"
+        >新增</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table border height="500" v-loading="loading" :data="customerLevelList">
+      <el-table-column label="ID" align="center" prop="id" />
+      <el-table-column label="级别名称" align="center" prop="name" />
+      <el-table-column  label="状态" align="center" prop="status">
+        <template slot-scope="scope">
+          <el-tag :type="getStatusType(scope.row.status)">{{getStatusLabel(scope.row.status)}}</el-tag>
+        </template>
+      </el-table-column>
+      <el-table-column label="序号" align="center" prop="sort" />
+      <el-table-column label="操作"   align="center" class-name="small-padding fixed-width">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            @click="handleUpdate(scope.row)"
+            v-hasPermi="['crm:customerLevel:edit']"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            @click="handleDelete(scope.row)"
+            v-hasPermi="['crm:customerLevel:remove']"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total>0"
+      :total="total"
+      :page-sizes="pageSizes"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <el-dialog :title="customLevelDialog.title" :visible.sync="customLevelDialog.open" width="500px" append-to-body>
+      <el-form ref="form" :model="customLevelDialog.form" :rules="customLevelDialog.rules" label-width="80px">
+        <el-form-item label="级别名称" prop="name">
+          <el-input v-model="customLevelDialog.form.name" placeholder="请输入级别名称" />
+        </el-form-item>
+        <el-form-item label="状态" prop="status">
+          <el-radio v-model="customLevelDialog.form.status" label="0">正常</el-radio>
+          <el-radio v-model="customLevelDialog.form.status" label="1">停用</el-radio>
+        </el-form-item>
+        <el-form-item label="排序" prop="sort">
+          <el-input-number v-model="customLevelDialog.form.sort" placeholder="请输入排序" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+
+  </div>
+</template>
+
+<script>
+import {add, del, get, edit, list} from '@/api/crm/customerLevel'
+
+const initForm = {
+  id: null,
+  name: null,
+  status: '0',
+  sort: 0
+}
+
+const statusOptions = [
+  {
+    dictLabel: "正常",
+    dictValue: 0,
+    type: 'success'
+  },
+  {
+    dictLabel: "停用",
+    dictValue: 1,
+    type: 'danger'
+  }
+]
+
+export default {
+  name: "index",
+  data() {
+    return {
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        name: null
+      },
+      loading: false,
+      customerLevelList: [],
+      statusOptions: statusOptions,
+      total: 0,
+      pageSizes:[10, 20, 30, 50, 100],
+      showSearch: true,
+      customLevelDialog: {
+        title: "新增",
+        open: false,
+        form: initForm,
+        rules: {
+          name: [
+            { required: true, message: "级别名称不能为空", trigger: "blur" }
+          ]
+        }
+      }
+    }
+  },
+  created() {
+    this.handleQuery()
+  },
+  methods: {
+    handleQuery() {
+      this.queryParams.pageNum = 1
+      this.getList()
+    },
+    resetQuery() {
+      this.resetForm("queryForm");
+      this.handleQuery();
+    },
+    getList() {
+      this.loading = true
+      list(this.queryParams).then(response => {
+        this.customerLevelList = response.rows
+        this.total = response.total
+        this.loading = false
+      })
+    },
+    getStatusType(status) {
+      return this.statusOptions.find(val => val.dictValue === status)?.type || ''
+    },
+    getStatusLabel(status) {
+      return this.statusOptions.find(val => val.dictValue === status)?.dictLabel || ''
+    },
+    handleAdd() {
+      this.reset()
+      this.customLevelDialog.open = true
+      this.customLevelDialog.title = "新增级别"
+    },
+    handleUpdate(row) {
+      this.reset()
+      get(row.id).then(response => {
+        this.customLevelDialog.form = response.data
+        this.customLevelDialog.form.status = response.data.status.toString()
+        this.customLevelDialog.open = true
+        this.customLevelDialog.title = "修改级别"
+      })
+    },
+    handleDelete(row) {
+      this.$confirm('是否确认删除级别编号为"' + row.id + '"的数据项?', "警告", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function() {
+        return del(row.id)
+      }).then(() => {
+        this.getList()
+        this.msgSuccess("删除成功")
+      })
+    },
+    submitForm() {
+      this.$refs["form"].validate(valid => {
+        if (valid) {
+          if (this.customLevelDialog.form.id != null) {
+            edit(this.customLevelDialog.form).then(response => {
+              const {code} = response
+              if (code === 200) {
+                this.msgSuccess("修改成功");
+                this.customLevelDialog.open = false;
+                this.getList();
+              }
+            })
+          } else {
+            add(this.customLevelDialog.form).then(response => {
+              const {code} = response
+              if (code === 200) {
+                this.msgSuccess("新增成功");
+                this.customLevelDialog.open = false;
+                this.getList();
+              }
+            })
+          }
+        }
+      });
+    },
+    cancel() {
+      this.customLevelDialog.open = false
+      this.reset();
+    },
+    reset() {
+      this.customLevelDialog.form = initForm
+      this.resetForm("form")
+    },
+  }
+}
+</script>
+
+<style scoped>
+
+</style>