customerChangeCheck.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div>
  3. <el-button size="small" type="primary" @click="isCheck" class="inline-16 normal-btn-width">查 重</el-button>
  4. <el-dialog title="重复客户" :visible.sync="dialogTableVisible" append-to-body width="1000px">
  5. <div slot="title" class="dialog-title">
  6. <span class="title-text">重复客户</span>
  7. <p style="font-size: 14px;color: red">已存在重复客户不可继续创建</p>
  8. </div>
  9. <tableLayout :layout="tablecols" :data="list" :opwidth="200" height="calc(100vh - 550px)" :width="true" :custom="true">
  10. <template v-slot:customcol="scope">
  11. <div v-if="scope.column.columnname === 'tag'">
  12. <div v-for="item in scope.column.data.tag_sys" :key="item.index" style="float: left;margin-left: 5px;margin-bottom: 5px">
  13. <el-tag color="#3874F6" size="mini" type="primary" effect="dark">
  14. <span>{{item}}</span>
  15. </el-tag>
  16. </div>
  17. <div v-for="item in scope.column.data.tag" :key="item.index" style="float: left;margin-left: 5px;margin-bottom: 5px">
  18. <el-tag color="#FA8C16" size="mini" type="warning" effect="dark">
  19. <span>{{item}}</span>
  20. </el-tag>
  21. </div>
  22. </div>
  23. <div v-else-if="scope.column.columnname === 'leader'">
  24. <span>{{scope.column.data.leader?scope.column.data.leader.length !== 0 ? scope.column.data.leader[0].name:'--':'--'}}</span>
  25. </div>
  26. <p v-else>{{scope.column.data[scope.column.columnname]?scope.column.data[scope.column.columnname]:'--'}}</p>
  27. </template>
  28. </tableLayout>
  29. <div class="container normal-panel" style="text-align:right">
  30. <el-pagination
  31. background
  32. @size-change="handleSizeChange"
  33. @current-change="handleCurrentChange"
  34. :current-page="currentPage"
  35. :page-sizes="[20, 50, 100, 200]"
  36. :page-size="20"
  37. :total="total">
  38. </el-pagination>
  39. </div>
  40. <span slot="footer" class="dialog-footer" v-if="creatShow">
  41. <el-button @click="dialogTableVisible = false" type="primary" size="small" class="normal-btn-width">确 定</el-button>
  42. <!-- <el-button :type="buttonTitle === '确定保存'?'warning':'primary'" @click="onCheck" size="small" class="normal-btn-width">{{buttonTitle}}</el-button>-->
  43. </span>
  44. </el-dialog>
  45. </div>
  46. </template>
  47. <script>
  48. export default {
  49. name: "customerCheck",
  50. props:["data"],
  51. data(){
  52. return {
  53. dialogTableVisible:false,
  54. list:[],
  55. tablecols:[],
  56. total:0,
  57. currentPage:0,
  58. duplicates:false,
  59. creatShow:false,
  60. message:'该客户疑似重复,是否确认创建客户?',
  61. buttonTitle:'确定创建',
  62. param:{
  63. "id": 20221208172002,
  64. "content": {
  65. "sa_customersid":'',
  66. "enterprisename":'',
  67. "taxno":'',
  68. "address":''
  69. },
  70. },
  71. fields1:[],
  72. fields2:[],
  73. fields3:[],
  74. }
  75. },
  76. methods:{
  77. async listData(){
  78. this.param.content.sa_customersid = this.data.sa_customersid || 0
  79. this.fields1.forEach(item=>{
  80. this.param.content[item] = this.data[item] || ""
  81. })
  82. this.fields2.forEach(item=>{
  83. this.param.content[item] = this.data[item] || ""
  84. })
  85. this.fields3.forEach(item=>{
  86. this.param.content[item] = this.data[item] || ""
  87. })
  88. const res = await this.$api.requested(this.param)
  89. if (res.total > 0){
  90. this.list = res.data
  91. this.total = res.total
  92. this.currentPage = res.pageNumber
  93. this.dialogTableVisible = true
  94. }else {
  95. if (this.creatShow){
  96. this.onSubmit()
  97. }else {
  98. this.$message({
  99. message: '无重复数据',
  100. type: 'success'
  101. });
  102. }
  103. }
  104. },
  105. onCheck(){
  106. if (this.buttonTitle === '确定保存'){
  107. this.message = '该客户疑似重复,是否确认更新客户?'
  108. }else {
  109. this.message = '该客户疑似重复,是否确认创建客户?'
  110. }
  111. this.$confirm(this.message, '提示', {
  112. confirmButtonText: '确定',
  113. cancelButtonText: '取消',
  114. type: 'warning'
  115. }).then(() => {
  116. this.duplicates = true
  117. this.onSubmit()
  118. }).catch(() => {
  119. this.$message({
  120. type: 'info',
  121. message: '已取消'
  122. });
  123. });
  124. },
  125. async onSubmit(){
  126. if (this.data.contactsinfo.telephone){
  127. this.data.contactsinfo.phonenumber = this.data.contactsinfo.telephone
  128. this.data.contactsinfo.telephone = ''
  129. }
  130. const res = await this.$api.requested({
  131. "id": 20221216184302,
  132. "content": this.data
  133. })
  134. this.tool.showMessage(res,()=>{
  135. if (this.duplicates){
  136. this.setTag(res.data.sa_customersid,'疑似重复')
  137. }else {
  138. this.$emit('onSuccess')
  139. /* this.setTag(res.data.sa_customersid,'')*/
  140. }
  141. })
  142. },
  143. async setTag(id,data){
  144. const res = await this.$api.requested({
  145. "id": 20220929090901,
  146. "content": {
  147. "ownertable":"sa_customers",
  148. "ownerid":id,
  149. "datatag":[data]
  150. }
  151. })
  152. this.dialogTableVisible = false
  153. this.duplicates = false
  154. this.$emit('onSuccess')
  155. },
  156. handleSizeChange(val) {
  157. // console.log(`每页 ${val} 条`);
  158. this.param.content.pageSize = val
  159. this.listData()
  160. },
  161. handleCurrentChange(val) {
  162. // console.log(`当前页: ${val}`);
  163. this.param.content.pageNumber = val
  164. this.listData()
  165. },
  166. /*查询规则*/
  167. isCheck(){
  168. this.$emit('onCheck')
  169. },
  170. async queryRule(){
  171. const res = await this.$api.requested({
  172. "id": "20230410090502",
  173. "content": {},
  174. })
  175. this.fields1 = res.data.custcheckrule.fields1
  176. this.fields2 = res.data.custcheckrule.fields2
  177. this.fields3 = res.data.custcheckrule.fields3
  178. this.listData()
  179. }
  180. },
  181. created() {
  182. this.tablecols = this.tool.tabelCol(this.$route.name).duplicatesCustomerTable.tablecols
  183. }
  184. }
  185. </script>
  186. <style scoped>
  187. </style>