Ver Fonte

新建客户查重

qymljy há 3 anos atrás
pai
commit
9b67aea53c

+ 8 - 22
src/Form/publicCustomer/add.vue

@@ -251,7 +251,7 @@
       </div>
       <div class="fixed__btn__panel">
         <el-button size="small" @click="onClose" class="normal-btn-width inline-16">取 消</el-button>
-        <duplicateCheck :data="form" @checkSuccess="checkSuccess"></duplicateCheck>
+        <duplicateCheck ref="check" :data="form" @onSuccess="onClose"></duplicateCheck>
         <el-button size="small" type="primary" @click="onSave" class="normal-btn-width">确 定</el-button>
       </div>
     </el-drawer>
@@ -259,7 +259,7 @@
 </template>
 
 <script>
-import duplicateCheck from "@/SDrpManagement/salerPrivatecustomer/components/duplicateCheck";
+import duplicateCheck from "@/components/duplicatesCheck/publicCustomerCheck";
 export default {
   name: "add",
   inject:['customerLead','customerType','arealist','publicList'],
@@ -422,26 +422,11 @@ export default {
       })
     },
     onSave(){
-      if (this.checkResults === ''){
-        this.duplicateCheck()
-      }else {
-        if (this.checkResults !== 0){
-          this.$confirm('该客户疑似重复,是否确认创建客户?', '提示', {
-            confirmButtonText: '确定',
-            cancelButtonText: '取消',
-            type: 'warning'
-          }).then(() => {
-            this.onSubmit()
-          }).catch(() => {
-            this.$message({
-              type: 'info',
-              message: '已取消创建'
-            });
-          });
-        }else {
-          this.onSubmit()
-        }
-      }
+      this.$refs.form.validate((valid) => {
+        if (!valid) return false
+        this.$refs.check.creatShow = true
+        this.$refs.check.listData()
+      })
     },
     onSubmit(){
       this.$refs['form'].validate(async (valid) => {
@@ -552,6 +537,7 @@ export default {
       this.checkResults = ''
       this.value = ''
       this.businessShow = false
+      this.$emit('onSuccess')
     },
     cascaderChange (val) {
       this.form.province = val[0]

+ 9 - 22
src/Form/publicCustomer/edit.vue

@@ -249,7 +249,7 @@
       </div>
       <div class="fixed__btn__panel">
         <el-button size="small" @click="onClose" class="normal-btn-width inline-16">取 消</el-button>
-        <duplicateCheck :data="form"></duplicateCheck>
+        <duplicateCheck :data="form" ref="check" @onSuccess="onClose"></duplicateCheck>
         <el-button size="small" type="warning" @click="onSave" class="normal-btn-width">保 存</el-button>
       </div>
     </el-drawer>
@@ -257,7 +257,7 @@
 </template>
 
 <script>
-import duplicateCheck from "@/SDrpManagement/salerPrivatecustomer/components/duplicateCheck";
+import duplicateCheck from "@/components/duplicatesCheck/publicCustomerCheck";
 export default {
   name: "add",
   inject:['customerLead','customerType','arealist','publicList'],
@@ -355,6 +355,7 @@ export default {
     onClose(){
       this.businessShow = false
       this.dialogFormVisible = false
+      this.$emit('onSuccess')
     },
     editBtn () {
       this.dialogFormVisible = true
@@ -439,26 +440,12 @@ export default {
       })
     },
     onSave(){
-      if (this.checkResults === ''){
-        this.duplicateCheck()
-      }else {
-        if (this.checkResults !== 0){
-          this.$confirm('该客户疑似重复,是否确认保存客户?', '提示', {
-            confirmButtonText: '确定',
-            cancelButtonText: '取消',
-            type: 'warning'
-          }).then(() => {
-            this.onSubmit()
-          }).catch(() => {
-            this.$message({
-              type: 'info',
-              message: '已取消保存'
-            });
-          });
-        }else {
-          this.onSubmit()
-        }
-      }
+      this.$refs.form.validate((valid) => {
+        if (!valid) return false
+        this.$refs.check.creatShow = true
+        this.$refs.check.buttonTitle = '确定保存'
+        this.$refs.check.listData()
+      })
     },
     onSubmit(){
       this.$refs['form'].validate(async (valid) => {

+ 7 - 80
src/Form/salerPrivatecustomer/add.vue

@@ -254,7 +254,7 @@
       <div class="fixed__btn__panel">
         <el-button size="small" @click="onClose" class="normal-btn-width inline-16">取 消</el-button>
 <!--        <el-button size="small" type="primary" @click="duplicateChecking" class="normal-btn-width">查 重</el-button>-->
-        <duplicateCheck :data="form"></duplicateCheck>
+        <duplicateCheck ref="check" :data="form" @onSuccess="onClose"></duplicateCheck>
         <el-button size="small" type="primary" @click="onSave" class="normal-btn-width">确 定</el-button>
       </div>
     </el-drawer>
@@ -446,85 +446,11 @@ export default {
       })
     },
     onSave(){
-      if (this.checkResults === ''){
-        this.duplicateCheck()
-      }else {
-        if (this.checkResults !== 0){
-          this.$confirm('该客户疑似重复,是否确认创建客户?', '提示', {
-            confirmButtonText: '确定',
-            cancelButtonText: '取消',
-            type: 'warning'
-          }).then(() => {
-            this.onSubmit()
-          }).catch(() => {
-            this.$message({
-              type: 'info',
-              message: '已取消创建'
-            });
-          });
-        }else {
-          this.onSubmit()
-        }
-      }
-    },
-    onSubmit(){
-      console.log(this.form)
-      this.$refs['form'].validate(async (valid) => {
-        if (!valid) return false
-        const res = await this.$api.requested({
-          "id": 20221012163902,
-          "content": this.form
-        })
-        this.tool.showMessage(res, ()=>{
-          console.log(this.checkResults,"查重结果")
-          if (this.checkResults === 0){
-            this.$emit('onSuccess')
-            this.$refs['form'].resetFields();
-            this.form = {
-              sa_customersid:0,
-              sys_enterpriseid:0,
-              enterprisename:'',
-              type:'',
-              source:'',
-              parentid:0,
-              superiorenterprisename:'',
-              abbreviation:'',
-              taxno:'',
-              customergrade:'',
-              industry:'',
-              phonenumber:'',
-              province:'',
-              city:'',
-              county:'',
-              address:'',
-              ispublic:0
-            }
-            this.dialogFormVisible = false
-            this.checkResults = ''
-            this.value = ''
-          }else {
-            this.setTag(res.data.sa_customersid)
-          }
-        })
-      })
-    },
-    async setTag(id){
-      const res = await this.$api.requested({
-        "id": 20220929090901,
-        "content": {
-          "ownertable":"sa_customers",
-          "ownerid":id,
-          "datatag":[
-            "疑似重复",
-          ]
-        }
-      })
-      this.$emit('onSuccess')
-      this.$refs['form'].resetFields();
-      this.form = {}
-      this.dialogFormVisible = false
-      this.checkResults = ''
-      this.value = ''
+     this.$refs.form.validate((valid) => {
+       if (!valid) return false
+       this.$refs.check.creatShow = true
+       this.$refs.check.listData()
+     })
     },
     onClose () {
       this.$refs['form'].resetFields();
@@ -551,6 +477,7 @@ export default {
       this.checkResults = ''
       this.value = ''
       this.businessShow = false
+      this.$emit('onSuccess')
     },
     /*客户类型列表*/
     async typeList(){

+ 10 - 23
src/Form/salerPrivatecustomer/edit.vue

@@ -195,8 +195,8 @@
         </el-row>
       </div>
       <div class="fixed__btn__panel">
-        <el-button size="small" @click="onClose" class="normal-btn-width">取 消</el-button>
-        <duplicateCheck :data="form"></duplicateCheck>
+        <el-button  size="small" @click="onClose" class="normal-btn-width inline-16">取 消</el-button>
+        <duplicateCheck :data="form" ref="check" @onSuccess="onClose"></duplicateCheck>
         <el-button size="small" type="warning" @click="onSave" class="normal-btn-width">保 存</el-button>
       </div>
     </el-drawer>
@@ -212,7 +212,7 @@
 
 <script>
 import enterprise from '@/SDrpManagement/salerPrivatecustomer/components/enterprise'
-import duplicateCheck from "@/SDrpManagement/salerPrivatecustomer/components/duplicateCheck";
+import duplicateCheck from "@/components/duplicatesCheck/customerCheck";
 export default {
   name: "edit",
   props:['data','btnType'],
@@ -302,6 +302,7 @@ export default {
     onClose(){
       this.dialogFormVisible = false
       this.businessShow = false
+      this.$emit('onSuccess')
     },
     show(){
       this.dialogFormVisible = true
@@ -394,26 +395,12 @@ export default {
       })
     },
     onSave(){
-      if (this.checkResults === ''){
-        this.duplicateCheck()
-      }else {
-        if (this.checkResults !== 0){
-          this.$confirm('该客户疑似重复,是否确认保存客户?', '提示', {
-            confirmButtonText: '确定',
-            cancelButtonText: '取消',
-            type: 'warning'
-          }).then(() => {
-            this.onSubmit()
-          }).catch(() => {
-            this.$message({
-              type: 'info',
-              message: '已取消保存'
-            });
-          });
-        }else {
-          this.onSubmit()
-        }
-      }
+      this.$refs.form.validate((valid) => {
+        if (!valid) return false
+        this.$refs.check.creatShow = true
+        this.$refs.check.buttonTitle = '确定保存'
+        this.$refs.check.listData()
+      })
     },
     onSubmit(){
       console.log(this.form)

+ 61 - 9
src/components/duplicatesCheck/customerCheck.vue

@@ -33,9 +33,9 @@
             :total="total">
         </el-pagination>
       </div>
-      <span slot="footer" class="dialog-footer">
-        <el-button @click="dialogTableVisible = false" size="small">取 消</el-button>
-        <el-button type="primary" @click="dialogTableVisible = false" size="small">确定创建</el-button>
+      <span slot="footer" class="dialog-footer" v-if="creatShow">
+        <el-button @click="dialogTableVisible = false" size="small" class="normal-btn-width">取 消</el-button>
+        <el-button :type="buttonTitle === '确定保存'?'warning':'primary'" @click="onCheck" size="small" class="normal-btn-width">{{buttonTitle}}</el-button>
       </span>
     </el-dialog>
   </div>
@@ -44,7 +44,7 @@
 <script>
 export default {
   name: "customerCheck",
-  props:["data"],
+  props:["data",'creatShow'],
   data(){
     return {
       dialogTableVisible:false,
@@ -52,6 +52,9 @@ export default {
       tablecols:[],
       total:0,
       currentPage:0,
+      duplicates:false,
+      message:'该客户疑似重复,是否确认创建客户?',
+      buttonTitle:'确定创建',
       param:{
         "id": 20221208172002,
         "content": {
@@ -65,7 +68,6 @@ export default {
   },
   methods:{
     async listData(){
-      console.log(this.data,'表单数据')
       this.param.content.sa_customersid = this.data.sa_customersid || 0
       this.param.content.enterprisename = this.data.enterprisename
       this.param.content.taxno = this.data.taxno
@@ -77,12 +79,62 @@ export default {
         this.currentPage = res.pageNumber
         this.dialogTableVisible = true
       }else {
+        if (this.creatShow){
+          this.onSubmit()
+        }else {
+          this.$message({
+            message: '无重复数据',
+            type: 'success'
+          });
+        }
+      }
+    },
+    onCheck(){
+      if (this.buttonTitle === '确定保存'){
+        this.message = '该客户疑似重复,是否确认更新客户?'
+      }else {
+        this.message = '该客户疑似重复,是否确认创建客户?'
+      }
+      this.$confirm(this.message, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.duplicates = true
+        this.onSubmit()
+      }).catch(() => {
         this.$message({
-          message: '无重复数据',
-          type: 'success'
+          type: 'info',
+          message: '已取消'
         });
-      }
-      console.log(res,'查重结果')
+      });
+    },
+    async onSubmit(){
+      const res = await this.$api.requested({
+        "id": 20221012163902,
+        "content": this.data
+      })
+      this.tool.showMessage(res,()=>{
+        if (this.duplicates){
+          this.setTag(res.data.sa_customersid)
+        }else {
+          this.$emit('onSuccess')
+        }
+      })
+    },
+    async setTag(id){
+      const res = await this.$api.requested({
+        "id": 20220929090901,
+        "content": {
+          "ownertable":"sa_customers",
+          "ownerid":id,
+          "datatag":[
+            "疑似重复",
+          ]
+        }
+      })
+      this.dialogTableVisible = false
+      this.$emit('onSuccess')
     },
     handleSizeChange(val) {
       // console.log(`每页 ${val} 条`);

+ 158 - 0
src/components/duplicatesCheck/publicCustomerCheck.vue

@@ -0,0 +1,158 @@
+<template>
+  <div>
+    <el-button size="small" type="primary" @click="listData" class="inline-16 normal-btn-width">查 重</el-button>
+    <el-dialog title="重复客户" :visible.sync="dialogTableVisible" append-to-body width="1000px">
+      <tableLayout :layout="tablecols"   :data="list" :opwidth="200" height="calc(100vh - 550px)" :width="true" :custom="true">
+        <template v-slot:customcol="scope">
+          <div v-if="scope.column.columnname === 'tag'">
+            <div v-for="item in scope.column.data.tag_sys" :key="item.index"  style="float: left;margin-left: 5px;margin-bottom: 5px">
+              <el-tag  color="#3874F6" size="mini" type="primary" effect="dark">
+                <span>{{item}}</span>
+              </el-tag>
+            </div>
+            <div v-for="item in scope.column.data.tag" :key="item.index"  style="float: left;margin-left: 5px;margin-bottom: 5px">
+              <el-tag color="#FA8C16" size="mini" type="warning" effect="dark">
+                <span>{{item}}</span>
+              </el-tag>
+            </div>
+          </div>
+          <div v-else-if="scope.column.columnname === 'leader'">
+            <span>{{scope.column.data.leader?scope.column.data.leader.length !== 0 ? scope.column.data.leader[0].name:'--':'--'}}</span>
+          </div>
+          <p v-else>{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
+        </template>
+      </tableLayout>
+      <div  class="container normal-panel" style="text-align:right">
+        <el-pagination
+            background
+            @size-change="handleSizeChange"
+            @current-change="handleCurrentChange"
+            :current-page="currentPage"
+            :page-sizes="[20, 50, 100, 200]"
+            :page-size="20"
+            :total="total">
+        </el-pagination>
+      </div>
+      <span slot="footer" class="dialog-footer" v-if="creatShow">
+        <el-button @click="dialogTableVisible = false" size="small" class="normal-btn-width">取 消</el-button>
+        <el-button :type="buttonTitle === '确定保存'?'warning':'primary'" @click="onCheck" size="small" class="normal-btn-width">{{buttonTitle}}</el-button>
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "customerCheck",
+  props:["data",'creatShow'],
+  data(){
+    return {
+      dialogTableVisible:false,
+      list:[],
+      tablecols:[],
+      total:0,
+      currentPage:0,
+      duplicates:false,
+      message:'该客户疑似重复,是否确认创建客户?',
+      buttonTitle:'确定创建',
+      param:{
+        "id": 20221208172002,
+        "content": {
+          "sa_customersid":'',
+          "enterprisename":'',
+          "taxno":'',
+          "address":''
+        },
+      }
+    }
+  },
+  methods:{
+    async listData(){
+      this.param.content.sa_customersid = this.data.sa_customersid || 0
+      this.param.content.enterprisename = this.data.enterprisename
+      this.param.content.taxno = this.data.taxno
+      this.param.content.address = this.data.address
+      const res = await this.$api.requested(this.param)
+      if (res.total > 0){
+        this.list = res.data
+        this.total = res.total
+        this.currentPage = res.pageNumber
+        this.dialogTableVisible = true
+      }else {
+        if (this.creatShow){
+          this.onSubmit()
+        }else {
+          this.$message({
+            message: '无重复数据',
+            type: 'success'
+          });
+        }
+      }
+    },
+    onCheck(){
+      if (this.buttonTitle === '确定保存'){
+        this.message = '该客户疑似重复,是否确认更新客户?'
+      }else {
+        this.message = '该客户疑似重复,是否确认创建客户?'
+      }
+      this.$confirm(this.message, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        this.duplicates = true
+        this.onSubmit()
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消'
+        });
+      });
+    },
+    async onSubmit(){
+      const res = await this.$api.requested({
+        "id": 20221010164302,
+        "content": this.data
+      })
+      this.tool.showMessage(res,()=>{
+        if (this.duplicates){
+          this.setTag(res.data.sa_customersid)
+        }else {
+          this.$emit('onSuccess')
+        }
+      })
+    },
+    async setTag(id){
+      const res = await this.$api.requested({
+        "id": 20220929090901,
+        "content": {
+          "ownertable":"sa_customers",
+          "ownerid":id,
+          "datatag":[
+            "疑似重复",
+          ]
+        }
+      })
+      this.dialogTableVisible = false
+      this.$emit('onSuccess')
+    },
+    handleSizeChange(val) {
+      // console.log(`每页 ${val} 条`);
+      this.param.content.pageSize = val
+      this.listData()
+    },
+    handleCurrentChange(val) {
+      // console.log(`当前页: ${val}`);
+      this.param.content.pageNumber = val
+      this.listData()
+    },
+  },
+  created() {
+    this.tablecols = this.tool.tabelCol(this.$route.name).duplicatesCustomerTable.tablecols
+  }
+}
+</script>
+
+<style scoped>
+
+</style>