publicCustomerCheck.vue 7.3 KB

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